fix(prompt-filter): refresh and remove failed review keys - #492
fix(prompt-filter): refresh and remove failed review keys#492ifThink404 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe review API key flow now accepts normalized key lists, reloads configured keys after successful saves, and lets users remove failed draft or configured keys from per-key test results. English and Chinese localization strings describe masked keys and removal actions. ChangesReview API key management
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PromptFilter
participant OverviewView
participant ReviewKeyAPI
PromptFilter->>PromptFilter: Parse and deduplicate review keys
PromptFilter->>OverviewView: Pass settingsSaveRevision
OverviewView->>ReviewKeyAPI: Reload configured keys after save
PromptFilter->>ReviewKeyAPI: Delete failed configured key
Possibly related PRs
Suggested reviewers: 🚥 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 |
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 `@frontend/src/pages/PromptFilter.tsx`:
- Around line 2935-2947: Update removeFailedReviewTestKey and the related
remove-button condition to support draft results identified only by key_index:
do not require key_id for the draft branch, remove the corresponding draft entry
by key_index, and filter the displayed draft result by key_index. For configured
results, require or resolve a stable key_id before invoking deleteReviewKey,
ensuring no saved result with only key_index remains unremovable.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4bb283f5-5a4e-432a-b899-ee583ee1c5c9
📒 Files selected for processing (3)
frontend/src/locales/en.jsonfrontend/src/locales/zh.jsonfrontend/src/pages/PromptFilter.tsx
| const removeFailedReviewTestKey = async (item: PromptReviewKeyTestResult) => { | ||
| if (!item.key_id) return | ||
| const masked = item.key_masked || `Key #${item.key_index}` | ||
| if (draftReviewKeys.length > 0) { | ||
| const draftIndex = item.key_index - 1 | ||
| if (draftIndex < 0 || draftIndex >= draftReviewKeys.length) return | ||
| const remaining = draftReviewKeys.filter((_, index) => index !== draftIndex) | ||
| setForm((current) => ({ ...current, prompt_filter_review_api_key: remaining.join('\n') })) | ||
| setReviewTestResult((current) => current ? { | ||
| ...current, | ||
| key_count: remaining.length, | ||
| results: current.results?.filter((result) => result.key_id !== item.key_id), | ||
| } : null) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Do not require key_id for draft-key removal.
PromptReviewKeyTestResult.key_id is optional in frontend/src/types.ts. Line [2936] exits before the draft branch when the result contains only key_index. Lines [3288-3290] also hide the remove button. A valid failed draft key therefore cannot be removed.
Use key_index to identify draft results and filter draft results by key_index. For configured results, require a stable key_id from the API or resolve the configured descriptor before calling deleteReviewKey. Do not leave a saved result with only key_index as an unremovable card.
Proposed draft-side fix
const removeFailedReviewTestKey = async (item: PromptReviewKeyTestResult) => {
- if (!item.key_id) return
+ const isDraft = draftReviewKeys.length > 0
+ if (!isDraft && !item.key_id) return
const masked = item.key_masked || `Key #${item.key_index}`
- if (draftReviewKeys.length > 0) {
+ if (isDraft) {
const draftIndex = item.key_index - 1
if (draftIndex < 0 || draftIndex >= draftReviewKeys.length) return
const remaining = draftReviewKeys.filter((_, index) => index !== draftIndex)
setForm((current) => ({ ...current, prompt_filter_review_api_key: remaining.join('\n') }))
setReviewTestResult((current) => current ? {
...current,
key_count: remaining.length,
- results: current.results?.filter((result) => result.key_id !== item.key_id),
+ results: current.results?.filter((result) => result.key_index !== item.key_index),
} : null)Also applies to: 3288-3290
🤖 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 `@frontend/src/pages/PromptFilter.tsx` around lines 2935 - 2947, Update
removeFailedReviewTestKey and the related remove-button condition to support
draft results identified only by key_index: do not require key_id for the draft
branch, remove the corresponding draft entry by key_index, and filter the
displayed draft result by key_index. For configured results, require or resolve
a stable key_id before invoking deleteReviewKey, ensuring no saved result with
only key_index remains unremovable.
修复内容
验证
Summary by CodeRabbit