Repository navigation
refactor(terminal): one PTY attribution for teardown, close and identity; delete the deprecated owner resolver - #30626
Conversation
…ity; delete the deprecated resolver pair - strict ssh: route: a proven direct listing beats a same-id server proxy; other contradictions refuse - terminal spawn's git branch takes the strict route when a host is named (rivals refuse) - resolveTerminalPtyOwner + isUnattributedTwinWorktree replace resolveRuntimeOwnerForWorktree in shutdown, pane and agent hibernation, and PTY identity; close logs unroutable runtime ids - delete getRuntimeEnvironmentIdForWorktree/resolveRuntimeOwnerForWorktree (legacy branch moved into the adapter), the alias golden test, the importer ratchet, its baseline and pr.yml step - hasHostEvidence reads the owner indexes instead of scanning repos and groups
…ed remote ids (Opus P2) - an unattributed twin's unscoped remote: id is skipped and logged on close, never closed locally - setup terminals: identity and close follow spawn's runtime; raw-id teardown stays local - drop the last stale getRuntimeEnvironmentIdForWorktree mock (tests/e2e unit suite)
… listing (Opus P3)
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/renderer/src/store/terminals/terminal-tab-close-providers.test.ts: 1
11-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMake the "where spawn started it" test depend on the mocked owner.
The
resolveTerminalWorktreeRoutemock always returnsenv-a. The test also setsmocks.ptyOwner.currenttoenv-a. Because of this, the first test passes for any non-ambiguous owner value. The test does not prove that the close destination follows the owner that spawn resolved. Derive the route mock frommocks.ptyOwner.current, or set a different environment ID for the route mock. Then the assertion checks a real dependency.Based on learnings: "check that the test actually exercises that resolution path (e.g., via a fake provider/fixture returning values that differ from defaults)".
♻️ Proposed change
vi.mock('@/lib/terminal-worktree-route', () => ({ resolveTerminalPtyOwner: () => mocks.ptyOwner.current, - resolveTerminalWorktreeRoute: () => ({ runtimeEnvironmentId: 'env-a' }) + resolveTerminalWorktreeRoute: () => ({ + runtimeEnvironmentId: + mocks.ptyOwner.current.kind === 'runtime' ? mocks.ptyOwner.current.environmentId : null + }) }))it('closes it where spawn started it', () => { - mocks.ptyOwner.current = { kind: 'runtime', environmentId: 'env-a' } + mocks.ptyOwner.current = { kind: 'runtime', environmentId: 'env-spawn' } retire() expect(mocks.callRuntimeRpc).toHaveBeenCalledWith( - { kind: 'environment', environmentId: 'env-a' }, + { kind: 'environment', environmentId: 'env-spawn' },Also applies to: 48-56
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
510fbc27-1dac-4a09-ab6f-194a65c1955c
📒 Files selected for processing: 28
.github/workflows/pr.ymlconfig/deprecated-runtime-owner-importers-baseline.txtconfig/focus-setting-read-baseline.txtconfig/scripts/check-deprecated-runtime-owner-ratchet.mjsconfig/scripts/check-deprecated-runtime-owner-ratchet.test.mjsconfig/scripts/pr-preflight-gates.test.mjspackage.jsonsrc/renderer/src/components/terminal-workspace-model.tssrc/renderer/src/lib/agent-hibernation-coordinator.tssrc/renderer/src/lib/agent-hibernation-runtime-owner.tssrc/renderer/src/lib/legacy-runtime-owner-answers.test-fixture.tssrc/renderer/src/lib/paired-web-client-host.test.tssrc/renderer/src/lib/resolve-owner-acceptance.test.tssrc/renderer/src/lib/runtime-owner-alias-golden.test.tssrc/renderer/src/lib/terminal-pty-owner-acceptance.test.tssrc/renderer/src/lib/terminal-worktree-route.tssrc/renderer/src/lib/worktree-operation-route.tssrc/renderer/src/lib/worktree-reactivation-preserved-pane-replacement.test.tssrc/renderer/src/lib/worktree-runtime-owner.test.tssrc/renderer/src/lib/worktree-runtime-owner.tssrc/renderer/src/store/slices/terminal-pane-retirement-ownership.test.tssrc/renderer/src/store/slices/terminal-tab-retirement.tssrc/renderer/src/store/terminals/terminal-pane-hibernation.tssrc/renderer/src/store/terminals/terminal-shutdown.tssrc/renderer/src/store/terminals/terminal-tab-close-providers.test.tssrc/renderer/src/store/terminals/terminal-tab-close-providers.tssrc/renderer/src/store/terminals/terminal-teardown-owner.tstests/e2e/codex-child-approval-activity-row.unit.test.ts
💤 Files with no reviewable changes: 7
- .github/workflows/pr.yml
- config/deprecated-runtime-owner-importers-baseline.txt
- src/renderer/src/lib/runtime-owner-alias-golden.test.ts
- config/scripts/check-deprecated-runtime-owner-ratchet.test.mjs
- config/scripts/pr-preflight-gates.test.mjs
- config/scripts/check-deprecated-runtime-owner-ratchet.mjs
- tests/e2e/codex-child-approval-activity-row.unit.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The upstream/main merge of 2026-10-19 deleted getRuntimeEnvironmentIdForWorktree (stablyai#30626) and changed Store.updateRepo to take the repo as its host target. The Perforce workspace target still imported the deleted function, so the renderer failed to load and the window stayed black; the copy commands no longer type checked. - perforce-workspace-target reads runtimeEnvironmentIdWithLegacyFallbackUnlessTwin, the read-only replacement that keeps the old legacy fallback and twin-as-null answer - detectProject passes the repo to updateRepo; its executionHostId names the host Co-Authored-By: Claude Opus 5.5 <[email protected]>
ELI5
When you close, hibernate or shut down a terminal, Orca has to work out which machine that terminal's process runs on. Until now it asked one resolver when it started the terminal and a different, older resolver when it stopped it. Usually the two agreed, but in a few edge cases they didn't. This PR makes stopping ask the same question starting does, and then deletes the older resolver.
What Changed
Before, for the user:
remote:terminal id with no server named could be closed on this app instead of where it was started.After:
Mechanism:
resolveTerminalPtyOwnerplusisUnattributedTwinWorktree(inlib/terminal-worktree-route.ts) sit on top ofresolveTerminalHostOwnership, which spawn already uses. Shutdown, pane and agent hibernation, individual close, and PTY identity all read them.ssh:targets, handled inresolveStrictWorktreeOperationRouteResultForHost:ambiguous;ambiguous.resolveOwnerand the terminal route answer alike.getRuntimeEnvironmentIdForWorktree/resolveRuntimeOwnerForWorktree. The legacy branch survives only as the private fallback insideresolveOwnerWithLegacyFallback.pr.ymlstep and thepackage.jsonscript.hasHostEvidencenow reads the owner indexes instead of scanning.Deliberate differences from the deleted resolver's teardown answers. Exactly these, as listed in
terminal-pty-owner-acceptance.test.ts:ambiguous;ambiguous.Every one moves an answer toward the server or to "refuse", never toward local.
Why
Alternatives considered:
Linked Issue
Round 3 of the SSH/remote hardening (design
round3-design.md§7, S6(a)/F8). No single issue.Visual Proof
N/A. There's no UI change; this is ownership routing for terminal teardown.
Testing
terminal-pty-owner-acceptance.test.ts:terminal-tab-close-providers.test.ts: an ambiguous owner skips and logs an unscopedremote:id instead of closing it on this app. This fails before the fix.terminal-pane-retirement-ownership.test.ts,worktree-runtime-owner.test.ts,paired-web-client-host.test.ts,store/terminals/.Local units:
src/renderer/src/lib,src/renderer/src/store,components/terminal-pane,components/terminal-workspace,config/scripts, single worker. 2,074 files passed. The 3 failingconfig/scriptsbuild-harness files (process-host-dev-rebuild,main-entry-facade,macos-terminal-host-bundle) fail identically onorigin/mainon this machine.Full pr.yml static job run locally: 0 failures.
ssh-orcad Docker lane: dispatched on the head (all
tests/e2e/ssh-orcad-*.spec.ts).Live verification: none beyond the Docker lane. This changes which host a teardown targets in twin and contested states, which the unit matrix enumerates exhaustively.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Claude (Opus) implemented this. Codex (gpt-6.1-sol, high) and a separate Opus pass reviewed it.
Review
ExecutionHostId, andresolveOwneruses the same rule, so they stay in parity.remote:ids, and no indexed lookup became a scan.ref-oss check (after 3+ review rounds; VS Code
terminalProcessManager.ts/remotePty.ts, Zedproject/src/terminals.rs):remote:<env>PTY ids carry their server, and close and identity use it directly.Focus-read ratchet: 1085 → 1081. The ratchet's discovery skips functions that return their value inside an object literal, so it does not count
resolveTerminalPtyOwner. That function reads the focused runtime only for setup terminals, as before. Seeding it would newly count about 10 teardown files that the deleted resolver also never registered in. So I left the discovery unchanged rather than inflate the baseline.Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)