Fix/duihuanm del1 - #6741
Conversation
WalkthroughThe 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 ChangesRedemption quota input
Usage-log test runtime
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
web/src/features/redemption-codes/components/__tests__/redemptions-mutate-drawer.test.tsxweb/src/features/redemption-codes/components/redemptions-mutate-drawer.tsxweb/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
| e.target.value === '' | ||
| ? '' | ||
| : Number.parseFloat(e.target.value) |
There was a problem hiding this comment.
🗄️ 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}' || trueRepository: 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
51fdfc5 to
2b6f1df
Compare
Important
📝 变更描述 / Description
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
Summary by CodeRabbit
Bug Fixes
Tests