Repository navigation
refactor(renderer): one twin check, one worktree-copy scan, drop stale resolver mocks - #30579
Conversation
…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
1c81791 to
2872c9d
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
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
isTwinWorkspace(state, workspaceId)inlib/resolve-owner.tsreplaces four inlineresolveOwner(...).kind === 'ambiguous'checks: file preview, the file:// open target, the doc-preview "open externally" action and the file-search runner.someWorktreeCopydoes the listed-plus-detected row scan thatisUnprovenServerSshRouteandhasHostEvidenceeach did on their own.getRuntimeEnvironmentIdForWorktreemocks are deleted from 29 suites. The code under test stopped importing it during the F2–F7 folds.web-runtime-session.test.tsnow names its mock after the helper it really stubs.lib/workspace-twin-rows.test-fixture.ts.workspace-file-browser-open-target.test.ts, next to their module.mocks.twinis reset inbeforeEach.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
runtimeEnvironmentIdUnlessTwinwith 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
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.Review
Codex clean; Opus clean.
Agent skill upstream boundary
Notes
SSH and folder workspaces: the owner answers are unchanged. The twin check is the same
resolveOwnercall, just behind a name.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)