Skip to content

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

Merged
brennanb2025 merged 1 commit into
mainfrom
nwparker/fix-close-mirrored-editor-tab-environmentid
Jul 22, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
nwparker/fix-close-mirrored-editor-tab-environmentid

Conversation

@nwparker

@nwparker nwparker commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

What

recordWebSessionCloseIntent and isWebSessionCloseIntentPending gained a leading environmentId parameter in #9804, and the web-runtime-session.ts callers were updated to the 4-arg form — but the second caller, in close-mirrored-editor-tab.ts, was missed and still passed 3 args. This breaks the web typecheck on main:

src/renderer/src/runtime/close-mirrored-editor-tab.ts(43,3): error TS2554: Expected 4 arguments, but got 3.
src/renderer/src/runtime/close-mirrored-editor-tab.test.ts(49,12): error TS2554: Expected 4 arguments, but got 3.

Fix: pass the already-validated runtimeEnvironmentId (the exact same value handed to closeWebRuntimeSessionTab({ environmentId }) immediately below) so the close intent is recorded under the correct closeIntentScopeKey(environmentId, worktreeId). Update the test's isWebSessionCloseIntentPending assertion to the 4-arg form (env-1 is what the test's mock resolves the worktree's runtime env to).

ELI5

When you close a file that's mirrored from a remote host, Orca whispers to the host "I closed this, don't send it back." A recent change started filing those whispers in per-environment folders, but one code path forgot to say which environment — so the compiler refused to build, and even if it had built, the whisper would've gone in the wrong folder and the tab could pop back. This puts the environment label back on that one path.

Proof of zero regression

  • close-mirrored-editor-tab.test.ts: 4/4 pass (including the "records the host close intent SYNCHRONOUSLY" test that exercises the fixed call path with env-1).
  • pnpm typecheck:web: clean (was failing on main before this).
  • The passed value is identical to the environmentId already used two lines down in closeWebRuntimeSessionTab, so the two now agree on scope — this is the behavior fix(terminal): prevent reconnect from killing live daemon sessions #9804 intended.

Why this is a fix, not just a type patch

Had the code compiled with the missing arg, the intent would have been recorded under closeIntentScopeKey(undefined, worktreeId) while closeWebRuntimeSessionTab re-records/reads under closeIntentScopeKey(runtimeEnvironmentId, worktreeId) — a scope mismatch that reopens the "host snapshot flashes the just-closed mirrored tab back" race #9804 was hardening against.

Made with Orca 🐋

…onment

#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>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 97e624ba-4069-4ffd-9784-fe44886eab33

📥 Commits

Reviewing files that changed from the base of the PR and between f9f3cd2 and 79a2b64.

📒 Files selected for processing (2)
  • src/renderer/src/runtime/close-mirrored-editor-tab.test.ts
  • src/renderer/src/runtime/close-mirrored-editor-tab.ts

📝 Walkthrough

Walkthrough

Updated mirrored editor tab closure to record the web session close intent with the runtime environment ID and worktree ID in the revised argument order. Updated the corresponding test assertion to verify pending close intent using the runtime environment ID.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the bug, fix, and validation, but omits most required template sections like Screenshots, Testing, AI Review Report, Security Audit, and Notes. Add the missing template sections: Screenshots, a full Testing checklist, AI Review Report, Security Audit, and Notes, or mark non-applicable items explicitly.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main fix: scoping mirrored-editor close intent to the runtime environment.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025 brennanb2025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against current main — this is the correct and complete fix for the typecheck breakage that's failing verify on every open PR.

Verified:

  • #9804 widened recordWebSessionCloseIntent/isWebSessionCloseIntentPending with a leading environmentId and updated the web-runtime-session.ts callers, but merged past #5975's then-new caller in close-mirrored-editor-tab.ts — a semantic merge conflict (both PRs were green individually). Current main fails web typecheck on exactly the two lines this PR touches.
  • Swept main for all call sites of the close-intent functions (record/isPending/reconcile/clear*): everything else is already 4-arg, so this PR closes the only gap — no other stale caller left behind.
  • Passing runtimeEnvironmentId is semantically right, not just type-appeasing: it's the same validated value handed to closeWebRuntimeSessionTab below, and matches the environmentId the snapshot reconcile in web-session-tabs-sync.ts uses when checking isWebSessionCloseIntentPending — so the intent lands in the scope the reconcile actually reads.
  • Test update matches the mock (getRuntimeEnvironmentIdForWorktree → 'env-1').
  • verify passed on the merge commit after #9804 landed, so the merged tree is proven green.

LGTM — landing this unbreaks typecheck for every open PR.

@brennanb2025
brennanb2025 merged commit 2a32c5c into main Jul 22, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…onment (stablyai#9836)

stablyai#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants