Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/client-message-handler-table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@schlessera/brain-ui-server": patch
---

WebSocket client messages are now dispatched through a per-message handler table. Behaviour and the wire protocol are unchanged.
2 changes: 1 addition & 1 deletion docs/decisions/answer-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ carries, no longer by position.

The host also re-sends a session's pending questions after `session_resume`
(`resendPendingAsks(host, ws, msg.sessionId)`,
`packages/ui-server/src/ws/dispatch.ts:651`). Before this, a resume replaced
`packages/ui-server/src/ws/handlers/session-resume.ts:37`). Before this, a resume replaced
the transcript and left only a history card behind, which was the second
symptom.

Expand Down
2 changes: 1 addition & 1 deletion docs/decisions/session-principals.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ mint (owner only, router mounted AFTER the guard)
──► upgradeWebSocket((c) => createWsHandlers(host, c.get("principal")))
(hono passes the context to createEvents:
hono/helper/websocket/index.js:34)
──► ConnectionState.principal (ws/dispatch.ts:14-17)
──► ConnectionState.principal (ws/handlers/context.ts:14-15)
──► clients.add(ws, principalId)
──► QueuedFollowUp.principalId / RunningTurn.principalId
(reset per queued follow-up, like lastResult)
Expand Down
10 changes: 5 additions & 5 deletions docs/decisions/voice-permission.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ exchange over a security decision is a second chance for noise to produce a
grant.

**"Always allow" cannot be given by voice.** It is a persistent policy change
(the block computing `remembers`, `packages/ui-server/src/ws/dispatch.ts:437-443`)
(the block computing `remembers`, `packages/ui-server/src/ws/handlers/tool-permission.ts:86-92`)
and it is the one decision on
the card with no keyboard shortcut, by D37's ruling 5, and the reason given
there is exactly the one that applies here: *"a letter that grants standing
Expand All @@ -435,7 +435,7 @@ permission by reflex is the one footgun in the vocabulary"*
A microphone is a reflex surface with worse recognition than a keyboard. This
costs nothing measurable:
the server already refuses `always` for kind `command` requests
(the block computing `remembers`, `dispatch.ts:437-443`, and the lookup computing
(the block computing `remembers`, `tool-permission.ts:86-92`, and the lookup computing
`remembered`, `ws/bridge.ts:372-392`), and 192 of 192 measured
approvals were kind `command`.

Expand Down Expand Up @@ -504,8 +504,8 @@ the record is by construction a bug — which makes the field a detector, not ju
provenance.

The wire needs nothing new: a spoken refusal is an ordinary `tool_denial`
(in `handleClientMessage`, the arm `case "tool_denial"`,
`packages/ui-server/src/ws/dispatch.ts:480-493`) with a message naming the
(its handler `handleToolDenial`,
`packages/ui-server/src/ws/handlers/tool-permission.ts:127-140`) with a message naming the
phrase that produced it.

## Containment: shared with #51, deliberately not identical
Expand Down Expand Up @@ -640,7 +640,7 @@ matters because a reader cannot otherwise tell a live hazard from a fixed one.
left out (the lookup computing `remembered`,
`packages/ui-server/src/ws/bridge.ts:372-392`,
and the block computing `remembers`,
`packages/ui-server/src/ws/dispatch.ts:437-443`).
`packages/ui-server/src/ws/handlers/tool-permission.ts:86-92`).
The evaluation happens
before the lookup, which is what this record asked for.

Expand Down
4 changes: 2 additions & 2 deletions docs/investigations/live-conversation-investigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ matcher. An isolated ambiguous refusal denies all **current** pending requests;
an exact refusal can name one. With none pending, it is ordinary input. Bind
each denial to existing IDs, echoed turn and `channel:"voice"`; the server still
rejects voice grants
(`if (msg.channel === "voice")`, `packages/ui-server/src/ws/dispatch.ts:397-420`).
(`if (msg.channel === "voice")`, `packages/ui-server/src/ws/handlers/tool-permission.ts:46-69`).
Never add a spoken approve or always-allow path.

On the evidence date the denial handler removed/resolved a matched request but
provided no dedicated denial receipt at that branch; #957 added one
(`case "tool_denial"`, `packages/ui-server/src/ws/dispatch.ts:480-493`). The
(`handleToolDenial`, `packages/ui-server/src/ws/handlers/tool-permission.ts:127-140`). The
integration therefore needs host-authoritative resolution/replay: denied,
already granted, expired, or unknown/disconnected. Speak a denial confirmation
only for a confirmed denied outcome. A visual grant winning the race remains
Expand Down
4 changes: 2 additions & 2 deletions docs/plans/chat-history-deletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ and both handoff stages (`startHandoff`, `packages/ui-server/src/ws/handoff.ts:1
belongs to `createDraftClient` (`createDraftClient`,
`packages/ui-react/src/lib/draft-client.ts:45-57`); browser reloadable work belongs
to `createLocalWork` (`createLocalWork`, `packages/ui-react/src/lib/local-work.ts:227-245`).
The paired WS dispatcher is `packages/ui-server/src/ws/dispatch.ts`; gating its
resume case alone would leave HTTP, background readers and provider startup open.
The paired WS dispatcher is `packages/ui-server/src/ws/dispatch.ts`, with one
handler per frame under `ws/handlers/`; gating its resume handler alone would leave HTTP, background readers and provider startup open.

Existing ordinary history publication checks concurrent turn changes
(`publishHistory`, `packages/ui-server/src/ws/host.ts:540-574`). Future deletion
Expand Down
2 changes: 1 addition & 1 deletion docs/plans/navigation-recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ implementation. Any PR moving these lines owns their citation repairs.

- Host reconnect: (`const runningTurns = [...coordinator.running].filter((t) => t.sessionId);`, `packages/ui-server/src/ws/connection.ts:128-193`).

- Host resume: (`case "session_resume": {`, `packages/ui-server/src/ws/dispatch.ts:622-686`).
- Host resume: (`export const handleSessionResume`, `packages/ui-server/src/ws/handlers/session-resume.ts:7-71`).

- Catalog activity: (`persistSessionStub(sessionId, promptText, providerId, backendId) {`, `packages/ui-server/src/ws/session-catalog.ts:479-486`).

Expand Down
Loading
Loading