TUI should emit OSC 7 when its working directory changes
Open 💬 1 comment Opened Aug 12, 2026 by JeremyMoeglich
What variant of Codex are you using?
CLI
What feature would you like to see?
When you resume a session in a different working directory, Codex needs to tell the terminal emulator which directory it is using. OSC 7 is the standard way to do that.
This is supported by modern Linux/macOS terminals and by Windows Terminal following
https://github.com/microsoft/terminal/pull/20019
I don't know what other behaviours in codex may need this other than resume, there may be some.
Additional information
In my case, I want this so Ctrl+Shift+T opens the same working directory as codex is using. I'm using ghostty
1 Comment
Implementation notes: codex already has the exact plumbing pattern this needs —
tui/src/terminal_title.rsowns a sanitized OSC 0 write path used for session titles (https://github.com/openai/codex/blob/1f41cc5d92/codex-rs/tui/src/terminal_title.rs#L46-L68). An OSC 7 sibling is small: emitESC ] 7 ; file://{hostname}{percent-encoded-path} ESC \on the samestdout().is_terminal()guard.Emission points beyond resume: TUI startup (the shell's last OSC 7 goes stale the moment codex is the foreground app in a different dir), and any future mid-session cwd change (the
/cdrequest in #38585 ridesThreadSettingsOverrides, which would need the same re-emission). On exit nothing special is needed — the shell prompt re-emits its own.Two details worth getting right: percent-encode non-ASCII path bytes (ghostty and Windows Terminal both parse RFC 8089-style file URLs), and skip emission when the cwd is remote/virtual (a
PathUrithat isn't a local absolute path has no meaningful file:// form).