Repository navigation
refactor(shared): dedupe the local-default connection-to-host conversion and the trim helpers - #27797
Merged
Merged
Conversation
…ion and the trim helpers
OrcaWin
marked this pull request as ready for review
October 12, 2026 06:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Orca had the same tiny rule written out several times: "turn a stored SSH connection id into a host id, and treat a blank one as this computer", plus three copies of "trim a stored id, blank means none". This PR keeps one copy of each and points the callers at it.
What Changed
src/shared/execution-host.tsnow exports its trim-to-null helpernormalizeHostPart. The private copy inexecution-host-registry.tsandnormalizeConnectionIdinfolder-workspace-execution-host.ts(same body, one caller file) are gone.local-path-open-guard.ts→getConnectionExecutionHostIdresolved-worktree-execution-host.ts(repo branch) →getRepoExecutionHostIddetected-worktree-meta.tsfolderWorkspaceMatchesHost→getRepoExecutionHostIdnull/undefinedwhen ownership is unknown (workspace cleanup host identity, worktree host ownership, PTY stable owner, pane evidence). There, "absent" means "no ownership evidence", and turning it into "local" would let cleanup act on the wrong machine.ssh-pty-id'snormalizeConnectionIdis an id decoder and also stays. ThehostScope.kind === 'ssh' ? … : localsites take a parsed scope, a different shape, and stay.User-visible before/after: none. The one theoretical difference: a connection id stored with surrounding whitespace (no write path produces one) used to become
ssh:%20id%20in the two renderer readers and now becomesssh:id, which is what every other reader, including the host registry, already produced.Net lines: prod −20 (10 added / 30 removed in 6 files); tests +35 (characterization only).
Why
Each hand-written copy is a place a future change can drift: the two renderer readers already differed from the shared one on trimming. Folding them into the functions the rest of the app already uses removes that. The design narrowed this from a broader sweep after review found that most "connection ? ssh : …" spots are evidence readers whose missing branch must stay "unknown", not "local".
Linked Issue
N/A (maintainer cleanup, Phase 3.99 PR 2.8).
Visual Proof
N/A: no UI or behaviour change.
Testing
New characterization tests pin the precedence (host stamp > connection id > local), a blank/whitespace connection id reading as local, an explicit SSH owner without a connection id, and a runtime stamp winning over a nested connection id:
local-path-open-guard.test.ts,resolved-worktree-execution-host.test.ts,detected-worktree-meta.test.ts.Dead-code proof:
rg normalizeConnectionId|normalizeHostPartacrosssrc config scripts mobile(including@ts-nocheckfiles) leaves only the new export and the unrelated private decoder inssh-pty-id.ts;pnpm run build:electron-vitesucceeds.pnpm tc,pnpm lint(all ratchets),pnpm run check:code-quality:changed, andpnpm test src/renderer/src/store/slices/worktrees src/renderer/src/lib src/shared(1799 files, 20193 tests) pass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
P0/P1 review: own review plus an independent reviewer; no P0/P1 findings.
Agent skill upstream boundary
Notes
SSH: SSH ownership spellings (stamp-only, connection-id-only) resolve exactly as before. Folder workspaces:
folderWorkspaceMatchesHostcovered. No wire, mobile, or platform-specific change.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)