fix(desktop): show local diff stats in v1 workspace hover card

Merged
SA
6mo ago
+45-48

Summary

  • v1 workspace hover modal was reading pr.additions/pr.deletions from the GitHub PR snapshot while the sidebar row showed local working-tree stats — the two surfaces disagreed and the modal LOC appeared to flicker as PR data refetched.
  • Centralize the additions/deletions math into a new useLocalDiffStats hook (wraps useGitChangesStatus) and use it in both the sidebar row and the hover modal.
  • Drop the PR-stats fallback in the sidebar row so the value is the same before and after hover (no flicker).
  • getWorktreeInfo now also returns worktreePath so the hover card can drive the local git query without prop-drilling.

Workspace list view (WorkspaceRow) is intentionally left alone — it shows closed worktrees too, so any change there needs a separate think-through.

Test plan

  • Hover a workspace in the v1 sidebar — modal +/- matches the inline +/- on the row and stays stable across refetches.
  • Make local edits → both surfaces update via git:changed invalidation.
  • Workspace with no PR still shows local diff stats in the modal.
  • Branch (non-worktree) workspace shows correct local diff stats.

Summary by cubic

Show local working‑tree diff stats in the v1 workspace hover card to match the sidebar and eliminate LOC flicker. Compute the stats once in WorkspaceListItem and pass them into the hover card; remove PR-based LOC from the workspace list view.

  • Bug Fixes

    • Hover card shows local +/- counts, matching the sidebar.
    • LOC badge appears without a PR or remote and stays stable across refetches.
    • Removed PR-based LOC from workspace list rows to stop flicker.
  • Refactors

    • Inlined diff math in WorkspaceListItem (removed useLocalDiffStats) and passed diffStats to the hover card, collapsed item, and context menu.
    • Dropped PR-stats fallback and reverted the prior worktreePath addition to getWorktreeInfo.

Summary by CodeRabbit

  • Refactor
    • Unified diff statistics (additions/deletions) calculation and display across workspace components, now relying on locally computed data for consistent rendering in hover cards and context menus.