Skip to content

feat(claw): prompt users to purchase credits when selecting a paid model#1324

Merged
RSO merged 7 commits into
mainfrom
purchase-credits-k
Mar 23, 2026
Merged

feat(claw): prompt users to purchase credits when selecting a paid model#1324
RSO merged 7 commits into
mainfrom
purchase-credits-k

Conversation

@RSO
Copy link
Copy Markdown
Contributor

@RSO RSO commented Mar 20, 2026

Summary

  • When a user without credits selects a paid model during KiloClaw onboarding, an inline credit purchase nudge now appears below the model picker. It offers preset amounts ($10, $20, $50), a Stripe checkout CTA, and a "Use the free model instead" fallback.
  • After completing payment, the user is automatically redirected back to /claw with their model selection preserved via the existing payment-return-url cookie mechanism, a success toast is shown, and provisioning starts automatically.
  • Free model detection uses the shared isFreeModel() helper, so selecting any free model (not just Kilo Auto: Free) from the 500+ dropdown also hides the nudge.

Verification

  • pnpm typecheck — passes across all packages
  • pnpm format:check (oxfmt) — passes
  • pnpm lint — passes (oxlint + eslint)

Visual Changes

credit-purchase.mp4

Reviewer Notes

  • The Stripe cancel URL still redirects to /profile (hardcoded in getStripeTopUpCheckoutUrl). A follow-up could pass a custom cancel URL so users return to /claw on cancellation too.
  • The auto-provision effect uses a useRef guard (hasAutoProvisioned) to prevent double-firing in React strict mode or on re-renders.

Comment thread src/app/(app)/claw/components/CreateInstanceCard.tsx
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Mar 20, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
src/app/(app)/claw/components/CreateInstanceCard.tsx 106 The auto-provision effect re-fires on refresh or back-navigation because the payment=success URL marker is never consumed after the first request.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
src/app/payments/topup/success/page.tsx 79 The redirect effect can run before getPaymentReturnUrl() resolves, so the /claw?model=...&payment=success cookie is ignored and users fall back to /payments/topup/thank-you.
Files Reviewed (6 files)
  • src/app/(app)/claw/components/CreateInstanceCard.tsx - 1 issue
  • src/app/(app)/claw/components/CreditsNudge.actions.ts - 0 issues
  • src/app/(app)/claw/components/CreditsNudge.tsx - 0 issues
  • src/app/payments/topup/route.ts - 0 issues
  • src/lib/stripe.ts - 0 issues
  • src/app/payments/topup/success/page.tsx - 1 issue

Reviewed by gpt-5.4-20260305 · 1,558,125 tokens

RSO added 7 commits March 23, 2026 09:28
…del during onboarding

Users without credits can select paid models during KiloClaw onboarding,
but the bot won't work without a balance. This adds an inline credit
purchase nudge (amount selector + Stripe checkout CTA + free model
fallback) and preserves model selection across the checkout redirect via
the existing payment-return-url cookie.
Replace useTransition with a plain useState boolean that stays true
once set, since the form submission navigates away and never needs
to reset.
Show a success toast and immediately start provisioning when the user
returns from Stripe checkout, so they don't have to manually click
Get Started again.
Replace the hand-rolled Set of free model IDs with a direct call to the
existing isFreeModel() helper, which already covers all free model
detection cases (kilo free models, :free suffix, stealth models, etc.).
Add an optional cancel-path query param to the /payments/topup route,
validated with isValidReturnUrl to prevent open redirects. The claw
CreditsNudge now passes cancel-path=/claw so users return to the
onboarding page instead of /profile when they cancel checkout.
@RSO RSO force-pushed the purchase-credits-k branch from d2b9bc7 to 7d29bff Compare March 23, 2026 08:42
Comment thread src/app/(app)/claw/components/CreateInstanceCard.tsx
@RSO RSO requested a review from a team March 23, 2026 09:01
@RSO RSO merged commit 117f947 into main Mar 23, 2026
18 checks passed
@RSO RSO deleted the purchase-credits-k branch March 23, 2026 09:15
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