fix: diff panel uses AI session CWD when terminal is linked (#3)#112
Conversation
When the Copilot CLI changes directory internally (via cwd command), the diff panel failed with 'No git repository found from: C:\Users' because terminal.cwd (shell CWD) stays stale — the CLI doesn't emit OSC sequences. Instead of overwriting terminal.cwd (which causes ping-pong, WSL path corruption, and session restore poisoning), the diff panel's CWD selector now checks the linked AI session's CWD first, falling back to shell CWD when no session is linked. Closes #3 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Reviewed the change end-to-end. Verdict: looks good to merge. The selector correctly reads the linked AI session's cwd (from CI: The failing Playwright (Windows) job is a pre-existing main-branch flake hitting unrelated specs (clawpilot-cwd-detection, task-70 image path click, ai-session-sort-and-group, task-61 rich text paste). The new Nit (not blocking): the new spec re-declares the selector inline instead of importing it - so a future refactor of the real selector won't break the test. The inline comment ("mirrors DiffReview.tsx's terminalCwd selector") makes the intent explicit, so this is fine as-is. Heads-up: PR #114 from the same author rewrites this same selector with an explicit helper. If #114 lands first, this PR's inline change becomes redundant and should rebase on top. |
InbarR
left a comment
There was a problem hiding this comment.
Looks good - small targeted fix for the diff panel CWD when a pane is linked to an AI session. The 18-line selector swap is correct for the happy path, and the e2e test covers the linked/unlinked transitions.
Noted that the stale-but-linked edge case (AI session went idle but aiSessionId not cleared) isn't handled here, but you've called it out as a follow-up - happy for that to land separately.
The Playwright (Windows) failures in CI look like a pre-existing base-branch issue: the same ~32 tests fail on multiple unrelated PRs touching different areas. Shouldn't block this PR.
Approving.
Summary
Fixes #3 — Diff panel fails to resolve git root when the Copilot CLI changes directory internally.
Problem
When the Copilot CLI changes directory via its
cwdcommand, the diff panel fails with:Error invoking remote method 'diff:resolveGitRoot': No git repository found from: C:\UsersThe shell's CWD (tracked via OSC 7/9;9/prompt regex) stays stale because the CLI changes directory internally without emitting escape sequences.
Solution
Instead of overwriting
terminal.cwd(which was rejected by 4 adversarial reviewers due to ping-pong, WSL corruption, and session restore poisoning), the diff panel's CWD selector now checks the linked AI session's CWD first:Why this approach
terminal.cwdstays purely shell CWD, untouchedworkspace.cwd, the store re-renders the diff panelChanges
src/renderer/components/DiffReview.tsxtests/e2e/issue-3-diff-cwd-resolution.spec.ts