Skip to content

Fix diff view empty in worktree mode until page refresh#402

Merged
Mng-dev-ai merged 3 commits intomainfrom
fix/worktree-diff-realtime-cwd
Mar 15, 2026
Merged

Fix diff view empty in worktree mode until page refresh#402
Mng-dev-ai merged 3 commits intomainfrom
fix/worktree-diff-realtime-cwd

Conversation

@Mng-dev-ai
Copy link
Owner

Summary

  • Emit a system SSE event with worktree_cwd from the stream processor on session init, so the frontend gets the worktree path immediately instead of waiting for stream completion
  • Update the react-query chat cache on receiving the event, making DiffView work as soon as the stream starts
  • Default diff mode to "Uncommitted" instead of "Branch" for worktree chats
  • Remove dead prevCwdRef tracking code left over from the old conditional logic

Test plan

  • Start a new worktree chat, make a change, open diff view before stream completes — should show changes immediately
  • Verify diff view defaults to "Uncommitted" mode in worktree chats
  • Verify diff view still works correctly for non-worktree chats
  • Verify page refresh still loads worktree_cwd correctly from the chat record

The diff view showed nothing when opened during a worktree stream because
worktree_cwd was only available after stream completion (chat query
invalidation). Now the backend emits a system event with worktree_cwd on
session init, and the frontend updates the chat cache immediately.

Also defaults diff mode to Uncommitted instead of Branch for worktree
chats, and removes dead prevCwdRef tracking that was left over from
the old conditional logic.
…_cwd

useChatData reads from the infinite chats list first, so updating only
queryKeys.chat(id) had no effect — the stale entry in the infinite list
always took priority. Now we patch both caches, matching the pattern
used by other chat mutations.
@Mng-dev-ai Mng-dev-ai merged commit 652e1a9 into main Mar 15, 2026
2 of 3 checks passed
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