Skip to content

refactor(renderer): fold launch, paste and terminal-create callers off the deprecated owner resolver; spawn refuses folder twins - #30497

Merged
nwparker merged 4 commits into
mainfrom
nwparker/r3-f5-launch-folds
Oct 19, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/r3-f5-launch-folds

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​86 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31

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

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 test single worker over src/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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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.
@nwparker
nwparker force-pushed the nwparker/r3-f5-launch-folds branch from 4e404b7 to c09bbe1 Compare October 19, 2026 04:00
@nwparker
nwparker changed the base branch from nwparker/r3-f4-mirroring-sort-order to main October 19, 2026 04:00
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Runtime-owner lookups across renderer features now use legacy-fallback-unless-twin resolution. Terminal paste resolves the environment from the pane transport’s PTY ID when available, then falls back to worktree ownership. Terminal worktree routing uses legacy fallback ownership and handles unresolved owners differently for spawn and teardown.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to c09bb

Remote sessions, notes, terminals, and image paste can fail or target the wrong host in the identified ownership cases. Resolve these routing issues before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 28 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description is detailed and covers the change, rationale, testing, visual proof, review, and checklist sections. However, it does not provide the required linked issue and leaves the lint, typeche… Add a valid issue reference under “Linked Issue” and state whether pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass locally or are covered by CI.
Passed Passed checks: 3 passed
Check name Status Explanation
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.
Title check Passed The title clearly summarizes the main changes: migrating callers from the deprecated owner resolver and refusing folder-twin spawns.
Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 28 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, visual proof, review, and checklist sections. However, it does not provide the required linked issue and leaves the lint, typecheck, test, and build validation item unchecked.

Resolution

Add a valid issue reference under “Linked Issue” and state whether pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass locally or are covered by CI.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 00b2f8ca-3df3-41cc-97cf-b1bf316244d3
📥 Commits

Reviewing files that changed from the base of the PR and between 4d65c76 and c09bbe1.

📒 Files selected for processing: 30
  • config/deprecated-runtime-owner-importers-baseline.txt
  • config/focus-setting-read-baseline.txt
  • src/renderer/src/components/native-chat/native-chat-paste-routing.test.tsx
  • src/renderer/src/components/native-chat/native-chat-runtime-owner.ts
  • src/renderer/src/components/tab-bar/use-tab-bar-runtime-model-worktree-write-probe.ts
  • src/renderer/src/components/tab-bar/use-tab-bar-runtime-model.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-menu-paste.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-paste-execution.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-paste-listeners.ts
  • src/renderer/src/components/terminal-pane/terminal-paste-runtime.test.ts
  • src/renderer/src/components/terminal-pane/terminal-paste-runtime.ts
  • src/renderer/src/lib/activate-ai-vault-structured-session-reveal.test.ts
  • src/renderer/src/lib/activate-ai-vault-structured-session.ts
  • src/renderer/src/lib/active-agent-note-send.ts
  • src/renderer/src/lib/active-agent-note-target.ts
  • src/renderer/src/lib/agent-launch-caller-permissions.test.ts
  • src/renderer/src/lib/agent-launch-caller-placement.test.ts
  • src/renderer/src/lib/agent-launch-caller-prompt-transport.test.ts
  • src/renderer/src/lib/agent-launch-caller-routing.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/lib/launch-agent-in-new-tab-cwd.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab-placement.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/launch-ai-vault-session.test.ts
  • src/renderer/src/lib/launch-ai-vault-session.ts
  • src/renderer/src/lib/terminal-worktree-route.test.ts
  • src/renderer/src/lib/terminal-worktree-route.ts
  • src/renderer/src/lib/web-runtime-worktree-terminal-after-wake.ts
  • src/renderer/src/lib/worktree-creation-agent-seeds.ts
  • src/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.

Comment on lines +124 to +125
(ptyId ? parseRemoteRuntimePtyId(ptyId)?.environmentId : null) ??
runtimeEnvironmentIdWithLegacyFallbackUnlessTwin(state, worktreeId)

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -n -C 5 'getRuntimeEnvironmentId\s*[:=(]|saveClipboardImageAsTempFile\s*[:=(]' src

Repository: 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)

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.

🗄️ 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)

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.

🎯 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)

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.

🎯 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.

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.

1 participant