Repository navigation
Conversation
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryTerminal startup now preserves literal backslashes in POSIX folder names.
Reviews (2) · Last reviewed commit: "fix(terminal): preserve backslashes in P..." · Reviewed by Greptile |
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
Terminal startup inferred Windows path flavor from any backslash in the requested cwd, so a valid Linux folder such as `reports\2026` was rewritten to `reports/2026`, failed the existence check, and fell back to the workspace root. Startup now picks Windows flavor only for Windows-absolute roots or requests, and the shared resolver keeps backslashes literal under POSIX flavor. Fixes stablyai#52557 Co-authored-by: Neil <[email protected]>
51e3ff9 to
cd00d2b
Compare
ELI5
On Linux and macOS, a folder name can contain a backslash, for example
reports\2026. When you opened a terminal in such a folder, Orca treated the backslash as a Windows path separator, couldn't find the folder, and opened the terminal in the workspace root. The terminal now opens in the folder you picked.What Changed
Before: asking for a startup cwd of
reports\2026(relative, or the absolute path sent by the file explorer) in a POSIX workspace was rewritten toreports/2026. The missing-directory check then failed and the shell started in the workspace root. A workspace root with a backslash in it, such as/work\archive/repo, was also reported as being outside itself.After: the shell starts in
<workspace>/reports\2026.Mechanism:
resolveTerminalStartupCwdpicks the path flavor fromisWindowsAbsolutePathLike(workspaceRoot)orisWindowsAbsolutePathLike(cwd). A backslash in a relative name no longer switches to Windows flavor. It passes that flavor toresolveRuntimePath.resolveRuntimePathtakes an optionalpathFlavorargument. Its default is the old inference, so other callers don't change. Under POSIX flavor it, along withnormalizeRuntimePathDots, no longer turns\into/, and a leading\is no longer treated as a drive-root path.Why
The bug started in terminal startup: it guessed Windows path rules from any backslash in the requested name. On POSIX a backslash is a normal filename character, so path rules have to come from absolute path syntax (a drive letter or a UNC prefix), not from a backslash inside a name. Changing the default for every
resolveRuntimePathcaller would have changed check annotations, bot home files and browser document locations too. An explicit flavor keeps this fix limited to terminal startup.Linked Issue
Fixes #52557
Visual Proof
There is no UI change. The visible effect is which directory the shell starts in. Below is the output of a real filesystem probe: real directories under a temp workspace (
<ws>), the production startup resolver with its real missing-directory check, then/bin/pwdrun in the returned directory.Before (main)
After (this PR)
A missing folder (
missing\dir) still falls back to the workspace root. Across 17 sampled path pairs (Windows drive, UNC, WSL UNC,/c/...,~,..at/), the two-argumentresolveRuntimePathreturns the same result on main and on this branch.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
I reproduced the bug on macOS with real directories named
reports\2026,a\b/canddup\x(probe above). With this change the shell starts in the requested folder. The contributor also reproduced it on Linux with/bin/pwd.I added
terminal-startup-cwd.test.ts, which covers a relative backslash name,..from a root with a backslash in it, and the workspace-root inside check. All three fail on main.I ran the targeted vitest for
src/shared/shell/launch/andcross-platform-path.test.ts. The existing Windows drive and UNC coverage passes.These pass on the touched files: oxlint (anti-slop and code-quality native plugins), ast-grep, oxfmt, and the changed-code quality gate.
Windows, WSL and SSH were checked by reviewing the source and sampling path pairs. Explicit Windows paths keep their old interpretation.
Performance
None. This only runs once each time a terminal starts. It does the same filesystem probes as before, and choosing the flavor is two string checks. Microbenchmark, old vs new, in ns per
resolveTerminalStartupCwdcall:sub/dir314 vs 296,<root>/reports\2026342 vs 239,C:\r+..\y\z378 vs 379. An adversarial 2.6 KB input took 46.3 µs before and 20.5 µs after. No new I/O, subprocesses or polling.Risk
Level: Low. In a POSIX workspace, a relative startup cwd that uses Windows separators (
sub\dir) now keeps the backslash as part of the name. If no such folder exists, it falls back to the workspace root as before. Workspaces whose root looks like a Windows path, and requests with a drive letter or UNC prefix, use the Windows rules as before. OtherresolveRuntimePathcallers keep the default inference. There are no storage, protocol or remote-compat changes, and a plain revert backs it out.Review
Reviewed in the bug-bash pass. A maintainer follow-up simplified how the flavor is picked and tightened the tests.
Agent skill upstream boundary
Notes
Original fix by @SeungWoonSong in #52558. Their authorship is kept on the squashed commit.
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance. The path flavor comes from the workspace path syntax, not the client OS, so SSH workspaces on POSIX hosts are fixed the same way.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)