feat(web): allow free-model sessions on zero balance and unify access…#4367
Conversation
…-level eligibility Combine five related changes that mirror AppBuilder behavior in Cloud Agent Next and extract a shared helper for the balance-threshold access level shape used by three routers. - Cloud Agent Next: allow users with no balance to create sessions against free models. NewSessionPanel hides the blocking banner and filters to free / BYOK-capable models when accessLevel is 'limited'; the personal and organization prepareSession routers route free or BYOK-capable models through the shared AppBuilder client so the worker skips the $1 minimum balance check. Paid models continue to require the minimum. - Introduce apps/web/src/lib/access-level-eligibility.ts with a generic buildAccessLevelEligibility helper. cloud-agent-next-eligibility.ts is now a thin wrapper that preserves its type aliases and constant; app-builder-router.ts and organization-app-builder-router.ts delegate to the shared helper with MIN_BALANCE_FOR_APP_BUILDER. No public/tRPC type changes. - Extract server-side eligibility into computeCloudAgentNextBalanceCheckEligibility so the routers consult the user's enabled BYOK providers (or the org's) alongside isFreeModel, closing the gap where a zero-balance user picking a BYOK-capable paid model still hit the worker minimum. Tests cover free / BYOK / paid gating on both routers, the accessLevel branches, and the new helper.
| : personalEligibilityQuery.isPending; | ||
| const hasInsufficientBalance = | ||
| !isEligibilityLoading && eligibilityData && !eligibilityData.isEligible; | ||
| const hasLimitedAccess = !isEligibilityLoading && eligibilityData?.accessLevel === 'limited'; |
There was a problem hiding this comment.
CRITICAL: isFormValid still blocks submission for limited-access users, defeating this PR's goal
Further down in this component, isFormValid requires !hasInsufficientBalance, and hasInsufficientBalance is true whenever eligibilityData.isEligible is false — which is exactly the case whenever accessLevel is 'limited' (i.e. whenever hasLimitedAccess here is true). So for every zero/low-balance user, the submit button (disabled={!isFormValid || ...}) and the Cmd/Ctrl+Enter shortcut stay disabled even after they pick a free or BYOK-capable model from the filtered modelOptions. The stated purpose of this PR — letting zero-balance users start Cloud Agent sessions on free models — can't actually be exercised from this UI as written. isFormValid needs to permit submission when hasLimitedAccess is true and the selected model is free/BYOK-capable, mirroring the filter already applied to modelOptions.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe previously flagged CRITICAL issue is fixed: Files Reviewed (1 file)
Previous Review Summary (commit 9e37184)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 9e37184)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe new Overview
Issue Details (click to expand)CRITICAL
Files Reviewed (13 files)
Reviewed by claude-sonnet-5-20260630 · Input: 30 · Output: 8K · Cached: 682.4K Review guidance: REVIEW.md from base branch |
…gent users isFormValid still gated submission on !hasInsufficientBalance, which is true for every accessLevel: 'limited' user. The submit button (and Cmd/Ctrl+Enter shortcut) stayed disabled even after such a user picked a free or BYOK-capable model from the already-filtered picker. Mirror the picker's isFree || hasUserByokAvailable filter in isFormValid so the UI matches what the server (computeCloudAgentNextBalanceCheckEligibility + x-skip-balance-check) already permits. Paid models selected via stale state or agent override remain blocked.
…-level eligibility
Combine five related changes that mirror AppBuilder behavior in Cloud Agent Next and extract a shared helper for the balance-threshold access level shape used by three routers.
Tests cover free / BYOK / paid gating on both routers, the accessLevel branches, and the new helper.
Summary
Verification
Visual Changes
Reviewer Notes