Skip to content

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

Merged
saddlepaddle merged 4 commits into
mainfrom
centralize-loc-retrieval
Apr 29, 2026
Merged

fix(desktop): show local diff stats in v1 workspace hover card#3881
saddlepaddle merged 4 commits into
mainfrom
centralize-loc-retrieval

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Apr 29, 2026

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.

Written for commit 15546ab. Summary will update on new commits. Review in cubic

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.

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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6aa295bb-0f2b-4afe-acac-c9770682f9d5

📥 Commits

Reviewing files that changed from the base of the PR and between df3af8f and 15546ab.

📒 Files selected for processing (4)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/CollapsedWorkspaceItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceContextMenu.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/WorkspaceHoverCard/WorkspaceHoverCard.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceContextMenu.tsx

📝 Walkthrough

Walkthrough

The changes refactor how diff statistics (additions/deletions counts) flow through WorkspaceSidebar components. WorkspaceListItem now computes diffStats explicitly without falling back to githubStatus.pr data, and passes it as a prop through CollapsedWorkspaceItem, WorkspaceContextMenu, and WorkspaceHoverCard, while WorkspaceRow removes PR diff stat rendering entirely.

Changes

Cohort / File(s) Summary
Data Flow Refactoring
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
Reorders query and hook declarations, removes githubStatus.pr fallback for diffStats computation, and explicitly passes computed diffStats to child components.
Hover Card Updates
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/WorkspaceHoverCard/WorkspaceHoverCard.tsx
Accepts optional diffStats prop and uses it for additions/deletions UI rendering, replacing prior dependency on pr.additions/pr.deletions.
Prop Threading
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/CollapsedWorkspaceItem.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceContextMenu.tsx
Both components add optional diffStats prop and forward it to WorkspaceHoverCardContent.
Simplification
apps/desktop/src/renderer/screens/main/components/WorkspacesListView/WorkspaceRow/WorkspaceRow.tsx
Removes GitHub status hover hook and eliminates PR diff statistics rendering from the row component.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hoppity hops through the sidebar stream,
Diff stats now flow like a well-planned dream,
Props passed down, no fallback sight,
The data flows clean and just right! 🌿✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: showing local diff stats in the workspace hover card instead of relying on PR snapshot data.
Description check ✅ Passed The PR description is comprehensive and well-structured with a clear summary explaining the problem, solution, testing plan, and rationale for design decisions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch centralize-loc-retrieval

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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 24a07cd and 5afa70b.

📒 Files selected for processing (6)
  • apps/desktop/src/lib/trpc/routers/workspaces/procedures/git-status.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceListItem.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/WorkspaceHoverCard/WorkspaceHoverCard.tsx
  • apps/desktop/src/renderer/screens/main/hooks/index.ts
  • apps/desktop/src/renderer/screens/main/hooks/useLocalDiffStats/index.ts
  • apps/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.
@saddlepaddle saddlepaddle merged commit b508fb3 into main Apr 29, 2026
7 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch

Thank you for your contribution! 🎉

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.

1 participant