From 43ba8a1fcada52bd30da65401c52a7c09ab08d21 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sun, 26 Jul 2026 17:24:29 -0700 Subject: [PATCH] test(codex): key the thrown-sweep mock on the swept PTY, not call order The strand regression test rejected listStalePanes by call ordinal, so the rejection would silently attach to the wrong sweep if the flush sequence ever changed. Key it on the requested ptyIds instead. --- src/renderer/src/lib/codex-stale-pane-sweep.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/lib/codex-stale-pane-sweep.test.ts b/src/renderer/src/lib/codex-stale-pane-sweep.test.ts index 333d2600478..05f08bcbccc 100644 --- a/src/renderer/src/lib/codex-stale-pane-sweep.test.ts +++ b/src/renderer/src/lib/codex-stale-pane-sweep.test.ts @@ -208,9 +208,14 @@ describe('notifyCodexPaneBoundForStaleSweep', () => { // and never touched by that sweep — was left with nothing to fire it, ever. useAppStore.setState({ ptyIdsByTabId: { 'tab-1': ['pty-1', 'pty-2'] } }) vi.mocked(window.api.pty.inspectProcess).mockRejectedValueOnce(new Error('terminal_gone')) - vi.mocked(window.api.codexAccounts.listStalePanes) - .mockRejectedValueOnce(new Error('registry unreadable')) - .mockResolvedValue([STALE_PANE]) + // Why: keyed on the swept PTY rather than call order, so the rejection stays + // bound to pty-2's sweep even if the flush sequence changes. + vi.mocked(window.api.codexAccounts.listStalePanes).mockImplementation(async ({ ptyIds }) => { + if (ptyIds.includes('pty-2')) { + throw new Error('registry unreadable') + } + return [STALE_PANE] + }) notifyCodexPaneBoundForStaleSweep('pty-1') // t = 300: pty-1 reads inconclusive and parks on its 1500ms rung (due 1800).