Skip to content

feat: EditTokenModal 中针对用户创建的 token 默认无限额度 - #2182

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
zhaolion:main
Nov 6, 2025
Merged

feat: EditTokenModal 中针对用户创建的 token 默认无限额度#2182
seefs001 merged 1 commit into
QuantumNous:mainfrom
zhaolion:main

Conversation

@zhaolion

@zhaolion zhaolion commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

背景

在当前情况下,大多数用户创建 token 是默认 1$,大多数人在使用过程会很快遇到 token 使用完毕,我们大多数用户都应该会以自己额度为准,而且 key 大多数情况只有1个,因此改成默认创建无限额度 token 更合适。有需求的用户可以自行创建限额的 token

Summary by CodeRabbit

  • Bug Fixes
    • Refined token editor initial settings. The unlimited quota option is now enabled by default instead of using a preset limit, and the associated quota field resets appropriately. This provides a more flexible and intuitive starting configuration when editing or creating tokens.

Copilot AI review requested due to automatic review settings November 6, 2025 11:40
@coderabbitai

coderabbitai Bot commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Updated default initial values in EditTokenModal.jsx: remain_quota changed from 500000 to 0, and unlimited_quota changed from false to true. These modifications alter the initial form state when editing tokens.

Changes

Cohort / File(s) Summary
Default Quota Configuration
web/src/components/table/tokens/modals/EditTokenModal.jsx
Changed default remain_quota from 500000 to 0 and default unlimited_quota from false to true, altering the initial form state for token editing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Verify the intent behind enabling unlimited quota by default and resetting remain_quota to 0
  • Confirm no dependent logic relies on the previous default values

Poem

🐰 A token's tale, now simplified and bright,
Unlimited by default—a rabbity delight!
Quotas reset to zero, fresh as morning dew,
Our modal grows more generous, hopping forward true. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: setting unlimited quota as the default for tokens created by users in EditTokenModal.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4243251 and c86bc94.

📒 Files selected for processing (1)
  • web/src/components/table/tokens/modals/EditTokenModal.jsx (1 hunks)
🔇 Additional comments (1)
web/src/components/table/tokens/modals/EditTokenModal.jsx (1)

69-71: Code changes are safe and ready. Backend correctly prioritizes unlimited flag over remain_quota.

The backend implementation confirms the changes are safe:

  • Quota checks use short-circuit evaluation: if !token.UnlimitedQuota && token.RemainQuota < quota, meaning when unlimited_quota=true, the remain_quota value is never evaluated
  • The middleware only sets token_quota in context when !token.UnlimitedQuota is true, so the 0 value doesn't propagate to quota validation
  • Pre-consumption logic also checks the unlimited flag first before evaluating the quota value

The default change from remain_quota: 500000 to remain_quota: 0 with unlimited_quota: true is correct and consistent with the backend's quota handling. No backend changes needed.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seefs001
seefs001 merged commit f8f5d26 into QuantumNous:main Nov 6, 2025
4 of 5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the default values for new token creation in the EditTokenModal component. The changes make the default experience more user-friendly by enabling unlimited quota by default instead of starting with a fixed quota amount.

  • Changed remain_quota default from 500000 to 0
  • Changed unlimited_quota default from false to true

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const getInitValues = () => ({
name: '',
remain_quota: 500000,
remain_quota: 0,

Copilot AI Nov 6, 2025

Copy link

Choose a reason for hiding this comment

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

When unlimited_quota is false, the remain_quota field is required (line 486). Setting the default to 0 could be problematic as it represents no quota. If a user toggles unlimited_quota from true to false without entering a value, the form will accept 0 as a valid quota, which may not be the intended behavior. Consider using a more appropriate default like 500000 (matching the autocomplete suggestion for 1$) or add validation to prevent 0 when unlimited_quota is disabled.

Suggested change
remain_quota: 0,
remain_quota: 500000,

Copilot uses AI. Check for mistakes.
This was referenced Dec 22, 2025
Closed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
feat:  EditTokenModal 中针对用户创建的 token 默认无限额度
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.

3 participants