fix(desktop): show local diff stats in v1 workspace hover card#3881
Conversation
The v1 workspace hover modal was rendering pr.additions/pr.deletions from the GitHub PR snapshot, while the sidebar row showed local working-tree stats — so the two surfaces could disagree and the modal LOC appeared to flicker as PR data refetched. Centralize via a new useLocalDiffStats hook (wraps useGitChangesStatus) and use it in both surfaces. Drop the PR-stats fallback in the sidebar row so before-hover and after-hover stay consistent.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe changes refactor how diff statistics (additions/deletions counts) flow through WorkspaceSidebar components. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/WorkspaceHoverCard/WorkspaceHoverCard.tsx`:
- Around line 173-180: The hover card currently only renders diffStats inside a
branch gated by PR presence, so local workspace +/- counts (diffStats) are
hidden for non-PR workspaces; update the WorkspaceHoverCard to render diffStats
unconditionally when available (remove or move the PR-specific conditional that
surrounds the diff-stats block), ensuring the JSX that references diffStats (the
<div> showing +{diffStats.additions} and -{diffStats.deletions}) is evaluated
for regular workspaces as well as PR workspaces; keep existing null/undefined
checks on diffStats but decouple it from the "pr" branch so local diffs show in
the no-PR hover modal.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2a3bb0a7-a544-4766-8944-27a2d3045f2f
📒 Files selected for processing (6)
apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.tsapps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsxapps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/WorkspaceHoverCard/WorkspaceHoverCard.tsxapps/desktop/src/renderer/screens/main/hooks/index.tsapps/desktop/src/renderer/screens/main/hooks/useLocalDiffStats/index.tsapps/desktop/src/renderer/screens/main/hooks/useLocalDiffStats/useLocalDiffStats.ts
Lift the LOC source up to the parent (WorkspaceListItem already computes it for the inline +/-) and pass the same value into the hover card, so the modal renders whatever it's handed instead of fetching its own copy. Also render the diff stats in the no-PR and no-remote branches — they were previously gated behind PR presence. Reverts the worktreePath addition to getWorktreeInfo since the hover card no longer needs it.
… view The workspace list row was reading additions/deletions from the GitHub PR snapshot, which can drift from the local working tree and refetches on its own cadence — values appeared to flicker. List rows don't need LOC, so drop the display (and the now-unused githubStatus prefetch).
The useLocalDiffStats hook was only called in one place; the other three imports were just for the LocalDiffStats type on a prop. Inline the useMemo back into WorkspaceListItem and use a structural type on the prop instead — drops the hook file and its index export.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Summary
pr.additions/pr.deletionsfrom 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.useLocalDiffStatshook (wrapsuseGitChangesStatus) and use it in both the sidebar row and the hover modal.getWorktreeInfonow also returnsworktreePathso 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
+/-matches the inline+/-on the row and stays stable across refetches.git:changedinvalidation.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
WorkspaceListItemand pass them into the hover card; remove PR-based LOC from the workspace list view.Bug Fixes
+/-counts, matching the sidebar.Refactors
WorkspaceListItem(removeduseLocalDiffStats) and passeddiffStatsto the hover card, collapsed item, and context menu.worktreePathaddition togetWorktreeInfo.Written for commit 15546ab. Summary will update on new commits. Review in cubic
Summary by CodeRabbit