Skip to content

fix: follow the session's live cwd in the dock - #174

Merged
omartelo merged 1 commit into
mainfrom
fix/dock-follows-session-cwd
Aug 6, 2026
Merged

fix: follow the session's live cwd in the dock#174
omartelo merged 1 commit into
mainfrom
fix/dock-follows-session-cwd

Conversation

@omartelo

@omartelo omartelo commented Aug 6, 2026

Copy link
Copy Markdown
Owner

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 larifo and 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 -120 from the tree the agent was actually in. The Code tab listed that same wrong checkout.

How

  • useActiveSession now resolves path as cwd || checkout || projectPath, so Review, Code, the file tree and the pull-request screen follow the directory the card and footer already showed.
  • FooterBar drops its own copy of the overlay — one source of truth.
  • The hook also returns checkout, the session's static path. The sidebar keys a worktree's pull-request card on it, so openPulls and the "did removing this worktree pull the screen out from under me" check stay on the checkout instead of following a cd to a directory no sidebar group can show.

Not a provider-specific path: the cwd is polled off the PTY child in internal/terminal/cwd.go for every session regardless of kind, 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 a cd inside a nested shell still moves nothing.

Test plan

  • pnpm check, tsc --noEmit, vitest run (636 passed), vite build
  • In the app: from a worktree session cd into another repository — Review and Code follow it, and the footer's PR button still opens the worktree's card in the sidebar

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.
@omartelo
omartelo merged commit 53642e0 into main Aug 6, 2026
3 checks passed
@omartelo
omartelo deleted the fix/dock-follows-session-cwd branch August 6, 2026 23:33
@omartelo omartelo mentioned this pull request Aug 7, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant