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:
1 parent
aeca1c0f1a
commit
fdeda8a468
18 files changed
+1741
-225
No files matched your search
@@ -270,8 +270,14 @@ vi.mock("@/lib/nanobot-client", async (importOriginal) => {
|
||||
runStatusHandlers.add(handler);
|
||||
return () => runStatusHandlers.delete(handler);
|
||||
};
|
||||
onRunCompletion = () => () => {};
|
||||
getRunStartedAt = () => null;
|
||||
getRunTurnId = () => null;
|
||||
getUnsettledRunChatIds = () => [];
|
||||
getRunGeneration = () => 0;
|
||||
hasUnsettledRun = () => false;
|
||||
canReconcileCanonicalCompletion = () => true;
|
||||
reconcileCanonicalCompletion = () => true;
|
||||
fenceCanonicalCompletedTurns = vi.fn();
|
||||
getGoalState = () => undefined;
|
||||
sendMessage = sendMessageSpy;
|
||||
@@ -2850,7 +2856,7 @@ describe("App layout", () => {
|
||||
.not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("restores sidebar run indicators after a page reload", async () => {
|
||||
it("restores sidebar runs from lifecycle replay without reviving them from stale session rows", async () => {
|
||||
mockSessions = [
|
||||
{
|
||||
key: "websocket:chat-a",
|
||||
@@ -2875,15 +2881,23 @@ describe("App layout", () => {
|
||||
JSON.stringify(["chat-b"]),
|
||||
);
|
||||
|
||||
render(<App />);
|
||||
const { rerender } = render(<App />);
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
await waitFor(() =>
|
||||
expect(within(sidebar).getByRole("img", { name: "Agent running" })).toBeInTheDocument(),
|
||||
);
|
||||
await waitFor(() => expect(attachSpy).toHaveBeenCalledWith("chat-a"));
|
||||
expect(within(sidebar).queryByRole("img", { name: "Agent running" })).not.toBeInTheDocument();
|
||||
act(() => {
|
||||
for (const handler of runStatusHandlers) handler("chat-a", 12_345);
|
||||
});
|
||||
expect(within(sidebar).getByRole("img", { name: "Agent running" })).toBeInTheDocument();
|
||||
expect(within(sidebar).getByRole("img", { name: "New activity" })).toBeInTheDocument();
|
||||
expect(attachSpy).toHaveBeenCalledWith("chat-a");
|
||||
act(() => {
|
||||
for (const handler of runStatusHandlers) handler("chat-a", null);
|
||||
});
|
||||
mockSessions = mockSessions.map((session) => ({ ...session }));
|
||||
rerender(<App />);
|
||||
expect(within(sidebar).queryByRole("img", { name: "Agent running" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("restores the active chat from the URL hash after a page reload", async () => {
|
||||
|
||||
Reference in new issue
Block a user