Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Oct 19, 2025

Follow-up to PR #318 (untracked files feature). Includes two improvements:

1. Trigger refresh after Track All

After staging untracked files via Track All button, the UI should automatically refresh to reflect the changes (updated hunks, tree, and untracked count).

Implementation:

  • Pass onRefresh callback from ReviewPanel through ReviewControls to UntrackedStatus
  • Call onRefresh() after successful git add operation in Track All handler
  • This refresh only happens from user action (clicking Track All), preventing infinite loops

2. Rename 'Dirty' to 'Uncommitted' for clarity

The checkbox was labeled "Dirty" but actually includes ALL uncommitted changes (staged + unstaged) via git diff HEAD. "Uncommitted" is more accurate and less ambiguous.

Breaking change: localStorage keys changed from review-include-dirty to review-include-uncommitted. Users will lose this preference per workspace (acceptable for early development phase).

Testing

  1. Open Code Review panel
  2. Create an untracked file
  3. Click the untracked badge to open tooltip
  4. Click "Track All" button
  5. ✅ UI automatically refreshes showing the files are now staged
  6. ✅ Untracked count updates to 0
  7. ✅ Hunks and tree reflect the new staged changes
  8. ✅ Checkbox now labeled "Uncommitted" instead of "Dirty"

Generated with cmux

After staging untracked files via Track All button, the UI should
automatically refresh to reflect the changes (updated hunks, tree,
and untracked count).

Solution: Pass onRefresh callback from ReviewPanel through ReviewControls
to UntrackedStatus. Call it after successful git add operation.

This refresh only happens from user action (clicking Track All),
preventing infinite loops.
The Code Review panel checkbox was labeled 'Dirty' but actually includes
ALL uncommitted changes (staged + unstaged) via git diff HEAD.

'Uncommitted' is more accurate and less ambiguous than 'Dirty'.

Breaking change: localStorage keys changed from review-include-dirty
to review-include-uncommitted. Users will lose this preference per
workspace (acceptable for early development phase).

Changes:
- Renamed includeDirty → includeUncommitted in types and all components
- Updated localStorage key: review-include-dirty → review-include-uncommitted
- Updated UI label: 'Dirty' → 'Uncommitted'
- Updated comments to reference 'uncommitted changes'
Fixed three potential race conditions:

1. **Optimistic update race**: Removed setUntrackedFiles([]) call before
   onRefresh(). Now refresh reloads from git, avoiding flicker if git
   index hasn't flushed yet.

2. **Concurrent load race**: Added loadingRef to prevent multiple
   simultaneous git ls-files commands when refreshTrigger changes rapidly.

3. **hasLoadedOnce persistence**: This ref already resets per-workspace
   via workspaceId dependency, so no fix needed here.

The refresh now correctly happens AFTER git add completes successfully,
and the UI updates are sourced from the subsequent git query rather than
optimistic local state.
@ammario ammario merged commit 99e1f10 into main Oct 19, 2025
8 checks passed
@ammario ammario deleted the cr-track-all-refresh branch October 19, 2025 02:22
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.

2 participants