Repository navigation
fix(relay): expand Windows ~\ paths in session.resolveHome - #7650
Conversation
📝 WalkthroughWalkthroughThe relay entrypoint's session.resolveHome handler in src/relay/relay.ts was refactored to delegate tilde-path expansion to a shared expandTilde helper imported from ./context, replacing the previous manual logic that used os.homedir() and path.resolve() to handle " Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RelayHandler as session.resolveHome handler
participant ExpandTilde as expandTilde
Client->>RelayHandler: request resolveHome(inputPath)
RelayHandler->>ExpandTilde: expandTilde(inputPath)
ExpandTilde-->>RelayHandler: resolved path
RelayHandler-->>Client: return resolved path
Estimated code review effort: 2 🔵🔵⚪⚪⚪ Related issues: None found Related PRs: None found Suggested labels: refactor, relay Suggested reviewers: None found 🐰 A tilde once wandered, lost in its way, 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
The session.resolveHome handler only matched `~` and `~/`, so a Windows remote relay host returned `~\projects\repo` verbatim and every downstream fs op failed. Route through the shared expandTilde helper, which already handles `~`, `~/`, `~\`, and `~\…`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
0bb5e55 to
8453f73
Compare
|
Thanks so much for this, @xianjianlf2 — expand Windows ~\ paths in session.resolveHome. Reviewed, rebased on latest |
…7650) Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Fixes Windows relay hosts returning
~\…home paths unexpanded, which broke every downstream filesystem operation on the resolved path.ELI5
On Windows, "home folder" is written with a backslash (
~\). The relay didn't understand that shorthand, so it handed back a literal~and files couldn't be found. Now it translates the shorthand correctly.Root cause & fix
The relay's
session.resolveHomehandler had its own inline tilde expansion that only matched~,~/, and~/…— POSIX-only forms. A Windows relay host sending~\or~\…fell through unexpanded and was returned verbatim. The fix routes the handler through the sharedexpandTilde()insrc/relay/context.ts, which preserves the existing POSIX cases and additionally maps~\→homedir()and~\…→${homedir()}\<rest>. Now-unusedhomedirandresolveimports are dropped fromrelay.ts(resolve()at the call site was the Promise resolver, notpath.resolve, so removal is safe).Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
~\…branch changes.origin/main.expandTildehelper the handler now delegates to.Trade-offs
None — pure fix.
Regression risk
Near-zero. Existing
~,~/, and~/…inputs resolve byte-identically throughexpandTilde(); only the formerly-broken~\…branch gains new behavior. The removed imports are provably unused, and theresolve()at line 727 is the Promise resolver, notpath.resolve.Credit to original author @xianjianlf2. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.