Skip to content

refactor(renderer): one twin check, one worktree-copy scan, drop stale resolver mocks - #30579

Merged
nwparker merged 1 commit into
mainfrom
nwparker/r3-cleanpass-2
Oct 19, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/r3-cleanpass-2

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 33 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​107 $\color{#cf222e}{\Huge{\mathbf{−}}}$​195 $\color{#cf222e}{\Huge{\mathbf{−}}}$​88
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83 $\color{#cf222e}{\Huge{\mathbf{−}}}$​45 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38

ELI5

A tidy-up after the last batch of "which machine owns this project" changes. Nothing the user sees changes. Repeated checks become one named check, a duplicated scan becomes one helper, and about 30 test files stop pretending to stub a function the code no longer calls.

What Changed

  • One twin check. isTwinWorkspace(state, workspaceId) in lib/resolve-owner.ts replaces four inline resolveOwner(...).kind === 'ambiguous' checks: file preview, the file:// open target, the doc-preview "open externally" action and the file-search runner.
  • One worktree-copy scan. someWorktreeCopy does the listed-plus-detected row scan that isUnprovenServerSshRoute and hasHostEvidence each did on their own.
  • File-explorer owner. The runtime answer is checked before the SSH connection lookup. That makes a second "unresolved" guard and a stale comment about a projected runtime owner unnecessary, so they are gone. The result is the same for every input, including empty or whitespace environment ids.
  • Native chat owner. A null check the helper already does is removed.
  • Tests:
    • Stale getRuntimeEnvironmentIdForWorktree mocks are deleted from 29 suites. The code under test stopped importing it during the F2–F7 folds.
    • web-runtime-session.test.ts now names its mock after the helper it really stubs.
    • One shared local+SSH twin fixture, lib/workspace-twin-rows.test-fixture.ts.
    • The file:// target tests move to workspace-file-browser-open-target.test.ts, next to their module.
    • mocks.twin is reset in beforeEach.

Before and after for the user: identical.

Why

These are the follow-ups from the second clean-code pass over #30478, #30484, #30497 and #30562. Each removes a copy or a dead branch, so the next owner-resolution change has one place to edit. The stale mocks matter because they make a suite look as if it controls the owner when it doesn't. F8 deletes the deprecated resolver, and any mock still naming it would have to be cleaned up then anyway.

Alternative considered: merging runtimeEnvironmentIdUnlessTwin with the legacy-fallback wrapper now. It was held back on purpose, because that only becomes safe once F8 removes the legacy branch.

Linked Issue

Internal SSH hardening, round 3 (clean-code pass 2). Stacked on #30562; it will be rebased onto main once that merges.

Visual Proof

N/A: no UI or behaviour change. Refactor and test clean-up only.

Testing

  • Automated tests added/updated, or explained why not below
  • The full static-analysis job was run locally (every step of pr.yml's static job, including the ratchets): 0 failures.
  • Unit folders around every changed file, single process: src/renderer/src/lib, components/right-sidebar, components/browser-pane, components/native-chat, runtime, components/activity, components/tab-group. Result: 1,865 files and 17,915 tests passed.
  • Codex review (gpt-6.1-sol, high): no findings.
  • Adversarial Opus review: no P1 or P2 findings. It checked the file-explorer reorder against every input shape, and that no deleted mock was still needed.
  • Live: not applicable (no behaviour change).

Review

Codex clean; Opus clean.

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 and folder workspaces: the owner answers are unchanged. The twin check is the same resolveOwner call, just behind a name.

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)

…e resolver mocks

- isTwinWorkspace replaces four inline resolveOwner(...).kind === 'ambiguous' checks
- someWorktreeCopy shared by isUnprovenServerSshRoute and hasHostEvidence
- file-explorer owner: drop the unreachable second unresolved guard and the stale comment
- native chat owner: drop a null ternary the helper already handles
- tests: delete stale getRuntimeEnvironmentIdForWorktree mocks (29 suites), one shared
  local+ssh twin fixture, file:// open-target tests next to their module, reset mocks.twin
@nwparker
nwparker force-pushed the nwparker/r3-cleanpass-2 branch from 1c81791 to 2872c9d Compare October 19, 2026 06:18
@nwparker
nwparker changed the base branch from nwparker/r3-f7-write-folds to main October 19, 2026 06:18
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 56be68d5-1aef-48ce-82b6-e909bdc37b78
📥 Commits

Reviewing files that changed from the base of the PR and between 75b6fa2 and 2872c9d.

📒 Files selected for processing: 42
  • src/renderer/src/components/activity/activity-answered-ask-timeline.test.tsx
  • src/renderer/src/components/browser-pane/assemble-chrome/browser-deferred-lifecycle.test.tsx
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-document-actions.test.ts
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-document-actions.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsx
  • src/renderer/src/components/native-chat/native-chat-runtime-owner.ts
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-clock.test.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-failed-start.test.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-stopping.test.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-unconfirmed-start.test.tsx
  • src/renderer/src/components/native-chat/structured-child-records-switch.test.tsx
  • src/renderer/src/components/right-sidebar/file-explorer-operation-owner.ts
  • src/renderer/src/components/right-sidebar/useFileSearchRunner.test.tsx
  • src/renderer/src/components/right-sidebar/useFileSearchRunner.ts
  • src/renderer/src/components/tab-group/useTabGroupTabCloseCommands.structured-session.test.ts
  • src/renderer/src/components/terminal-workspace-keydown.test.ts
  • src/renderer/src/lib/file-preview.test.ts
  • src/renderer/src/lib/file-preview.ts
  • src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts
  • src/renderer/src/lib/resolve-owner.ts
  • src/renderer/src/lib/startup-draft-input-kind.test.ts
  • src/renderer/src/lib/workspace-file-browser-open-target.test.ts
  • src/renderer/src/lib/workspace-file-browser-open-target.ts
  • src/renderer/src/lib/workspace-twin-rows.test-fixture.ts
  • src/renderer/src/lib/worktree-runtime-owner.ts
  • src/renderer/src/runtime/web-runtime-browser-capability-cleanup.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-client-placement.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-failure.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-focus.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-split-placement.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-staged-focus.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-staged-hosting-intent.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-staging.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-placement-staleness.test.ts
  • src/renderer/src/runtime/web-runtime-session-tab-activate-close.test.ts
  • src/renderer/src/runtime/web-runtime-session-tab-close-undelivered-codes.test.ts
  • src/renderer/src/runtime/web-runtime-session-tab-move.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-host-authority.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-legacy-create.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-pane-delegation.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-workspace-routing.test.ts
  • src/renderer/src/runtime/web-runtime-session.test.ts
💤 Files with no reviewable changes: 28
  • src/renderer/src/components/browser-pane/assemble-chrome/browser-deferred-lifecycle.test.tsx
  • src/renderer/src/runtime/web-runtime-session-browser-create-staged-focus.test.ts
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-clock.test.tsx
  • src/renderer/src/runtime/web-runtime-session-browser-create-failure.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-pane-delegation.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-placement-staleness.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-staging.test.ts
  • src/renderer/src/runtime/web-runtime-browser-capability-cleanup.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-host-authority.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-split-placement.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-workspace-routing.test.ts
  • src/renderer/src/lib/startup-draft-input-kind.test.ts
  • src/renderer/src/components/terminal-workspace-keydown.test.ts
  • src/renderer/src/lib/launch-agent-structured-chat-guard.test.ts
  • src/renderer/src/components/tab-group/useTabGroupTabCloseCommands.structured-session.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-focus.test.ts
  • src/renderer/src/runtime/web-runtime-session-terminal-legacy-create.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-create-staged-hosting-intent.test.ts
  • src/renderer/src/runtime/web-runtime-session-tab-activate-close.test.ts
  • src/renderer/src/components/native-chat/structured-child-records-switch.test.tsx
  • src/renderer/src/runtime/web-runtime-session-tab-close-undelivered-codes.test.ts
  • src/renderer/src/runtime/web-runtime-session-browser-client-placement.test.ts
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-stopping.test.tsx
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsx
  • src/renderer/src/components/activity/activity-answered-ask-timeline.test.tsx
  • src/renderer/src/runtime/web-runtime-session-tab-move.test.ts
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-failed-start.test.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-status-bridge-unconfirmed-start.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

The change adds shared helpers for twin-workspace detection and worktree-copy checks. Runtime-owner selection and file-explorer owner resolution use updated routing logic. Document actions, file search, preview planning, and browser-open targets use the twin-workspace helper. Tests share a local-and-SSH twin-row fixture and remove several runtime-owner mocks.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 2872c

The routing cleanup appears mergeable after normal checks; the examined missing-owner cases preserve their previous behavior.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 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 and concisely identifies the main refactor: centralizing twin checks, sharing worktree-copy scanning, and removing stale resolver mocks.
Description check Passed The description is complete and aligned with the template. It explains the user impact, changes, rationale, linked issue context, testing, review results, scope, and compatibility considerations.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • 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.

@nwparker
nwparker merged commit d03d731 into main Oct 19, 2026
63 of 87 checks passed
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