diff options
| author | Adam Malczewski <[email protected]> | 2026-06-12 15:08:24 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-12 15:08:24 +0900 |
| commit | 5ef7cc2916c544a66d68805063b02290f24d9a25 (patch) | |
| tree | 51724187d01813bbbbaef513eb8cada2e1bda1a6 /src/core/wire | |
| parent | fb37680bd013509ab5d72619f261713e8473e988 (diff) | |
| download | dispatch-web-5ef7cc2916c544a66d68805063b02290f24d9a25.tar.gz dispatch-web-5ef7cc2916c544a66d68805063b02290f24d9a25.zip | |
feat(chat): multi-client live view — watch in-flight turns + user prompt on stream
- subscribe every open conversation on load + WS reconnect (resync), unsubscribe on tab close
- derive a stream-based 'generating' state for watchers (Composer running indicator)
- fold the user-message turn event so watchers render the prompt mid-turn (de-dup vs sender's optimistic echo)
- re-pin [email protected] / [email protected]; re-mirror contracts; add user-message to the exhaustiveness guard
Diffstat (limited to 'src/core/wire')
| -rw-r--r-- | src/core/wire/conformance.test.ts | 17 | ||||
| -rw-r--r-- | src/core/wire/conformance.ts | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/core/wire/conformance.test.ts b/src/core/wire/conformance.test.ts index 690ba4e..a258873 100644 --- a/src/core/wire/conformance.test.ts +++ b/src/core/wire/conformance.test.ts @@ -27,6 +27,7 @@ describe("classifies every AgentEvent type", () => { const samples: AgentEvent[] = [ { type: "status", conversationId: "c1", status: "idle" }, { type: "turn-start", conversationId: "c1", turnId: "t1" }, + { type: "user-message", conversationId: "c1", turnId: "t1", text: "hi" }, { type: "text-delta", conversationId: "c1", turnId: "t1", delta: "hi" }, { type: "reasoning-delta", conversationId: "c1", turnId: "t1", delta: "thinking" }, { @@ -81,6 +82,7 @@ describe("classifies every AgentEvent type", () => { expect(labels).toEqual([ "status", "turn-start", + "user-message", "text-delta", "reasoning-delta", "tool-call", @@ -94,8 +96,8 @@ describe("classifies every AgentEvent type", () => { ]); }); - it("covers all 12 AgentEvent variants", () => { - expect(samples).toHaveLength(12); + it("covers all 13 AgentEvent variants", () => { + expect(samples).toHaveLength(13); }); }); @@ -148,9 +150,18 @@ describe("classifies every WsClientMessage type", () => { { type: "unsubscribe" as const, surfaceId: "s" }, { type: "invoke" as const, surfaceId: "s", actionId: "a" }, { type: "chat.send" as const, message: "hi" }, + { type: "chat.subscribe" as const, conversationId: "c1" }, + { type: "chat.unsubscribe" as const, conversationId: "c1" }, ]; const labels = msgs.map(assertWsClientMessageExhaustive); - expect(labels).toEqual(["subscribe", "unsubscribe", "invoke", "chat.send"]); + expect(labels).toEqual([ + "subscribe", + "unsubscribe", + "invoke", + "chat.send", + "chat.subscribe", + "chat.unsubscribe", + ]); }); }); diff --git a/src/core/wire/conformance.ts b/src/core/wire/conformance.ts index d89772e..13be78c 100644 --- a/src/core/wire/conformance.ts +++ b/src/core/wire/conformance.ts @@ -12,6 +12,8 @@ export function assertAgentEventExhaustive(event: AgentEvent): string { return "status"; case "turn-start": return "turn-start"; + case "user-message": + return "user-message"; case "text-delta": return "text-delta"; case "reasoning-delta": @@ -96,6 +98,10 @@ export function assertWsClientMessageExhaustive(msg: WsClientMessage): string { return "invoke"; case "chat.send": return "chat.send"; + case "chat.subscribe": + return "chat.subscribe"; + case "chat.unsubscribe": + return "chat.unsubscribe"; default: return msg satisfies never; } |
