fix(runtime): scope mirrored-editor close intent to its runtime environment

#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 <help@stably.ai>
This commit is contained in:
Neil
2026-07-21 19:36:13 -07:00
co-authored by Orca
parent f9f3cd2fbe
commit 79a2b64f90
2 changed files with 9 additions and 2 deletions
@@ -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 () => {
@@ -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 }) =>