Skip to content

PE-9103: Refresh balance after Turbo topup from profile dropdown#2163

Merged
vilenarios merged 2 commits into
devfrom
PE-9103-turbo-balance-refresh
Jul 5, 2026
Merged

PE-9103: Refresh balance after Turbo topup from profile dropdown#2163
vilenarios merged 2 commits into
devfrom
PE-9103-turbo-balance-refresh

Conversation

@vilenarios

@vilenarios vilenarios commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

When a user tops up Turbo credits from the profile dropdown, no balance refresh was triggered after payment succeeded. The showTurboTopupModal() call was missing the onSuccess callback.

  • Turbo credits: already refresh automatically — TurboBalanceCubit is created fresh with ..getBalance() each time the dropdown opens
  • AR balance: was NOT refreshed after topup — now calls profileCubit.refreshBalance() via the onSuccess callback

This matches the pattern already used in payment_method_selector_widget.dart (upload flow topup) where onSuccess is passed.

Note: if the Turbo payment service has a server-side delay in crediting the account, the user may need to reopen the dropdown after a few seconds to see the updated credits. This is a server-side timing issue, not a client bug.

Test plan

  • Top up Turbo credits from profile dropdown → verify AR balance updates after modal closes
  • Reopen profile dropdown after topup → verify Turbo credits show new balance
  • Top up from upload dialog → verify existing behavior unchanged
  • Cancel topup → verify no balance refresh triggered

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • User balances now refresh automatically after a successful Turbo top-up, so credits reflect payment changes right away.
  • Refactor
    • Improved internal handling for table items to support more reliable updates.
    • Made some displayed table data more consistently immutable for better stability.

The profile card's topup button was not passing an onSuccess callback
to showTurboTopupModal, so no balance refresh happened after a
successful topup. Turbo credits update automatically on next dropdown
open (fresh TurboBalanceCubit), but the AR balance was stale if the
user paid with AR.

Now passes onSuccess to call profileCubit.refreshBalance() after
successful topup, matching the pattern already used in
payment_method_selector_widget.dart.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@vilenarios, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: beee549a-13f8-47ac-adc4-a7d6e51e23fb

📥 Commits

Reviewing files that changed from the base of the PR and between 3999df7 and 847f00b.

📒 Files selected for processing (3)
  • lib/pages/drive_detail/models/data_table_item.dart
  • packages/ardrive_ui/lib/src/components/data_table/data_table.dart
  • packages/ardrive_ui/storybook/lib/src/table.dart
📝 Walkthrough

Walkthrough

This PR adds a balance refresh callback after successful Turbo top-up in the profile card, and includes two unrelated minor refactors: converting IndexedItem to extend Equatable with a const constructor, and making File fields final in the storybook table component.

Changes

Turbo Top-up Balance Refresh

Layer / File(s) Summary
Refresh balance after top-up
lib/components/profile_card.dart
showTurboTopupModal now receives an onSuccess callback that calls ProfileCubit.refreshBalance() when the widget is still mounted, whereas previously no refresh occurred after a successful top-up.

Unrelated Component Cleanups

Layer / File(s) Summary
IndexedItem and File field refactors
packages/ardrive_ui/lib/src/components/data_table/data_table.dart, packages/ardrive_ui/storybook/lib/src/table.dart
IndexedItem now extends Equatable with a const constructor instead of using EquatableMixin; File's name, createdAt, and size fields are changed to final.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ProfileCard
    participant TurboTopupModal
    participant ProfileCubit

    User->>ProfileCard: Tap "+" on Credits
    ProfileCard->>TurboTopupModal: showTurboTopupModal(context, onSuccess)
    TurboTopupModal-->>ProfileCard: Top-up success
    ProfileCard->>ProfileCard: Check context.mounted
    ProfileCard->>ProfileCubit: refreshBalance()
    ProfileCubit-->>ProfileCard: Updated balance
Loading

Related Issues: None specified

Related PRs: None specified

Suggested labels: None specified

Suggested reviewers: None specified

Poem:
A rabbit taps the "+" with glee,
Top-up done, and balance free,
Equatable now wears a const new coat,
Files stay final, steady float,
Small hops of code, refined and light 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main user-facing change: refreshing balance after Turbo topup from the profile dropdown.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PE-9103-turbo-balance-refresh

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.

🧹 Nitpick comments (1)
packages/ardrive_ui/storybook/lib/src/table.dart (1)

123-128: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer a const constructor over suppressing the lint.

Since IndexedItem now has a const constructor and all of File's fields are final, the File constructor itself can be const, satisfying prefer_const_constructors_in_immutables without the ignore comment. The runtime call sites (e.g. name: 'Item $i') simply won't use const, but the declaration can still be const.

♻️ Proposed refactor
-  // ignore: prefer_const_constructors_in_immutables
-  File({
+  const File({
     required this.createdAt,
     required this.name,
     required this.size,
   }) : super(0);

Based on learnings: "prefer using const constructors for object instantiations whenever the constructor is declared as const and all arguments are compile-time constants."

🤖 Prompt for 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.

In `@packages/ardrive_ui/storybook/lib/src/table.dart` around lines 123 - 128, The
File constructor in table.dart is suppressing
prefer_const_constructors_in_immutables even though it can be const because
IndexedItem has a const constructor and all File fields are final. Remove the
ignore comment and declare File as a const constructor so call sites can still
choose non-const instantiation when needed. Use the File and IndexedItem
constructors to locate the change.

Source: Learnings

🤖 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.

Nitpick comments:
In `@packages/ardrive_ui/storybook/lib/src/table.dart`:
- Around line 123-128: The File constructor in table.dart is suppressing
prefer_const_constructors_in_immutables even though it can be const because
IndexedItem has a const constructor and all File fields are final. Remove the
ignore comment and declare File as a const constructor so call sites can still
choose non-const instantiation when needed. Use the File and IndexedItem
constructors to locate the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17941c9b-5b43-4f70-a4ea-a40986a01b22

📥 Commits

Reviewing files that changed from the base of the PR and between 14623fa and 3999df7.

📒 Files selected for processing (3)
  • lib/components/profile_card.dart
  • packages/ardrive_ui/lib/src/components/data_table/data_table.dart
  • packages/ardrive_ui/storybook/lib/src/table.dart

EquatableMixin is deprecated in favor of using Equatable directly.
Changed IndexedItem from `with EquatableMixin` to `extends Equatable`
with const constructor. This fixes the CI analyze failure in the
ardrive_ui package.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vilenarios vilenarios force-pushed the PE-9103-turbo-balance-refresh branch from 3999df7 to 847f00b Compare July 5, 2026 20:38
@vilenarios vilenarios merged commit 0860808 into dev Jul 5, 2026
6 checks passed
@vilenarios vilenarios deleted the PE-9103-turbo-balance-refresh branch July 5, 2026 20:53
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 847f00b):

https://ardrive-web--pr2163-pe-9103-turbo-balanc-wcrzk1og.web.app

(expires Sun, 12 Jul 2026 20:53:40 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a224ebaee2f0939e7665e7630e7d3d6cd7d0f8b0

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