From 1cb74dda8ba1f35c80d441547bba4c08a9e99dde Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Wed, 19 Aug 2026 13:11:35 -0700 Subject: [PATCH] test(terminal): pin the converging remote take-back resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two take-back tests both force the reclaim resize to fail, so nothing covered a take-back that converges. Deleting the `idle` driver flip left every suite green while applyRemoteDesktopLayout no-opped on a still-mobile driver — lock dropped, `true` returned, PTY stranded at the phone grid. --- .../runtime/remote-desktop-driver.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/runtime/remote-desktop-driver.test.ts b/src/main/runtime/remote-desktop-driver.test.ts index e031aed8d18..bf2370ee924 100644 --- a/src/main/runtime/remote-desktop-driver.test.ts +++ b/src/main/runtime/remote-desktop-driver.test.ts @@ -566,4 +566,27 @@ describe('remote desktop viewer width driver', () => { expect(runtime.getDriver('pty-1')).toEqual({ kind: 'desktop' }) expect(runtime.getTerminalFitOverride('pty-1')).toBeNull() }) + + it('take-back during the resubscribe grace still resizes the PTY off the phone grid', async () => { + // Why: both take-back tests above force the resize to fail, so nothing pinned that a + // converging remote reclaim reaches the host. A phone that unsubscribes cleanly holds + // driver=mobile for the 250ms resubscribe grace, and applyRemoteDesktopLayout no-ops on + // a mobile driver — so without the idle flip the lock drops and `true` is still reported + // while the PTY stays stranded at the phone grid. + const { runtime, resizeCalls } = createRuntime(null) + await runtime.updateRemoteDesktopViewer('pty-1', 'sub-A', 'viewer-A', 100, 30) + await runtime.handleMobileSubscribe('pty-1', 'phone-A', { cols: 45, rows: 20 }) + runtime.handleMobileUnsubscribe('pty-1', 'phone-A') + // Inside the grace window on purpose: the driver still reads mobile here. + expect(runtime.getDriver('pty-1')).toEqual({ kind: 'mobile', clientId: 'phone-A' }) + expect(runtime.getTerminalFitOverride('pty-1')).toMatchObject({ mode: 'mobile-fit' }) + const resizesBefore = resizeCalls.length + + await expect(runtime.reclaimTerminalForDesktop('pty-1')).resolves.toBe(true) + + expect(runtime.getTerminalFitOverride('pty-1')).toBeNull() + expect(runtime.getDriver('pty-1')).toEqual({ kind: 'desktop' }) + expect(resizeCalls.slice(resizesBefore)).toContainEqual({ ptyId: 'pty-1', cols: 100, rows: 30 }) + expect(runtime.getTerminalSize('pty-1')).toEqual({ cols: 100, rows: 30 }) + }) })