Skip to content

Fix navbar user-specific balances - #307

Merged
Benjtalkshow merged 2 commits into
boundlessfi:mainfrom
Codekill33:main
Jun 28, 2026
Merged

Fix navbar user-specific balances#307
Benjtalkshow merged 2 commits into
boundlessfi:mainfrom
Codekill33:main

Conversation

@Codekill33

@Codekill33 Codekill33 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the navbar rank badge and credit balance so they use the authenticated user's session ID instead of the hardcoded user-1 placeholder.

Changes

  • Reads the current session with authClient.useSession()
  • Derives userId from session?.user?.id
  • Passes userId to NavRankBadge and CreditBalance
  • Adds CreditBalance to the resizable navbar variant
  • Removes the stale TODO comment and hardcoded user-1

Verification

  • Confirmed no user-1 references remain in:
    • components/global-navbar.tsx
    • components/ui/global-resizable-navbar.tsx
  • Confirmed the old TODO comment was removed
  • git diff --check passed

Note: Full lint could not be run locally because eslint was not available in the checkout.

closes #272

Summary by CodeRabbit

  • Bug Fixes
    • Updated the global navbar to use the currently signed-in user’s real ID instead of placeholder data, so user-specific rank and credit balance display correctly.
    • Updated the resizable navbar to automatically read the active auth session and show the rank badge and credit balance on desktop.
    • Prevented credit-balance rendering when no user ID is available, avoiding incorrect or empty balance states.

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Codekill33 is attempting to deploy a commit to the Threadflow Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Codekill33 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c01c9cd1-69ab-4f6c-a143-d28ffc4284c0

📥 Commits

Reviewing files that changed from the base of the PR and between a9e2db6 and b69df60.

📒 Files selected for processing (2)
  • components/reputation/credit-balance.tsx
  • hooks/use-spark-credits.ts

📝 Walkthrough

Walkthrough

Both navbar components now derive userId from authClient.useSession() instead of using user-1, and GlobalResizableNavbar also renders CreditBalance in the desktop action area. CreditBalance and its hook now tolerate missing userId values.

Changes

Navbar Auth Session Wiring

Layer / File(s) Summary
Session-derived userId in both navbars
components/global-navbar.tsx, components/ui/global-resizable-navbar.tsx
authClient is imported in both files, userId is read from session?.user?.id, and both NavRankBadge and CreditBalance receive that value instead of userId="user-1".
Optional credit balance userId
components/reputation/credit-balance.tsx, hooks/use-spark-credits.ts
CreditBalance now returns null when userId is absent, and useSparkCreditsBalance accepts an optional userId while using userId ?? "" for its query key and query function.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • Benjtalkshow

Possibly related PRs

  • boundlessfi/bounties#63: Replaces the same hardcoded userId="user-1" navbar placeholder with session-derived auth state and updates connected user-specific components.
  • boundlessfi/bounties#301: Also replaces hardcoded user identifiers with session-derived values in user-specific UI flows.
  • boundlessfi/bounties#307: This PR continues the navbar auth wiring by passing the session user ID through CreditBalance and its balance hook.

🐇 No more borrowed IDs in sight,
The session sets the navbar right.
Rank and credits now hop true,
Each user sees their own view.

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the navbar auth-user balance fix.
Linked Issues check ✅ Passed The navbar files now use session user IDs for NavRankBadge and CreditBalance, and the signed-out fallback behavior is preserved.
Out of Scope Changes check ✅ Passed The changes stay within the navbar/auth balance fix and do not introduce unrelated edits.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@components/global-navbar.tsx`:
- Line 147: The CreditBalance component is falling through to a 0 badge when
userId is undefined, so signed-out users are shown as having credits instead of
the empty state. Add an explicit empty-state guard in CreditBalance (for example
in the component in components/reputation/credit-balance.tsx) so it returns
nothing or the signed-out state before reaching the data?.balance ?? 0 fallback,
while keeping global-navbar.tsx passing userId through as-is.
🪄 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: 196a2c55-5151-42aa-b680-3c57cf8c6b8f

📥 Commits

Reviewing files that changed from the base of the PR and between 26972e5 and a9e2db6.

📒 Files selected for processing (2)
  • components/global-navbar.tsx
  • components/ui/global-resizable-navbar.tsx

Comment thread components/global-navbar.tsx

@Benjtalkshow Benjtalkshow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, the swap from "user-1" to session-derived userId is right, but CI will fail on pnpm tsc --noEmit:

components/global-navbar.tsx(147,26): error TS2322: Type 'string | undefined' is not assignable to type 'string'.
components/ui/global-resizable-navbar.tsx(45,26): error TS2322: Type 'string | undefined' is not assignable to type 'string'.

CreditBalance declares userId: string (required) but receives string | undefined. The cleanest fix is to update components/reputation/credit-balance.tsx to accept userId?: string and add if (!userId) return null; at the top, matching what NavRankBadge already does. Also please attach a screenshot of the navbar while signed in (rank badge + credit balance visible) and while signed out (empty state) so I can verify the visual result, and consider using a feature branch instead of pushing from your fork's main next time.

@Codekill33

Copy link
Copy Markdown
Contributor Author

Fixed in b69df60. CreditBalance now accepts userId?: string and returns null when no user is signed in, matching NavRankBadge behavior. I also updated useSparkCreditsBalance to accept an optional user ID while keeping the query disabled when it is missing.

@Benjtalkshow Benjtalkshow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@Benjtalkshow
Benjtalkshow merged commit a7244b5 into boundlessfi:main Jun 28, 2026
4 of 5 checks passed
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.

Navbar passes hardcoded userId="user-1" to NavRankBadge and CreditBalance

2 participants