Repository navigation
feat(wsl): bridge fish panes report their folder (OSC 7) at every prompt - #35517
Conversation
The bridge fish launch's -C now also defines a fish_prompt hook that sends the same percent-encoded OSC 7 as bash and zsh, only inside WSL, after the user's config.fish.
[Low impact] The change is limited to folder tracking in WSL bridge fish panes. The PR appears safe to merge, with a non-blocking cleanup issue in the new test helper. Findings
SummaryAdds an OSC 7 folder report at every prompt in WSL bridge fish panes.
Reviews (1) · Last reviewed commit: "feat(wsl): bridge fish panes report thei..." · Reviewed by Greptile |
| await vi.waitFor(() => expect(prompts()).toBe(1), { timeout: 15_000 }) | ||
| await command(`cd ${JSON.stringify(deep)}`) | ||
| await command('cd .') | ||
| // A foreign report (an ssh session that set its own) lands between prompts. | ||
| await command(String.raw`printf '\e]7;file:///elsewhere\a'`) | ||
| term.write('exit\r') | ||
| await vi.waitFor(() => expect(exited).toBe(true), { timeout: 10_000 }) |
There was a problem hiding this comment.
Failed tests leave fish running
runFish only sends exit after every prompt check succeeds. If an earlier vi.waitFor times out, the child fish process and its terminal stay open while afterEach removes its home directory. Wrap the session in try/finally and kill the child during cleanup, as the neighboring fish tests do.
|
No actionable comments were generated in the recent review.
|
Flag-off: applies on the default bridge, with the flag on or off. It only changes WSL panes whose login shell is fish.
User-risk: Low. A fish pane in WSL now sends one extra cwd report (OSC 7) at each prompt. The user's config.fish, prompt and hooks still run unchanged. Our hook runs after their config and adds to it; it never replaces anything.
ELI5
Orca learns which folder a terminal is in from a small message the shell prints at each prompt (OSC 7). That message is what Orca uses to restore the terminal in the same folder. #35385 made bash and zsh print it in WSL panes; fish was left out. Now fish prints it too.
What Changed
-Cinit command that definesclaude.PWDchanges, so nothing corrects a foreign report (say, from an ssh session) at the next prompt.-C(getWslFishInitCommand()) also defines__orca_wsl_cwd_report --on-event fish_prompt. At every prompt it sendsESC ] 7 ; file://<path> BEL, only whenWSL_DISTRO_NAMEis set.string escape --style=url(fish 3.0+). That keeps the same unreserved set as the bash and zsh blocks, and is only recomputed whenPWDchanges.-Cafter reading the user's config, so theirfish_promptand their own prompt-event hooks keep working.src/shared/fish-wsl-cwd-report.tsholds the fish function.wsl-login-shell-command.tsappends it to the fish-C.Why
-Crather than add a fish wrapper or an XDG handoff for bridge panes. It is the one place Orca already injects into bridge fish, and it runs after user config by design.fish_prompt, not--on-variable PWD. This matches bash and zsh: re-sending at every prompt corrects a foreign report. fish also firesfish_promptonly with a terminal, which is exactly when a report matters.Linked Issue
Follow-up to #35385 (WSL bridge live cwd, bash and zsh).
Visual Proof
N/A: no UI change. The effect is the folder a restored terminal reopens in.
Testing
New real-fish test
src/shared/fish-wsl-cwd-report.node-pty.test.ts. It runs node-pty, with fish 3+, and isolated HOME and XDG dirs.-l -C <getWslFishInitCommand()>the launcher passes, under a config.fish with its ownfish_promptand prompt hook.cdintodeep er/déjà a%b#c, thencd ., then a foreign OSC 7 report, thenexit.[home, deep, deep, /elsewhere, deep](the same sequence as the bash and zsh tests), and the user hook still prints. WithoutWSL_DISTRO_NAME, only the foreign report appears.-C. It passed 4 runs in a row locally (fish 4.7.1).Added the test to the
shell contractsCI lane, which requires fish 4+. Thesrc/shared/fish-path prefix already triggers that lane.wsl-login-shell-commandandwindows-shell-argstests pass.Load rule:
pnpm tc,typecheck:ci,check:code-quality:changed, the anti-slop lint, and the ast-grep gates.Not run inside a real WSL distro.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
string escape --style=urlneeds fish 3.0+. Ubuntu 20.04 ships fish 3.1.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)