fix(desktop): refresh commits after external changes

Merged
FL
2mo ago
+85-0

Fixes #7416.

The commits list wasn't invalidated when an agent or terminal moved HEAD, so it could stay stale until the window refocused. Refresh it on broad git:changed events, alongside the existing branch and diff invalidations. Path-only edits still skip this refresh.

Tests:

  • bun test src/renderer/hooks/host-service/useGitStatus/useGitStatus.test.tsx src/renderer/hooks/host-service/useGitStatus/createTrailingRefreshScheduler.test.ts
  • bun x biome check apps/desktop/src/renderer/hooks/host-service/useGitStatus/useGitStatus.ts apps/desktop/src/renderer/hooks/host-service/useGitStatus/useGitStatus.test.tsx
  • desktop tsc --noEmit

Summary by cubic

Fixes #7416 by refreshing the commits list when a broad git:changed event occurs, so external HEAD moves (for example, an agent committing outside the app) no longer leave the list stale. Path-only edits still skip this refresh.

Summary by CodeRabbit

  • Bug Fixes

    • Commit lists now refresh when Git metadata changes move the current branch position, ensuring displayed commit history stays up to date.
    • Existing behavior is preserved for changes limited to specific file paths; these do not trigger unnecessary commit-list refreshes.
  • Tests

    • Added coverage for Git status events and commit-list refresh behavior.