Repository navigation
refactor(renderer): fold launch, paste and terminal-create callers off the deprecated owner resolver; spawn refuses folder twins - #30497
Conversation
…l-create callers off the deprecated owner resolver Agent launch, AI-vault resume and reveal, note target and send, wake and creation seeds, native chat owner, the shell menu and active-workspace terminal creation (#22, #31-#42, #44) read the owner through runtimeEnvironmentIdWithLegacyFallbackUnlessTwin. Paste uploads images to the server its PTY id names before falling back to the workspace owner. The folder and floating branch of the terminal spawn route (#53) reads resolveOwnerWithLegacyFallback: spawn refuses a folder twin instead of following the focused server, and teardown keeps tearing raw ids down locally. Deprecated importers 31 -> 16.
4e404b7 to
c09bbe1
Compare
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
00b2f8ca-3df3-41cc-97cf-b1bf316244d3
📒 Files selected for processing: 30
config/deprecated-runtime-owner-importers-baseline.txtconfig/focus-setting-read-baseline.txtsrc/renderer/src/components/native-chat/native-chat-paste-routing.test.tsxsrc/renderer/src/components/native-chat/native-chat-runtime-owner.tssrc/renderer/src/components/tab-bar/use-tab-bar-runtime-model-worktree-write-probe.tssrc/renderer/src/components/tab-bar/use-tab-bar-runtime-model.tssrc/renderer/src/components/terminal-pane/terminal-pane-menu-paste.tssrc/renderer/src/components/terminal-pane/terminal-pane-paste-execution.tssrc/renderer/src/components/terminal-pane/terminal-pane-paste-listeners.tssrc/renderer/src/components/terminal-pane/terminal-paste-runtime.test.tssrc/renderer/src/components/terminal-pane/terminal-paste-runtime.tssrc/renderer/src/lib/activate-ai-vault-structured-session-reveal.test.tssrc/renderer/src/lib/activate-ai-vault-structured-session.tssrc/renderer/src/lib/active-agent-note-send.tssrc/renderer/src/lib/active-agent-note-target.tssrc/renderer/src/lib/agent-launch-caller-permissions.test.tssrc/renderer/src/lib/agent-launch-caller-placement.test.tssrc/renderer/src/lib/agent-launch-caller-prompt-transport.test.tssrc/renderer/src/lib/agent-launch-caller-routing.test.tssrc/renderer/src/lib/launch-agent-background-session.tssrc/renderer/src/lib/launch-agent-in-new-tab-cwd.test.tssrc/renderer/src/lib/launch-agent-in-new-tab-placement.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-ai-vault-session.test.tssrc/renderer/src/lib/launch-ai-vault-session.tssrc/renderer/src/lib/terminal-worktree-route.test.tssrc/renderer/src/lib/terminal-worktree-route.tssrc/renderer/src/lib/web-runtime-worktree-terminal-after-wake.tssrc/renderer/src/lib/worktree-creation-agent-seeds.tssrc/renderer/src/store/terminals/terminal-active-workspace-creation.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.
| (ptyId ? parseRemoteRuntimePtyId(ptyId)?.environmentId : null) ?? | ||
| runtimeEnvironmentIdWithLegacyFallbackUnlessTwin(state, worktreeId) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -n -C 5 'getRuntimeEnvironmentId\s*[:=(]|saveClipboardImageAsTempFile\s*[:=(]' srcRepository: stablyai/orca
Length of output: 42193
Use the transport owner for legacy remote PTY IDs.
If a remote PTY ID has no encoded environment, resolve the runtime from transport.getRuntimeEnvironmentId() before using worktree ownership. The paste path passes this value to saveClipboardImageAsTempFile, so the current fallback can target a different runtime or return null for a twin workspace.
| target.target ?? | ||
| runtimeTargetForOwnerEnvironment( | ||
| getRuntimeEnvironmentIdForWorktree(useAppStore.getState(), target.worktreeId) | ||
| runtimeEnvironmentIdWithLegacyFallbackUnlessTwin(useAppStore.getState(), target.worktreeId) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Do not reveal an ambiguously owned session on the local host.
If a structured session belongs to a folder workspace published by two hosts and the caller supplies no explicit target, this resolver returns null. runtimeTargetForOwnerEnvironment then selects local, so agentSession.reveal cannot reach the host holding the session. A local agent_session_identity_required reply can also report the remote session as gone. Preserve the session’s host identity for activation, refresh, and reveal, or report unresolved ownership instead of selecting local.
| // this worktree's agent terminal, not the focused runtime. | ||
| const runtimeTarget = runtimeTargetForOwnerEnvironment( | ||
| getRuntimeEnvironmentIdForWorktree(state, worktreeId) | ||
| runtimeEnvironmentIdWithLegacyFallbackUnlessTwin(state, worktreeId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Route an active remote PTY to its host.
For a folder twin with a live remote:<env>@@… PTY, worktree ownership is unresolved, so this call builds a local probe target despite the PTY’s host identity. The probe cannot inspect that remote terminal. sendNotesToActiveAgentSessionInternal in src/renderer/src/lib/active-agent-note-send.ts makes the same local-target choice at Line 77, so sending the note can fail to find the terminal. Use the live PTY’s environment for both operations; retain worktree fallback for raw PTY IDs.
| const runtimeEnvironmentId = worktreeRoute | ||
| ? worktreeRoute.route.runtimeEnvironmentId | ||
| : getRuntimeEnvironmentIdForWorktree(state, worktreeId) | ||
| : runtimeEnvironmentIdWithLegacyFallbackUnlessTwin(state, worktreeId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Reject unresolved folder ownership before creating a terminal tab.
For a folder workspace published by two hosts, worktreeRoute is deliberately null and this resolver also returns null. On desktop, the action then creates and selects a tab. The folder-twin spawn route refuses unresolved ownership, leaving the selected tab without a terminal. Resolve the folder owner before tab creation and return an explicit refusal when ownership remains ambiguous.
ELI5
Starting an agent, resuming an AI-vault chat, sending a note to an agent, pasting into a terminal and opening a new terminal all asked an old "which server owns this workspace?" helper that is being retired. They now ask the replacement. The terminal spawn route also stops sending a folder workspace that two hosts publish to whichever server happens to be focused.
What Changed
runtimeEnvironmentIdWithLegacyFallbackUnlessTwin.resolveTerminalPasteRuntimeEnvironmentId(interminal-paste-runtime.ts) picks the server that the PTY id itself names (remote:<env>@@…), and only falls back to the workspace owner for raw ids. Before, a pasted image was always uploaded to the workspace owner's host, which for a twin was this desktop even when the pane ran on a server.resolveOwnerWithLegacyFallback.unresolved) instead of starting on the focused server.remote:ids, which route by id.terminal-paste-runtime.ts+1, annotated. It is the one shared paste-owner read, replacing three call-site reads that the ratchet still counts through the helper. F8 removes it.Stacked on #30484.
Why
The design (round 3 §6) asks paste to route by the PTY's own id where it can, because that needs no owner guess at all. For launches, adding a separate refusal in each launcher would duplicate the spawn route's own check, so this keeps the check in one place and makes it cover folder twins.
Linked Issue
Round 3 of the SSH/remote hardening (S6(b) F5+F6). No single issue.
Visual Proof
N/A: no UI change; ownership routing only.
Testing
New: a folder twin refuses spawn and tears raw ids down locally (fails before); paste uploads to the server its PTY id names on a twin, and to no server for a raw id (fails before).
pnpm testsingle worker oversrc/renderer/src/lib,components/terminal-pane,components/tab-bar,store/terminals,runtime,components/native-chat,components/tab-group,components/activity.Full local copy of the pr.yml static job.
ssh-orcad Docker lane dispatched on the exact head (link in a comment).
Live verification: unit-tested only.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Codex (
gpt-6.1-sol, high): see comment.Agent skill upstream boundary
Notes
SSH: changes only the twin, rival-server and stale-server-stamp rows; paste on a server PTY now uploads to that server. Wire: none. Cross-platform: none.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)