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
@@ -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", () => {
|
||||
|
||||
Reference in new issue
Block a user