fix(webui): reconcile turns after reconnect (#6211)

* fix(webui): reconcile turns after reconnect

* perf(webui): bound reconnect recovery and index turn reconciliation

* refactor(webui): simplify reconnect reconciliation

* fix(webui): preserve turn authority during recovery

* fix(webui): validate canonical completion identities
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-16 11:38:05 +08:00
1 parent aeca1c0f1a
commit fdeda8a468
18 files changed
+1741 -225

No files matched your search

+25
View File
@@ -863,6 +863,31 @@ describe("useNanobotStream", () => {
expect(result.current.isStreaming).toBe(false);
});
it("restores cached tool activity according to each conversation's completed turns", () => {
const fake = fakeClient();
const initialMessages: UIMessage[] = [{
id: "cached-tool-activity", role: "tool", kind: "trace", content: "exec(…)",
traces: ["exec(…)"], turnId: "completed-tool-turn", isStreaming: true, createdAt: 1,
}];
const initialProps = {
chatId: "completed-tools",
initialMessages,
completedTurnIds: ["completed-tool-turn"],
};
const { result, rerender } = renderHook((props: typeof initialProps) => useNanobotStream(
props.chatId, props.initialMessages, false, undefined, undefined, props.completedTurnIds,
), { wrapper: wrap(fake.client), initialProps });
expect(result.current.isStreaming).toBe(false);
rerender({
chatId: "active-tools",
initialMessages: [{ ...initialMessages[0], turnId: "active-tool-turn" }],
completedTurnIds: [],
});
expect(result.current.isStreaming).toBe(true);
rerender(initialProps);
expect(result.current.isStreaming).toBe(false);
});
it("drops pending stream work when switching chats", async () => {
const fake = fakeClient();
const { result, rerender } = renderHook(