fix(ui): add unread badge for Notifications in sidebar#256
Conversation
📝 WalkthroughWalkthroughAdded a notifications count badge to the sidebar navigation by implementing a React Query hook that fetches notifications via the Tauri backend, filters for unread items, and displays the unread count. Updated corresponding test mocks and added assertions validating the badge display. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
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)
Comment |
Greptile SummaryThis PR adds an unread notification badge to the Notifications sidebar item by introducing a new Confidence Score: 5/5Safe to merge — the change is a well-scoped UI enhancement with no logic errors, correct type usage, and adequate test coverage. No P0/P1 findings. The new query correctly shares the existing cache key, is gated on auth state, and all three changed files are in good shape. Previously flagged notificationType casing issues are already resolved in this diff. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant S as Sidebar
participant AQ as authQuery [auth, status]
participant NQ as notificationsQuery [github, notifications]
participant T as tauri (listNotifications)
participant NI as NavItem (Notifications)
S->>AQ: useQuery authGetStatus
AQ-->>S: { connected: true }
note over S: isGitHubConnected = true
S->>NQ: useQuery (enabled=true, staleTime=60s)
NQ->>T: listNotifications()
T-->>NQ: GithubNotification[]
NQ-->>S: data
note over S: unreadNotificationsCount = data.filter(unread).length
S->>NI: count={unreadNotificationsCount}
NI-->>S: renders badge if count > 0
Reviews (2): Last reviewed commit: "fix: address PR review comments" | Re-trigger Greptile |
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 `@src/components/Sidebar/Sidebar.tsx`:
- Around line 57-61: Extract isGitHubConnected by evaluating
authQuery.data?.connected === true, then pass enabled: isGitHubConnected into
the notificationsQuery useQuery call (notificationsQuery) so it only runs when
authenticated; also update the unreadNotificationsCount usage to use a nullish
fallback (unreadNotificationsCount ?? 0) to avoid undefined badge counts. Ensure
you reference notificationsQuery and unreadNotificationsCount in Sidebar.tsx
when making these changes.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4c50afd7-78c2-4b00-9855-813e751aad19
📒 Files selected for processing (3)
src/App.test.tsxsrc/components/Sidebar/Sidebar.test.tsxsrc/components/Sidebar/Sidebar.tsx
Summary
NavItembadge UIValidation
npm run test -- src/components/Sidebar/Sidebar.test.tsxnpm run test -- src/App.test.tsx./node_modules/.bin/tsc --noEmit./node_modules/.bin/oxlint src/components/Sidebar/Sidebar.tsx src/components/Sidebar/Sidebar.test.tsx src/App.test.tsxCloses #248
Summary by cubic
Shows an unread count badge on the Notifications nav item by fetching GitHub notifications and counting unread items. Adds tests and gates the fetch behind GitHub auth, fixing #248.
listNotificationswith React Query (staleTime: 60s), enabled only when connected to GitHub.NavItemfor the Notifications view.Written for commit 3bfee63. Summary will update on new commits.
Summary by CodeRabbit
Release Notes
New Features
Tests