From 79a2b64f906aa5bb92588b8caa455ae85b8f1ca8 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 21 Jul 2026 19:36:13 -0700 Subject: [PATCH] fix(runtime): scope mirrored-editor close intent to its runtime environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #9804 added a leading `environmentId` parameter to recordWebSessionCloseIntent (and isWebSessionCloseIntentPending) and updated the web-runtime-session.ts callers, but missed the second caller in close-mirrored-editor-tab.ts, which still passed 3 args. This broke the web typecheck on main and, had it compiled, would have recorded the close intent under the wrong scope key (closeIntentScopeKey(environmentId, worktreeId)) — so the host snapshot could flash the just-closed mirrored tab back. Pass the already-validated runtimeEnvironmentId (the same value handed to closeWebRuntimeSessionTab immediately below) so the intent is scoped correctly. Update the test's isWebSessionCloseIntentPending assertion to the 4-arg form. Co-authored-by: Orca --- src/renderer/src/runtime/close-mirrored-editor-tab.test.ts | 4 +++- src/renderer/src/runtime/close-mirrored-editor-tab.ts | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/runtime/close-mirrored-editor-tab.test.ts b/src/renderer/src/runtime/close-mirrored-editor-tab.test.ts index f95591eb49c..bc4e045e477 100644 --- a/src/renderer/src/runtime/close-mirrored-editor-tab.test.ts +++ b/src/renderer/src/runtime/close-mirrored-editor-tab.test.ts @@ -46,7 +46,9 @@ describe('notifyHostOfMirroredEditorClose', () => { // host snapshot in the dynamic-import gap can't flash the old-path tab back. notifyHostOfMirroredEditorClose(buildState(), 'wt-1', 'file-1') - expect(isWebSessionCloseIntentPending('wt-1', toHostSessionTabId('host-tab-1'), now)).toBe(true) + expect( + isWebSessionCloseIntentPending('env-1', 'wt-1', toHostSessionTabId('host-tab-1'), now) + ).toBe(true) }) it('closes the mirrored editor tab on the host using the host tab id', async () => { diff --git a/src/renderer/src/runtime/close-mirrored-editor-tab.ts b/src/renderer/src/runtime/close-mirrored-editor-tab.ts index 1dbd1fbf3a4..1030a13c920 100644 --- a/src/renderer/src/runtime/close-mirrored-editor-tab.ts +++ b/src/renderer/src/runtime/close-mirrored-editor-tab.ts @@ -40,7 +40,12 @@ export function notifyHostOfMirroredEditorClose( } // Record the close intent SYNCHRONOUSLY so a host snapshot landing before the dynamic import below resolves can't // flash the old-path tab back. closeWebRuntimeSessionTab re-records it idempotently. - recordWebSessionCloseIntent(worktreeId, toHostSessionTabId(unifiedTab.id), Date.now()) + recordWebSessionCloseIntent( + runtimeEnvironmentId, + worktreeId, + toHostSessionTabId(unifiedTab.id), + Date.now() + ) // Dynamic import: this helper is imported by the editor slice during store creation, so importing // web-runtime-session eagerly imports the store back and trips cyclic init in full-suite import order. void import('./web-runtime-session').then(({ closeWebRuntimeSessionTab }) =>