Skip to content

fix(relay): expand Windows ~\ paths in session.resolveHome - #7650

Merged
nwparker merged 1 commit into
stablyai:mainfrom
xianjianlf2:fix/relay-windows-tilde-expansion
Jul 24, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
xianjianlf2:fix/relay-windows-tilde-expansion

Conversation

@xianjianlf2

@xianjianlf2 xianjianlf2 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

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.resolveHome handler 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 shared expandTilde() in src/relay/context.ts, which preserves the existing POSIX cases and additionally maps ~\ → homedir() and ~\… → ${homedir()}\<rest>. Now-unused homedir and resolve imports are dropped from relay.ts (resolve() at the call site was the Promise resolver, not path.resolve, so removal is safe).

Evidence

Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.

  • Verified by code inspection: old-vs-new behavior is identical for all existing POSIX cases; only the previously-unhandled Windows ~\… branch changes.
  • Lint clean:
$ npx oxlint src/relay/relay.ts
EXIT=0 (clean)
  • Rebased cleanly onto origin/main.
  • No dedicated unit test was added in this change; the Windows expansion path is exercised by the shared expandTilde helper the handler now delegates to.

Trade-offs

None — pure fix.

Regression risk

Near-zero. Existing ~, ~/, and ~/… inputs resolve byte-identically through expandTilde(); only the formerly-broken ~\… branch gains new behavior. The removed imports are provably unused, and the resolve() at line 727 is the Promise resolver, not path.resolve.


Credit to original author @xianjianlf2. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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 "", "/", and "~/..." cases. Import statements were adjusted: the node:path import now only imports join, and the ./context import now includes expandTilde alongside RelayContext. No exported or public entity declarations changed.

Changes

Cohort / File Summary
src/relay/relay.ts Replaced manual tilde-path resolution logic in session.resolveHome handler with a call to expandTilde; updated node:path and ./context imports accordingly.

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
Loading

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,
Through homedir and resolve, it stumbled all day.
Now a helper named expandTilde shows it the door,
One clean little call, and it's home once more! 🏡

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the fix well, but it omits required template sections for screenshots, testing, AI review, security audit, and notes. Add the missing template sections, including screenshots/no visual change, test checklist status, AI review cross-platform checks, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 names the Windows tilde-path fix in session.resolveHome and matches the PR's main change.

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.

@AmethystLiang
AmethystLiang requested a review from Jinwoo-H July 9, 2026 16:52
@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:40
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]>
@nwparker
nwparker force-pushed the fix/relay-windows-tilde-expansion branch from 0bb5e55 to 8453f73 Compare July 23, 2026 11:48
@nwparker
nwparker merged commit 9373f5d into stablyai:main Jul 24, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Thanks so much for this, @xianjianlf2 — expand Windows ~\ paths in session.resolveHome. Reviewed, rebased on latest main, and merged. Really appreciate the contribution! 🙏

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

4 participants