fix(webui): share sidebar and Composer run state (#6337)
This commit is contained in:
1 parent
3d0f8feb77
commit
5ae49a43e7
13 files changed
+378
-374
No files matched your search
@@ -630,7 +630,7 @@ describe("NanobotClient", () => {
|
||||
expect(client.getRunStartedAt("chat-stop")).toBeNull();
|
||||
expect(client.hasUnsettledRun("chat-stop")).toBe(false);
|
||||
expect(client.isRunCompleted("chat-stop", "turn-stop")).toBe(true);
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-stop", null);
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-stop", expect.objectContaining({ active: false, startedAt: null }));
|
||||
});
|
||||
|
||||
it("preserves durable run clocks and identities through transport reconnect", async () => {
|
||||
@@ -672,7 +672,7 @@ describe("NanobotClient", () => {
|
||||
expect(client.getUnsettledRunChatIds()).toEqual([]);
|
||||
expect(client.isRunCompleted("chat-strip", "turn-strip")).toBe(true);
|
||||
expect(client.isRunCompleted("another-chat", "turn-strip")).toBe(false);
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-strip", null);
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-strip", expect.objectContaining({ active: false, startedAt: null }));
|
||||
client.close();
|
||||
});
|
||||
|
||||
@@ -697,7 +697,7 @@ describe("NanobotClient", () => {
|
||||
chat_id: "chat-strip",
|
||||
});
|
||||
expect(client.getRunStartedAt("chat-strip")).toBeNull();
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-strip", null);
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-strip", expect.objectContaining({ active: false, startedAt: null }));
|
||||
});
|
||||
|
||||
it("rejects a completed snapshot when a newer run is not represented", () => {
|
||||
@@ -1752,7 +1752,7 @@ describe("NanobotClient", () => {
|
||||
),
|
||||
).toBe(true);
|
||||
expect(client.getRunStartedAt("chat-canonical")).toBeNull();
|
||||
expect(runHandler).toHaveBeenLastCalledWith("chat-canonical", null);
|
||||
expect(runHandler).toHaveBeenLastCalledWith("chat-canonical", expect.objectContaining({ active: false, startedAt: null }));
|
||||
const deliveredBeforeLateFrames = chatHandler.mock.calls.length;
|
||||
|
||||
lastSocket().fakeMessage({
|
||||
@@ -1805,19 +1805,22 @@ describe("NanobotClient", () => {
|
||||
status: "running",
|
||||
started_at: 12_345,
|
||||
});
|
||||
expect(handler).toHaveBeenCalledWith("chat-status", 12_345);
|
||||
expect(handler).toHaveBeenCalledWith("chat-status", expect.objectContaining({ active: true, startedAt: 12_345 }));
|
||||
|
||||
const lateHandler = vi.fn();
|
||||
client.onRunStatus(lateHandler);
|
||||
expect(lateHandler).toHaveBeenCalledWith("chat-status", 12_345);
|
||||
expect(lateHandler).toHaveBeenCalledWith("chat-status", expect.objectContaining({ active: true, startedAt: 12_345 }));
|
||||
|
||||
lastSocket().fakeMessage({
|
||||
event: "goal_status",
|
||||
chat_id: "chat-status",
|
||||
status: "idle",
|
||||
});
|
||||
expect(handler).toHaveBeenCalledWith("chat-status", null);
|
||||
expect(lateHandler).toHaveBeenCalledWith("chat-status", null);
|
||||
expect(handler).toHaveBeenCalledWith("chat-status", expect.objectContaining({ active: false, startedAt: null }));
|
||||
expect(lateHandler).toHaveBeenCalledWith("chat-status", expect.objectContaining({ active: false, startedAt: null }));
|
||||
const idleSubscriber = vi.fn();
|
||||
client.onRunStatus(idleSubscriber);
|
||||
expect(idleSubscriber).toHaveBeenCalledWith("chat-status", expect.objectContaining({ active: false, startedAt: null }));
|
||||
});
|
||||
|
||||
it("records goal_state per chat_id without an onChat subscriber", () => {
|
||||
@@ -2567,6 +2570,7 @@ describe("binary attachment transport", () => {
|
||||
const delivery = client.sendAttachments("chat", "look", [
|
||||
{ data_url: "data:text/plain;base64,eA==", name: "note.txt" },
|
||||
], { turnId: "slow-upload" });
|
||||
expect(client.getRunState("chat")).toMatchObject({ active: true, startedAt: null });
|
||||
await vi.advanceTimersByTimeAsync(80_000);
|
||||
expect(socket.sent.some((frame) => frame.includes("slow-ref"))).toBe(true);
|
||||
socket.fakeMessage({ event: "message_accepted", chat_id: "chat", turn_id: "slow-upload" });
|
||||
@@ -2637,6 +2641,7 @@ describe("binary attachment transport", () => {
|
||||
upload: { path: "/api/attachments", token: "cap" } });
|
||||
const draft = [{ data_url: "data:text/plain;base64,eA==", name: "note.txt" }];
|
||||
await expect(client.sendAttachments("chat", "look", draft)).rejects.toThrow("401");
|
||||
expect(client.getRunState("chat").active).toBe(false);
|
||||
expect(socket.sent.filter((frame) => JSON.parse(frame).type === "message")).toHaveLength(0);
|
||||
expect(draft[0].data_url).toBe("data:text/plain;base64,eA==");
|
||||
fetchMock.mockImplementation(async () => {
|
||||
@@ -2644,6 +2649,7 @@ describe("binary attachment transport", () => {
|
||||
return Response.json({ reference: "old-connection-ref" });
|
||||
});
|
||||
await expect(client.sendAttachments("chat", "look", draft)).rejects.toThrow("Connection changed");
|
||||
expect(client.getRunState("chat").active).toBe(false);
|
||||
expect(socket.sent.filter((frame) => JSON.parse(frame).type === "message")).toHaveLength(0);
|
||||
} finally { client.close(); vi.unstubAllGlobals(); }
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user