feat: inherit the focused session's working directory in boo ui#78
Merged
Conversation
In `boo ui`, C-a c now creates the new session in the focused session's working directory, like Ghostty's new windows, instead of inheriting the UI process's directory. The daemon resolves the live working directory of the session's child process (Linux /proc/<pid>/cwd, macOS proc_pidinfo) and exposes it via a new `cwd` control command. `boo new` gains a `--cwd` flag that the UI passes through; the child chdir's there before exec. Creation falls back to a plain `new` when the directory cannot be resolved or used.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
boo ui,C-a cnow creates the new session in the focused session's working directory, like Ghostty's new windows, instead of inheriting theboo uiprocess's directory.How it works
cwdcontrol command. Resolution reads the OS directly:/proc/<pid>/cwdon Linux,proc_pidinfo(PROC_PIDVNODEPATHINFO)on macOS.boo newgains a--cwd <dir>flag (validated, must be an existing directory). The childchdirs there beforeexec.cwdand passes it through toboo new --cwd. If the directory can't be resolved or used, it falls back to a plainnew, so the keybind always works.The directory comes from the live child process rather than OSC 7 shell integration: boo doesn't inject shell integration, and a process cwd is always a valid local path for
chdir(OSC 7 can be empty, or describe a remote directory over ssh). See the decision log below.boo new --cwdis also useful on its own, e.g.boo new build -d --cwd /srv/app -- make.Decision log
term.getPwd()matches Ghostty and is portable, but boo never injects shell integration so it is usually empty, and under ssh it can report a remote path that is wrong for a localchdir. The child process cwd works without shell integration and is always a valid local path. OSC 7 could be added later as a fallback.cwdcontrol command; the UI (a client) cannot read the child pid itself.cwdis its own command rather than a field oninfoso the extra syscall only happens on create, not on everyls/waitpoll.proc_pidinfoonly fills the buffer when its size exactly matchesstruct proc_vnodepathinfo, so the full<sys/proc_info.h>layout is reproduced. The size (2352) and the cdir path offset (152) were verified against the system headers and are locked with comptime asserts that run on every target.boo new --cwdresolves the path to an absolute, openable directory up front and fails with a clear error if it can't, so a bad value never produces a dead session. The UI retries without--cwdif the inherited create fails (e.g. the directory vanished).Testing
zig build(native Linux) andzig build -Dtarget=aarch64-macos(cross) both succeed; the macOS cross build exercises theproc_pidinfopath and the comptime layout asserts.zig build test(130/130) andzig build test-integration(76/76) pass;zig build test-all -Doptimize=ReleaseSafepasses (206/206).zig fmt --checkis clean.cwd.ofPidagainst a child spawned in a temp dir;boo new --cwdstarts the command in that directory; invalid--cwdexits non-zero; and aboo uiend-to-end test assertingC-a clands the new session in the focused session's directory and not the UI's.Generated with Coder Agents on behalf of @kylecarbs.