From b91c1665be500279fa48abc66a2ad8be142142c3 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Mon, 3 Aug 2026 22:09:16 -0700 Subject: [PATCH] test(renderer): cover stale remote layout failures --- .../remote-pane-layout-push.test.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/renderer/src/components/terminal-pane/remote-pane-layout-push.test.ts b/src/renderer/src/components/terminal-pane/remote-pane-layout-push.test.ts index ef9a0d63597..d6d777f728c 100644 --- a/src/renderer/src/components/terminal-pane/remote-pane-layout-push.test.ts +++ b/src/renderer/src/components/terminal-pane/remote-pane-layout-push.test.ts @@ -17,6 +17,14 @@ const { createRemotePaneLayoutPusher } = await import('./remote-pane-layout-push const PERSISTS = 100 +function deferred(): { promise: Promise; resolve: (value: T) => void } { + let resolve = (_value: T): void => undefined + const promise = new Promise((complete) => { + resolve = complete + }) + return { promise, resolve } +} + function makeLayout(overrides: Partial = {}): TerminalLayoutSnapshot { return { root: { @@ -144,6 +152,24 @@ describe('createRemotePaneLayoutPusher', () => { expect(updateWebRuntimePaneLayout).toHaveBeenCalledTimes(2) }) + it('does not let a stale failure invalidate a newer in-flight layout', async () => { + const first = deferred() + const second = deferred() + updateWebRuntimePaneLayout.mockImplementationOnce(() => first.promise) + updateWebRuntimePaneLayout.mockImplementationOnce(() => second.promise) + const pusher = createRemotePaneLayoutPusher() + const changedLayout = makeLayout({ expandedLeafId: 'leaf-a' }) + + pusher.push({ worktreeId: 'wt-1', tabId: 'tab-1', layout: makeLayout() }) + pusher.push({ worktreeId: 'wt-1', tabId: 'tab-1', layout: changedLayout }) + first.resolve(false) + await Promise.resolve() + pusher.push({ worktreeId: 'wt-1', tabId: 'tab-1', layout: changedLayout }) + + expect(updateWebRuntimePaneLayout).toHaveBeenCalledTimes(2) + second.resolve(true) + }) + it('re-pushes after a remount re-establishes host geometry', () => { const pusher = createRemotePaneLayoutPusher() pusher.push({ worktreeId: 'wt-1', tabId: 'tab-1', layout: makeLayout() })