Repository navigation
feat(clues): add filtered commander review queue - #133
Conversation
- Add source_type filtering to clue timeline API, validation, and OpenAPI docs - Expose typed paginated clue timeline queries in the frontend API client - Build commander queue filters for status, source, time field, and sort order - Add loading, error retry, and pagination states for the review queue - Require explicit confirmation before submitting clue review decisions - Refresh queued clues after case mutations and completed reviews - Add frontend and API coverage for filtering, queue loading, and review confirmation - Add Testing Library DOM dependency and regenerate Yarn lockfile
|
Warning Review limit reached
Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthrough新增 Changes线索时间线来源筛选
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
tests/api/case_clues_get.rs (1)
128-164: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win补充来源筛选与角色裁剪组合的覆盖。
当前正向断言只使用可查看全部线索的 commander,无法验证
source_type不会泄露其他角色不可见的待审核线索。请增加 family 或 volunteer 查询source_type=field_report的断言,验证返回total=0且没有该线索。As per path instructions,
tests/**必须覆盖有意义的正向、负向和边界场景。🤖 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 `@tests/api/case_clues_get.rs` around lines 128 - 164, Extend the source_type filtering coverage in the case clues test after the existing commander assertions by issuing a field_report query with a family or volunteer token. Assert that the response total is 0 and the items collection contains no field_report clue, while preserving the existing commander positive assertions.Source: Path instructions
🤖 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/CaseWorkspacePage.tsx`:
- Around line 769-781: Update the isConfirming confirmation dialog in
CaseWorkspacePage to implement keyboard-modal behavior: move focus into the
dialog when opened, trap Tab navigation within it, restore focus to the
triggering control when closed, and close on Escape by reusing the existing
setIsConfirming(false) path. Preserve the current confirmation actions and
busy-state handling.
- Around line 322-346: Update loadClueQueue to isolate requests by case and
queueFilters, resetting the queue when either changes and ensuring only the
latest request can update clueQueue items, queueError, or isQueueLoading. Use a
request sequence or AbortController, and add a regression test covering
out-of-order responses so stale case/filter results are discarded.
- Line 348: Update the title/count rendering in CaseWorkspacePage to use
clueQueue.total and accurate “matching count” wording when isCommander is true,
keeping detail.clues.length and the existing wording for non-commander users.
Ensure the displayed count matches the visibleClues source selected for each
role.
---
Nitpick comments:
In `@tests/api/case_clues_get.rs`:
- Around line 128-164: Extend the source_type filtering coverage in the case
clues test after the existing commander assertions by issuing a field_report
query with a family or volunteer token. Assert that the response total is 0 and
the items collection contains no field_report clue, while preserving the
existing commander positive assertions.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f77643cb-c35b-4d2a-a948-957f36dde42a
⛔ Files ignored due to path filters (2)
frontend/package-lock.jsonis excluded by!**/package-lock.jsonfrontend/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (9)
docs/openapi.yamlfrontend/package.jsonfrontend/src/api/cases.test.tsfrontend/src/api/cases.tsfrontend/src/pages/CaseWorkspacePage.test.tsxfrontend/src/pages/CaseWorkspacePage.tsxsrc/models.rssrc/services/case_service.rstests/api/case_clues_get.rs
| } | ||
| }, [detail.id, isCommander, queueFilters, token]) | ||
|
|
||
| const visibleClues = isCommander ? clueQueue.items : detail.clues |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
同步队列计数与当前渲染的数据源。
指挥端已改为渲染 clueQueue.items,但标题仍显示 detail.clues.length。例如队列返回 1 条、详情内线索为空时,页面会同时显示“0 条可见”和一条线索。指挥端应使用 clueQueue.total,并改为“匹配条数”等准确文案。
🤖 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/CaseWorkspacePage.tsx` at line 348, Update the title/count
rendering in CaseWorkspacePage to use clueQueue.total and accurate “matching
count” wording when isCommander is true, keeping detail.clues.length and the
existing wording for non-commander users. Ensure the displayed count matches the
visibleClues source selected for each role.
Source: Path instructions
- Track each commander queue request with a monotonically increasing version - Clear queue data while loading a refreshed filtered result - Apply queue results, errors, and loading state only for the latest request - Invalidate pending queue requests when leaving commander mode - Add coverage for stale responses resolving after newer filtered results
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
frontend/src/pages/CaseWorkspacePage.tsx (2)
527-533: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win请求失败时不要同时显示“暂无可见线索”。
加载开始时队列会被清空;请求失败后,页面既显示
ErrorState,又因为visibleClues为空显示“暂无可见线索”,会给用户造成矛盾的状态反馈。错误时应跳过空态。As per path instructions,前端失败路径应提供一致的用户反馈。
建议修改
- ) : visibleClues.length === 0 ? ( + ) : queueError ? null : visibleClues.length === 0 ? (🤖 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/CaseWorkspacePage.tsx` around lines 527 - 533, Update the queue rendering logic in CaseWorkspacePage around queueError, isQueueLoading, and visibleClues so a failed request does not render the “暂无可见线索” empty state alongside ErrorState. Prioritize the loading and error states before the empty-list branch, while preserving the existing clue list rendering for successful responses.Source: Path instructions
375-382: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift刷新队列时不要使用旧闭包中的筛选条件。
run在异步操作完成后调用的是调用时捕获的loadClueQueue。如果期间筛选从 A 改为 B,B 请求可能先发出,但这里会随后用旧筛选再次发起 A 请求;该请求会取得最新版本号并覆盖当前队列。请通过刷新状态触发依赖最新筛选条件的 effect,或读取最新 callback/ref,不要直接调用旧闭包。建议的刷新方式
+ const [queueRefreshVersion, setQueueRefreshVersion] = useState(0) async function run(key: string, action: () => Promise<unknown>, message: string) { ... try { await action() await onChanged(message) - await loadClueQueue() + setQueueRefreshVersion((value) => value + 1) return true并让队列 effect 依赖
queueRefreshVersion,由 effect 使用最新的loadClueQueue。🤖 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/CaseWorkspacePage.tsx` around lines 375 - 382, 更新 CaseWorkspacePage 中的 run 函数及队列刷新流程,避免异步完成后直接调用捕获旧筛选条件的 loadClueQueue。改用 queueRefreshVersion 触发依赖最新 loadClueQueue 的 effect,并在操作完成后递增该刷新状态;保留 onChanged(message) 的现有行为。
🧹 Nitpick comments (1)
frontend/src/pages/CaseWorkspacePage.tsx (1)
757-771: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win收敛为唯一的审核提交入口。
submitReview已包含完整提交逻辑,但按钮在isConfirming分支又复制了一份reviewClue调用。两条路径的收尾行为不一致:确认弹窗路径会关闭弹窗,重复路径成功后不会关闭。让触发按钮只负责打开确认框,统一由submitReview提交。🤖 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/CaseWorkspacePage.tsx` around lines 757 - 771, 让审核按钮的 onPress 仅负责在非确认状态下调用 setIsConfirming(true) 并返回;确认状态下改为调用已有的 submitReview,移除其中重复的 normalizedReason、reviewClue 和成功回调逻辑,确保所有审核提交统一经过 submitReview 并执行一致的收尾行为。
🤖 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/CaseWorkspacePage.tsx`:
- Around line 323-329: Update loadClueQueue in the missing-token or unauthorized
path to clear clue queue data, reset queue errors, and set queue loading to
false before returning. Preserve request-version invalidation so earlier
responses remain ignored, and ensure stale queue state is not retained after
authentication is lost.
---
Outside diff comments:
In `@frontend/src/pages/CaseWorkspacePage.tsx`:
- Around line 527-533: Update the queue rendering logic in CaseWorkspacePage
around queueError, isQueueLoading, and visibleClues so a failed request does not
render the “暂无可见线索” empty state alongside ErrorState. Prioritize the loading and
error states before the empty-list branch, while preserving the existing clue
list rendering for successful responses.
- Around line 375-382: 更新 CaseWorkspacePage 中的 run 函数及队列刷新流程,避免异步完成后直接调用捕获旧筛选条件的
loadClueQueue。改用 queueRefreshVersion 触发依赖最新 loadClueQueue 的
effect,并在操作完成后递增该刷新状态;保留 onChanged(message) 的现有行为。
---
Nitpick comments:
In `@frontend/src/pages/CaseWorkspacePage.tsx`:
- Around line 757-771: 让审核按钮的 onPress 仅负责在非确认状态下调用 setIsConfirming(true)
并返回;确认状态下改为调用已有的 submitReview,移除其中重复的 normalizedReason、reviewClue
和成功回调逻辑,确保所有审核提交统一经过 submitReview 并执行一致的收尾行为。
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 090051ab-5f12-45fd-b123-1e1f5eb6bfda
📒 Files selected for processing (2)
frontend/src/pages/CaseWorkspacePage.test.tsxfrontend/src/pages/CaseWorkspacePage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/src/pages/CaseWorkspacePage.test.tsx
3c2700d to
78e4f20
Compare
- enable Corepack before frontend dependency operations - install, lint, and build frontend from its working directory with Yarn - replace npm audit with Yarn audit against the public advisory registry - declare Yarn 1.22.22 as the frontend package manager - update workflow documentation and cache references for Yarn
- replace custom modal markup with HeroUI AlertDialog primitives - trap focus within the confirmation dialog during keyboard navigation - support Escape key dismissal and restore focus to the review trigger - extend review tests for focus management and dialog dismissal
- Reset queued clues, pagination, loading state, and errors when no token exists - Prevent sensitive commander review clues from remaining visible after logout - Add coverage for clearing the commander queue on authentication loss
Summary by CodeRabbit