Skip to content

fix(prompt-filter): refresh and remove failed review keys - #492

Open
ifThink404 wants to merge 1 commit into
james-6-23:mainfrom
ifThink404:codex/prompt-policy-unified-pr
Open

fix(prompt-filter): refresh and remove failed review keys#492
ifThink404 wants to merge 1 commit into
james-6-23:mainfrom
ifThink404:codex/prompt-policy-unified-pr

Conversation

@ifThink404

@ifThink404 ifThink404 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

修复内容

  • 保存审查 Key 后自动刷新“已保存的审查 Key”列表,避免仍显示旧数量
  • 连接测试结果与每个已保存 Key 的状态对应显示
  • 未保存 Key 测试失败时,可直接从待保存输入列表移除
  • 已保存 Key 测试失败时,可从结果卡片确认并永久删除
  • Key 输入解析与后端保持一致,支持空白、逗号、分号并自动去重

验证

  • npm run typecheck
  • npm run build
  • 本地完整交互:6 个旧 Key → 输入并测试 10 个 → 删除 1 个待保存失败 Key → 保存后列表自动刷新为 9 个 → 测试已保存 Key → 永久删除失败 Key 后刷新为 8 个

Summary by CodeRabbit

  • New Features
    • Review API keys can now be entered using spaces, commas, or semicolons.
    • Duplicate keys are automatically removed.
    • Key test results now show status for each key and support removing failed draft or configured keys.
  • Bug Fixes
    • Saved review keys reload correctly after settings are updated.
    • Localization now clarifies that saved keys display masked suffixes and provides removal confirmation messages.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Review API key management

Layer / File(s) Summary
Normalize and reload review keys
frontend/src/pages/PromptFilter.tsx
Review API keys are split on whitespace, commas, and semicolons, then trimmed and deduplicated. Successful saves increment a revision that causes OverviewView to reload configured keys.
Remove failed review-test keys
frontend/src/pages/PromptFilter.tsx, frontend/src/locales/en.json, frontend/src/locales/zh.json
Per-key results show masked keys and removal controls. Draft keys are removed locally. Configured keys use the existing confirmation and API deletion flow. Localized labels and messages support both languages.

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
Loading

Possibly related PRs

Suggested reviewers: james-6-23

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: refreshing saved review keys and removing failed review keys.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 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

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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between 6864770 and 627775d.

📒 Files selected for processing (3)
  • frontend/src/locales/en.json
  • frontend/src/locales/zh.json
  • frontend/src/pages/PromptFilter.tsx

Comment on lines +2935 to +2947
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ 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.

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.

1 participant