Skip to content

feat: add subscription and credit to auth status#234

Merged
leechenghsiu merged 1 commit intomainfrom
matthewlee/des-530-auth-status-fields
May 4, 2026
Merged

feat: add subscription and credit to auth status#234
leechenghsiu merged 1 commit intomainfrom
matthewlee/des-530-auth-status-fields

Conversation

@leechenghsiu
Copy link
Copy Markdown
Contributor

@leechenghsiu leechenghsiu commented May 2, 2026

Show plan and credit balance in auth status output and JSON.

DES-530

Description (required)

Related issues & labels (optional)

  • Closes #
  • Suggested label:

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Summary by CodeRabbit

  • New Features
    • The status command now displays enhanced account information, including subscription plan and credit balance (shown in currency), providing a more comprehensive view of your account details.

Show plan and credit balance in `auth status` output and JSON.

DES-530

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@leechenghsiu leechenghsiu self-assigned this May 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

Walkthrough

The PR enriches user account display by adding subscription and billing fields to the User model (Subscription, Credit, ReferralCode), extends the model's table output methods to include plan and formatted credit columns, and updates the status command's login message to display username, plan, and credit alongside the existing name and email.

Changes

User Account Status Enrichment

Layer / File(s) Summary
Data Model & Methods
pkg/model/user.go
Adds Subscription type with Plan field and extends User struct with Subscription, Credit, and ReferralCode fields. Header() adds Plan and Credit columns; Rows() emits subscription plan and credit formatted as dollars (converted from cents).
Command Wiring
internal/cmd/auth/status/status.go
Status command log output now displays username, plan, and formatted credit in addition to existing name and email when logged in and non-JSON output is used.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Title check ✅ Passed The title accurately captures the main changes: adding subscription and credit fields to the auth status command, which aligns with the core modifications in both the status command and User model.

✏️ 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 matthewlee/des-530-auth-status-fields

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

@leechenghsiu leechenghsiu requested a review from a team May 2, 2026 05:06
@canyugs
Copy link
Copy Markdown
Contributor

canyugs commented May 3, 2026

Consolidated Review Summary

Reviewed by 4 parties (CodeRabbit + 3 internal reviewers + AI agent).

⚠️ Suggested fix before merge

referralCode is in the PR title but not visible in auth status output

The PR title states:

feat: add subscription, credit, and referralCode to auth status

But:

  • auth status text output (status.go:57) only shows plan and credit, not referralCode
  • auth status -v table (User.Header() / Rows()) only adds Plan/Credit columns, not ReferralCode
  • Only auth status --json exposes it (via struct serialization)

Fix (pick one):

  1. Add referralCode to the log line and to Header() / Rows() so it shows in both default and -v output
  2. Or update the PR title/description to clarify it is a JSON-only field

🟡 Non-blocking suggestions (follow-up OK)

  • Money in float64: float64(u.Credit)/100 works but loses precision for large values. Prefer integer arithmetic: fmt.Sprintf("$%d.%02d", u.Credit/100, u.Credit%100).
  • Subscription as value type: when the API returns null (no subscription), output becomes plan: (empty). Consider *Subscription or fall back to Free/N/A.
  • Negative credit display: edge case $-0.50 reads awkwardly — minor.
  • Unit tests for the cents→dollars formatting and zero/negative cases.

🟢 Already correct

  • GraphQL field tags align with schema
  • Struct field re-alignment is clean
  • USD assumption is correct (Zeabur platform is USD-only)

LGTM after the referralCode decision.

@leechenghsiu leechenghsiu changed the title feat: add subscription, credit, and referralCode to auth status feat: add subscription and credit to auth status May 3, 2026
@leechenghsiu
Copy link
Copy Markdown
Contributor Author

Fixed PR title — removed referralCode mention. The field is still included in JSON output via the User model but doesn't need to be in the text output.

@leechenghsiu leechenghsiu merged commit 18268b9 into main May 4, 2026
5 checks passed
@leechenghsiu leechenghsiu deleted the matthewlee/des-530-auth-status-fields branch May 4, 2026 02:53
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.

2 participants