fix: follow the session's live cwd in the dock - #174
Merged
Conversation
A session that moved — spawned in one checkout and `cd`-ed into another repository — took its card and the footer with it: both overlay the backend's live cwd on the session's static start path. The dock did not. Review read the spawn directory, so a clean worktree answered "No uncommitted changes" while the footer, one row below, counted 35 changed files from the tree the agent was actually working in; the Code tab listed that same wrong checkout. The overlay moves into useActiveSession, so every screen that follows the active session — Review, Code, the file tree and the pull-request screen — resolves the same directory the card and footer show, and FooterBar drops its own copy of it. The hook also returns `checkout`, the static path: the sidebar keys a worktree's pull-request card on it, so opening that card (and deciding whether removing a worktree leaves the screen standing in it) must not follow a `cd` to a directory no group can show. The cwd itself is unchanged: it is polled off the PTY child for every session regardless of provider, and a platform without a reader still degrades to the start directory.
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.
What
A session that moved — spawned in one checkout and
cd-ed into another repository — took its card and the footer with it: both overlay the backend's live cwd on the session's static start path. The dock did not.Reported against a session spawned in the worktree
larifoand working in~/snk/logistica: Review answered No uncommitted changes (the worktree is clean) while the footer, one row below, counted 35 changed files and+194 -120from the tree the agent was actually in. The Code tab listed that same wrong checkout.How
useActiveSessionnow resolvespathascwd || checkout || projectPath, so Review, Code, the file tree and the pull-request screen follow the directory the card and footer already showed.FooterBardrops its own copy of the overlay — one source of truth.checkout, the session's static path. The sidebar keys a worktree's pull-request card on it, soopenPullsand the "did removing this worktree pull the screen out from under me" check stay on the checkout instead of following acdto a directory no sidebar group can show.Not a provider-specific path: the cwd is polled off the PTY child in
internal/terminal/cwd.gofor every session regardless ofkind, and a platform without a reader (cwdTracked = false) or a session with no child PID still degrades to the start directory — the pre-existing behaviour. The known ceiling is unchanged: only the direct child is tracked, so acdinside a nested shell still moves nothing.Test plan
pnpm check,tsc --noEmit,vitest run(636 passed),vite buildcdinto another repository — Review and Code follow it, and the footer's PR button still opens the worktree's card in the sidebar