Skip to content

refactor(kilo-pass): inline promo eligibility into getState to reduce DB calls#1491

Merged
markijbema merged 2 commits intomainfrom
mark/inline-promo-eligibility-into-getstate
Mar 24, 2026
Merged

refactor(kilo-pass): inline promo eligibility into getState to reduce DB calls#1491
markijbema merged 2 commits intomainfrom
mark/inline-promo-eligibility-into-getstate

Conversation

@markijbema
Copy link
Copy Markdown
Contributor

Summary

  • Inline promo eligibility into the kiloPass.getState response by adding isEligibleForFirstMonthPromo to GetStateOutputSchema, eliminating the need for a separate getFirstMonthPromoEligibility tRPC procedure and its redundant getKiloPassStateForUser DB query.
  • Remove the getFirstMonthPromoEligibility procedure entirely and update ProfileKiloPassSection to read promo eligibility directly from getState data.
  • This reduces the number of getKiloPassStateForUser DB calls on the profile page from 2 to 1 for users without an active subscription.

Verification

  • pnpm typecheck — passes
  • pnpm jest -- src/routers/kilo-pass-router.test.ts — 35/35 tests pass, including 2 new tests for isEligibleForFirstMonthPromo (eligible when no subscriptions, ineligible when canceled subscription exists)

Visual Changes

N/A

Reviewer Notes

  • The isEligibleForFirstMonthPromo field is placed at the top level of the getState response (alongside subscription) so it's available even when subscription is null.
  • The promo eligibility logic is: true when getKiloPassStateForUser returns null (no subscription rows at all), false otherwise (including canceled/ended subscriptions). This matches the prior getFirstMonthPromoEligibility behavior exactly.

… DB calls

Include isEligibleForFirstMonthPromo in the getState response and remove
the separate getFirstMonthPromoEligibility tRPC procedure. This eliminates
one redundant getKiloPassStateForUser DB call per profile page load for
users without an active subscription.
@markijbema markijbema marked this pull request as ready for review March 24, 2026 18:14
@markijbema markijbema enabled auto-merge March 24, 2026 18:15
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 24, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

No inline-commentable issues found in diff hunks.

Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/trpc/dist/index.d.ts 14741 The checked-in @kilocode/trpc declarations are stale: getState still omits isEligibleForFirstMonthPromo, and the removed getFirstMonthPromoEligibility procedure is still exported. Since packages/trpc/package.json publishes ./dist/index.d.ts, repo consumers will keep seeing the old API surface until this build artifact is regenerated.
Files Reviewed (7 files)
  • src/components/profile/ProfileKiloPassSection.tsx - 0 issues
  • src/routers/kilo-pass-router.ts - 0 diff-line issues
  • src/routers/kilo-pass-router.test.ts - 0 issues
  • src/lib/kilo-pass/state.ts - context reviewed
  • packages/trpc/dist/index.d.ts - 1 warning
  • packages/trpc/package.json - context reviewed
  • kilo-app/src/lib/trpc.ts - context reviewed

Reviewed by gpt-5.4-20260305 · 657,106 tokens

@markijbema markijbema merged commit 76db611 into main Mar 24, 2026
19 checks passed
@markijbema markijbema deleted the mark/inline-promo-eligibility-into-getstate branch March 24, 2026 18:27
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