Skip to content

[codex] show review counts in v2 sidebar header#4670

Merged
Kitenite merged 10 commits into
mainfrom
review-numbers-sidebar
May 17, 2026
Merged

[codex] show review counts in v2 sidebar header#4670
Kitenite merged 10 commits into
mainfrom
review-numbers-sidebar

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented May 17, 2026

Summary

  • Render SidebarTabDefinition.badge values in the v2 workspace right-sidebar header.
  • Surface the Review tab's existing unresolved review/comment count in normal and compact header layouts.
  • Hide the Review badge when there are no open comments.

Why

The review tab was already computing an open review/comment count, but the v2 right-sidebar header did not render tab badges, so users could not see pending review work from the header.

Validation

  • bun run --cwd apps/desktop typecheck
  • bun run lint
  • bun run --cwd apps/desktop test 'src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/PRActionHeader/utils/getPRFlowState/getPRFlowState.test.ts'

Open in Stage

Summary by cubic

Render tab badges in the v2 right-sidebar header and show the Review tab’s open review count. Split the Review tab into Conversations and Review with copy actions and bulk resolve, and improve open‑in‑diff targeting using thread anchors and side awareness.

  • New Features
    • Render SidebarTabDefinition.badge on header tabs; capped at 99+, hidden at 0, included in tooltip/aria-label, positioned correctly in compact mode.
    • Split Review into two collapsible lists with counts and separate “Copy all”: “Comments” (conversations) and “Review” (open review comments).
    • Add “Resolve all” to batch-resolve review threads with spinner, error toasts, and auto-refresh via invalidating git.getPullRequestThreads.
    • Show an “Outdated” tag on review comments marked as outdated.
    • Open-in-diff for review comments uses GitHub thread-level anchors and rename-aware paths, targets the correct side (additions/deletions), and skips outdated/original-only threads.

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

Summary by CodeRabbit

  • New Features

    • Tab labels show badge counts (capped at "99+") and include counts in compact tooltips.
    • Diff navigation can focus a specific side ("deletions" or "additions") when opening files.
    • Review views now require workspace context to enable bulk resolve and accurate diff navigation.
  • Improvements

    • "Resolve all" supports concurrent resolving with loading/error reporting.
    • "Copy all" distinguishes conversation vs open review comments.
    • Outdated review comments show an "Outdated" badge.
  • Bug Fixes

    • Review tab badge only appears for unresolved review comments.

Review Change Stack

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 17, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@stage-review
Copy link
Copy Markdown

stage-review Bot commented May 17, 2026

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Track outdated status for review comments
2 Implement bulk resolution and split comment sections
3 Wire workspace context through review components
4 Render tab badges in sidebar header
Open in Stage

Chapters generated by Stage for commit cfb062a on May 17, 2026 8:18pm UTC.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds capped badge formatting to SidebarHeader, only shows the Review tab badge when open review comments exist, threads workspaceId into review UI, implements a bulk “Resolve all” in CommentsSection, and introduces side-aware diff focus plumbing across panes and annotations.

Changes

Sidebar badge rendering

Layer / File(s) Summary
Badge formatting and sidebar rendering
apps/desktop/src/renderer/.../SidebarHeader/SidebarHeader.tsx, apps/desktop/src/renderer/.../useReviewTab/useReviewTab.tsx
SidebarHeader computes tab labels with formatted badge counts, uses cn for classNames, conditionally renders badge <span>s for compact/non-compact modes, and shows badge text in compact tooltips. formatBadgeCount caps numbers at "99+". useReviewTab provides the Review badge only when non-zero.

Review threads: resolve all & workspace wiring

Layer / File(s) Summary
Propagate workspaceId to review components
apps/desktop/src/renderer/.../ReviewTabContent/ReviewTabContent.tsx, apps/desktop/src/renderer/.../useReviewTab/useReviewTab.tsx
ReviewTabContentProps now requires workspaceId: string; useReviewTab passes workspaceId and processed normalized comments (with optional diffPath and isOutdated) into review UI. onOpenInDiff is extended to accept an optional focusSide.
CommentsSection: resolve-all implementation
apps/desktop/src/renderer/.../CommentsSection/CommentsSection.tsx
Adds workspaceTrpc wiring, isResolvingAll, de-duplicated resolvableThreadIds, handleResolveAll using Promise.allSettled + invalidation of utils.git.getPullRequestThreads, failure reporting via toast.error, separate copy-all behaviors, clipboard and skeleton helpers, and displays an “Outdated” badge for outdated review comments.
Diff-side focus plumbing
apps/desktop/src/renderer/.../DiffPane/..., .../DiffFileEntry/DiffFileEntry.tsx, .../WorkspaceDiff/*, .../useDiffAnnotations/useDiffAnnotations.ts, .../useWorkspacePaneOpeners/useWorkspacePaneOpeners.ts, apps/desktop/src/renderer/.../types.ts
Introduces DiffFocusSide and focusSide across pane openers, DiffPane scroll/finding logic, DiffFileEntry, WorkspaceDiff (with oldPath), and useDiffAnnotations (matches threads against path or oldPath), and updates DiffPaneData to include focusSide.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I hop through tabs with counted cheer,
Ninety-nine plus — the numbers clear.
Threads await a gentle call,
One click clears many, big and small.
A tidy burrow, bugs disappear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% 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 Title is concise and specific, directly referencing the main change of rendering review badge counts in the v2 sidebar header as described in the PR objectives.
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.
Description check ✅ Passed The PR description provides a clear summary of changes, explicit reasoning, and validation steps that align with the template structure.

✏️ 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 review-numbers-sidebar

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

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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR surfaces the Review tab's existing open-comment count as a badge in the v2 workspace sidebar header, for both normal and compact layouts. It refactors the duplicated button markup in SidebarHeader into a shared variable and adds proper aria-label support so the count is accessible.

  • SidebarHeader.tsx: Adds a formatBadgeCount helper (capped at "99+"), renders a pill badge inside the tab button (absolute-positioned in compact mode), and updates aria-label to include the count. The non-compact button duplication is eliminated by reusing the shared btn element.
  • useReviewTab.tsx: Changes badge from always emitting the raw openCommentCount (including 0) to emitting undefined when there are no open comments, so the header hides the badge correctly when nothing is pending.

Confidence Score: 4/5

Safe to merge; the badge and accessibility changes are self-contained with no regressions to existing functionality.

The implementation is clean and the refactor is correct. One thing worth a follow-up: conversation comments are always marked isResolved: false and therefore permanently counted in the badge, even though users cannot resolve them through the UI. The badge will never reach zero while any such comments exist, which could be confusing once users start watching the count.

The normalizeThreadsToComments function in useReviewTab.tsx — specifically how conversationComments contribute to the open count — deserves a second look given the badge is now user-visible.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/components/SidebarHeader/SidebarHeader.tsx Adds badge rendering to tab buttons in both normal and compact layouts; refactors duplicated button markup into a shared btn variable; adds accessible aria-label including badge count.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/useReviewTab.tsx Changes badge from always emitting the raw count (including 0) to emitting undefined when count is zero, so the header correctly hides the badge when there is nothing pending.

Sequence Diagram

sequenceDiagram
    participant Hook as useReviewTab (hook)
    participant Type as SidebarTabDefinition
    participant Header as SidebarHeader (component)
    participant UI as Rendered Tab Button

    Hook->>Hook: filter comments where !isResolved → openCommentCount
    Hook->>Type: "badge = openCommentCount > 0 ? openCommentCount : undefined"
    Type->>Header: "tabs[] with optional badge: number | undefined"

    Header->>Header: "typeof tab.badge === number && > 0 → badge string or null"
    Header->>Header: "label = badge ? "Review (N)" : "Review""

    alt compact mode
        Header->>UI: Tooltip wrapping button with aria-label, icon, absolute badge span
    else normal mode
        Header->>UI: button with aria-label, visible label text, inline badge span
    end

    Note over Header,UI: badge > 99 rendered as "99+"
    Note over Header,UI: badge hidden when undefined or 0
Loading

Comments Outside Diff (1)

  1. apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/useReviewTab.tsx, line 147-158 (link)

    P2 Conversation comments always inflate the badge count

    conversationComments are always pushed with isResolved: false, so they permanently contribute to openCommentCount. With the badge now visible in the header, users will always see these comments counted as "pending" even though there is no way to mark them as resolved through the UI. Depending on how many PR-body/issue-level comments exist, the badge count may be consistently higher than users expect, and will never reach zero while any conversation comments remain.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/useReviewTab.tsx
    Line: 147-158
    
    Comment:
    **Conversation comments always inflate the badge count**
    
    `conversationComments` are always pushed with `isResolved: false`, so they permanently contribute to `openCommentCount`. With the badge now visible in the header, users will always see these comments counted as "pending" even though there is no way to mark them as resolved through the UI. Depending on how many PR-body/issue-level comments exist, the badge count may be consistently higher than users expect, and will never reach zero while any conversation comments remain.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/useReviewTab.tsx:147-158
**Conversation comments always inflate the badge count**

`conversationComments` are always pushed with `isResolved: false`, so they permanently contribute to `openCommentCount`. With the badge now visible in the header, users will always see these comments counted as "pending" even though there is no way to mark them as resolved through the UI. Depending on how many PR-body/issue-level comments exist, the badge count may be consistently higher than users expect, and will never reach zero while any conversation comments remain.

Reviews (1): Last reviewed commit: "show review counts in v2 sidebar header" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/`$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/components/CommentsSection/CommentsSection.tsx:
- Around line 147-176: In handleResolveAll, wrap the await
utils.git.getPullRequestThreads.invalidate({ workspaceId }) call in its own
try/catch so any rejection is handled and won’t surface as an unhandled promise
rejection; on catch, log the error (e.g. console.error or processLogger) and
optionally show a toast.error with the rejection reason, then continue to
compute failedCount and clear isResolvingAll using isMountedRef; keep the rest
of the Promise.allSettled logic and ensure setReviewThreadResolution.mutateAsync
and resolvableThreadIds flow remain unchanged.
🪄 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: 5aecaea9-184b-4162-970e-ece7d6d47fa9

📥 Commits

Reviewing files that changed from the base of the PR and between b98fac3 and ea9bbf6.

📒 Files selected for processing (3)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/components/CommentsSection/CommentsSection.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/components/ReviewTabContent/ReviewTabContent.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/useReviewTab.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/components/WorkspaceSidebar/hooks/useReviewTab/useReviewTab.tsx

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileEntry/DiffFileEntry.tsx">

<violation number="1" location="apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileEntry/DiffFileEntry.tsx:76">
P2: `hasFocusRequest` is latched by non-null values, so a single line-jump can permanently force full diff mount/expanded-unchanged behavior instead of handling focus as a one-time request.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 17, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@Kitenite Kitenite merged commit ce95089 into main May 17, 2026
10 checks passed
@Kitenite Kitenite deleted the review-numbers-sidebar branch May 17, 2026 20:20
sazabi Bot pushed a commit that referenced this pull request May 20, 2026
* show review counts in v2 sidebar header

* add resolve all action to review sidebar

* split review sidebar comment sections

* show outdated review tag in sidebar

* fix review comment diff targets

* improve review comment diff jumps

* reduce review diff jump flicker

* use current review thread anchors

* use rendered diff indexes for review jumps

* revert review comment diff jump changes
MocA-Love added a commit to MocA-Love/superset that referenced this pull request May 25, 2026
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