[DRAFT] [PLAN] AI Credits Widget: buy or stream developer AI credits with G$
This plan sub-issue drafts the execution strategy for AI Credits Widget: buy developer AI credits with G$, with the following additional requirement: user should also be able to stream G$s to buy credits.
Required states, flows, and behaviors
Expand the original required states to support G$ streaming for credits:
- All original states:
disconnected, connected_empty, quote_ready, payment_pending, payment_confirmed, has_credits, usage_empty, usage_active, insufficient_g_balance, insufficient_ai_credits, payment_failed, backend_unavailable, unsupported_chain
- New/modified states:
streaming_setup: option to initiate streaming G$ if supported by the wallet or backend (wallet disconnected, connected, or after credits are spent)
streaming_active: user has enabled an active G$ streaming payment toward credits; display streaming status, running balance, option to pause/cancel
streaming_paused/streaming_stopped: stream is paused or ended; offer to restart or switch to one-time buy
Extended Flows
- Allow switching between one-time G$ buy and streaming G$ purchase modes.
- Streaming UX:
- Wallet connects.
- User selects between "Buy Once" or "Stream G$ for Credits".
- If streaming, configure stream amount/rate and confirm approval.
- Show running stream status card: credits accrue in near real-time, user can pause/stop.
- If stream is paused/stopped, maintain credits and offer to top-up or resume stream.
- API key, setup, usage, and error states match the one-time buy flow after credits are accrued.
- Preserve all original behaviors for wallet, balance quoting, payment confirmation, usage logs, API key/privacy management, error/degraded states, and Storybook scenarios.
Execution plan
-
Reference file mapping:
- From
GoodDollar/antseed-integration:
AGENTS.md (design/actor semantics)
README.md, docs/ARCHITECTURE.md, docs/PAYMENT_FLOW.md (API/payment boundaries)
backend/README.md, backend/src/types.ts, backend/src/pricing.ts (backend API structure, pricing, extensibility for streaming)
contracts/src/AgentCreditVault.sol, contracts/src/CeloGdAntSeedVault.sol (credit/token vault mechanics—assess G$ streaming feasibility)
- From
GoodDollar/GoodWidget:
- Use
packages/claim-widget as reference for package, project, theming, embed/host patterns
- Use
packages/ui for all primitives; extend if streaming-specific UI elements (progress, status bars, editable tickers) needed
- Use
packages/core, packages/embed as above
- Storybook: implement new streaming states under
packages/ai-credits-widget Storybook folder; update/add fixtures as needed
- Playwright: Add streaming-specific tests under
tests/widgets/ai-credits-widget/
-
Component mapping:
- New, package-local components in
@goodwidget/ai-credits-widget:
StreamingCreditSetupCard: stream/buy mode selector, controls for stream amount/rate, start/stop buttons
StreamingStatusCard: indicator/progress for streaming state, real-time estimated credits, pause/cancel
- Extend state machine/context for streaming operation with fallback to one-time flows
- Update/additions in
packages/ui if reusable:
- Possibly generic
StreamingProgressBar, toggle controls, or confirmation dialogs if needed elsewhere
-
Supports both buy and stream:
- Add UI affordance to toggle between the two
- Fixture/mocked backend streaming endpoint
- Clearly indicate streaming is beta/experimental if backend is not yet productionized
-
Acceptance Criteria:
- All original ACs from MVP, with clear streaming capability (select, start, run/monitor, pause/stop, switch to buy)
- Streaming-specific states, flows, and error handling covered in Storybook and Playwright
- No settlement details or multi-chain complexity leaks into the UI
-
Human Reviewer Checklist:
- All reference files from antseed-integration and GoodWidget mapped/linked
- UI supports both G$ one-time buys and streaming, states switch cleanly
- All required states and behaviors implemented including streaming user flows
- Storybook and Playwright cover all streaming and original scenarios
- Code is modular, streaming logic isolated, UI/UX follows GoodWidget conventions
- Copy and error messages are clear about streaming status, fallback options
- No premature exposure of Antseed/USDC details to users
Parent: #30
[DRAFT] [PLAN] AI Credits Widget: buy or stream developer AI credits with G$
This plan sub-issue drafts the execution strategy for AI Credits Widget: buy developer AI credits with G$, with the following additional requirement: user should also be able to stream G$s to buy credits.
Required states, flows, and behaviors
Expand the original required states to support G$ streaming for credits:
disconnected,connected_empty,quote_ready,payment_pending,payment_confirmed,has_credits,usage_empty,usage_active,insufficient_g_balance,insufficient_ai_credits,payment_failed,backend_unavailable,unsupported_chainstreaming_setup: option to initiate streaming G$ if supported by the wallet or backend (wallet disconnected, connected, or after credits are spent)streaming_active: user has enabled an active G$ streaming payment toward credits; display streaming status, running balance, option to pause/cancelstreaming_paused/streaming_stopped: stream is paused or ended; offer to restart or switch to one-time buyExtended Flows
Execution plan
Reference file mapping:
GoodDollar/antseed-integration:AGENTS.md(design/actor semantics)README.md,docs/ARCHITECTURE.md,docs/PAYMENT_FLOW.md(API/payment boundaries)backend/README.md,backend/src/types.ts,backend/src/pricing.ts(backend API structure, pricing, extensibility for streaming)contracts/src/AgentCreditVault.sol,contracts/src/CeloGdAntSeedVault.sol(credit/token vault mechanics—assess G$ streaming feasibility)GoodDollar/GoodWidget:packages/claim-widgetas reference for package, project, theming, embed/host patternspackages/uifor all primitives; extend if streaming-specific UI elements (progress, status bars, editable tickers) neededpackages/core,packages/embedas abovepackages/ai-credits-widgetStorybook folder; update/add fixtures as neededtests/widgets/ai-credits-widget/Component mapping:
@goodwidget/ai-credits-widget:StreamingCreditSetupCard: stream/buy mode selector, controls for stream amount/rate, start/stop buttonsStreamingStatusCard: indicator/progress for streaming state, real-time estimated credits, pause/cancelpackages/uiif reusable:StreamingProgressBar, toggle controls, or confirmation dialogs if needed elsewhereSupports both buy and stream:
Acceptance Criteria:
Human Reviewer Checklist:
Parent: #30