

















@@ -1,4 +1,4 @@
1-import { afterEach, describe, expect, it } from "vitest";
1+import { afterEach, describe, expect, it, vi } from "vitest";
22import { createReplyOperation, testing } from "./reply-run-registry.js";
33import { admitReplyTurn } from "./reply-turn-admission.js";
44@@ -39,6 +39,74 @@ describe("reply turn admission", () => {
3939}
4040});
414142+it("does not apply cleanup settle timeout to visible turn admission", async () => {
43+vi.useFakeTimers();
44+try {
45+const active = createReplyOperation({
46+sessionKey: "agent:main:discord:channel:42",
47+sessionId: "active-session",
48+resetTriggered: false,
49+});
50+active.setPhase("running");
51+52+const admitted = admitReplyTurn({
53+sessionKey: "agent:main:discord:channel:42",
54+sessionId: "waiting-session",
55+kind: "visible",
56+resetTriggered: false,
57+});
58+59+let settled = false;
60+void admitted.then(() => {
61+settled = true;
62+});
63+64+await vi.advanceTimersByTimeAsync(15_000);
65+expect(settled).toBe(false);
66+67+active.complete();
68+const result = await admitted;
69+expect(result.status).toBe("owned");
70+if (result.status === "owned") {
71+result.operation.complete();
72+}
73+} finally {
74+await vi.runOnlyPendingTimersAsync();
75+vi.useRealTimers();
76+}
77+});
78+79+it("keeps the cleanup settle timeout for queued follow-up retry", async () => {
80+vi.useFakeTimers();
81+try {
82+const active = createReplyOperation({
83+sessionKey: "agent:main:discord:channel:42",
84+sessionId: "active-session",
85+resetTriggered: false,
86+});
87+active.setPhase("running");
88+89+const admitted = admitReplyTurn({
90+sessionKey: "agent:main:discord:channel:42",
91+sessionId: "queued-session",
92+kind: "queued_followup",
93+resetTriggered: false,
94+});
95+96+await vi.advanceTimersByTimeAsync(15_000);
97+98+await expect(admitted).resolves.toMatchObject({
99+status: "skipped",
100+reason: "active-run",
101+activeOperation: active,
102+});
103+active.complete();
104+} finally {
105+await vi.runOnlyPendingTimersAsync();
106+vi.useRealTimers();
107+}
108+});
109+42110it("uses the active run's final session id after waiting", async () => {
43111const active = createReplyOperation({
44112sessionKey: "agent:main:telegram:topic:42",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。