mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
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:
@@ -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
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user