Repository navigation
[hardening 3/N] refactor(renderer): fold getExplicitRuntimeEnvironmentIdForWorktree callers into resolveOwner - #30059
Conversation
e3625de to
7c3cf40
Compare
56a3be6 to
871fab9
Compare
7c3cf40 to
c7c5f93
Compare
871fab9 to
65689bf
Compare
c7c5f93 to
8b7d1da
Compare
65689bf to
59fda1b
Compare
8b7d1da to
a459995
Compare
9732228 to
81fd4e5
Compare
a459995 to
ae7ded7
Compare
81fd4e5 to
0fe57b4
Compare
0fe57b4 to
858e871
Compare
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
…allers into resolveOwner and delete it
858e871 to
98a5426
Compare
Stack (unmerged, review in order):
ELI5
The same project can be open on two machines at once (for example this computer and a paired Orca server). Orca had a helper that answered "which paired server owns this workspace?" with either a server id or nothing, and "nothing" meant both "it's this computer" and "two machines claim it, I can't tell". A few actions that write or start things read that "nothing" as "this computer" and acted locally. This PR moves every caller of that helper onto the newer owner resolver, which says "ambiguous" out loud, so actions that change things stop instead of guessing.
What Changed
getExplicitRuntimeEnvironmentIdForWorktree(inworktree-runtime-owner.ts) had 20 production callers. Nineteen now useruntimeEnvironmentIdForWorkspaceOwner/resolveOwner(resolve-owner.ts). The last one,store/terminals/terminal-tab-create-through-layout-owner.ts, is owned by a parallel PR, so the old function stays, is marked@deprecated, and is now covered by the deprecated-owner importer ratchet.What a user sees, per caller:
recently-closed-tabs.tsfile-explorer-operation-owner.tsnative-chat-attachment-upload.tsworkspace-file-drag-source.tsnative-chat-skill-discovery-context.tsuseAgentDetectionTarget.tsuse-web-session-tabs-sync.ts,active-session-subscription.ts(via newmirrored-workspace-owner.ts)layout-apply-send.tsterminal-worktree-route.tsremote:ids, so a raw id is local or SSH on either twinAlso in
resolve-owner.ts:runtime:unresolved-ownersentinel) is nowambiguous, notmissing. Before, the adapter readmissingas "this app", so a workspace selected on the sentinel could reopen a terminal locally or read its diff here.resolveOwnernow builds a small state object with only the fields the route resolvers read, instead of copying the whole store on every call. Per-row sidebar selectors call it on each store write.Behaviour deltas (old helper vs
resolveOwner)The old helper used the active-workspace route, then detected-row explicit provenance, then the first matching worktree/repo row.
resolveOwneruses the same rows, but:ssh:host that two paired servers both proxy, the old helper returned "no server" (a direct SSH guess); now it isambiguous. Read-only callers still see "no server"; mutating callers refuse.ambiguous. Read-only callers see "no server" instead of the first row's server.withRuntimeRepoOwner/withRuntimeWorktreeOwner), so in practice both answers already agree there.Session mirroring from every server, including a twin's server, comes from
getRuntimeSessionMirrorEnvironmentIds, which is untouched. Only the active-workspace stream uses this owner check, and it still mirrors a twin once the user picks that copy (tested).No wire change: nothing sent to or published by a host changes, so older paired servers, relays and web clients see the same traffic.
Why
Stage 1a of the SSH hardening work: "ambiguous" must be an outcome, and mutating callers must refuse it rather than read it as local. Folding this parallel resolver into
resolveOwnerremoves one of the places where a twin silently became "this computer". I considered keeping a thin null-returning wrapper, but that would recreate the same collapse under a new name. Making each caller decide (refuse, or "no server" with a one-line reason) keeps the decision visible where it matters.Linked Issue
SSH hardening tracker row 1a.4 (parallel owner resolvers). Third in the hardening stack; base branch is #30035.
Visual Proof
N/A: no layout or styling change. The only visible difference is that a few actions on a workspace two machines publish now wait or refuse instead of acting on this computer.
Testing
New
src/renderer/src/store/host-twin-owner-refusals.test.ts(useshost-twin.test-fixture.ts): local+runtime and local+ssh twins refuse terminal reopen, chat attachment host and drag source; folder and project-group twins leave file operations unresolved; a single paired-server row still routes (attachment host, drag source, folder file op, mirroring); a local-only row still reopens locally; a twin's server is mirrored once picked; a workspace selected on the unresolved-owner sentinel neither reopens a terminal locally nor uploads; chat skill discovery waits on a twin and scans the picked copy (fails without the selector fix). The terminal-reopen and folder-file-operation cases fail on the old code. The attachment and drag-source twin cases already refused on these fixtures through missing connection evidence, so they pin the new explicit refusal.Updated mocks in the session-tab-sync, layout-owner, reveal and drag-source tests to the new resolver.
Deprecated-owner ratchet self-test covers the new name.
pnpm tc,pnpm tc:web, the local static-analysis gate (PASS), and unit tests forlib,runtime,hooks,storeand the touchedcomponentsfolders (all green).terminal-pane-recovery.test.tsandterminal-pane-recovery-unsettled-fallback.test.tshang on this branch, but they hang the same way on fix(renderer): destructive host callers refuse an ambiguous owner instead of reading it as local #30035's head without this PR and pass on main, so the hang comes from lower in the stack.Live verify: not run; the change is renderer owner routing covered by store-level twin fixtures, with no wire or main-process change.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Ratchets: deprecated runtime-owner importers 57 → 58 (scope widened to the third deprecated name; the only added file is
store/terminals/terminal-tab-create-through-layout-owner.ts, owned by a parallel PR). Focus-read 1088 → 1088.Agent skill upstream boundary
Notes
SSH and folder workspaces are covered by the twin fixtures. Cross-platform: no platform-specific code. Mobile: untouched.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)