[FEATURE] Emit OSC 9;9 / OSC 7 (working directory) when the session cwd changes
Problem
Terminals use working-directory reports for "duplicate tab/pane opens in the same directory" (Windows Terminal consumes ConEmu OSC 9;9; other terminals use OSC 7). Shells emit these from the prompt — but while a Claude Code session runs, the prompt never fires. So after the session changes its working directory (EnterWorktree is the big one), duplicating the tab lands where claude was launched, not where the session actually works. With the worktree workflow this is constant: the session lives in a worktree, every duplicated tab lands in the base repo.
Userland can't fix it cleanly:
- statusline stdout is filtered to color codes only, so a statusline script can't emit the sequence (same filter discussed in #21586 / #26356)
- hook and tool output never reaches the terminal either
Workaround that works today (writing to the console device directly from a statusline child — CONOUT$ on Windows / /dev/tty): https://github.com/ykdojo/claude-code-tips/issues/36 — but it's a hack around the output filter.
Ask
Emit OSC 9;9 (Windows) / OSC 7 (elsewhere) to the terminal when the session's cwd changes: session start, EnterWorktree/ExitWorktree, and any other cwd switch. Claude Code already writes OSC 0 titles, so the plumbing exists.
Sibling request for OSC 133 shell-integration marks: #22528.
Environment
- Claude Code 2.x, Windows 11 + Windows Terminal (Git Bash statusline), also applies to WSL