Repository navigation
Conversation
WalkthroughThe redemption drawer now suppresses rejected redemption fetch errors. Successful loads still reset form defaults. The quota input preserves empty and invalid numeric states by rendering ChangesRedemption drawer behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 Warning |
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 94-100: Update the redemption load flow around getRedemption so
Save is disabled until the fresh data load succeeds, including when
result.success is false or the request rejects. Track the update-load state,
call handleServerError and show the localized t(ERROR_MESSAGES.LOAD_FAILED)
toast on load failure, and narrow the catch to only the request rejection so
transformRedemptionToFormDefaults or form.reset errors remain visible.
🪄 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: e51d524c-9a4c-4479-b7b2-e6c77dce7b3b
📒 Files selected for processing (1)
web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx
| getRedemption(currentRow.id) | ||
| .then((result) => { | ||
| if (result.success && result.data) { | ||
| form.reset(transformRedemptionToFormDefaults(result.data)) | ||
| } | ||
| }) | ||
| .catch(() => undefined) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Expect: failed update loads set an error state and cannot submit stale form data.
rg -n -C 8 \
'getRedemption|handleServerError|toast\.error|isSubmitting|handleSubmit|currentRow' \
web/src/features/redemption-codes --glob '*.{ts,tsx}'Repository: QuantumNous/new-api
Length of output: 44265
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "== api.ts =="
cat -n web/src/features/redemption-codes/api.ts | sed -n '1,90p'
echo "== common error-server helper =="
rg -n -C 6 "handleServerError" web/src --glob '*.{ts,tsx}' | sed -n '1,160p'
echo "== toast/error usage around mutations =="
rg -n -C 5 "toast\.error|ERROR_MESSAGES\.(UPDATE_FAILED|CREATE_FAILED|DELETE_FAILED|UPDATE_INVALID_FAILED)" web/src/features/redemption-codes --glob '*.{ts,tsx}'
echo "== drawer outline =="
ast-grep outline web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx --view compact || true
echo "== drawer relevant sections =="
cat -n web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx | sed -n '75,105p;105,155p;334,342p'
echo "== behavioral probe for current load failure behavior =="
python3 - <<'PY'
from pathlib import Path
text = Path('web/src/features/redemption-codes/components/redemptions-mutate-drawer.tsx').read_text()
checks = {
"load_has_error_state": "loadRedemptionFailed" in text or "isLoadFailed" in text or "loadError" in text or "loading" in text,
"load_catch_returns_undefined": "catch(() => undefined)" in text or ".catch(e => null)" in text,
"handleServerError_imported": "handleServerError" in text,
"toast_error_imported": "toast" in text and ".error(" in text,
"save_disabled_only_by_submitting": "disabled={isSubmitting}" in text,
"onSubmit_has_result_success_branch_update": "if (result.success)" in text[text.find("const onSubmit"): text.find("const handleSubmit")],
}
for k, v in checks.items():
print(f"{k}={v}")
PYRepository: QuantumNous/new-api
Length of output: 12281
Do not leave the update form usable after a failed load.
getRedemption(currentRow.id) can reject, and result.success === false also skips form.reset. Both paths keep the existing form state while Save remains enabled, so updating with the current currentRow.id can send stale values.
Track the update-load state. Disable Save until the fresh load succeeds. On failure, call handleServerError and show the localized error toast with t(ERROR_MESSAGES.LOAD_FAILED). Keep the catch narrow so transformRedemptionToFormDefaults or form.reset errors are not hidden.
🤖 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 94 - 100, Update the redemption load flow around getRedemption so
Save is disabled until the fresh data load succeeds, including when
result.success is false or the request rejects. Track the update-load state,
call handleServerError and show the localized t(ERROR_MESSAGES.LOAD_FAILED)
toast on load failure, and narrow the catch to only the request rejection so
transformRedemptionToFormDefaults or form.reset errors remain visible.
Source: Coding guidelines
|
关联的bug编号写错了,应该是 #6681 |
Important
📝 变更描述 / Description
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
已支持删除后为空

Summary by CodeRabbit