diff --git a/.changeset/3389-consumer-frames-without-pong.md b/.changeset/3389-consumer-frames-without-pong.md new file mode 100644 index 0000000000..832e8feb1b --- /dev/null +++ b/.changeset/3389-consumer-frames-without-pong.md @@ -0,0 +1,12 @@ +--- +"@schlessera/brain-ui-sdk": minor +"@schlessera/brain-ui-react": minor +--- + +**Breaking (types, #3389):** `pong` is no longer a frame a consumer can handle. `BrainUiClient` answers its own liveness probes and never handed a `pong` on, so `ServerFrameHandlers` (from `@schlessera/brain-ui-sdk/client`) is now keyed on the new `ConsumerServerMessage` union, which is every `ServerMessage` except `ServerPong`, and its `onAny` receives a `ConsumerServerMessage`. + +Migration: delete any `pong` handler you pass in `handlers`; it was never called. A consumer that types its frame handling as `ServerMessage` keeps compiling. To call such code from `onAny`, nothing changes, because a `ConsumerServerMessage` is a `ServerMessage`. Code that switches exhaustively over the frames a handler receives can drop its `pong` case. + +Nothing changes on the wire. The host still answers `ping` with `pong`, and `ServerMessage`, `ServerPong` and `parseServerMessage` still include it. + +In `@schlessera/brain-ui-react`, the server-frame handler map is now the only router for the voice conversation's own frames: `dialogue_history`, `tool_resolution` and the six `conversation_*` frames reach the conversation client through their map entries, not through its prefilter. The conversation client (`root.connection.conversation`) gains `receive(frame)` for those frames, and `frame()` now passes them through unchanged. Its `permissions` gains `resolution(frame)` for `tool_resolution`, which `permissions.frame()` no longer reads. Nothing changes for the person using voice. diff --git a/api-report/ui-react.txt b/api-report/ui-react.txt index 2755fb9d2d..a3de030a63 100644 --- a/api-report/ui-react.txt +++ b/api-report/ui-react.txt @@ -384,6 +384,12 @@ signatures (every public export and the types it is made of) dialogueNotice: string; dialogueRestoredThrough: Record; } + ConversationFrame (packages/ui-react/src/hooks/websocket-handlers/types.ts) + export type ConversationFrame = Extract; + ConversationFrameType (packages/ui-react/src/hooks/websocket-handlers/types.ts) + type ConversationFrameType = "dialogue_history" | "tool_resolution" | "conversation_opened" | "conversation_closed" | "conversation_event" | "conversation_work" | "conversation_output" | "conversation_permission"; ConversationRecognition (packages/ui-react/src/voice/conversation-client.ts) export type ConversationRecognition = Extract import("@schlessera/brain-ui-sdk").ServerMessage | null; + frame: (message: import("@schlessera/brain-ui-sdk").ConsumerServerMessage) => import("@schlessera/brain-ui-sdk").ConsumerServerMessage | null; historyOwnerFor: (key: string) => string | undefined; leave: () => void; levels: () => { @@ -1724,11 +1730,15 @@ signatures (every public export and the types it is made of) lost(): void; quiet: () => void; refresh(): void; + resolution: (message: Extract) => void; state: import("zustand").StoreApi<{ line: string; records: import("./voice/conversation-permissions.js").VoicePermissionReceipt[]; }>; }; + receive: (message: import("./hooks/websocket-handlers/types.js").ConversationFrame) => void; recoverOutput(): void; resume(): void; reviewUnassigned(): boolean; @@ -1763,7 +1773,7 @@ signatures (every public export and the types it is made of) edit (packages/ui-react/src/lib/answer-delivery/manager.ts) function edit(requestId: string): void; frame (packages/ui-react/src/voice/conversation-client.ts) - function frame(message: ServerMessage): ServerMessage | null; + function frame(message: ConsumerServerMessage): ConsumerServerMessage | null; frame (packages/ui-react/src/voice/conversation-permissions.ts) function frame(message: ServerMessage): void; handleServerMessage (packages/ui-react/src/ws-client/inbound.ts) @@ -1790,6 +1800,8 @@ signatures (every public export and the types it is made of) function quiet(): void; receipt (packages/ui-react/src/lib/answer-delivery/manager.ts) function receipt(frame: ServerAskAnswerReceipt): void; + receive (packages/ui-react/src/voice/conversation-client.ts) + function receive(message: ConversationFrame): void; registerContentRendererPack (packages/ui-react/src/content-renderers/register.ts) export function registerContentRendererPack(pack: ContentRendererPack, module: { name: string; @@ -1799,6 +1811,10 @@ signatures (every public export and the types it is made of) export function registerUpdateHold(root: BrainUiServices, hold: UpdateHold): () => void; renderBlockHtml (packages/ui-react/src/components/chat/share-document.tsx) export function renderBlockHtml(block: Block, trackDisplay?: TrackDisplay): Promise; + resolution (packages/ui-react/src/voice/conversation-permissions.ts) + function resolution(message: Extract): void; retry (packages/ui-react/src/lib/answer-delivery/manager.ts) function retry(requestId: string): Promise; retryTurn (packages/ui-react/src/ws-client/turn-retry.ts) diff --git a/api-report/ui-sdk.txt b/api-report/ui-sdk.txt index f9b1a80d48..5f26cee3fe 100644 --- a/api-report/ui-sdk.txt +++ b/api-report/ui-sdk.txt @@ -147,6 +147,7 @@ export "." (./src/index.ts) type ConfigurationCoverageRead type ConfiguredModule type ConflictVersionSelection + type ConsumerServerMessage type ContentRendererDeclaration type ConversationAudioFormat type ConversationCapabilities @@ -742,6 +743,7 @@ export "./client" (./src/client/index.ts) type ConfigurationCoverageRead type ConflictVersionSelection type ConnectionStatus + type ConsumerServerMessage type ContentRenderer type ContentRendererPack type ContentRendererProps @@ -1769,6 +1771,7 @@ export "./protocol" (./src/protocol.ts) type ClientToolDenial type ConfigurationCoverageRead type ConflictVersionSelection + type ConsumerServerMessage type ConversationAudioFormat type ConversationCapabilities type ConversationCloseReason @@ -2602,6 +2605,7 @@ export "./server" (./src/server/index.ts) type ConfirmPattern type ConfirmPatternSource type ConflictVersionSelection + type ConsumerServerMessage type ConversationAudioFormat type ConversationCapabilities type ConversationCloseReason @@ -7466,6 +7470,8 @@ signatures (every public export and the types it is made of) } ConnectionStatus (packages/ui-sdk/src/client/ws-client.ts) export type ConnectionStatus = "connecting" | "connected" | "disconnected"; + ConsumerServerMessage (packages/ui-sdk/src/protocol.ts) + export type ConsumerServerMessage = Exclude; ContentRenderer (packages/ui-sdk/src/client/content-renderers.ts) export interface ContentRenderer extends StaticRenderer { Component: ComponentType; @@ -13365,11 +13371,11 @@ signatures (every public export and the types it is made of) } ServerFrameHandlers (packages/ui-sdk/src/client/ws-client.ts) export type ServerFrameHandlers = { - [K in ServerMessage["type"]]?: (frame: Extract) => void; } & { - onAny?: (frame: ServerMessage) => void; + onAny?: (frame: ConsumerServerMessage) => void; }; ServerHandoffDraft (packages/ui-sdk/src/protocol.ts) export interface ServerHandoffDraft { diff --git a/docs/decisions/answer-delivery.md b/docs/decisions/answer-delivery.md index 2c1999331f..3ab85489f0 100644 --- a/docs/decisions/answer-delivery.md +++ b/docs/decisions/answer-delivery.md @@ -190,7 +190,7 @@ for the lock ahead of the submitting tab, and a unit test caught that. Browser WebSocket ping/pong is not exposed to scripts, so the host answers an application-level `ping` (`private sendProbe`, -`packages/ui-sdk/src/client/ws-client.ts:458`). A replaced socket is retired, +`packages/ui-sdk/src/client/ws-client.ts:459`). A replaced socket is retired, and every one of its callbacks checks that before it touches the client, so a late close from a dead socket cannot reset its replacement. @@ -200,7 +200,7 @@ runs on a socket that never opened, and `reconnectNow()` does nothing while one is connecting, so the client waited forever. A connection that has delivered nothing after 10 seconds, whether still connecting or open, is now abandoned and retried through the normal backoff (`private abandon`, -`ws-client.ts:492`). This adds no new timeout to a question. The host's turn +`ws-client.ts:493`). This adds no new timeout to a question. The host's turn deadline stays the only limit on an ask. ## A question whose turn ended (#3356) diff --git a/docs/decisions/hardening.md b/docs/decisions/hardening.md index d3c3ca86e2..3c9b0a6588 100644 --- a/docs/decisions/hardening.md +++ b/docs/decisions/hardening.md @@ -146,7 +146,7 @@ instead, and treat 8 as the question it was answering. production (`adapter.adapt(msg)`, `packages/ui-backend-claude/src/turn-stream.ts:103`) and U33 changes frame consumption - (`handleServerMessage`, `packages/ui-react/src/ws-client/inbound.ts:188`), the + (`handleServerMessage`, `packages/ui-react/src/ws-client/inbound.ts:214`), the same symptom could come from either, so they are **0.34.0** (seam) and **0.34.1** (splits), each its own image. For the same reason the cron bin and emitters (U13/U14) ship as **0.33.0** with the denylist unchanged and the allowlist (U21) as diff --git a/docs/integration-contract.md b/docs/integration-contract.md index 55eed447fe..fa71e2e134 100644 --- a/docs/integration-contract.md +++ b/docs/integration-contract.md @@ -29,6 +29,22 @@ optional `treeRequest`. A strict, voice or autonomous turn on managed storage now keeps its data tree there, filled by reflinks. Described in [the package API](integration-contract/package-api.md#managed-turn-data-trees-additive-0450-2911). +## Consumer frames without `pong` (breaking before 1.0, 0.45.0, #3389) + +`@schlessera/brain-ui-sdk/protocol` (and the root and `./client` entries that +re-export it) exports `ConsumerServerMessage`: every `ServerMessage` except +`ServerPong`. `ServerFrameHandlers` from `./client` is keyed on it, and its +`onAny` receives one, so a `pong` handler no longer type-checks. +`BrainUiClient` consumes `pong` for liveness and never called such a handler. +This removes a member from a public type and needs the +[recorded ruling](https://github.com/schlessera/brain-kit/issues/3389#issuecomment-6601349605); +it ships in a minor with the `breaking` label. The wire is unchanged: the host +still answers `ping` with `pong`, and `ServerMessage`, `ServerPong` and +`parseServerMessage` keep it. In `@schlessera/brain-ui-react`, the +conversation client gains `receive(frame)` for the eight frames it owns, which +reach it through the handler map instead of its `frame()` prefilter. See +[the package component](integration-contract/package-api.md#consumer-frames-without-pong-breaking-3389). + ## JeV reranking through the provider relay (additive, 0.45.0, #3792) The CLI provider relay gains the `typesafe` family, `x-brain-provider: diff --git a/docs/integration-contract/package-api.md b/docs/integration-contract/package-api.md index aa35c9ec4c..6f4b9133d7 100644 --- a/docs/integration-contract/package-api.md +++ b/docs/integration-contract/package-api.md @@ -154,6 +154,36 @@ passes its origin to `startInferenceRelay` as the new internal origin, and a turn without a relay refuses to start. The first-party Claude and pi backends implement all three. + + +## Consumer frames without `pong` (breaking before 1.0, #3389) + +`@schlessera/brain-ui-sdk/protocol` (and the root and `./client` entries that +re-export it) exports `ConsumerServerMessage`, defined as +`Exclude`: the frames `BrainUiClient` hands its +consumer. `ServerFrameHandlers` is keyed on `ConsumerServerMessage["type"]` +and its `onAny` takes a `ConsumerServerMessage`. Before, both were keyed on +`ServerMessage`, so a consumer could register a `pong` handler that the client +never called, because it answers its own probes and returns first. That +handler is now a type error; delete it. Code typed against `ServerMessage` +still accepts every frame the client delivers. + +`ServerMessage`, `ServerPong`, `serverPongSchema` and `parseServerMessage` are +unchanged, as is the [liveness exchange](wire.md#interactive-answer-receipts-breaking-910) on the wire. + +In `@schlessera/brain-ui-react`, `root.connection.conversation` gains +`receive(frame)` for the frames the conversation client owns: +`dialogue_history`, `tool_resolution`, `conversation_opened`, +`conversation_closed`, `conversation_event`, `conversation_work`, +`conversation_output` and `conversation_permission`. The server-frame handler +map routes them there, and `frame()`, which still sees every inbound frame +first, now returns them unchanged instead of consuming them. `frame()` takes +and returns a `ConsumerServerMessage`. `root.connection.handleServerMessage` +still takes a `ServerMessage` and ignores a `pong` fed to it. The client's +`permissions` likewise gains `resolution(frame)` for `tool_resolution`, which +`permissions.frame()` no longer reads. What voice does with each frame is +unchanged. + ## Reading a chat deletion's outcome (additive, #3455) diff --git a/docs/integration-contract/wire.md b/docs/integration-contract/wire.md index 0c5c5a07cb..42c1a47cdc 100644 --- a/docs/integration-contract/wire.md +++ b/docs/integration-contract/wire.md @@ -1896,7 +1896,9 @@ seconds is abandoned the same way and retried with the normal backoff, which resets only once a connection delivers a valid frame. `checkLiveness()` probes at once, for a return to the page, a resume or going online. `setForeground(false)` pauses the periodic probe. These are targets: -a frozen page runs no timers. +a frozen page runs no timers. The client consumes every `pong` itself: none reaches a +consumer handler or `onAny`, and `ServerFrameHandlers` has no `pong` key +([#3389](package-api.md#consumer-frames-without-pong-breaking-3389)). **principalKey** is a one-way digest of the principal id, stable per principal. A client files queued answers under it and never replays an diff --git a/docs/process/test-waits.md b/docs/process/test-waits.md index 94322c9efb..430e8ca61b 100644 --- a/docs/process/test-waits.md +++ b/docs/process/test-waits.md @@ -176,8 +176,8 @@ each complete delay and awaiting each actual failed native handshake before advancing again. One original 20-second failure cap covers the whole drop. The clock observes the client's `onclose` callback and owns only its final registered timer: that callback ends with `scheduleReconnect` -(`ws.onclose`, `packages/ui-sdk/src/client/ws-client.ts:267-285`; -`scheduleReconnect`, `packages/ui-sdk/src/client/ws-client.ts:544-551`). +(`ws.onclose`, `packages/ui-sdk/src/client/ws-client.ts:268-286`; +`scheduleReconnect`, `packages/ui-sdk/src/client/ws-client.ts:545-552`). The test independently checks the three registered delays and the native connection-attempt/failure counts. A changed registration order or callback must satisfy those controls; it cannot silently become a shorter policy. @@ -231,8 +231,8 @@ case observes that later effect through its retained native window. The history and queue receiving observer is only a barrier for the current synchronous production handlers, not a generic asynchronous-handler completion claim: `session_history` and scoped `status` update the chat store synchronously -(`session_history`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:444-464`; -`status`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:458-483`), while +(`session_history`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:442-462`; +`status`, `packages/ui-react/src/hooks/websocket-handlers/chat.ts:463-488`), while queue adoption updates the follow-up/draft stores synchronously (`function queueReport(`, `packages/ui-react/src/ws-client/follow-ups.ts:85-94`). Native protocol completion, committed store state and the retained observation window serve diff --git a/packages/ui-react/src/hooks/websocket-handlers/chat.ts b/packages/ui-react/src/hooks/websocket-handlers/chat.ts index 1021c0ee5e..465c4ba68a 100644 --- a/packages/ui-react/src/hooks/websocket-handlers/chat.ts +++ b/packages/ui-react/src/hooks/websocket-handlers/chat.ts @@ -30,7 +30,6 @@ type ChatFrame = | "result" | "retry_receipt" | "ask_answer_receipt" - | "pong" | "message_blocks" | "message_links" | "turn_journal" @@ -410,8 +409,6 @@ export const chatFrameHandlers = { // Receipts are connection-wide: they never reach a session's demux. retry_receipt: (msg, context) => context.retryReceipt(msg), ask_answer_receipt: (msg, context) => context.answerReceipt(msg), - // The SDK client answers its own probes; a pong never reaches a consumer. - pong: () => {}, message_blocks: (msg, context) => { // Arrives after `result`, for the turn's own assistant message. An // answer never waits on it: the markdown is already on screen, and this diff --git a/packages/ui-react/src/hooks/websocket-handlers/connection.ts b/packages/ui-react/src/hooks/websocket-handlers/connection.ts index d258b0a07d..11a9c4ba5e 100644 --- a/packages/ui-react/src/hooks/websocket-handlers/connection.ts +++ b/packages/ui-react/src/hooks/websocket-handlers/connection.ts @@ -10,7 +10,6 @@ type ConnectionFrame = "safety_history" | "safety_update" | "safety_unavailable" export const connectionFrameHandlers = { safety_history: () => {}, safety_update: () => {}, safety_unavailable: () => {}, - dialogue_history: () => {}, scope_decision_receipt: (msg, context) => context.state.setScopeDecisionReceipt(msg), server_hello: (msg, context) => { context.stores.connection.getState().setSessionProfiles(msg.capabilities?.sessionProfiles === true); @@ -41,9 +40,6 @@ export const connectionFrameHandlers = { inbox_delta: (msg, context) => { context.stores.inbox.getState().applyDelta(msg); }, - // Root-owned conversation routing consumes permission outcomes before demux; - // ordinary chat progress keeps its existing handlers. - tool_resolution: () => {}, // Pending follow-ups (#1002): a connection-wide frame, never demultiplexed. session_queue: (msg, context) => context.queueReport(msg), // Browser invalidation is #3231's: this client does not declare @@ -52,16 +48,21 @@ export const connectionFrameHandlers = { // Sent-row read states (#3155): the account's read client takes the frame // beside the demux, so nothing here touches a transcript. attachment_read: () => {}, - conversation_opened: () => {}, // The live-service default (#3616): the root conversation client reads it beside the demux. live_settings: () => {}, // The conversation client reads the selected persona beside the demux (#3617). live_persona: () => {}, - conversation_closed: () => {}, - conversation_event: () => {}, - conversation_work: () => {}, - conversation_output: () => {}, - conversation_permission: () => {}, + // The voice conversation client owns these frames (#3389): durable voice + // history, permission outcomes and the live conversation itself. The map is + // their only router; nothing here touches a transcript. + dialogue_history: (msg, context) => context.conversation(msg), + tool_resolution: (msg, context) => context.conversation(msg), + conversation_opened: (msg, context) => context.conversation(msg), + conversation_closed: (msg, context) => context.conversation(msg), + conversation_event: (msg, context) => context.conversation(msg), + conversation_work: (msg, context) => context.conversation(msg), + conversation_output: (msg, context) => context.conversation(msg), + conversation_permission: (msg, context) => context.conversation(msg), location_request: (msg, context) => { context.requestBrowserLocation(msg); }, diff --git a/packages/ui-react/src/hooks/websocket-handlers/index.ts b/packages/ui-react/src/hooks/websocket-handlers/index.ts index 1c037d087e..149cc4be48 100644 --- a/packages/ui-react/src/hooks/websocket-handlers/index.ts +++ b/packages/ui-react/src/hooks/websocket-handlers/index.ts @@ -1,4 +1,4 @@ -import type { ServerMessage } from "@schlessera/brain-ui-sdk/protocol"; +import type { ConsumerServerMessage } from "@schlessera/brain-ui-sdk/protocol"; import { activityFrameHandlers } from "./activity.js"; import { chatFrameHandlers } from "./chat.js"; import { connectionFrameHandlers } from "./connection.js"; @@ -62,7 +62,7 @@ const serverMessageHandlers = { ...handoffFrameHandlers, } satisfies ServerMessageHandlerMap; -export function dispatchServerMessage(msg: ServerMessage, context: DispatchContext): void { +export function dispatchServerMessage(msg: ConsumerServerMessage, context: DispatchContext): void { // The mapped type preserves the message/handler correlation. TypeScript // loses that correlation at an indexed union access, so restore it only at // this single composition boundary. diff --git a/packages/ui-react/src/hooks/websocket-handlers/types.ts b/packages/ui-react/src/hooks/websocket-handlers/types.ts index 11e123d7aa..c52ff29d89 100644 --- a/packages/ui-react/src/hooks/websocket-handlers/types.ts +++ b/packages/ui-react/src/hooks/websocket-handlers/types.ts @@ -1,9 +1,28 @@ -import type { InboxView, ServerMessage } from "@schlessera/brain-ui-sdk/protocol"; +import type { ConsumerServerMessage, InboxView, ServerMessage } from "@schlessera/brain-ui-sdk/protocol"; import type { ChatKey, SessionChat } from "../../stores/chat-store.js"; import type { ChatState } from "../../stores/chat-state.js"; import type { BrainStores } from "../../stores/create-stores.js"; -export type ServerMessageType = ServerMessage["type"]; +/** + * The frames the map routes: what the SDK client hands its consumer. `pong` + * is not one; the client consumes it for liveness (#3389). + */ +export type ServerMessageType = ConsumerServerMessage["type"]; + +/** + * The voice conversation client's own frames (#3389). Their map entries hand + * them to the conversation client; nothing in the chat demux reads them. + */ +type ConversationFrameType = + | "dialogue_history" + | "tool_resolution" + | "conversation_opened" + | "conversation_closed" + | "conversation_event" + | "conversation_work" + | "conversation_output" + | "conversation_permission"; +export type ConversationFrame = Extract; export interface DispatchContext { state: ChatState; @@ -33,11 +52,13 @@ export interface DispatchContext { answerReceipt: (msg: Extract) => void; /** A session's pending follow-ups, as the host holds them (#1002). */ queueReport: (msg: Extract) => void; + /** The voice conversation client, for the frames it owns (#3389). */ + conversation: (msg: ConversationFrame) => void; } export type ServerMessageHandlerMap = { [K in T]: ( - msg: Extract, + msg: Extract, context: DispatchContext ) => void; }; diff --git a/packages/ui-react/src/voice/conversation-client.ts b/packages/ui-react/src/voice/conversation-client.ts index 101a6e892d..07e6cfb222 100644 --- a/packages/ui-react/src/voice/conversation-client.ts +++ b/packages/ui-react/src/voice/conversation-client.ts @@ -2,8 +2,9 @@ import { createConversationRecovery } from "./conversation-recovery.js"; import { createConversationPermissions } from "./conversation-permissions.js"; import { createStore } from "zustand/vanilla"; import { CONVERSATION_LIMITS } from "@schlessera/brain-ui-sdk/protocol"; -import type { ClientMessage, ServerMessage, ServerConversationOpened, ConversationPersonaRef, ConversationProfile, LiveDefault, LivePersonaStatus, ServerConversationClosed, ConversationWireEvent, ConversationWorkReceipt, ConversationOutputRecord, DialoguePage, DialogueRecord } from "@schlessera/brain-ui-sdk/protocol"; +import type { ClientMessage, ConsumerServerMessage, ServerMessage, ServerConversationOpened, ConversationPersonaRef, ConversationProfile, LiveDefault, LivePersonaStatus, ServerConversationClosed, ConversationWireEvent, ConversationWorkReceipt, ConversationOutputRecord, DialoguePage, DialogueRecord } from "@schlessera/brain-ui-sdk/protocol"; import type { BrainUiServices } from "../root.js"; +import type { ConversationFrame } from "../hooks/websocket-handlers/types.js"; import { openConversationMicrophone, createConversationPlayback } from "./conversation-pcm.js"; export interface ConversationClientOutput extends ConversationOutputRecord { @@ -701,7 +702,12 @@ export function createConversationClient(root: BrainUiServices, send: (message: if (root.stores.voice.getState().mode === "conversation") root.stores.voice.getState().setMode("idle"); } let inputFormat: Extract["input"] | undefined; - function frame(message: ServerMessage): ServerMessage | null { + /** + * Every inbound frame, before the chat routing: rewrites, observations and + * the frames voice consumes beside the map. The frames this client owns + * outright go through the handler map to {@link receive} instead (#3389). + */ + function frame(message: ConsumerServerMessage): ConsumerServerMessage | null { // Preserve only exact fixed admission copy; request identity does not make diagnostics safe. if (message.type === "error" && message.code === "SESSION_LOAD_ERROR" && ![ "The host cannot verify this conversation. No work was started; your draft is kept.", @@ -716,65 +722,6 @@ export function createConversationClient(root: BrainUiServices, send: (message: state.setState({durableAvailable}); } if (message.type === "session_info") loadDialogue(message.sessionId); - if (message.type === "dialogue_history") { - const read = message.requestId ? dialogueReads.get(message.requestId) : undefined; - if (message.requestId && !read) return null; - if (message.requestId) dialogueReads.delete(message.requestId); - const key = message.sessionId ?? read?.key ?? `dialogue:${message.ownerId}`; - // Native reads cannot change target. Owner-addressed reads may return - // the host's canonical owner after a merge; the request pins the source. - if (read && !read.ownerId && key !== read.key) return null; - const previousPage = state.getState().dialogue[key] ?? Object.values(state.getState().dialogue).find(p => p.ownerId === message.ownerId); - if (previousPage && previousPage.generation !== message.generation && !read) return null; - if(!message.sessionId) root.stores.chat.getState().setHistoryOwner(key,message.ownerId); - const selected=root.stores.chat.getState().activeSessionId; - if(message.sessionId && selected && historyOwnerFor(selected) && state.getState().dialogue[selected]?.ownerId === message.ownerId){ - const oldBuffer=root.stores.chat.getState().buffers[selected]; - if(state.getState().sessionId===selected) state.setState({sessionId:message.sessionId}); - if(oldBuffer)root.stores.chat.getState().setMessages(message.sessionId,oldBuffer.messages); - root.stores.chat.getState().setActiveSession(message.sessionId); - } - - if(read?.ownerId && message.sessionId && selected === read.key){ - root.stores.chat.getState().setActiveSession(message.sessionId); - send({type:"session_resume",sessionId:message.sessionId}); - } - if (read?.ownerId && !message.sessionId) { - root.stores.chat.getState().setMessages(read.key, []); - root.stores.chat.getState().noteHistoryLoaded(read.key); - // There is deliberately no backend transcript or synthetic turn. - } - let refreshCursor=false; - state.setState(current => { - const old = current.dialogue[key] ?? Object.values(current.dialogue).find(p=>p.ownerId===message.ownerId); - if (old && old.generation !== message.generation && !read) return current; - const merged = new Map(); - // A new snapshot replaces old pages, retaining a live tail above H. - if (old && old.generation === message.generation) for (const r of old.records) if (!read || read.older || r.sequence > message.through) merged.set(r.sequence, r); - for (const r of message.records) merged.set(r.sequence, r); - let records = [...merged.values()].sort((a,b) => a.sequence-b.sequence); - const overflow = records.length > 2000; - if(overflow && !read) refreshCursor=true; - if (overflow) records = read?.older ? records.slice(0,2000) : records.slice(-2000); - const page = {...message, through: Math.max(old?.generation === message.generation ? old.through : 0,message.through), records, - before: read ? message.before : old?.before, cursor:read ? message.cursor : old?.cursor, - ...(overflow && !read?.older ? {before:message.before ?? old?.before} : {})}; - const entries = Object.entries({...current.dialogue,[key]:page}).filter(([k,p])=>k===key || (k!==read?.key && p.ownerId!==message.ownerId)).slice(-8); - return {dialogue: Object.fromEntries(entries), dialogueRestoredThrough: Object.fromEntries(entries.map(([k])=>[k,k===key && read ? message.through : current.dialogueRestoredThrough[k] ?? -1])), dialogueNotice: unsavedOverflow ? current.dialogueNotice : message.coverage === "partial" ? "Voice history may be incomplete." : ""}; - }); - const retained = state.getState().dialogue[key]; - if (message.sessionId && retained?.ownerId === message.ownerId && retained.generation === message.generation) { - // Exact correlated owner reads authorize O -> canonical C/session S. - // Native reads and unsolicited current-generation updates authorize - // only aliases already known to have the returned owner. - const sourceOwner = read?.ownerId ?? message.ownerId; - for (const from of new Set(unassignedWorkOwners.map(owner => owner.sessionId))) { - if (from && (read?.ownerId && from === read.key || historyOwnerFor(from) === sourceOwner)) moveUnassignedWork(from, message.sessionId); - } - } - if(refreshCursor) queueMicrotask(()=>loadDialogue(key)); - return null; - } if (message.type === "error" && message.requestId && dialogueReads.has(message.requestId) && (message.code === "SESSION_NOT_FOUND" || message.code === "SESSION_LOAD_ERROR")) { const read = dialogueReads.get(message.requestId)!; @@ -878,30 +825,90 @@ export function createConversationClient(root: BrainUiServices, send: (message: if (message.type === "live_persona") { // Takes effect at the next new conversation's Start, never mid-conversation. state.setState({ livePersona: message.livePersona }); - return message; } - if (!message.type.startsWith("conversation_")) return message; + return message; + } + function dialogueHistory(message: Extract) { + const read = message.requestId ? dialogueReads.get(message.requestId) : undefined; + if (message.requestId && !read) return; + if (message.requestId) dialogueReads.delete(message.requestId); + const key = message.sessionId ?? read?.key ?? `dialogue:${message.ownerId}`; + // Native reads cannot change target. Owner-addressed reads may return + // the host's canonical owner after a merge; the request pins the source. + if (read && !read.ownerId && key !== read.key) return; + const previousPage = state.getState().dialogue[key] ?? Object.values(state.getState().dialogue).find(p => p.ownerId === message.ownerId); + if (previousPage && previousPage.generation !== message.generation && !read) return; + if(!message.sessionId) root.stores.chat.getState().setHistoryOwner(key,message.ownerId); + const selected=root.stores.chat.getState().activeSessionId; + if(message.sessionId && selected && historyOwnerFor(selected) && state.getState().dialogue[selected]?.ownerId === message.ownerId){ + const oldBuffer=root.stores.chat.getState().buffers[selected]; + if(state.getState().sessionId===selected) state.setState({sessionId:message.sessionId}); + if(oldBuffer)root.stores.chat.getState().setMessages(message.sessionId,oldBuffer.messages); + root.stores.chat.getState().setActiveSession(message.sessionId); + } + + if(read?.ownerId && message.sessionId && selected === read.key){ + root.stores.chat.getState().setActiveSession(message.sessionId); + send({type:"session_resume",sessionId:message.sessionId}); + } + if (read?.ownerId && !message.sessionId) { + root.stores.chat.getState().setMessages(read.key, []); + root.stores.chat.getState().noteHistoryLoaded(read.key); + // There is deliberately no backend transcript or synthetic turn. + } + let refreshCursor=false; + state.setState(current => { + const old = current.dialogue[key] ?? Object.values(current.dialogue).find(p=>p.ownerId===message.ownerId); + if (old && old.generation !== message.generation && !read) return current; + const merged = new Map(); + // A new snapshot replaces old pages, retaining a live tail above H. + if (old && old.generation === message.generation) for (const r of old.records) if (!read || read.older || r.sequence > message.through) merged.set(r.sequence, r); + for (const r of message.records) merged.set(r.sequence, r); + let records = [...merged.values()].sort((a,b) => a.sequence-b.sequence); + const overflow = records.length > 2000; + if(overflow && !read) refreshCursor=true; + if (overflow) records = read?.older ? records.slice(0,2000) : records.slice(-2000); + const page = {...message, through: Math.max(old?.generation === message.generation ? old.through : 0,message.through), records, + before: read ? message.before : old?.before, cursor:read ? message.cursor : old?.cursor, + ...(overflow && !read?.older ? {before:message.before ?? old?.before} : {})}; + const entries = Object.entries({...current.dialogue,[key]:page}).filter(([k,p])=>k===key || (k!==read?.key && p.ownerId!==message.ownerId)).slice(-8); + return {dialogue: Object.fromEntries(entries), dialogueRestoredThrough: Object.fromEntries(entries.map(([k])=>[k,k===key && read ? message.through : current.dialogueRestoredThrough[k] ?? -1])), dialogueNotice: unsavedOverflow ? current.dialogueNotice : message.coverage === "partial" ? "Voice history may be incomplete." : ""}; + }); + const retained = state.getState().dialogue[key]; + if (message.sessionId && retained?.ownerId === message.ownerId && retained.generation === message.generation) { + // Exact correlated owner reads authorize O -> canonical C/session S. + // Native reads and unsolicited current-generation updates authorize + // only aliases already known to have the returned owner. + const sourceOwner = read?.ownerId ?? message.ownerId; + for (const from of new Set(unassignedWorkOwners.map(owner => owner.sessionId))) { + if (from && (read?.ownerId && from === read.key || historyOwnerFor(from) === sourceOwner)) moveUnassignedWork(from, message.sessionId); + } + } + if(refreshCursor) queueMicrotask(()=>loadDialogue(key)); + } + /** The live conversation's own frames, routed here by the handler map (#3389). */ + function conversation(message: Exclude) { const s = state.getState(); if ((message.type === "conversation_opened" || message.type === "conversation_closed") && openingId && message.requestId === openingId) { // A duplicate/foreign response cannot consume the valid pending request. if (s.active && openingEntry === entryLifetime && s.profile - && (message.conversationId !== s.profile.conversationId || message.epoch <= s.profile.epoch)) return null; + && (message.conversationId !== s.profile.conversationId || message.epoch <= s.profile.epoch)) return; openingId = undefined; if (!s.active || openingEntry !== entryLifetime) { requested = false; send({ type: "conversation_stop", conversationId: message.conversationId }); if (s.active) queueMicrotask(startEpoch); - return null; + return; } - if (message.type === "conversation_closed") { closedNotice = closeDiagnostic(message.reason,message); send({ type: "conversation_stop", conversationId: message.conversationId }); pause(true, true, false); return null; } - } else if (message.type === "conversation_opened") return null; + if (message.type === "conversation_closed") { closedNotice = closeDiagnostic(message.reason,message); send({ type: "conversation_stop", conversationId: message.conversationId }); pause(true, true, false); return; } + } else if (message.type === "conversation_opened") return; if (message.type === "conversation_work") { const p = scope(); const request = requests.get(message.requestId); const ownRequest = request?.conversationId === message.conversationId && request.epoch === message.epoch; - if (p?.conversationId !== message.conversationId && !ownRequest && !contextualWork.has(message.requestId)) return null; + if (p?.conversationId !== message.conversationId && !ownRequest && !contextualWork.has(message.requestId)) return; const contextual = retainContextualWork(message); - if (contextual === false) return null; + if (contextual === false) return; if (contextual && message.turnId && message.sessionId) moveUnassignedWork(contextual.noticeOwner, message.sessionId, message.conversationId, contextual.draftOrigin); const neverStarted = message.state === "refused" || (!message.turnId && (message.state === "cancelled" || message.state === "error")); if (ownRequest && neverStarted && request.composerDraftId && !restoredRequests.has(message.requestId)) { @@ -919,40 +926,40 @@ export function createConversationClient(root: BrainUiServices, send: (message: if (resync > 0) resync--; refresh(); if (consent) void capture(); } - return null; + return; } - if (!s.active) return null; + if (!s.active) return; if (message.type === "conversation_opened") { - if (!requested || (s.profile && (s.profile.conversationId !== message.conversationId || message.epoch <= s.profile.epoch))) return null; + if (!requested || (s.profile && (s.profile.conversationId !== message.conversationId || message.epoch <= s.profile.epoch))) return; clearClosedNotice(); generation++; state.setState({ token: generation }); stopMic(); resetRecovery(); playback.dispose(); playback = makePlayback(); fragments.clear(); unassignedThrough = -1; seenRecognition.clear(); retiredInputs.clear(); capturedInputs.clear(); manualReview.clear(); incompleteReview.clear(); lastInput = undefined; state.setState({ profile: message, connection: "Connected", text: "", interaction: "Listening", disclosureOpen: agreedEntry !== entryLifetime || agreedDisclosure !== disclosureKey(message, message.agentProviderId ?? entryProfileId) }); if (agreedEntry !== entryLifetime || agreedDisclosure !== disclosureKey(message, message.agentProviderId ?? entryProfileId)) setConsent(false); resync = message.resync.work + message.resync.outputs; ready = false; if (consent) void capture(); - return null; + return; } const p = scope(); - if (!p || !("conversationId" in message) || message.conversationId !== p.conversationId) return null; - if (message.type === "conversation_output") { updateOutput(message.epoch, message.outputId, message, true); if (resync > 0) resync--; refresh(); if (consent) void capture(); return null; } - if (!("epoch" in message) || message.epoch !== p.epoch) return null; + if (!p || !("conversationId" in message) || message.conversationId !== p.conversationId) return; + if (message.type === "conversation_output") { updateOutput(message.epoch, message.outputId, message, true); if (resync > 0) resync--; refresh(); if (consent) void capture(); return; } + if (!("epoch" in message) || message.epoch !== p.epoch) return; if (message.type === "conversation_closed") { // An old epoch can close after explicit Resume has already requested // its replacement. The opening's own closed response is handled above; // this receipt must not retire the replacement request or its consent. - if (openingId && requested) return null; + if (openingId && requested) return; requested = false; if (message.reason === "stopped") { suspend(); startEpoch(); } else if (message.reason === "disconnected" || message.reason === "provider_closed") { closedNotice = closeDiagnostic(message.reason,message); suspend(); startEpoch(); } else { closedNotice = closeDiagnostic(message.reason,message); pause(true); } - return null; + return; } - if (message.type !== "conversation_event") return null; + if (message.type !== "conversation_event") return; const event = message.event; - if (event.kind === "ready") { inputFormat = event.input; ready = true; refresh(); if (consent) void capture(); return null; } - if (!ready) return null; + if (event.kind === "ready") { inputFormat = event.input; ready = true; refresh(); if (consent) void capture(); return; } + if (!ready) return; if (message.retention === "unsaved") { stopForStorageFailure(); if (event.kind === "unassigned_input_fragment") retainRecognition(event,true); @@ -962,17 +969,17 @@ export function createConversationClient(root: BrainUiServices, send: (message: updateOutput(p.epoch,event.outputId,{unsavedGenerated:(old?.unsavedGenerated ?? "")+event.text,unsavedFragments:(old?.unsavedFragments ?? 0)+1}); } // Historical failure evidence never enters review, permissions, tasks or playback. - return null; + return; } - if (storageFailedScope === liveScopeKey()) return null; + if (storageFailedScope === liveScopeKey()) return; if (event.kind === "unassigned_input_fragment") { - if (!retainRecognition(event)) return null; + if (!retainRecognition(event)) return; const retained = state.getState().unassigned; - if (retained.some(f => f.conversationId === p.conversationId && f.epoch === p.epoch && !f.utteranceId && f.sequence === event.sequence)) return null; + if (retained.some(f => f.conversationId === p.conversationId && f.epoch === p.epoch && !f.utteranceId && f.sequence === event.sequence)) return; // Review context is separate from exact archived recognition. Never merge // approximate session intervals into captured utterances. const fragment = { sessionId: s.sessionId, conversationId: p.conversationId, epoch: p.epoch, taskContext: p.capabilities.contextualTasks === "supported", ...event }; - if (fragment.taskContext) { retainContext(fragment); return null; } + if (fragment.taskContext) { retainContext(fragment); return; } // Earlier contextual discussion has its own bound and is never review text. const unassigned = [...retained.filter(f => !f.taskContext), fragment]; let reviewChars=unassigned.reduce((n,f)=>n+f.text.length,0), trimmed=false; @@ -980,7 +987,7 @@ export function createConversationClient(root: BrainUiServices, send: (message: reviewChars-=unassigned.shift()!.text.length; trimmed=true; } state.setState({unassigned:[...retained.filter(f => f.taskContext),...unassigned],...(trimmed ? {notice:REVIEW_TRIMMED_NOTICE} : {})}); - return null; + return; } if (event.kind === "unassigned_delegation") { const ownerDraft = s.sessionId === null ? draftOrigin : null; @@ -988,23 +995,23 @@ export function createConversationClient(root: BrainUiServices, send: (message: if (owner) owner.count++; else unassignedWorkOwners.push({ conversationId: p.conversationId, sessionId: s.sessionId, draftOrigin: ownerDraft, count: 1 }); while (unassignedWorkOwners.length > CONVERSATION_LIMITS.maxFragmentsPerUtterance) unassignedWorkOwners.shift(); - refreshUnassignedWork(); return null; + refreshUnassignedWork(); return; } if (event.kind === "input_fragment") { - if (!capturedInputs.has(event.utteranceId) || retiredInputs.has(event.utteranceId)) return null; + if (!capturedInputs.has(event.utteranceId) || retiredInputs.has(event.utteranceId)) return; // Display deduplication must not intercept the existing permission or // manual-review path, including its attribution/finality validation. const newRecognition = retainRecognition(event); if (permissions.input(event)) { retiredInputs.add(event.utteranceId); fragments.delete(event.utteranceId); lastInput = undefined; state.setState({ text: [...fragments.values()].flatMap(items => [...items.values()].map(f => f.text)).join(" ").trim() }); - saveDraft(); refresh(); return null; + saveDraft(); refresh(); return; } if (p.capabilities.contextualTasks === "supported") { - if (!newRecognition) return null; + if (!newRecognition) return; // Bounded ephemeral context, never a manual-review draft or grant. retainContext({ sessionId: s.sessionId, conversationId: p.conversationId, epoch: p.epoch, taskContext: true, utteranceId: event.utteranceId, sequence: event.sequence, text: event.text, timing: { kind: "unavailable" }, finalization: event.finalization === "final" ? "final" : "unknown" }); - return null; + return; } const items = fragments.get(event.utteranceId) ?? new Map(); if (event.certainty !== "known" || event.origin !== "user" || (event.confidence ?? 0) < 0.9) manualReview.add(event.utteranceId); @@ -1022,7 +1029,7 @@ export function createConversationClient(root: BrainUiServices, send: (message: if (reviewIsIncomplete()) { removeSavedDraft(); clearTimeout(hold); hold=undefined; state.setState({notice:REVIEW_BOUNDED_NOTICE}); - refresh(); return null; + refresh(); return; } saveDraft(); maybeHold(generation); refresh(); @@ -1032,18 +1039,26 @@ export function createConversationClient(root: BrainUiServices, send: (message: } else if (event.kind === "audio") { try { const pcm = Uint8Array.from(atob(event.pcm), c => c.charCodeAt(0)); - if (state.getState().disclosureOpen || typeof document !== "undefined" && document.hidden) { updateOutput(p.epoch, event.outputId, { playback: "unknown" }); return null; } + if (state.getState().disclosureOpen || typeof document !== "undefined" && document.hidden) { updateOutput(p.epoch, event.outputId, { playback: "unknown" }); return; } if (recovery.phase !== "audible") { recovery.observe(pcm, performance.now()); updateOutput(p.epoch, event.outputId, { playback: "unknown" }); // Poll before the next event; never enqueue a suppressed chunk. - return null; + return; } playback.enqueue(event.outputId, pcm, event.format); } catch { pause(true); } } else if (event.kind === "interrupted") { suppressOutput(!!mic && !ended && !!utterance); refresh(); } - return null; + } + /** + * The frames this client owns, from their handler-map entries (#3389). The + * map is their only router: `frame` passes them through unchanged. + */ + function receive(message: ConversationFrame) { + if (message.type === "dialogue_history") dialogueHistory(message); + else if (message.type === "tool_resolution") permissions.resolution(message); + else conversation(message); } const unwatchChat = root.stores.chat.subscribe((next, previous) => { if (state.getState().active) { @@ -1088,7 +1103,7 @@ export function createConversationClient(root: BrainUiServices, send: (message: const unwatchAuth = root.authLock.registerStop(async () => { leave(); clearPrivateDialogue(); }); return { loadDialogue, historyOwnerFor, - state, frame, permissions, + state, frame, receive, permissions, attachControls() { controlOwners++; let attached = true; diff --git a/packages/ui-react/src/voice/conversation-permissions.ts b/packages/ui-react/src/voice/conversation-permissions.ts index da7b6b97cd..701280ef1b 100644 --- a/packages/ui-react/src/voice/conversation-permissions.ts +++ b/packages/ui-react/src/voice/conversation-permissions.ts @@ -88,20 +88,6 @@ export function createConversationPermissions(root: BrainUiServices, send: (mess if (!previous) put({ sessionId, turnId, toolUseId: message.toolUseId, label, phase: "pending", announced: false, ambiguous: false, byVoice: false, script: "", word: "" }); else if (previous.phase === "unknown") put({ ...previous, phase: "pending", word: "Refusal unconfirmed · request still waiting" }); publish(); quiet(); - } else if (message.type === "tool_resolution") { - const key = identity(sessionId, turnId, message.toolUseId); - const previous = records.get(key); - const phase = message.outcome === "granted" ? "granted" : message.outcome === "expired" ? "expired" : message.outcome === "denied" ? "denied" : "unknown"; - // A posture denial can have an outcome without ever having a grant card. - const byVoice = phase === "unknown" ? previous?.byVoice === true : previous?.heardAt !== undefined && message.channel === "voice"; - const word = phase === "granted" ? previous?.heardAt ? "The screen decision was already accepted." : "Approved on screen" : phase === "expired" ? "Expired · denied · no answer before the turn ended" - : phase === "unknown" ? "Couldn't confirm the refusal" : byVoice ? previous?.ambiguous ? "Denied · by voice · heard unclearly · taken as refusal" : "Denied · by voice" - : message.reason === "voice_posture" ? "not done · denied by voice posture · no card" : "Denied on screen"; - put({ sessionId, turnId, toolUseId: message.toolUseId, announced: previous?.announced ?? false, ambiguous: previous?.ambiguous ?? false, byVoice, - ...(previous?.heardAt ? { heardAt: previous.heardAt } : {}), ...(message.reason === "voice_posture" ? { postureDenied: true as const } : {}), label: previous?.label, phase, word, - script: phase === "denied" && byVoice ? previous?.ambiguous ? "I couldn't hear that clearly, so I took it as a refusal. The action was denied." : "I took that as a refusal. The action was denied." - : phase === "expired" ? "I stopped without doing it. Ask me again when you can look at a screen." : word }); - publish(); } else if (message.type === "result" || message.type === "status" && (message.status === "idle" || message.status === "cancelled")) { for (const receipt of records.values()) if (receipt.sessionId === sessionId && receipt.turnId === turnId && ["pending", "sent"].includes(receipt.phase)) { put({ ...receipt, phase: "expired", word: message.type === "status" && message.status === "cancelled" ? "Cancelled · not done" : "Expired · denied · no answer before the turn ended", script: "I stopped without doing it. Ask me again when you can look at a screen." }); @@ -109,6 +95,24 @@ export function createConversationPermissions(root: BrainUiServices, send: (mess publish(); } } + /** A permission's settled outcome (#957), from its handler-map entry (#3389). */ + function resolution(message: Extract) { + const { sessionId, turnId } = message; + if (!sessionId || !turnId) return; + const key = identity(sessionId, turnId, message.toolUseId); + const previous = records.get(key); + const phase = message.outcome === "granted" ? "granted" : message.outcome === "expired" ? "expired" : message.outcome === "denied" ? "denied" : "unknown"; + // A posture denial can have an outcome without ever having a grant card. + const byVoice = phase === "unknown" ? previous?.byVoice === true : previous?.heardAt !== undefined && message.channel === "voice"; + const word = phase === "granted" ? previous?.heardAt ? "The screen decision was already accepted." : "Approved on screen" : phase === "expired" ? "Expired · denied · no answer before the turn ended" + : phase === "unknown" ? "Couldn't confirm the refusal" : byVoice ? previous?.ambiguous ? "Denied · by voice · heard unclearly · taken as refusal" : "Denied · by voice" + : message.reason === "voice_posture" ? "not done · denied by voice posture · no card" : "Denied on screen"; + put({ sessionId, turnId, toolUseId: message.toolUseId, announced: previous?.announced ?? false, ambiguous: previous?.ambiguous ?? false, byVoice, + ...(previous?.heardAt ? { heardAt: previous.heardAt } : {}), ...(message.reason === "voice_posture" ? { postureDenied: true as const } : {}), label: previous?.label, phase, word, + script: phase === "denied" && byVoice ? previous?.ambiguous ? "I couldn't hear that clearly, so I took it as a refusal. The action was denied." : "I took that as a refusal. The action was denied." + : phase === "expired" ? "I stopped without doing it. Ask me again when you can look at a screen." : word }); + publish(); + } function input(event: Extract) { // Unknown attribution is never a user decision. Neither an assistant // transcript nor replayed output can authorize even a scoped denial. @@ -124,7 +128,7 @@ export function createConversationPermissions(root: BrainUiServices, send: (mess return true; } const unsubscribe = root.stores.chat.subscribe(apply); - return { state, frame, input, quiet, refresh() { publish(); quiet(); }, + return { state, frame, resolution, input, quiet, refresh() { publish(); quiet(); }, lost() { for (const receipt of records.values()) if (receipt.phase === "sent") put({ ...receipt, phase: "unknown", word: "Couldn't confirm the refusal" }); publish(); }, clear() { records.clear(); turns.clear(); announced.clear(); full = false; publish(); }, dispose() { unsubscribe(); records.clear(); turns.clear(); announced.clear(); }, diff --git a/packages/ui-react/src/ws-client/inbound.ts b/packages/ui-react/src/ws-client/inbound.ts index 91c53fe30d..2ea6de9c18 100644 --- a/packages/ui-react/src/ws-client/inbound.ts +++ b/packages/ui-react/src/ws-client/inbound.ts @@ -1,4 +1,4 @@ -import type { ClientMessage, InboxView, ServerMessage, ServerLocationRequest } from "@schlessera/brain-ui-sdk/protocol"; +import type { ClientMessage, ConsumerServerMessage, InboxView, ServerMessage, ServerLocationRequest } from "@schlessera/brain-ui-sdk/protocol"; import type { BrainUiServices } from "../root.js"; import { restorationOf, type ChatState, type ChatKey } from "../stores/chat-state.js"; import type { SessionChat } from "../stores/chat-store.js"; @@ -14,7 +14,7 @@ import { refusalReason } from "../lib/turn-failure.js"; import type { AccountServices } from "./account.js"; import type { createConversationClient } from "../voice/conversation-client.js"; -type InboundConversation = Pick, "frame" | "historyOwnerFor" | "state">; +type InboundConversation = Pick, "frame" | "receive" | "historyOwnerFor" | "state">; interface InboundDeps { disposed: () => boolean; @@ -56,10 +56,28 @@ const CONNECTION_WIDE = new Set([ ]); /** - * Every inbound frame, in order: the voice conversation's routing, the - * restoration and turn-boundary prefilter, request receipts, then the typed - * handler map — once for connection-wide frames, or after the demux has - * found the frame's session buffer. The map is the single routing table. + * The voice conversation's own frames (#3389), dispatched connection-wide at + * the point the conversation client sees every frame. Nothing after that + * reads them: they carry no chat state, run state or request receipt. + * `tool_resolution` is the conversation client's too, but it continues to the + * demux, which records its session's run state before dispatching it once. + */ +const CONVERSATION_OWNED = new Set([ + "dialogue_history", + "conversation_opened", + "conversation_closed", + "conversation_event", + "conversation_work", + "conversation_output", + "conversation_permission", +]); + +/** + * Every inbound frame, in order: the voice conversation's prefilter (its own + * frames go from there straight to the map), the restoration and + * turn-boundary prefilter, request receipts, then the typed handler map — + * once for connection-wide frames, or after the demux has found the frame's + * session buffer. The map is the single routing table. */ export function createInbound(root: BrainUiServices, deps: InboundDeps) { // A connect snapshot may answer after its captured turn ended on this socket. @@ -109,9 +127,17 @@ export function createInbound(root: BrainUiServices, deps: InboundDeps) { retryReceipt: deps.retries.receipt, answerReceipt: (msg) => deps.services.answers.receipt(msg), queueReport: deps.followUps.queueReport, + conversation: deps.conversation.receive, }; } + /** Dispatch a frame once, outside the per-session demux. */ + function dispatchConnectionWide(msg: ConsumerServerMessage): void { + const state = root.stores.chat.getState(); + const key = state.activeSessionId; + dispatchServerMessage(msg, context(state, key, undefined, undefined, () => (key === null ? state.draft : state.buffers[key]))); + } + /** * Does this frame announce the identity of the conversation THIS client just * started? @@ -187,11 +213,15 @@ export function createInbound(root: BrainUiServices, deps: InboundDeps) { function handleServerMessage(msg: ServerMessage): void { if (deps.disposed() || root.authLock.state.getState().phase !== "active") return; + // The SDK client consumes `pong` for liveness and never hands one on, so + // the map has no entry for it (#3389). Neither does a frame fed in here. + if (msg.type === "pong") return; // Voice frames bypass handleFrame; flush earlier backend text before observing them. if (msg.type.startsWith("conversation_")) deps.deltas.flush(); const routed = deps.conversation.frame(msg); if (!routed) return; msg = routed; + if (CONVERSATION_OWNED.has(msg.type)) { dispatchConnectionWide(msg); return; } if (deps.services.safety.frame(msg)) return; if (!prefilter(msg)) return; handleFrame(msg); @@ -330,18 +360,14 @@ export function createInbound(root: BrainUiServices, deps: InboundDeps) { return undefined; } - function handleFrame(msg: ServerMessage): void { + function handleFrame(msg: ConsumerServerMessage): void { // Every frame that is not itself a delta must see the transcript fully // applied: the demux below reads buffer state, and the store records parts in // arrival order, so a tool call landing ahead of buffered text would reorder // the message. if (msg.type !== "text_delta" && msg.type !== "thinking_delta") deps.deltas.flush(); + if (CONNECTION_WIDE.has(msg.type)) { dispatchConnectionWide(msg); return; } const state = root.stores.chat.getState(); - if (CONNECTION_WIDE.has(msg.type)) { - const key = state.activeSessionId; - dispatchServerMessage(msg, context(state, key, undefined, undefined, () => (key === null ? state.draft : state.buffers[key]))); - return; - } trackRequest(msg, state); // Parallel-session demux (per-session buffers). Every frame is scoped by @@ -351,6 +377,9 @@ export function createInbound(root: BrainUiServices, deps: InboundDeps) { // session's pre-binding frames) apply to the buffer in view. const frameSessionId = (msg as { sessionId?: string }).sessionId; if (!noteRunState(msg, state, frameSessionId)) return; + // A permission outcome is the voice client's, whether or not its session + // has a buffer here; only its run state belongs to the demux. + if (msg.type === "tool_resolution") { dispatchConnectionWide(msg); return; } const key = bufferKeyFor(msg, state, frameSessionId); if (key === undefined) return; if ((msg.type === "session_info" || msg.type === "status") && msg.requestId && msg.thinkingLevel !== undefined) { diff --git a/packages/ui-react/tests/browser/conversation.offline.tsx b/packages/ui-react/tests/browser/conversation.offline.tsx index eb8b0f8e7d..98c9806a64 100644 --- a/packages/ui-react/tests/browser/conversation.offline.tsx +++ b/packages/ui-react/tests/browser/conversation.offline.tsx @@ -3,7 +3,7 @@ import { afterAll, beforeAll, expect, test, type TestContext } from "vitest"; import { commands, userEvent, page } from "vitest/browser"; import { createRoot } from "react-dom/client"; import { flushSync } from "react-dom"; -import { CONVERSATION_LIMITS, type ConversationCapabilities, type ConversationWireEvent, type ServerConversationOpened, type ServerMessage } from "@schlessera/brain-ui-sdk/protocol"; +import { CONVERSATION_LIMITS, type ConversationCapabilities, type ConversationWireEvent, type ConsumerServerMessage, type ServerConversationOpened, type ServerMessage } from "@schlessera/brain-ui-sdk/protocol"; import { createBrainUiRoot } from "../../src/root.js"; import { BrainUiProvider } from "../../src/root-context.js"; import { AppShell } from "../../src/components/layout/app-shell.js"; @@ -1259,7 +1259,7 @@ test("root refresh: dispose releases physical capture and a fresh root requires expect(fresh.client.state.getState().micOn).toBe(false); expect(mic.opens()).toBe(1); old.client.enter(); old.client.resume(); - old.client.frame({ ...PROFILE, epoch: 2, requestId: String(old.socket.frames("conversation_start")[0]?.requestId) }); + old.client.receive({ ...PROFILE, epoch: 2, requestId: String(old.socket.frames("conversation_start")[0]?.requestId) }); expect(mic.opens()).toBe(1); await userEvent.click(fresh.button("Start")); await expect.poll(() => fresh.client.state.getState().micOn).toBe(true); @@ -1367,7 +1367,7 @@ for (const ending of ["leave", "logout", "dispose"] as const) test(`close diagno else if (ending === "logout") await s.ui.authLock.expire("signed out", true); else s.dispose(); expect(s.client.state.getState().notice, "LIFECYCLE_CLEARS_CLOSE_DIAGNOSTIC").not.toContain(CLOSE_DIAGNOSTICS.provider_error); - s.client.frame(closed); + s.client.receive(closed); expect(s.client.state.getState().notice, "LATE_CLOSE_CANNOT_RESTORE_DIAGNOSTIC").not.toContain(CLOSE_DIAGNOSTICS.provider_error); expect(s.client.state.getState().active).toBe(false); }); @@ -1897,8 +1897,8 @@ test("late contextual correlation is bounded, exact and cleared with its princip expect(s.client.state.getState().unassignedWork, "BOUND_CONTEXTUAL_NOTICE_CANNOT_RETARGET").toBe(0); flushSync(() => s.ui.stores.chat.getState().setActiveSession("odysseus-bounded-native")); await s.ui.authLock.expire("signed out", true); - s.client.frame({ ...retained, state: "running", turnId: "odysseus-retained-turn" }); - s.client.frame({ type: "session_info", sessionId: "odysseus-bounded-native", requestId: retained.requestId, turnId: "odysseus-retained-turn", isNew: true } as ServerMessage & { turnId: string }); + s.client.receive({ ...retained, state: "running", turnId: "odysseus-retained-turn" }); + s.client.frame({ type: "session_info", sessionId: "odysseus-bounded-native", requestId: retained.requestId, turnId: "odysseus-retained-turn", isNew: true } as ConsumerServerMessage & { turnId: string }); expect(s.client.state.getState().unassignedWork, "LATE_CONTEXTUAL_IDENTITY_CANNOT_SURVIVE_AUTH_CLEAR").toBe(0); expect(s.socket.frames("conversation_commit")).toHaveLength(0); expect(s.socket.frames("chat_message")).toHaveLength(0); diff --git a/packages/ui-react/tests/handler-map-frames.test-d.ts b/packages/ui-react/tests/handler-map-frames.test-d.ts new file mode 100644 index 0000000000..f25dd2b5b8 --- /dev/null +++ b/packages/ui-react/tests/handler-map-frames.test-d.ts @@ -0,0 +1,20 @@ +/** + * The server-frame handler map is keyed on the frames the SDK client hands its + * consumer (#3389): exhaustive over them (`satisfies` in the map itself), and + * with no `pong`, which the client consumes for liveness. `tsc --noEmit` + * checks this file. + */ + +import type { ConsumerServerMessage } from "@schlessera/brain-ui-sdk/protocol"; +import type { ServerMessageHandlerMap, ServerMessageType } from "../src/hooks/websocket-handlers/types.js"; + +type Assert = T; +type Equal = (() => T extends A ? 1 : 2) extends (() => T extends B ? 1 : 2) ? true : false; + +type HandlerMapDropsPong = Assert, never>>; +type HandlerMapKeysEveryConsumerFrame = Assert>; + +// @ts-expect-error A handler map cannot claim `pong`. +type PongEntry = ServerMessageHandlerMap<"pong">; + +export type HandlerMapFrameAssertions = [HandlerMapDropsPong, HandlerMapKeysEveryConsumerFrame, PongEntry]; diff --git a/packages/ui-react/tests/ws-client-lifecycle.test.ts b/packages/ui-react/tests/ws-client-lifecycle.test.ts index 1f089bf136..b643b6334d 100644 --- a/packages/ui-react/tests/ws-client-lifecycle.test.ts +++ b/packages/ui-react/tests/ws-client-lifecycle.test.ts @@ -7,7 +7,7 @@ */ import { afterEach, describe, expect, test } from "bun:test"; import type { BrainUiClient, BrainUiClientOptions } from "@schlessera/brain-ui-sdk/client"; -import type { ClientMessage, ServerMessage } from "@schlessera/brain-ui-sdk/protocol"; +import type { ClientMessage, ConsumerServerMessage, ServerMessage } from "@schlessera/brain-ui-sdk/protocol"; import { createBrainUiRoot, type BrainUiRoot } from "../src/root.js"; import { createDeltaBuffer } from "../src/ws-client/delta-buffer.js"; import { createReconnectHealing } from "../src/ws-client/reconnect.js"; @@ -266,7 +266,7 @@ describe("socket lease", () => { test("a closed socket's frames and pinned replies never reach the page", () => { const { sockets, opened, messages } = lease(); sockets.acquire(() => {}); - const hello = { type: "pong" } as ServerMessage; + const hello: ConsumerServerMessage = { type: "server_hello", protocolRev: 2 }; opened[0].handlers?.onAny?.(hello); const replies: ClientMessage[] = []; const client = sockets.client()! as unknown as { send: (message: ClientMessage) => boolean }; @@ -276,7 +276,7 @@ describe("socket lease", () => { sockets.acquire(() => {}); opened[0].handlers?.onAny?.(hello); reply({ type: "location_error", requestId: "r1", code: 0, message: "gone" }); - expect(messages).toEqual(["pong"]); + expect(messages).toEqual(["server_hello"]); expect(replies).toEqual([]); expect(opened).toHaveLength(2); }); @@ -308,14 +308,65 @@ describe("the handler map is the single routing table", () => { retryReceipt: (msg) => calls.push(`retry:${msg.requestId}`), answerReceipt: (msg) => calls.push(`answer:${msg.type}`), queueReport: (msg) => calls.push(`queue:${msg.sessionId}`), + conversation: (msg) => calls.push(`conversation:${msg.type}`), } as Partial as DispatchContext; } + // The voice conversation client's own frames (#3389), one minimal instance each. + const VOICE_FRAMES = [ + { type: "dialogue_history", ownerId: "mast", sessionId: "ithaca", generation: 1, coverage: "partial", through: 0, records: [] }, + { type: "tool_resolution", toolUseId: "oar-1", outcome: "denied", sessionId: "ithaca", turnId: "t1" }, + { type: "conversation_opened", conversationId: "sirens", epoch: 1 }, + { type: "conversation_closed", conversationId: "sirens", epoch: 1, reason: "stopped" }, + { type: "conversation_event", conversationId: "sirens", epoch: 1, event: { kind: "ready" } }, + { type: "conversation_work", conversationId: "sirens", epoch: 1, requestId: "w1", sessionId: "ithaca", state: "running" }, + { type: "conversation_output", conversationId: "sirens", epoch: 1, outputId: "o1" }, + { type: "conversation_permission", conversationId: "sirens", epoch: 1 }, + ] as unknown as ConsumerServerMessage[]; + + for (const frame of VOICE_FRAMES) { + test(`a ${frame.type} frame is the conversation client's, through its own map entry`, () => { + const calls: string[] = []; + dispatchServerMessage(frame, context(calls)); + expect(calls, "VOICE_FRAME_MAP_ENTRY").toEqual([`conversation:${frame.type}`]); + }); + + test(`a ${frame.type} frame reaches the conversation client once from the socket, outside the demux`, () => { + const root = makeRoot(); + const conversation = root.connection.conversation; + const received: string[] = []; + const receive = conversation.receive; + conversation.receive = (msg) => { received.push(msg.type); receive(msg); }; + // The prefilter passes the frame on unchanged: only the map routes it. + expect(conversation.frame(frame), "VOICE_PREFILTER_PASSES_THROUGH").toBe(frame); + expect(received).toEqual([]); + root.connection.handleServerMessage(frame); + expect(received, "VOICE_FRAME_REACHES_CONVERSATION").toEqual([frame.type]); + // A conversation frame names a session without being chat progress. + if (frame.type !== "tool_resolution") expect(root.stores.chat.getState().runStates, "VOICE_FRAME_SKIPS_DEMUX").toEqual({}); + }); + } + + test("durable voice history lands in the conversation client through the map", () => { + const root = makeRoot(); + root.connection.handleServerMessage(VOICE_FRAMES[0]!); + expect(root.connection.conversation.state.getState().dialogue.ithaca).toMatchObject({ ownerId: "mast", generation: 1 }); + }); + + test("a permission outcome reaches voice for a session with no buffer here, and still marks its run", () => { + const root = makeRoot(); + root.connection.handleServerMessage(VOICE_FRAMES[1]!); + expect(root.connection.conversation.permissions.state.getState().records).toMatchObject([ + { sessionId: "ithaca", turnId: "t1", toolUseId: "oar-1", phase: "denied", word: "Denied on screen" }, + ]); + expect(root.stores.chat.getState().runStates.ithaca).toBe("streaming"); + }); + test("each frame the connection owns is handled by its own map entry", () => { const calls: string[] = []; - dispatchServerMessage({ type: "retry_receipt", sessionId: "s1", requestId: "r1", state: "unknown" } as ServerMessage, context(calls)); - dispatchServerMessage({ type: "ask_answer_receipt", answerId: "a1", state: "accepted" } as unknown as ServerMessage, context(calls)); - dispatchServerMessage({ type: "session_queue", sessionId: "s1", followUps: [] } as unknown as ServerMessage, context(calls)); + dispatchServerMessage({ type: "retry_receipt", sessionId: "s1", requestId: "r1", state: "unknown" } as ConsumerServerMessage, context(calls)); + dispatchServerMessage({ type: "ask_answer_receipt", answerId: "a1", state: "accepted" } as unknown as ConsumerServerMessage, context(calls)); + dispatchServerMessage({ type: "session_queue", sessionId: "s1", followUps: [] } as unknown as ConsumerServerMessage, context(calls)); expect(calls).toEqual(["retry:r1", "answer:ask_answer_receipt", "queue:s1"]); }); diff --git a/packages/ui-sdk/src/client/ws-client.ts b/packages/ui-sdk/src/client/ws-client.ts index 2359bf93dd..5a171a6c56 100644 --- a/packages/ui-sdk/src/client/ws-client.ts +++ b/packages/ui-sdk/src/client/ws-client.ts @@ -27,7 +27,7 @@ * socket. */ import { ACTIVITY_COMPUTE_CAPABILITY, ASK_RECEIPTS_CAPABILITY, ATTACHMENT_READS_CAPABILITY, FOLLOW_UP_QUEUE_CAPABILITY, SESSION_SAFETY_CAPABILITY, LIVENESS_CAPABILITY, PROTOCOL_REV } from "../protocol.js"; -import type { ClientMessage, ServerMessage } from "../protocol.js"; +import type { ClientMessage, ConsumerServerMessage } from "../protocol.js"; import { parseServerMessage } from "../schemas.js"; export type ConnectionStatus = "connecting" | "connected" | "disconnected"; @@ -69,17 +69,18 @@ export type LivenessEvent = export type HelloState = "pending" | "received" | "absent"; /** - * One optional handler per frame type. + * One optional handler per frame type the consumer receives. * * Optional individually so a consumer implements only what it renders, and an * unhandled frame is a no-op rather than an error — the same additive posture - * the parser takes. + * the parser takes. `pong` has no handler: the client consumes it for + * liveness, so it is not part of {@link ConsumerServerMessage} (#3389). */ export type ServerFrameHandlers = { - [K in ServerMessage["type"]]?: (frame: Extract) => void; + [K in ConsumerServerMessage["type"]]?: (frame: Extract) => void; } & { /** Called for every valid frame, before the per-type handler. */ - onAny?: (frame: ServerMessage) => void; + onAny?: (frame: ConsumerServerMessage) => void; }; /** Why a frame was discarded. A bounded token, never the payload. */ @@ -346,7 +347,7 @@ export class BrainUiClient { } const handlers = this.options.handlers; - const handler = handlers?.[frame.type] as ((f: ServerMessage) => void) | undefined; + const handler = handlers?.[frame.type] as ((f: ConsumerServerMessage) => void) | undefined; // `onAny` counts as handling. A consumer whose dispatch shares a preamble // across every frame type — resolving which session buffer a frame belongs diff --git a/packages/ui-sdk/src/protocol.ts b/packages/ui-sdk/src/protocol.ts index 3999b8683d..b112792b4d 100644 --- a/packages/ui-sdk/src/protocol.ts +++ b/packages/ui-sdk/src/protocol.ts @@ -968,6 +968,15 @@ export type ServerMessage = | ServerAttachmentRead | ServerLiveSettings; +/** + * The frames `BrainUiClient` hands its consumer: every {@link ServerMessage} + * except `pong` (#3389). The client answers its own liveness probes and + * returns before any consumer handler runs, so a consumer never sees one and + * needs no case for it. `pong` stays on the wire and in `ServerMessage`, the + * union `parseServerMessage` validates. + */ +export type ConsumerServerMessage = Exclude; + /** * First frame a server sends after a socket opens (rev 2, additive). Clients * that don't know it ignore it; clients that do can gate behavior on diff --git a/packages/ui-sdk/tests/consumer-frames.test-d.ts b/packages/ui-sdk/tests/consumer-frames.test-d.ts new file mode 100644 index 0000000000..29df5a47dc --- /dev/null +++ b/packages/ui-sdk/tests/consumer-frames.test-d.ts @@ -0,0 +1,38 @@ +/** + * `pong` is the client's own frame (#3389). `BrainUiClient` answers its + * liveness probes and returns before any consumer handler runs, so the + * consumer-facing union and the handler type leave it out, while the wire + * union the parser validates keeps it. `tsc --noEmit` checks this file. + */ + +import type { ServerFrameHandlers } from "../src/client/index.js"; +import type { ConsumerServerMessage, ServerMessage, ServerPong } from "../src/protocol.js"; +import type { parseServerMessage } from "../src/schemas.js"; +import type { Assert, Equal } from "./type-equality.js"; + +type ParsedFrame = Extract, { ok: true }>["message"]; + +// The parser still accepts a wire `pong`. +type ParserKeepsPong = Assert, ServerPong>>; +type WireUnionKeepsPong = Assert, ServerPong>>; + +// The consumer never receives one, and loses nothing else. +type ConsumerUnionDropsPong = Assert, never>>; +type ConsumerUnionIsTheRest = Assert>; + +const handlers: ServerFrameHandlers = { + // @ts-expect-error A consumer `pong` handler is no longer accepted. + pong: () => {}, +}; + +const anyFrame: ServerFrameHandlers = { + onAny: (frame) => { + // @ts-expect-error `onAny` never sees a `pong` either: the comparison has no overlap. + if (frame.type === "pong") return; + }, +}; + +export type ConsumerFrameAssertions = [ + ParserKeepsPong, WireUnionKeepsPong, ConsumerUnionDropsPong, ConsumerUnionIsTheRest, +]; +export { handlers, anyFrame }; diff --git a/scripts/source-browser-dispatch.ts b/scripts/source-browser-dispatch.ts index 25bb085e7f..a294f0f96c 100644 --- a/scripts/source-browser-dispatch.ts +++ b/scripts/source-browser-dispatch.ts @@ -16,22 +16,29 @@ const helperConsumers:Record={ // Re-audited for #3812: inbound.ts gained refusalReason from lib/turn-failure.ts, // which imports only protocol types and constants; still only runStateForFrame // from the chat handlers. - "packages/ui-react/src/ws-client/inbound.ts":"513ef019608371d41da3d15c3f48fdc2a8bcbb49882975b6f8099e2cd0a2d64c", + // Re-audited for #3389: inbound.ts now dispatches the voice-owned frames + // connection-wide through dispatchServerMessage and hands the conversation + // client's receive to the context; from chat.ts it still imports only + // runStateForFrame and never acquires or mutates chatFrameHandlers. + "packages/ui-react/src/ws-client/inbound.ts":"4de90794456038a9e424c034c36c95a7c20651b529adb7a5a20d18c0490051c1", "packages/ui-react/src/hooks/use-websocket.ts":"6edd8b289fa4dcf7f0a512ce1275bd9e9c70661ce5630e22503b4b1d888cf557" }; // Re-audited for #3155: chat.ts only gained `attachmentFiles` in its history // message mapping; chatFrameHandlers and its dispatch are unchanged. +// Re-audited for #3389: index.ts only retyped dispatchServerMessage's frame +// as ConsumerServerMessage, and chat.ts only lost its `pong` no-op entry and +// union member; the registry, its spreads and its one call site are unchanged. const declarations=[ { "owner": "packages/ui-react/src/hooks/websocket-handlers/index.ts", - "source": "21bf20fc8dad6e8a985f1d8686b559627b46824048f1021ad422c5c002f123b8", + "source": "72b7747cf4704cd16718919610d71b3aa74d17c6d5adbece3426eb5ed4da823d", "registry": "serverMessageHandlers", "expression": "serverMessageHandlers[msg.type](msg as never, context)", "maps": [ { "owner": "packages/ui-react/src/hooks/websocket-handlers/chat.ts", "name": "chatFrameHandlers", - "source": "7293732dfe85e43815c013e86af467a6d57c33d0eb8232310938ed3a6d5e3048" + "source": "e1728b598b8c187f5776e092de4be685e29912949af24171890e6a9c81130a51" }, { "owner": "packages/ui-react/src/hooks/websocket-handlers/activity.ts", @@ -55,10 +62,14 @@ const declarations=[ // reads no runtime input; the conversation client takes the frame. // Re-audited for #3616: the added live_settings handler is a no-op that // reads no runtime input; the root conversation client reads the frame. + // Re-audited for #3389: the eight voice-owned entries (dialogue_history, + // tool_resolution, conversation_*) now only pass their frame to + // context.conversation, the conversation client's receive, which read + // the same frames from its prefilter before; they read nothing else. { "owner": "packages/ui-react/src/hooks/websocket-handlers/connection.ts", "name": "connectionFrameHandlers", - "source": "f4d7125dd5212dab15eea102c7e45f4ed5139f5dddc2a48f6a77fc3bd9838b70" + "source": "76b9ca482cc1cf0d2cc990fd25bbdc4862e5e3c78b0231ead36184edb06b6f8e" }, { "owner": "packages/ui-react/src/hooks/websocket-handlers/handoff.ts", diff --git a/tests/helpers/unit-consumer-audit.ts b/tests/helpers/unit-consumer-audit.ts index 90114b2940..9a4f58634c 100644 --- a/tests/helpers/unit-consumer-audit.ts +++ b/tests/helpers/unit-consumer-audit.ts @@ -89,6 +89,8 @@ export function auditUnitConsumers(root: string, browserEntrypoints: readonly st "packages/ui-backend-pi/scripts/measure-startup.ts", "packages/ui-react/tests/render/streaming-bench.tsx", "packages/ui-react/tests/block-contract.test-d.ts", + // Type-only handler-map assertions (#3389), checked by the root `tsc --noEmit`. + "packages/ui-react/tests/handler-map-frames.test-d.ts", "packages/ui-server/tests/maintenance-temp-shared-uid-proof.ts"]; return records.map(record => { const closure = owners(record.importer);