Skip to content

feat(admin): require expiration for credit grants unless 'Never expire' is checked#44

Open
kiloconnect[bot] wants to merge 3 commits intomainfrom
session/agent_24f40a75-e1b7-485d-bf5a-91d949d84e3c
Open

feat(admin): require expiration for credit grants unless 'Never expire' is checked#44
kiloconnect[bot] wants to merge 3 commits intomainfrom
session/agent_24f40a75-e1b7-485d-bf5a-91d949d84e3c

Conversation

@kiloconnect
Copy link
Contributor

@kiloconnect kiloconnect bot commented Feb 5, 2026

Summary

This PR updates the admin user credit grant form to require an expiration date or expiration hours for credit grants, unless the admin explicitly checks a "Never expire" checkbox.

Changes

  • Added a "Never expire" checkbox to the credit grant form
  • Made expiration date OR expiry hours required by default (for non-negative credit grants)
  • Only allow empty expiration fields if "Never expire" is checked
  • Added a validation warning message when expiration is missing
  • Disabled expiration fields when "Never expire" is checked
  • Clear expiration fields when "Never expire" is toggled on
  • Reset "Never expire" checkbox when credit category changes or form is submitted

How it works

  1. When a credit category is selected, the form checks if the category has a default expiration (via expiry_hours or credit_expiry_date)
  2. If the category has no default expiration, the admin must either:
    • Enter an expiry hours value, OR
    • Enter an expiration date, OR
    • Check the "Never expire" checkbox
  3. The submit button is disabled until one of these conditions is met
  4. A yellow warning message is displayed when expiration is required but not provided

Testing

  • Verified type checking passes with pnpm typecheck
  • Form validation prevents submission without expiration
  • "Never expire" checkbox properly enables/disables expiration fields

Built for Brendan by Kilo for Slack

…e' is checked

- Add 'Never expire' checkbox to the credit grant form
- Make expiration date OR expiry hours required by default
- Only allow empty expiration fields if 'Never expire' is checked
- Show validation warning when expiration is missing
- Disable expiration fields when 'Never expire' is checked
- Clear expiration fields when 'Never expire' is toggled on
@kiloconnect
Copy link
Contributor Author

kiloconnect bot commented Feb 5, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 1
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

CRITICAL

File Line Issue
src/app/admin/components/UserAdmin/UserAdminCreditGrant.tsx 64 "Never expire" doesn’t override category default expiration

WARNING

File Line Issue
src/app/admin/components/UserAdmin/UserAdminCreditGrant.tsx 256 Category default expiration date isn’t displayed in date input; success message may omit expiry
Files Reviewed (1 files)

olearycrew and others added 2 commits February 5, 2026 12:36
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@olearycrew
Copy link

Tested and works

@olearycrew olearycrew enabled auto-merge February 5, 2026 20:38
selectedCreditCategory?.expiry_hours != null ||
selectedCreditCategory?.credit_expiry_date != null;
const hasExpirationFromForm = expirationDate.trim() !== '' || Number(expiryHours) > 0;
const hasExpiration = hasExpirationFromCategory || hasExpirationFromForm || neverExpire;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: "Never expire" doesn’t override category defaults

src/app/admin/components/UserAdmin/UserAdminCreditGrant.tsx:64 treats neverExpire as satisfying the "must have an expiration" validation, but the request payload sent in UserAdminCreditGrant.handleGrantCredit() doesn’t include any flag/override to tell the server to ignore selectedCreditCategory defaults. If the selected category has expiry_hours/credit_expiry_date, checking "Never expire" will still grant expiring credits (contradicting the UI text).

Consider either (a) sending an explicit override (e.g. never_expire: true or expiry_hours: null / credit_expiry_date: null with server support), or (b) hiding/disabled the checkbox when the category already has an expiry.

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