Skip to content

feat(dev): add credits dev tool on /profile - #5389

Open
IamCoder18 wants to merge 1 commit into
Kilo-Org:mainfrom
IamCoder18:feat/dev-add-credits-profile
Open

feat(dev): add credits dev tool on /profile#5389
IamCoder18 wants to merge 1 commit into
Kilo-Org:mainfrom
IamCoder18:feat/dev-add-credits-profile

Conversation

@IamCoder18

@IamCoder18 IamCoder18 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a companion "Add Credits" dev tool on /profile, mirroring the existing "Consume Credits" tool so devs can grant themselves credits without a real Stripe purchase or admin grant.

Changes:

  • apps/web/src/app/api/dev/add-credits/route.ts (new) — dev-only POST that inserts a credit_transactions row (credit_category: 'dev-tools', is_free: true) and increments kilocode_users.total_microdollars_acquired, then calls forceImmediateExpirationRecomputation to bust the balance cache. Mirrors the auth/guard pattern in apps/web/src/app/api/dev/consume-credits/route.ts and the write pattern in apps/web/src/lib/promotionalCredits.ts:175-224, but bypasses promoCreditCategoriesByKey since this is not a real campaign.
  • apps/web/src/components/dev/DevAddCreditsButton.tsx (new) — mirrors DevConsumeCreditsButton.tsx: amount input + Add button, router.refresh() on success, dev-mode guard.
  • apps/web/src/app/(app)/profile/page.tsx — adds an "Add Credits" section above "Consume Credits" in the existing Development Tools card.

No DB migration. No new env vars. No changes outside apps/web/src/app/api/dev, apps/web/src/components/dev, and the /profile page.

Verification

  • Visited /profile, entered an amount in the new "Add Credits" section, and submitted. Verified total_microdollars_acquired increases and the profile balance counter refreshes.

  • Ran pnpm -w exec oxlint --config .oxlintrc.json on the changed files — 0 warnings, 0 errors.

Visual Changes

add_screen credits_adding

Reviewer Notes

  • Endpoint is gated by process.env.NODE_ENV === 'development', same as the sibling consume-credits route, so it is unreachable in production.
  • The credit_category literal 'dev-tools' is intentionally not registered in promoCreditCategoriesByKey, keeping it isolated from real campaigns.

@kilo-code-bot

kilo-code-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the three-file dev-only Add Credits tool on /profile; it mirrors the existing consume-credits auth, write, and UI patterns with no high-confidence defects.

Files Reviewed (3 files)
  • apps/web/src/app/(app)/profile/page.tsx
  • apps/web/src/app/api/dev/add-credits/route.ts
  • apps/web/src/components/dev/DevAddCreditsButton.tsx

Reviewed by grok-4.6 · Input: 78K · Output: 8K · Cached: 321.9K

Review guidance: REVIEW.md from base branch main

@IamCoder18

Copy link
Copy Markdown
Contributor Author

Ready for review!

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