Skip to content

Fix/duihuanm del1 - #6741

Open
lihu-001 wants to merge 3 commits into
QuantumNous:mainfrom
lihu-001:fix/duihuanm_del1
Open

Fix/duihuanm del1#6741
lihu-001 wants to merge 3 commits into
QuantumNous:mainfrom
lihu-001:fix/duihuanm_del1

Conversation

@lihu-001

@lihu-001 lihu-001 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

  • 修复兑换码新增和修改页面的额度输入框清空后强制显示0的问题

📝 变更描述 / Description

  • 调整 web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx:300
  • 输入框为空时保留空字符串,不再通过 || 0 强制转换为 0
  • 非空输入仍正常转换为数字
  • 新增回归测试,覆盖:
    • 新增兑换码时清空额度
    • 修改兑换码时清空额度

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

image

Summary by CodeRabbit

  • Bug Fixes

    • Quota fields now preserve an intentionally blank value instead of automatically converting it to zero.
    • Non-empty quota values continue to accept decimal numbers as expected.
  • Tests

    • Updated automated test coverage and execution setup to improve reliability across supported test environments.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The redemption drawer now preserves an empty quota field after deletion. The cost display test now loads Bun’s test APIs at runtime and uses Bun’s afterAll cleanup hook. The redemption drawer test file was removed.

Changes

Redemption quota input

Layer / File(s) Summary
Preserve cleared quota input
web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx, web/src/features/redemption-codes/components/__tests__/redemptions-mutate-drawer.test.tsx
The quota handler keeps cleared input empty and parses non-empty input as a number. The redemption drawer test file was deleted.

Usage-log test runtime

Layer / File(s) Summary
Use Bun test hooks
web/src/features/usage-logs/components/__tests__/cost-display.test.tsx
The test dynamically imports bun:test, applies Node-compatible test types, and uses afterAll for cleanup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: calcium-ion

Poem

I nibble the quota, then leave it quite bare,
No zero appears when the field loses its fare.
Bun cleans the test room when all tests are through,
The rabbit approves with a hop and a chew.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR deletes an unrelated redemption drawer test file and changes fee-display test setup beyond issue #6681. Restore the deleted test file and separate unrelated fee-display test changes into another pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title includes a fix reference but does not clearly describe the redemption-code amount input change. Use a concise title such as "Fix empty redemption-code amount input".
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The implementation preserves an empty amount value and satisfies issue #6681 for creation and modification forms.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx`:
- Around line 303-305: Update the quota change handler in the redemption mutate
drawer so clearing the input remains compatible with getRedemptionFormSchema()
and RedemptionFormValues: either accept an explicit string-empty state in the
form contract or normalize the empty value before validation/submission, while
preserving numeric parsing for non-empty input. Add regression tests covering
cleared quota values in both create and update flows.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ccf9be1-493d-4039-a215-3a6e440a9dc0

📥 Commits

Reviewing files that changed from the base of the PR and between 823e263 and 49a5b45.

📒 Files selected for processing (3)
  • web/src/features/redemption-codes/components/__tests__/redemptions-mutate-drawer.test.tsx
  • web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx
  • web/src/features/usage-logs/components/__tests__/cost-display.test.tsx
💤 Files with no reviewable changes (1)
  • web/src/features/redemption-codes/components/tests/redemptions-mutate-drawer.test.tsx

Comment on lines +303 to +305
e.target.value === ''
? ''
: Number.parseFloat(e.target.value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 8 \
  'RedemptionFormValues|getRedemptionFormSchema|parseQuotaFromDollars|transformFormDataToPayload|quota_dollars' \
  web/src

rg -n -C 8 \
  'quota_dollars|clear|Backspace|create|update' \
  web/src/features/redemption-codes/components/__tests__

Repository: QuantumNous/new-api

Length of output: 50375


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== target file outline and relevant slices =="
ast-grep outline web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx --match 'handleQuotaDollarsChange|onSubmit|quota_dollars' || true
sed -n '260,330p' web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx
sed -n '180,240p' web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx

echo "== redemption lib relevant slices =="
sed -n '1,140p' web/src/features/redemption-codes/lib/redemption-form.ts

echo "== format/parsing implementation =="
rg -n -C 6 'function parseQuotaFromDollars|export const parseQuotaFromDollars|function quotaUnitsToDollars|export const quotaUnitsToDollars' web/src/lib

echo "== tests exact matches =="
fd -a -t f '__(redemption|redemptions).*|(.*)redemption.*test.*' web/src | sed 's#^\./##'
rg -n -C 5 'redemption|quota_dollars|clear|Backspace|create|update' web/src/features/redemption-codes -g '*.{ts,tsx,md}' || true

Repository: QuantumNous/new-api

Length of output: 50375


Keep empty quota input compatible with the redemption form contract.

getRedemptionFormSchema() only accepts a number, but this handler stores '' in quota_dollars; RedemptionFormValues also declares number. Add a runtime/string contract or normalize the empty value before submission. Add regression tests for clearing quota in create and update flows.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx`
around lines 303 - 305, Update the quota change handler in the redemption mutate
drawer so clearing the input remains compatible with getRedemptionFormSchema()
and RedemptionFormValues: either accept an explicit string-empty state in the
form contract or normalize the empty value before validation/submission, while
preserving numeric parsing for non-empty input. Add regression tests covering
cleared quota values in both create and update flows.

Source: Coding guidelines

@Calcium-Ion
Calcium-Ion force-pushed the main branch 2 times, most recently from 51fdfc5 to 2b6f1df Compare August 30, 2026 15:03
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.

兑换码的新值与修改页面的额度输入框,有值时,点击键盘的backspace键,删除到最后会强制显示为0

2 participants