Skip to content

Commit 201cbc1

Browse files
doudouOUCqwencoder
andcommitted
codex: address PR review feedback (#9820)
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
1 parent 6dddc29 commit 201cbc1

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

packages/acp-bridge/src/bridge.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,49 @@ describe('createAcpSessionBridge', () => {
813813
},
814814
);
815815

816+
it('retains a stale non-empty cache after an oversized close refusal', async () => {
817+
const refusalHolds = Array.from(
818+
{ length: ACTIVE_WORK_MAX_SESSION_HOLDS + 1 },
819+
(_unused, index) => agentHold(`h${index}`),
820+
);
821+
const handle = makeChannel({
822+
initializeImpl: () => activeWorkInitializeResponse(),
823+
extMethodImpl: async (method, params) => {
824+
if (method !== SERVE_CONTROL_EXT_METHODS.sessionClose) return {};
825+
if (params?.[ACTIVE_WORK_CLOSE_IF_UNHELD_PARAM] === true) {
826+
return { closed: false, holds: refusalHolds };
827+
}
828+
return { closed: true };
829+
},
830+
});
831+
const bridge = makeBridge({
832+
channelFactory: async () => handle.channel,
833+
sessionReapIntervalMs: 0,
834+
});
835+
const session = await bridge.spawnOrAttach({ workspaceCwd: WS_A });
836+
await sendActiveWorkSnapshot(handle, 1, [
837+
{ sessionId: session.sessionId, holds: [agentHold('cached-agent')] },
838+
]);
839+
840+
vi.useFakeTimers();
841+
try {
842+
vi.setSystemTime(
843+
Date.now() +
844+
ACTIVE_WORK_HEARTBEAT_INTERVAL_MS * ACTIVE_WORK_STALE_INTERVALS +
845+
1_000,
846+
);
847+
await bridge.detachClient(session.sessionId, session.clientId);
848+
849+
expect(bridge.sessionCount).toBe(1);
850+
expect(bridge.activeWork).toBe(true);
851+
expect(reportingGrade(bridge)).toBe('partial');
852+
} finally {
853+
vi.useRealTimers();
854+
}
855+
856+
await bridge.shutdown();
857+
});
858+
816859
it('leaves the session in place when the close request never resolves', async () => {
817860
let closeAttempts = 0;
818861
const handle = makeChannel({

0 commit comments

Comments
 (0)