From 21672439b5119c76e890c632012e2e24095c0e9d Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Thu, 27 Aug 2026 19:52:17 -0700 Subject: [PATCH] test(pty): isolate the remote-handle guard from the swap-window gate --- .../pty-startup-swap-window-presence.test.ts | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/ipc/pty-startup-swap-window-presence.test.ts b/src/main/ipc/pty-startup-swap-window-presence.test.ts index 57f9429b3eb..383e9037bce 100644 --- a/src/main/ipc/pty-startup-swap-window-presence.test.ts +++ b/src/main/ipc/pty-startup-swap-window-presence.test.ts @@ -145,14 +145,23 @@ describe('registerPtyHandlers daemon-swap-window presence', () => { }) it('runtime controller hasPty never answers a paired-runtime handle from the local registry', () => { - const barrier = makeDeferred() - const controller = installRuntimeControllerWithBarrier(barrier.promise) - barrier.resolve() + // No startup barrier: the remote-handle guard must hold on its own, not + // ride on the swap-window gate. Same routing hazard the async probe and + // pty:hasPty already guard — no locally routed provider can + // authoritatively answer for a remote host's PTY, so remote-scoped ids + // stay unknown, never absent. + let controller: { hasPty: (ptyId: string) => boolean | null } | undefined + registerPtyHandlers(mainWindow as never, { + setPtyController: vi.fn((next) => { + controller = next + }), + registerPty: vi.fn(), + onPtySpawned: vi.fn(), + onPtyExit: vi.fn(), + onPtyData: vi.fn() + } as never) - // Same routing hazard the async probe and pty:hasPty already guard: no - // locally routed provider can authoritatively answer for a remote host's - // PTY, so remote-scoped ids stay unknown, never absent. - expect(controller.hasPty('remote:environment@@pty-1')).toBe(null) + expect(controller?.hasPty('remote:environment@@pty-1')).toBe(null) }) it('runtime controller hasPty answers SSH-owned ids without waiting on the local swap', () => {