Skip to content

fix(kilo-pass): hide unreachable bonus progress - #4896

Merged
jeanduplessis merged 1 commit into
mainfrom
diligent-osprey
Jul 30, 2026
Merged

fix(kilo-pass): hide unreachable bonus progress#4896
jeanduplessis merged 1 commit into
mainfrom
diligent-osprey

Conversation

@jeanduplessis

Copy link
Copy Markdown
Contributor

Summary

Prevent Kilo Pass from showing progress toward a usage-triggered bonus when the persisted threshold has already been cleared.

Why this change is needed

A subscription can resume after its usage threshold was consumed while inactive. The current state projection still derives a prospective bonus from the latest base issuance, even though no threshold remains to trigger that bonus. This leaves customers seeing progress toward a reward that cannot unlock.

How this is addressed

  • Treat the persisted threshold and current issuance items as authoritative for current-period bonus availability.
  • Distinguish an already unlocked bonus from a bonus that remains available to unlock.
  • Return no current-period bonus projection when neither a threshold nor a bonus-like issuance item exists.
  • Suppress progress and explanatory copy in both Kilo Pass UI surfaces for that unavailable state.
  • Preserve threshold-present progress, unlocked bonuses, renewal projections, and paused or ended subscription rendering.

Human Verification

  • Focused Kilo Pass router and component logic suites passed: 118 tests.
  • Local code review passed all eight quality focuses with no findings.
  • React Doctor reported no issues with a 93/100 score.

Reviewer Notes

Human Reviewer Flags

  • The persisted user-global threshold remains the authority for whether the current bonus can still unlock.
  • This intentionally does not change paused-subscription threshold consumption or add deferred eligibility state.

Code Reviewer Agent

Code Reviewer Notes
  • The API exposes a derived isBonusAvailableToUnlock boolean rather than the raw cumulative threshold.
  • isBonusUnlocked remains based on bonus-like issuance items and is semantically separate from current unlock availability.
  • Next-period bonus projections are unchanged.

@kilo-code-bot

kilo-code-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the Kilo Pass current-period bonus availability gate across the tRPC state builder and both Kilo Pass UI surfaces; the derivation matches how kilocode_users.kilo_pass_threshold is actually written and cleared, and no correctness, security, or performance defects were found in the changed lines.

Verification notes

  • Confirmed kilo_pass_threshold is set on every base-issuance path (stripe-handlers-invoice-paid.ts, yearly-monthly-base-cron.ts, store-subscription-completion.ts) and cleared in usage-triggered-bonus.ts, including the non-active-subscription path that clears without issuing. This makes hasKiloPassThreshold && !isBonusUnlocked a sound signal for "still reachable this period".
  • Confirmed KILO_PASS_BONUS_LIKE_ITEM_KINDS includes ReferralBonus and PromoFirstMonth50Pct, so the referral case that skips the threshold update (stripe-handlers-invoice-paid.ts:753) still resolves to isBonusUnlocked, avoiding a false "unavailable" state.
  • Confirmed the new Promise.all destructuring order in buildActiveKiloPassSubscriptionState matches the promise order, so no value swap was introduced.
  • Confirmed currentPeriodBonusCreditsUsd and the new flag have only the two component consumers updated in this PR, so nullability of the bonus value does not reach an unguarded render path; computeUsageProgressModel already returned null for a non-positive bonus.
  • No .md files, no landing-page/SEO surfaces, and no listener/timer/subscription additions that could leak.

Assumptions

  • Database-backed router suites were not executed in this read-only session; test-behaviour claims rely on static reading of the updated fixtures.
Files Reviewed (6 files)
  • apps/web/src/routers/kilo-pass-router.ts
  • apps/web/src/routers/kilo-pass-router.test.ts
  • apps/web/src/components/profile/kilo-pass/KiloPassActiveSubscriptionCard.logic.ts
  • apps/web/src/components/profile/kilo-pass/KiloPassActiveSubscriptionCard.tsx
  • apps/web/src/components/profile/kilo-pass/KiloPassActiveSubscriptionCard.test.ts
  • apps/web/src/components/subscriptions/kilo-pass/KiloPassDetail.tsx

Reviewed by claude-opus-5 · Input: 42 · Output: 21.3K · Cached: 1.9M

Review guidance: REVIEW.md from base branch main

@jeanduplessis
jeanduplessis merged commit f6a77c7 into main Jul 30, 2026
21 checks passed
@jeanduplessis
jeanduplessis deleted the diligent-osprey branch July 30, 2026 16:58
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