fix(hub,web): apply selected permission mode when resuming inactive sessions (#540)

Previously, toggling the permission mode on an inactive session had no
effect on resume: the /permission-mode endpoint rejected inactive sessions
(HTTP 409), so the cache was never updated, and the spawned CLI always
received the stored default value.

- Remove the `requireActive` guard from POST /sessions/:id/permission-mode
  so inactive sessions can have their in-memory permission mode updated.
- In `SyncEngine.applySessionConfig`, skip the RPC call for inactive
  sessions and update the in-memory cache directly; the value is then
  available when the session is resumed.
- Accept an optional `{ permissionMode }` body in POST /sessions/:id/resume
  and forward it to `resumeSession` (takes precedence over the cached value),
  with flavor-compatibility validation.
- Extend `SyncEngine.resumeSession` with an optional `opts` argument so
  callers can supply a permission mode override at resume time.
- Update the web client (`api.resumeSession`) and `router.tsx` to pass
  `session.permissionMode` in the resume request body.
This commit is contained in:
Junmo Kim
2026-04-28 17:42:05 +08:00
committed by GitHub
parent 52ec08b6cb
commit 04fbc0d37f
5 changed files with 109 additions and 9 deletions
+7 -2
View File
@@ -268,10 +268,15 @@ export class ApiClient {
})
}
async resumeSession(sessionId: string): Promise<string> {
async resumeSession(sessionId: string, opts?: { permissionMode?: string }): Promise<string> {
const response = await this.request<{ sessionId: string }>(
`/api/sessions/${encodeURIComponent(sessionId)}/resume`,
{ method: 'POST' }
{
method: 'POST',
...(opts?.permissionMode !== undefined && {
body: JSON.stringify({ permissionMode: opts.permissionMode })
})
}
)
return response.sessionId
}
+1 -1
View File
@@ -274,7 +274,7 @@ function SessionPage() {
return currentSessionId
}
try {
return await api.resumeSession(currentSessionId)
return await api.resumeSession(currentSessionId, { permissionMode: session.permissionMode ?? undefined })
} catch (error) {
const message = error instanceof Error ? error.message : 'Resume failed'
addToast({