Repository navigation
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! 🎉 |
Already integrated, superseded by current versions, or net-empty in this fork: ParadevAI#3881 ParadevAI#3887 ParadevAI#3917 ParadevAI#3925 ParadevAI#3940 ParadevAI#3956 ParadevAI#3961 ParadevAI#3974 ParadevAI#4017 ParadevAI#4048 ParadevAI#4049 ParadevAI#4055 ParadevAI#4063 ParadevAI#4070 ParadevAI#4092 ParadevAI#4110 ParadevAI#4138 ParadevAI#4159 ParadevAI#4163 ParadevAI#4164 ParadevAI#4209 ParadevAI#4210 ParadevAI#4249 ParadevAI#4349 ParadevAI#4405 ParadevAI#4462 ParadevAI#4464 ParadevAI#4494 ParadevAI#4495 ParadevAI#4500 ParadevAI#4535 ParadevAI#4541 ParadevAI#4566 ParadevAI#4580 ParadevAI#4589 ParadevAI#4593 ParadevAI#4603 ParadevAI#4637 ParadevAI#4642 ParadevAI#4655 ParadevAI#4657 ParadevAI#4659 ParadevAI#4685 ParadevAI#4692 ParadevAI#4745 ParadevAI#4789 ParadevAI#4797 ParadevAI#4824 ParadevAI#4835 ParadevAI#4847 ParadevAI#4885 ParadevAI#4896.
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