Repository navigation
fix(renderer): destructive host callers refuse an ambiguous owner instead of reading it as local - #30035
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
da8d4b0c-1e9f-42fe-a863-4f6c73ea8982
📒 Files selected for processing: 22
config/deprecated-runtime-owner-importers-baseline.txtconfig/focus-setting-read-baseline.txtsrc/renderer/src/components/sidebar/use-workspace-board-task-status-sync.test.tssrc/renderer/src/components/sidebar/use-workspace-board-task-status-sync.tssrc/renderer/src/components/sidebar/workspace-board-task-status-sync.test.tssrc/renderer/src/components/sidebar/workspace-board-task-status-sync.tssrc/renderer/src/components/tab-group/useTabGroupTabCloseCommands.test.tsxsrc/renderer/src/hooks/ipc-events/tab-lifecycle-ipc-bridge.test.tssrc/renderer/src/hooks/ipc-events/tab-lifecycle-ipc-bridge.tssrc/renderer/src/lib/host-mirrored-pane-liveness.test.tssrc/renderer/src/lib/host-mirrored-pane-liveness.tssrc/renderer/src/lib/resolve-owner.test.tssrc/renderer/src/lib/resolve-owner.tssrc/renderer/src/lib/workspace-browser-tab-close.test.tssrc/renderer/src/lib/workspace-browser-tab-close.tssrc/renderer/src/runtime/close-mirrored-editor-tab.test.tssrc/renderer/src/runtime/close-mirrored-editor-tab.tssrc/renderer/src/runtime/web-runtime-pane-layout-intent.test.tssrc/renderer/src/runtime/web-runtime-session-tab-props.test.tssrc/renderer/src/runtime/web-runtime-terminal-actions.tssrc/renderer/src/store/slices/terminal-tab-retirement.test.tssrc/renderer/src/store/slices/terminal-tab-retirement.ts
💤 Files with no reviewable changes: 1
- config/deprecated-runtime-owner-importers-baseline.txt
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| const owner = resolveRuntimeOwnerForWorktree(state, worktreeId) | ||
| // Why: a twin's legacy id can't be pinned to either host, so it matches only its own exact id. | ||
| if (owner.kind === 'ambiguous') { | ||
| return `pty:${ptyId}` |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Scope ambiguous PTY identity to the worktree.
If two ambiguous worktrees contain the same legacy ptyId, this branch gives both terminals the same identity. The retirement plan can then mark separate terminals as shared. Include worktreeId in the ambiguous identity. Tabs in the same worktree will still share an identity. Add a test with two ambiguous worktrees to cover this case.
f0efcb8 to
e3625de
Compare
c7c5f93 to
8b7d1da
Compare
8b7d1da to
a459995
Compare
312dd36 to
0b29251
Compare
…tead of reading it as local
a459995 to
ae7ded7
Compare
ELI5
Sometimes the same project shows up from two machines at once, for example your laptop and a paired Orca server both publish
repo::/path. Orca calls these "twins". A few actions that change things on a host (new terminal tab, pushing a pane layout, closing a mirrored tab, syncing a Linear status) asked "which machine owns this?" through an old helper. When the answer was "both", the helper said "nobody", and the caller read "nobody" as "this computer". So a twin could get a shell started on the wrong machine, or borrow this computer's Linear account. Now these actions say "I can't tell which machine" and do nothing.What Changed
Before: for a workspace two hosts publish, these callers treated the owner as this computer:
After: each one refuses on an ambiguous owner, touches nothing on either host, and logs one
console.warnper site and workspace (deduplicated, because layout persists and resume sweeps repeat):runtime/web-runtime-terminal-actions.ts(pane layout, tab props)false(the local edit already happened, as for any local tab)runtime/close-mirrored-editor-tab.tslib/workspace-browser-tab-close.tshooks/ipc-events/tab-lifecycle-ipc-bridge.ts(new terminal tab)lib/host-mirrored-pane-liveness.ts{kind:'mirror', environmentId:null}) without arming a wait on either host. It never launches or clearsstore/slices/terminal-tab-retirement.ts(PTY identity)remote:<handle>id gets the identitypty:<raw id>: it matches only its own exact id and never merges with another host's terminal. Teardown already skips that id, because the twin's route is unresolvedcomponents/sidebar/use-workspace-board-task-status-sync.tsmissingmaps to this computerMechanism: one small adapter next to
resolveOwner,runtimeEnvironmentIdForWorkspaceOwner(state, ref), returns{resolved, environmentId}or{ambiguous}through an exhaustive switch:missingkeeps today's local reading (null), except that a folder whose saved session names its server (restoredRuntimeHostIdByWorkspaceSessionKey) still reads that server before its folder catalog loads.environmentendpoint gives its id.selfgivesnull.warnAmbiguousOwnerRefusalOncesits next to it. The Linear site reuses the existinggetRuntimeTargetForWorktreeOwner. No new UI strings.Behaviour deltas besides ambiguous (per site)
Sites 1–5 and 7 now use
resolveOwner, so they also pick up its intended differences from the deprecated resolver:ssh:tand two HUBs proxy it, the result isambiguous, so the site refuses. The deprecated resolver returned no transport and read that as local; the new-terminal case used to open a local shell.ssh:selection is unchanged in effect (it is recovered as before).Why these are safe for mixed-version servers: every repo row entering the client is stamped by the client itself (
adoptEndpointRepoinshared/endpoint-catalog-adoption.ts; worktrees viawithRepoHostOwnership), whatever the server's version. So the only rows that lose the focus fallback are rows with no repo row at all. Web clients keep routing through their only server (onPairedWebClientHost, whichresolveOwnerkeeps).Site 6 is the exception and stays on the deprecated
resolveRuntimeOwnerForWorktree, with only the ambiguous branch changed. Its identity has to agree with teardown's fallback route (resolveTerminalWorktreeRoute), which still reads focus. A focus-free identity would let closing a legacy-alias tab kill a terminal that another tab still shows (Codex round 1, P1). The fully focus-free version is blocked: the focus-read ratchet forbids making the identity function a focus reader, and the teardown route is outside this PR. It stays in the deprecated-owner baseline.Why
resolveOwnerat each site: six sites need exactly "environment id or refusal", so the mapping lives in one place.pty:<raw id>for a twin's legacy terminal: it can't be pinned to either host, and exact-id matching is the only identity that never merges two hosts' terminals.Mixed versions: no wire change. SSH: direct SSH owners read
selfand route exactly as before. Folder workspaces:folder:<id>keys go through the same resolver, including folder twins, nowambiguoussince #30009.Ratchets:
config/focus-setting-read-baseline.txt: 1096 → 1088.config/deprecated-runtime-owner-importers-baseline.txt: 62 → 57 entries.Linked Issue
Tracker row 1a.3 (SSH hardening, Stage 1a). No GitHub issue.
Visual Proof
N/A: no visual change. The refusals are no-ops plus a console warning, and the Linear skip reuses an existing toast.
Testing
For each site there is a test where an ambiguous twin (local plus a paired server publishing the same id) refuses and touches nothing, and one where a runtime-owned row still routes to its server. All the refusal tests fail on
origin/main(checked by restoring the old site files). Also added:resolveOwnercharacterization rows × Active Server,Existing tests that mocked the deprecated resolver now seed real owner rows.
Local gates:
pnpm tc,src/renderer/src/{lib,runtime,hooks,store}andcomponents/{sidebar,terminal-pane,tab-group,floating-terminal,terminal,tab-bar},Live verify: none.
AI Disclosure
Written with Claude Code. Reviewed with Codex (gpt-6.1-sol, high): round 1 had one P1 (fixed by keeping site 6 aligned with teardown) and one P2 (restored-folder evidence, fixed). Round 2 was clean.
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)