feat: centralize session state on terminal server

- Add SessionStateManager (server/services/session-state.ts) as source
  of truth for agent status, tools, approvals, and notifications
- Integrate into terminal server with state patches broadcast via WS
- Add /add-approval and /resolve-approval endpoints so approval
  lifecycle is tracked centrally and broadcast to all clients
- Add permissionMode field to AgentSessionState
- Frontend store (session-state.ts) + WS service (session-state-ws.ts)
  consume snapshots and patches from terminal server (4103)
- Rewrite useGlobalApproval to derive pending approvals from
  centralized state — resolving on one client now clears all others
- Migrate useTranscriptDebug: processing, hookMeta, serverRegistry
  now derived from session state store; remove 5s registry polling
- hooks-approval.ts notifies terminal server on add/resolve
This commit is contained in:
2026-02-20 21:06:20 -06:00
parent 15731b8f69
commit 9945be07b1
8 changed files with 868 additions and 223 deletions

View File

@@ -435,7 +435,7 @@ function openAtCursor(x: number, y: number) {
})
}
defineExpose({ openAtCursor })
defineExpose({ openAtCursor, openTerminals, activeTerminalSessionId, switchToTerminal })
function handleAgentSwitch(agent: AgentName) {
switchAgent(agent)
@@ -523,6 +523,7 @@ onMounted(async () => {
oceanLifeTimer = setInterval(tickOceanLife, 20000)
tickOceanLife()
await voice.init()
// Terminal registry is now synced via centralized session state WS (no polling needed)
})
onBeforeUnmount(() => {