























@@ -1135,7 +1135,7 @@ describe("tui-event-handlers: handleAgentEvent", () => {
1135113511361136describe("tui-event-handlers: streaming watchdog", () => {
11371137const expectedTimeoutMessage =
1138-"This response is taking longer than expected. Send another message to continue.";
1138+"This response is taking longer than expected. Still waiting for the current run.";
1139113911401140beforeEach(() => {
11411141vi.useFakeTimers();
@@ -1195,7 +1195,7 @@ describe("tui-event-handlers: streaming watchdog", () => {
11951195return { state, chatLog, tui, setActivityStatus, loadHistory, noteLocalRunId, handlers };
11961196};
119711971198-it("resets activityStatus to idle when no stream delta arrives for the watchdog window", () => {
1198+it("keeps the active run busy when no stream delta arrives for the watchdog window", () => {
11991199const { state, chatLog, setActivityStatus, handlers } = createHarness({
12001200streamingWatchdogMs: 5_000,
12011201});
@@ -1212,14 +1212,14 @@ describe("tui-event-handlers: streaming watchdog", () => {
1212121212131213vi.advanceTimersByTime(5_001);
121412141215-expect(setActivityStatus).toHaveBeenLastCalledWith("idle");
1216-expect(state.activeChatRunId).toBeNull();
1215+expect(setActivityStatus).not.toHaveBeenCalledWith("idle");
1216+expect(state.activeChatRunId).toBe("run-stuck");
12171217expect(chatLog.addPendingSystem).toHaveBeenCalledWith("run-stuck", expectedTimeoutMessage);
1218121812191219handlers.dispose?.();
12201220});
122112211222-it("flushes a deferred history reload when the watchdog clears the active run", () => {
1222+it("keeps deferred history reload pending while the watchdog waits on the active run", () => {
12231223const { state, loadHistory, noteLocalRunId, setActivityStatus, handlers } = createHarness({
12241224streamingWatchdogMs: 5_000,
12251225});
@@ -1242,10 +1242,9 @@ describe("tui-event-handlers: streaming watchdog", () => {
1242124212431243vi.advanceTimersByTime(5_001);
124412441245-expect(state.activeChatRunId).toBeNull();
1246-expect(state.activityStatus).toBe("idle");
1247-expect(setActivityStatus).toHaveBeenLastCalledWith("idle");
1248-expect(loadHistory).toHaveBeenCalledTimes(1);
1245+expect(state.activeChatRunId).toBe("run-stuck");
1246+expect(setActivityStatus).not.toHaveBeenCalledWith("idle");
1247+expect(loadHistory).not.toHaveBeenCalled();
1249124812501249handlers.dispose?.();
12511250});
@@ -1278,8 +1277,8 @@ describe("tui-event-handlers: streaming watchdog", () => {
1278127712791278vi.advanceTimersByTime(2_500);
128012791281-expect(setActivityStatus).toHaveBeenLastCalledWith("idle");
1282-expect(state.activeChatRunId).toBeNull();
1280+expect(setActivityStatus).not.toHaveBeenCalledWith("idle");
1281+expect(state.activeChatRunId).toBe("run-flow");
1283128212841283handlers.dispose?.();
12851284});
@@ -1312,8 +1311,8 @@ describe("tui-event-handlers: streaming watchdog", () => {
1312131113131312vi.advanceTimersByTime(2_001);
131413131315-expect(setActivityStatus).toHaveBeenLastCalledWith("idle");
1316-expect(state.activeChatRunId).toBeNull();
1314+expect(setActivityStatus).not.toHaveBeenCalledWith("idle");
1315+expect(state.activeChatRunId).toBe("run-tools");
1317131613181317handlers.dispose?.();
13191318});
@@ -1474,7 +1473,7 @@ describe("tui-event-handlers: streaming watchdog", () => {
14741473handlers.dispose?.();
14751474});
147614751477-it("does not let an older run steal the active run watchdog", () => {
1476+it("does not let another run replace a watchdog-noticed active run", () => {
14781477const { state, chatLog, setActivityStatus, handlers } = createHarness({
14791478streamingWatchdogMs: 5_000,
14801479});
@@ -1487,15 +1486,16 @@ describe("tui-event-handlers: streaming watchdog", () => {
14871486} satisfies ChatEvent);
1488148714891488vi.advanceTimersByTime(5_001);
1490-expect(state.activeChatRunId).toBeNull();
1489+expect(state.activeChatRunId).toBe("run-old");
1490+expect(chatLog.addPendingSystem).toHaveBeenCalledWith("run-old", expectedTimeoutMessage);
1491149114921492handlers.handleChatEvent({
14931493runId: "run-new",
14941494sessionKey: state.currentSessionKey,
14951495state: "delta",
14961496message: { content: "new" },
14971497} satisfies ChatEvent);
1498-expect(state.activeChatRunId).toBe("run-new");
1498+expect(state.activeChatRunId).toBe("run-old");
1499149915001500vi.advanceTimersByTime(3_000);
15011501@@ -1508,9 +1508,9 @@ describe("tui-event-handlers: streaming watchdog", () => {
1508150815091509vi.advanceTimersByTime(2_001);
151015101511-expect(setActivityStatus).toHaveBeenLastCalledWith("idle");
1512-expect(state.activeChatRunId).toBeNull();
1513-expect(chatLog.addPendingSystem).toHaveBeenCalledTimes(2);
1511+expect(setActivityStatus).not.toHaveBeenCalledWith("idle");
1512+expect(state.activeChatRunId).toBe("run-old");
1513+expect(chatLog.addPendingSystem).toHaveBeenCalledTimes(1);
1514151415151515handlers.dispose?.();
15161516});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。