refactor: remove unreachable internal code paths
Co-authored-by: chengyongru <61816729+chengyongru@users.noreply.github.com>
This commit is contained in:
1 parent
4212ad726d
commit
9257383bec
21 files changed
+86
-285
No files matched your search
@@ -110,7 +110,6 @@ interface ThreadMotionTurn {
|
||||
interface ThreadMotionSnapshot {
|
||||
mode: ThreadMotionMode;
|
||||
turnId: string | null;
|
||||
promptId: string | null;
|
||||
promptPositioned: boolean;
|
||||
measurementPending: boolean;
|
||||
}
|
||||
@@ -191,7 +190,6 @@ export class ThreadMotionCoordinator {
|
||||
return {
|
||||
mode: this.mode,
|
||||
turnId: this.turn.id,
|
||||
promptId: this.turn.promptId,
|
||||
promptPositioned: this.promptPositioned,
|
||||
measurementPending: this.measurementFrameId !== null,
|
||||
};
|
||||
@@ -315,17 +313,13 @@ export class ThreadMotionCoordinator {
|
||||
return result;
|
||||
}
|
||||
|
||||
navigateHistoryTo(top: number): ThreadCameraFollowResult | null {
|
||||
return this.beginHistoryNavigation(top, null);
|
||||
}
|
||||
|
||||
navigateHistoryToPrompt(promptId: string): ThreadCameraFollowResult | null {
|
||||
const geometry = this.measure(promptId);
|
||||
if (!geometry || geometry.promptTop === null) return null;
|
||||
return this.beginHistoryNavigation(geometry.promptTop, promptId);
|
||||
}
|
||||
|
||||
private beginHistoryNavigation(top: number, promptId: string | null): ThreadCameraFollowResult | null {
|
||||
private beginHistoryNavigation(top: number, promptId: string): ThreadCameraFollowResult | null {
|
||||
if (this.mode !== "navigating-history") this.camera.cancel();
|
||||
this.transition("navigate-history");
|
||||
this.historyNavigationPromptId = promptId;
|
||||
|
||||
@@ -363,11 +363,6 @@ export class NanobotClient {
|
||||
this.applyRunEffects(this.runs.transition({ kind: "restore-pending", chatId, generation, turnId }));
|
||||
}
|
||||
|
||||
/** Last ``goal_status`` ``started_at`` (unix sec) for *chatId*, if the turn is running. */
|
||||
getRunStartedAt(chatId: string): number | null {
|
||||
return this.runs.view(chatId).startedAt;
|
||||
}
|
||||
|
||||
/** Canonical lifecycle turn currently owning the run, retained after completion. */
|
||||
getRunTurnId(chatId: string): string | null {
|
||||
return this.runs.view(chatId).latestTurnId;
|
||||
|
||||
@@ -295,7 +295,6 @@ vi.mock("@/lib/nanobot-client", async (importOriginal) => {
|
||||
onRunCompletion = () => () => {};
|
||||
getRunState = () => runState(null);
|
||||
restorePendingRun = vi.fn();
|
||||
getRunStartedAt = () => null;
|
||||
getRunTurnId = () => null;
|
||||
getUnsettledRunChatIds = () => [];
|
||||
getRunGeneration = () => 0;
|
||||
|
||||
@@ -199,7 +199,7 @@ describe("NanobotClient", () => {
|
||||
});
|
||||
|
||||
expect(client.getRunTurnId("shared-chat")).toBe("turn-a");
|
||||
expect(client.getRunStartedAt("shared-chat")).toBe(1_700_000_000);
|
||||
expect(client.getRunState("shared-chat").startedAt).toBe(1_700_000_000);
|
||||
expect(client.hasUnsettledRun("shared-chat")).toBe(true);
|
||||
});
|
||||
|
||||
@@ -630,13 +630,13 @@ describe("NanobotClient", () => {
|
||||
status: "running",
|
||||
started_at: 12_345,
|
||||
});
|
||||
expect(client.getRunStartedAt("chat-strip")).toBe(12_345);
|
||||
expect(client.getRunState("chat-strip").startedAt).toBe(12_345);
|
||||
lastSocket().fakeMessage({
|
||||
event: "goal_status",
|
||||
chat_id: "chat-strip",
|
||||
status: "idle",
|
||||
});
|
||||
expect(client.getRunStartedAt("chat-strip")).toBeNull();
|
||||
expect(client.getRunState("chat-strip").startedAt).toBeNull();
|
||||
});
|
||||
|
||||
it("clears the local run strip immediately when a stop is requested", () => {
|
||||
@@ -659,7 +659,7 @@ describe("NanobotClient", () => {
|
||||
|
||||
client.finishRunLocally("chat-stop");
|
||||
|
||||
expect(client.getRunStartedAt("chat-stop")).toBeNull();
|
||||
expect(client.getRunState("chat-stop").startedAt).toBeNull();
|
||||
expect(client.hasUnsettledRun("chat-stop")).toBe(false);
|
||||
expect(client.isRunCompleted("chat-stop", "turn-stop")).toBe(true);
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-stop", expect.objectContaining({ active: false, startedAt: null }));
|
||||
@@ -687,7 +687,7 @@ describe("NanobotClient", () => {
|
||||
lastSocket().close();
|
||||
|
||||
expect(client.status).toBe("reconnecting");
|
||||
expect(client.getRunStartedAt("chat-strip")).toBe(12_345);
|
||||
expect(client.getRunState("chat-strip").startedAt).toBe(12_345);
|
||||
expect(client.getRunTurnId("chat-strip")).toBe("turn-strip");
|
||||
expect(client.isRunCompleted("chat-strip", "turn-strip")).toBe(false);
|
||||
expect(client.getUnsettledRunChatIds()).toEqual(["chat-strip"]);
|
||||
@@ -695,12 +695,12 @@ describe("NanobotClient", () => {
|
||||
await vi.advanceTimersByTimeAsync(20);
|
||||
expect(FakeSocket.instances.length).toBeGreaterThan(1);
|
||||
lastSocket().fakeOpen();
|
||||
expect(client.getRunStartedAt("chat-strip")).toBe(12_345);
|
||||
expect(client.getRunState("chat-strip").startedAt).toBe(12_345);
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
lastSocket().fakeMessage({
|
||||
event: "turn_end", chat_id: "chat-strip", turn_id: "turn-strip",
|
||||
});
|
||||
expect(client.getRunStartedAt("chat-strip")).toBeNull();
|
||||
expect(client.getRunState("chat-strip").startedAt).toBeNull();
|
||||
expect(client.getUnsettledRunChatIds()).toEqual([]);
|
||||
expect(client.isRunCompleted("chat-strip", "turn-strip")).toBe(true);
|
||||
expect(client.isRunCompleted("another-chat", "turn-strip")).toBe(false);
|
||||
@@ -728,7 +728,7 @@ describe("NanobotClient", () => {
|
||||
event: "turn_end",
|
||||
chat_id: "chat-strip",
|
||||
});
|
||||
expect(client.getRunStartedAt("chat-strip")).toBeNull();
|
||||
expect(client.getRunState("chat-strip").startedAt).toBeNull();
|
||||
expect(handler).toHaveBeenLastCalledWith("chat-strip", expect.objectContaining({ active: false, startedAt: null }));
|
||||
});
|
||||
|
||||
@@ -753,7 +753,7 @@ describe("NanobotClient", () => {
|
||||
expect(
|
||||
client.reconcileCanonicalCompletion("chat-race", requestGeneration, ["turn-old"]),
|
||||
).toBe(false);
|
||||
expect(client.getRunStartedAt("chat-race")).toBe(12_345);
|
||||
expect(client.getRunState("chat-race").startedAt).toBe(12_345);
|
||||
});
|
||||
|
||||
it("rejects a user-only snapshot for a submitted turn that has not completed", () => {
|
||||
@@ -945,7 +945,7 @@ describe("NanobotClient", () => {
|
||||
reason: "text_too_large",
|
||||
});
|
||||
|
||||
expect(client.getRunStartedAt("chat-rejection-race")).toBe(2_000);
|
||||
expect(client.getRunState("chat-rejection-race").startedAt).toBe(2_000);
|
||||
expect(
|
||||
client.reconcileCanonicalCompletion("chat-rejection-race", requestGeneration, []),
|
||||
).toBe(false);
|
||||
@@ -987,7 +987,7 @@ describe("NanobotClient", () => {
|
||||
detail: "message_rejected",
|
||||
});
|
||||
|
||||
expect(client.getRunStartedAt("chat-reject-newer-clock")).toBe(1_000);
|
||||
expect(client.getRunState("chat-reject-newer-clock").startedAt).toBe(1_000);
|
||||
expect(client.hasUnsettledRun("chat-reject-newer-clock")).toBe(true);
|
||||
});
|
||||
|
||||
@@ -1055,7 +1055,7 @@ describe("NanobotClient", () => {
|
||||
chatId: "chat-too-big-race",
|
||||
turnId: "turn-rejected",
|
||||
}]);
|
||||
expect(client.getRunStartedAt("chat-too-big-race")).toBe(1_000);
|
||||
expect(client.getRunState("chat-too-big-race").startedAt).toBe(1_000);
|
||||
expect(
|
||||
client.reconcileCanonicalCompletion(
|
||||
"chat-too-big-race",
|
||||
@@ -1259,7 +1259,7 @@ describe("NanobotClient", () => {
|
||||
};
|
||||
expect(client.canReconcileCanonicalCompletion("chat-authority", requestGeneration, [], snapshot)).toBe(false);
|
||||
expect(client.reconcileCanonicalCompletion("chat-authority", requestGeneration, [], snapshot)).toBe(false);
|
||||
expect(client.getRunStartedAt("chat-authority")).toBe(123);
|
||||
expect(client.getRunState("chat-authority").startedAt).toBe(123);
|
||||
expect(client.hasUnsettledRun("chat-authority")).toBe(true);
|
||||
received.mockClear();
|
||||
lastSocket().fakeMessage({ event: "delta", chat_id: "chat-authority", turn_id: "turn-authority", text: "Still running" });
|
||||
@@ -1392,7 +1392,7 @@ describe("NanobotClient", () => {
|
||||
});
|
||||
|
||||
expect(client.hasUnsettledRun("chat-legacy-idle")).toBe(false);
|
||||
expect(client.getRunStartedAt("chat-legacy-idle")).toBeNull();
|
||||
expect(client.getRunState("chat-legacy-idle").startedAt).toBeNull();
|
||||
expect(handler).toHaveBeenLastCalledWith(expect.objectContaining({
|
||||
event: "goal_status",
|
||||
status: "idle",
|
||||
@@ -1656,7 +1656,7 @@ describe("NanobotClient", () => {
|
||||
event: "goal_status", chat_id: "chat-late", turn_id: "turn-late",
|
||||
status: "running", started_at: 123,
|
||||
});
|
||||
expect(client.getRunStartedAt("chat-late")).toBe(123);
|
||||
expect(client.getRunState("chat-late").startedAt).toBe(123);
|
||||
socket.fakeMessage({ event: "turn_end", chat_id: "chat-late", turn_id: "turn-late" });
|
||||
const message = {
|
||||
event: "message", chat_id: "chat-late", turn_id: "turn-late", kind, text: "Late detail",
|
||||
@@ -1665,7 +1665,7 @@ describe("NanobotClient", () => {
|
||||
|
||||
expect(handler).toHaveBeenLastCalledWith(message);
|
||||
expect(client.isRunCompleted("chat-late", "turn-late")).toBe(true);
|
||||
expect(client.getRunStartedAt("chat-late")).toBeNull();
|
||||
expect(client.getRunState("chat-late").startedAt).toBeNull();
|
||||
expect(client.hasUnsettledRun("chat-late")).toBe(false);
|
||||
client.close();
|
||||
},
|
||||
@@ -1733,7 +1733,7 @@ describe("NanobotClient", () => {
|
||||
turn_id: "turn-old",
|
||||
});
|
||||
|
||||
expect(client.getRunStartedAt("chat-delayed-idle")).toBe(2_000);
|
||||
expect(client.getRunState("chat-delayed-idle").startedAt).toBe(2_000);
|
||||
expect(runHandler).not.toHaveBeenCalled();
|
||||
expect(chatHandler).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -1763,7 +1763,7 @@ describe("NanobotClient", () => {
|
||||
["turn-complete"],
|
||||
),
|
||||
).toBe(true);
|
||||
expect(client.getRunStartedAt("chat-delayed-run")).toBeNull();
|
||||
expect(client.getRunState("chat-delayed-run").startedAt).toBeNull();
|
||||
});
|
||||
|
||||
it("preflights canonical completion without fencing or settling the turn", () => {
|
||||
@@ -1831,7 +1831,7 @@ describe("NanobotClient", () => {
|
||||
["turn-canonical"],
|
||||
),
|
||||
).toBe(true);
|
||||
expect(client.getRunStartedAt("chat-canonical")).toBeNull();
|
||||
expect(client.getRunState("chat-canonical").startedAt).toBeNull();
|
||||
expect(runHandler).toHaveBeenLastCalledWith("chat-canonical", expect.objectContaining({ active: false, startedAt: null }));
|
||||
const deliveredBeforeLateFrames = chatHandler.mock.calls.length;
|
||||
|
||||
@@ -1854,7 +1854,7 @@ describe("NanobotClient", () => {
|
||||
});
|
||||
|
||||
expect(chatHandler).toHaveBeenCalledTimes(deliveredBeforeLateFrames);
|
||||
expect(client.getRunStartedAt("chat-canonical")).toBeNull();
|
||||
expect(client.getRunState("chat-canonical").startedAt).toBeNull();
|
||||
const otherChat = vi.fn();
|
||||
client.onChat("other-chat", otherChat);
|
||||
const taskUpdate = {
|
||||
@@ -1866,7 +1866,7 @@ describe("NanobotClient", () => {
|
||||
expect(chatHandler).toHaveBeenCalledTimes(deliveredBeforeLateFrames + 1);
|
||||
expect(otherChat).not.toHaveBeenCalled();
|
||||
expect(client.hasUnsettledRun("chat-canonical")).toBe(false);
|
||||
expect(client.getRunStartedAt("chat-canonical")).toBeNull();
|
||||
expect(client.getRunState("chat-canonical").startedAt).toBeNull();
|
||||
});
|
||||
|
||||
it("notifies run status subscribers and replays running chats", () => {
|
||||
|
||||
@@ -533,6 +533,7 @@ describe("ThreadMotionCoordinator", () => {
|
||||
camera,
|
||||
coordinator,
|
||||
advanceFrame,
|
||||
setGeometry,
|
||||
} = motionHarness();
|
||||
coordinator.updateTurn({
|
||||
id: "turn-1",
|
||||
@@ -540,7 +541,8 @@ describe("ThreadMotionCoordinator", () => {
|
||||
hasOutput: true,
|
||||
});
|
||||
advanceFrame();
|
||||
coordinator.navigateHistoryTo(900);
|
||||
setGeometry({ promptTop: 900 });
|
||||
coordinator.navigateHistoryToPrompt("prompt-2");
|
||||
camera.cancel.mockClear();
|
||||
|
||||
coordinator.completeTurn();
|
||||
@@ -554,13 +556,15 @@ describe("ThreadMotionCoordinator", () => {
|
||||
camera,
|
||||
coordinator,
|
||||
setCameraFollowing,
|
||||
setGeometry,
|
||||
} = motionHarness();
|
||||
|
||||
coordinator.handleUserScrollIntent(false);
|
||||
expect(coordinator.snapshot().mode).toBe("idle");
|
||||
expect(camera.cancel).not.toHaveBeenCalled();
|
||||
|
||||
coordinator.navigateHistoryTo(900);
|
||||
setGeometry({ promptTop: 900 });
|
||||
coordinator.navigateHistoryToPrompt("prompt-1");
|
||||
expect(camera.navigateTo).toHaveBeenCalledWith(900);
|
||||
expect(coordinator.snapshot().mode).toBe("navigating-history");
|
||||
expect(coordinator.observeScroll(false)).toBe("navigation");
|
||||
@@ -571,7 +575,8 @@ describe("ThreadMotionCoordinator", () => {
|
||||
expect(coordinator.snapshot().mode).toBe("browsing-history");
|
||||
expect(coordinator.observeScroll(false)).toBe("user");
|
||||
|
||||
coordinator.navigateHistoryTo(700);
|
||||
setGeometry({ promptTop: 700 });
|
||||
coordinator.navigateHistoryToPrompt("prompt-2");
|
||||
camera.cancel.mockClear();
|
||||
coordinator.takeUserControl();
|
||||
expect(camera.cancel).toHaveBeenCalledTimes(1);
|
||||
@@ -581,20 +586,21 @@ describe("ThreadMotionCoordinator", () => {
|
||||
coordinator.takeUserControl();
|
||||
expect(camera.cancel).not.toHaveBeenCalled();
|
||||
|
||||
coordinator.navigateHistoryTo(600);
|
||||
setGeometry({ promptTop: 600 });
|
||||
coordinator.navigateHistoryToPrompt("prompt-3");
|
||||
setCameraFollowing(false);
|
||||
expect(coordinator.observeScroll(false)).toBe("navigation");
|
||||
expect(coordinator.snapshot().mode).toBe("browsing-history");
|
||||
});
|
||||
|
||||
it("settles camera navigation without relying on a scroll event", () => {
|
||||
const { coordinator } = motionHarness();
|
||||
const { coordinator } = motionHarness({ promptTop: 200 });
|
||||
coordinator.takeUserControl();
|
||||
coordinator.navigateLatestTo(1_400);
|
||||
coordinator.cameraSettled();
|
||||
expect(coordinator.snapshot().mode).toBe("follow-latest");
|
||||
|
||||
coordinator.navigateHistoryTo(200);
|
||||
coordinator.navigateHistoryToPrompt("prompt-1");
|
||||
coordinator.cameraSettled();
|
||||
expect(coordinator.snapshot().mode).toBe("navigating-history");
|
||||
});
|
||||
|
||||
@@ -88,7 +88,6 @@ function makeClient() {
|
||||
},
|
||||
getRunState: lifecycle.getRunState.bind(lifecycle),
|
||||
restorePendingRun: lifecycle.restorePendingRun.bind(lifecycle),
|
||||
getRunStartedAt: lifecycle.getRunStartedAt.bind(lifecycle),
|
||||
getRunTurnId: lifecycle.getRunTurnId.bind(lifecycle),
|
||||
isRunCompleted: lifecycle.isRunCompleted.bind(lifecycle),
|
||||
finishRunLocally: vi.fn(lifecycle.finishRunLocally.bind(lifecycle)),
|
||||
@@ -4195,7 +4194,7 @@ describe("ThreadShell", () => {
|
||||
act(() => client._emitSessionUpdate("visibility-complete-a", "thread"));
|
||||
await waitFor(() => expect(screen.getByText("completed while hidden")).toBeInTheDocument());
|
||||
expect(screen.queryByRole("button", { name: "Stop response" })).not.toBeInTheDocument();
|
||||
expect(client.getRunStartedAt("visibility-complete-a")).toBeNull();
|
||||
expect(client.getRunState("visibility-complete-a").startedAt).toBeNull();
|
||||
|
||||
rerender(view("visibility-complete-b"));
|
||||
await waitFor(() => expect(screen.getByText("other thread")).toBeInTheDocument());
|
||||
@@ -4302,7 +4301,7 @@ describe("ThreadShell", () => {
|
||||
expect(screen.getByText("saved answer prefix")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Stop response" })).toBeInTheDocument();
|
||||
expect(client.reconcileCanonicalCompletion).not.toHaveBeenCalled();
|
||||
expect(client.getRunStartedAt(chatId)).toBe(1_700);
|
||||
expect(client.getRunState(chatId).startedAt).toBe(1_700);
|
||||
|
||||
const input = screen.getByRole("textbox", { name: "Message input" });
|
||||
fireEvent.change(input, { target: { value: "queued guidance" } });
|
||||
|
||||
@@ -155,7 +155,7 @@ describe("completed turn event ordering", () => {
|
||||
});
|
||||
expect(result.current.isStreaming).toBe(false);
|
||||
expect(result.current.runStartedAt).toBeNull();
|
||||
expect(client.getRunStartedAt(CHAT_ID)).toBeNull();
|
||||
expect(client.getRunState(CHAT_ID).startedAt).toBeNull();
|
||||
expect(client.hasUnsettledRun(CHAT_ID)).toBe(false);
|
||||
expect(result.current.messages.some((message) => message.content === "additional context")).toBe(true);
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ function fakeClient() {
|
||||
getRunState: lifecycle.getRunState.bind(lifecycle),
|
||||
getRunGeneration: lifecycle.getRunGeneration.bind(lifecycle),
|
||||
restorePendingRun: lifecycle.restorePendingRun.bind(lifecycle),
|
||||
getRunStartedAt: lifecycle.getRunStartedAt.bind(lifecycle),
|
||||
getRunTurnId: lifecycle.getRunTurnId.bind(lifecycle),
|
||||
getGoalState: lifecycle.getGoalState.bind(lifecycle),
|
||||
hasUnsettledRun: lifecycle.hasUnsettledRun.bind(lifecycle),
|
||||
|
||||
@@ -108,7 +108,7 @@ describe("durable run recovery", () => {
|
||||
expect(fetchMock).toHaveBeenCalledTimes(9);
|
||||
expect(peak).toBe(4);
|
||||
expect(client.getUnsettledRunChatIds()).toEqual(["chat-8"]);
|
||||
expect(client.getRunStartedAt("chat-8")).toBe(456);
|
||||
expect(client.getRunState("chat-8").startedAt).toBe(456);
|
||||
expect(webuiThreadCache.get("websocket:chat-8")).toBeUndefined();
|
||||
close();
|
||||
});
|
||||
@@ -171,7 +171,7 @@ describe("durable run recovery", () => {
|
||||
expect(fetchMock.mock.calls[1][1].headers["If-None-Match"]).toBe('"active-page"');
|
||||
await act(async () => { resolveRecovery(response(completedThread())); });
|
||||
expect(mounted.result.current.messages.at(-1)?.content).toBe("The complete answer");
|
||||
expect(client.getRunStartedAt("inactive")).toBeNull();
|
||||
expect(client.getRunState("inactive").startedAt).toBeNull();
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
mounted.unmount();
|
||||
close();
|
||||
@@ -285,7 +285,7 @@ describe("durable run recovery", () => {
|
||||
await act(async () => { reads[0](response(stale)); });
|
||||
expect(mounted.result.current.messages.at(-1)?.content).toBe("The complete answer");
|
||||
expect(mounted.result.current.hasPendingToolCalls).toBe(false);
|
||||
expect(client.getRunStartedAt("inactive")).toBeNull();
|
||||
expect(client.getRunState("inactive").startedAt).toBeNull();
|
||||
mounted.unmount();
|
||||
close();
|
||||
});
|
||||
@@ -309,7 +309,7 @@ describe("durable run recovery", () => {
|
||||
"/api/sessions/websocket%3Ainactive/webui-thread?limit=40&direction=latest&include_model_requests=1&context_graph_encoding=references-v1",
|
||||
expect.objectContaining({ headers: { Authorization: "Bearer renewed-token" } }),
|
||||
);
|
||||
expect(client.getRunStartedAt("inactive")).toBeNull();
|
||||
expect(client.getRunState("inactive").startedAt).toBeNull();
|
||||
expect(client.hasUnsettledRun("inactive")).toBe(false);
|
||||
expect(cachedAtCompletion).toEqual([body]);
|
||||
expect(projectThreadEvents(cachedAtCompletion[0].events).at(-1)?.content).toBe("The complete answer");
|
||||
@@ -335,8 +335,8 @@ describe("durable run recovery", () => {
|
||||
client.onRunStatus(runStatus);
|
||||
await reopen();
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
expect(client.getRunStartedAt("inactive")).toBeNull();
|
||||
expect(client.getRunStartedAt("running")).toBe(456);
|
||||
expect(client.getRunState("inactive").startedAt).toBeNull();
|
||||
expect(client.getRunState("running").startedAt).toBe(456);
|
||||
expect(client.getRunTurnId("running")).toBe("turn-running");
|
||||
expect(client.hasUnsettledRun("running")).toBe(true);
|
||||
expect(runStatus).toHaveBeenCalledTimes(3);
|
||||
@@ -354,7 +354,7 @@ describe("durable run recovery", () => {
|
||||
const { client, running, reopen, close } = setup();
|
||||
running();
|
||||
await reopen();
|
||||
expect(client.getRunStartedAt("inactive")).toBe(123);
|
||||
expect(client.getRunState("inactive").startedAt).toBe(123);
|
||||
expect(client.hasUnsettledRun("inactive")).toBe(true);
|
||||
expect(webuiThreadCache.get("websocket:inactive")).toBeUndefined();
|
||||
close();
|
||||
@@ -370,7 +370,7 @@ describe("durable run recovery", () => {
|
||||
await reopen();
|
||||
running("inactive", "turn-new", 456);
|
||||
await act(async () => { resolveRead(response(completedThread())); });
|
||||
expect(client.getRunStartedAt("inactive")).toBe(456);
|
||||
expect(client.getRunState("inactive").startedAt).toBe(456);
|
||||
expect(client.getRunTurnId("inactive")).toBe("turn-new");
|
||||
expect(client.hasUnsettledRun("inactive")).toBe(true);
|
||||
expect(webuiThreadCache.get("websocket:inactive")).toBeUndefined();
|
||||
@@ -396,7 +396,7 @@ describe("durable run recovery", () => {
|
||||
const { client, running, reopen, close } = setup();
|
||||
running();
|
||||
await reopen();
|
||||
expect(client.getRunStartedAt("inactive")).toBeNull();
|
||||
expect(client.getRunState("inactive").startedAt).toBeNull();
|
||||
expect(client.hasUnsettledRun("inactive")).toBe(false);
|
||||
expect(webuiThreadCache.get("websocket:inactive")).toEqual(body);
|
||||
close();
|
||||
@@ -410,7 +410,7 @@ describe("durable run recovery", () => {
|
||||
const { client, running, reopen, close } = setup();
|
||||
running();
|
||||
await reopen();
|
||||
expect(client.getRunStartedAt("inactive")).toBe(123);
|
||||
expect(client.getRunState("inactive").startedAt).toBe(123);
|
||||
expect(client.hasUnsettledRun("inactive")).toBe(true);
|
||||
expect(webuiThreadCache.get("websocket:inactive")).toBeUndefined();
|
||||
close();
|
||||
@@ -432,7 +432,7 @@ describe("durable run recovery", () => {
|
||||
body.completed_turn_ids = [];
|
||||
body.active_turn_id = null;
|
||||
await act(async () => { resolveRead(response(body)); });
|
||||
expect(client.getRunStartedAt("inactive")).toBe(456);
|
||||
expect(client.getRunState("inactive").startedAt).toBe(456);
|
||||
expect(client.hasUnsettledRun("inactive")).toBe(true);
|
||||
expect(webuiThreadCache.get("websocket:inactive")).toBeUndefined();
|
||||
const resumed = vi.fn();
|
||||
@@ -457,7 +457,7 @@ describe("durable run recovery", () => {
|
||||
await reopen();
|
||||
act(() => sockets.at(-1)!.close());
|
||||
await act(async () => { resolveRead(response(completedThread())); });
|
||||
expect(client.getRunStartedAt("inactive")).toBe(123);
|
||||
expect(client.getRunState("inactive").startedAt).toBe(123);
|
||||
expect(client.hasUnsettledRun("inactive")).toBe(true);
|
||||
expect(webuiThreadCache.get("websocket:inactive")).toBeUndefined();
|
||||
close();
|
||||
@@ -473,7 +473,7 @@ describe("durable run recovery", () => {
|
||||
await reopen();
|
||||
hook.unmount();
|
||||
await act(async () => { resolveRead(response(completedThread())); });
|
||||
expect(client.getRunStartedAt("inactive")).toBe(123);
|
||||
expect(client.getRunState("inactive").startedAt).toBe(123);
|
||||
expect(webuiThreadCache.get("websocket:inactive")).toBeUndefined();
|
||||
close();
|
||||
});
|
||||
|
||||
@@ -28,7 +28,6 @@ function fakeClient() {
|
||||
onRunCompletion: () => () => {},
|
||||
onError: () => () => {},
|
||||
onChat: () => () => {},
|
||||
getRunStartedAt: () => null,
|
||||
onSessionUpdate: (handler: (chatId: string, scope?: string) => void) => {
|
||||
sessionUpdateHandlers.add(handler);
|
||||
return () => sessionUpdateHandlers.delete(handler);
|
||||
|
||||
Reference in new issue
Block a user