feat(webui): track optimistic message delivery status (#5162)

This commit is contained in:
chengyongru
2026-07-29 23:15:45 +08:00
committed by GitHub
parent 5a28a6165c
commit 129b74b4cf
23 changed files with 431 additions and 21 deletions
+25
View File
@@ -90,6 +90,31 @@ describe("NanobotClient", () => {
});
});
it("routes message acceptance acknowledgements to the matching chat handler", () => {
const client = new NanobotClient({
url: "ws://test",
reconnect: false,
socketFactory: (url) => new FakeSocket(url) as unknown as WebSocket,
});
const handler = vi.fn();
client.onChat("chat-ack", handler);
client.connect();
lastSocket().fakeOpen();
client.sendMessage("chat-ack", "hello", undefined, { turnId: "turn-ack" });
lastSocket().fakeMessage({
event: "message_accepted",
chat_id: "chat-ack",
turn_id: "turn-ack",
});
expect(handler).toHaveBeenCalledWith({
event: "message_accepted",
chat_id: "chat-ack",
turn_id: "turn-ack",
});
});
it("can swap the socket factory when the runtime URL changes", () => {
const browserFactory = vi.fn(
(url: string) => new FakeSocket(`browser:${url}`) as unknown as WebSocket,