Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(desktop): preserve deferred terminal guards after upstream extraction

zqchrisd53ffde9a5ae
diff --git a/apps/desktop/src/main/__tests__/interruptedContinuationContract.test.ts b/apps/desktop/src/main/__tests__/interruptedContinuationContract.test.ts
index bde85dc781..2a8f13158b 100644
--- a/apps/desktop/src/main/__tests__/interruptedContinuationContract.test.ts
+++ b/apps/desktop/src/main/__tests__/interruptedContinuationContract.test.ts
@@ -384,7 +384,9 @@ describe('interrupted continuation enqueue contract', () => {
/if \(typeof event\.turnAttemptToken === 'number'\) \{\s*autoResumeBookkeeping\.clearFailedTurnCompletionTail\(session\.id\);/,
);
- expect(registerSource).toMatch(/finalizeOrcaSuppressedTerminal:\s*\(sessionId, payload\)\s*=>/);
+ expect(registerSource).toMatch(
+ /finalizeOrcaSuppressedTerminal:\s*settleDeferredOrcaWorkerTerminal,/,
+ );
expect(registerSource).toMatch(/status: payload\.status,\s*finalText: payload\.finalText/);
});
});
diff --git a/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.ts b/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.ts
index a6916667a0..60f4c7332e 100644
--- a/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.ts
+++ b/apps/desktop/src/main/__tests__/makerEventHotPathOrdering.test.ts
@@ -357,7 +357,7 @@ describe('maker:event hot path ordering', () => {
expect(source).toContain(
'deferredOrcaWorkerTerminal = autoResumeBookkeeping.stashOrcaSuppressedTerminal(',
);
- expect(source).toContain('finalizeOrcaSuppressedTerminal: (sessionId, payload) => {');
+ expect(source).toContain('finalizeOrcaSuppressedTerminal: settleDeferredOrcaWorkerTerminal,');
expect(source).toContain('shouldSkipOrcaWorkerTerminal({');
expect(source).toContain('stashedThisErrorEvent: deferredOrcaWorkerTerminal');
expect(source).toContain('isPairedFailedTurnDone,');
@@ -370,6 +370,43 @@ describe('maker:event hot path ordering', () => {
});
// only status/done/error paths request idle restore: covered by the executable sessionEventPipeline tests.
+ it('keeps the bound deferred Orca terminal behind worker start and forwards its original capture', async () => {
+ const binding = source.match(/finalizeOrcaSuppressedTerminal:\s*(\w+),/);
+ expect(binding).not.toBeNull();
+ const name = binding![1];
+ const start = source.indexOf(`function ${name}(`);
+ expect(start).toBeGreaterThanOrEqual(0);
+ const end = source.indexOf('\n/**', start);
+ expect(end).toBeGreaterThan(start);
+ const js = transpileModule(source.slice(start, end), {
+ compilerOptions: { target: ScriptTarget.ES2022 },
+ }).outputText;
+ let releaseStart!: () => void;
+ const started = new Promise<void>((resolve) => { releaseStart = resolve; });
+ const waitForStart = vi.fn(() => started);
+ const handleWorkerTerminalTurn = vi.fn(async (_terminal: { capture: unknown }) => undefined);
+ const finalize = new Function(
+ 'workerTurnStartSequencer',
+ 'orcaTeamServiceForEvents',
+ `${js}\nreturn ${name};`,
+ )({ waitForStart }, { handleWorkerTerminalTurn }) as (
+ sessionId: string,
+ payload: unknown,
+ ) => void;
+ const capture = { turnId: 'original-turn' };
+ const payload = {
+ status: 'error', finalText: 'original result', diagnostic: 'original failure', capture,
+ };
+
+ finalize('worker-session', payload);
+ expect(waitForStart).toHaveBeenCalledWith('worker-session');
+ expect(handleWorkerTerminalTurn).not.toHaveBeenCalled();
+ releaseStart();
+ await vi.waitFor(() => expect(handleWorkerTerminalTurn).toHaveBeenCalledTimes(1));
+ expect(handleWorkerTerminalTurn).toHaveBeenCalledWith({ sessionId: 'worker-session', ...payload });
+ expect(handleWorkerTerminalTurn.mock.calls[0]?.[0].capture).toBe(capture);
+ });
+
// does not persist remote Codex account snapshots into local account usage: covered by the executable sessionEventPipeline tests.
// fires git snapshots only from post-broadcast product-terminal done events: covered by the executable sessionEventPipeline tests.