feat(billing): Automatic top-up toggle in profile settings
Summary
Chat slice of #1861 — a user-facing kill switch for automatic credit top-up, so opting out of off-session charges is a setting instead of a support ticket (or removing your card).
BillingSection— a divided Billing section in the Account (Profile) modal: labeled Switch + helper text stating exactly what gets charged ($5 for 500 credits) and that disabling never removes the card. Applies instantly via PATCH (visually separated from the save-to-apply form); mutation failures surface as a toast. (Supersedes the originalAutoTopUpMenuItemdropdown checkbox — moved per review 2026-07-09: a billing-consent control needs explanation a menu item can't carry; see the redesign comment for screenshots.)useAutoRecharge— react-query hook (query + mutation) following theuseCreditspattern: Privy bearer from the provider, account fromuseUserProvider, cache updated from the PATCH response.lib/recoup/getAutoRechargeSetting/updateAutoRechargeSetting— fetch helpers mirroringgetAccountCredits, hittingGET/PATCH /api/accounts/{id}/auto-recharge(api#769, contract in docs#270).
The toggle renders the live Stripe-read state from the api (the setting lives on the Stripe customer record) — never a cached local flag — per the #1861 design decision.
Merge order
docs#270 → api#769 → this. The toggle 404s against an api without #769, so this merges last.
Verification
- TDD: fetch-helper tests were RED (module not found) before implementation, GREEN after — 35 files / 130 tests pass.
eslint+tsc --noEmitclean on all touched files (next lintitself is broken in Next 16 — build is the gate).pnpm buildcompiles successfully, 43/43 static pages generated.- Live end-to-end toggle verification happens against the api preview (results will be posted on api#769).
🤖 Generated with Claude Code
Summary by cubic
Adds an Automatic top-up toggle in the Account modal’s Billing section so users can opt out of off-session credit top-ups (Linear #1861). The switch reads and updates the live Stripe-backed setting via GET/PATCH /api/accounts/{id}/auto-recharge so the UI matches actual charge consent.
-
New Features
- Labeled “Automatic top-up”
Switchwith helper text ($5 for 500 credits; disabling doesn’t remove the card); applies instantly on flip. useAutoRecharge(@tanstack/react-query) loads/updates with a Privy bearer, updates cache from the PATCH response, and shows a toast on failure.
- Labeled “Automatic top-up”
-
Dependencies
- Requires
api#769(contract indocs#270); merge order:docs#270 → api#769 → this.
- Requires