perf(web): add debounce channel search and skip during IME composition - #5393
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThis PR introduces debounced, IME-composition-aware search input handling. The generic data-table toolbar gains a ChangesDebounced composition-aware search
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/default/src/features/channels/components/channels-table.tsx (1)
141-158:⚠️ Potential issue | 🟠 Major | ⚡ Quick winReset and URL sync can resurrect the previous model filter.
This debounced writeback has the same stale-value replay problem as the shared toolbar: after
onResetclearsmodelFilterPendingValue,debouncedModelFilterstill holds the old term until the timer catches up, so the effect on Lines 149-158 writes the old value straight back intocolumnFilters. In practice, Reset/back-forward can restore the previous model filter and fire an extra search. Skip commits when the debounced value no longer matches the current pending value.Suggested fix
useEffect(() => { - if (debouncedModelFilter !== modelFilterFromUrl) { + if ( + debouncedModelFilter === modelFilterPendingValue && + debouncedModelFilter !== modelFilterFromUrl + ) { onColumnFiltersChange((prev) => { const filtered = prev.filter((f) => f.id !== 'model') return debouncedModelFilter ? [...filtered, { id: 'model', value: debouncedModelFilter }] : filtered }) } - }, [debouncedModelFilter, modelFilterFromUrl, onColumnFiltersChange]) + }, [ + debouncedModelFilter, + modelFilterFromUrl, + modelFilterPendingValue, + onColumnFiltersChange, + ])Also applies to: 424-428
🤖 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/default/src/features/channels/components/channels-table.tsx` around lines 141 - 158, The debounced writeback effect can reapply a stale model filter after a reset because debouncedModelFilter may lag behind modelFilterPendingValue; update the effect (the second useEffect that currently checks debouncedModelFilter !== modelFilterFromUrl) to additionally verify that debouncedModelFilter === modelFilterPendingValue before calling onColumnFiltersChange so you only commit debounced values that still match the current pending value (use the existing modelFilterPendingValue variable), keeping the rest of the logic that filters/updates the 'model' column filter intact.
🤖 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/default/src/components/data-table/toolbar.tsx`:
- Around line 171-203: The effect that calls
commitSearchValue(debouncedSearchValue) can apply a stale debounced term; modify
that effect to guard against outdated debounce results by verifying the
debouncedSearchValue matches the current pendingSearchValue (and still not
composing) before calling commitSearchValue. In other words, inside the
React.useEffect that depends on commitSearchValue, debouncedSearchValue and
searchDebounceMs, return early if isSearchComposingRef.current is true or if
debouncedSearchValue !== pendingSearchValue (and optionally if
debouncedSearchValue === lastCommittedSearchValueRef.current) so
commitSearchValue only runs for the latest pending value.
---
Outside diff comments:
In `@web/default/src/features/channels/components/channels-table.tsx`:
- Around line 141-158: The debounced writeback effect can reapply a stale model
filter after a reset because debouncedModelFilter may lag behind
modelFilterPendingValue; update the effect (the second useEffect that currently
checks debouncedModelFilter !== modelFilterFromUrl) to additionally verify that
debouncedModelFilter === modelFilterPendingValue before calling
onColumnFiltersChange so you only commit debounced values that still match the
current pending value (use the existing modelFilterPendingValue variable),
keeping the rest of the logic that filters/updates the 'model' column filter
intact.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4fdcf3ce-d8a3-4dca-9779-f606b8b22546
📒 Files selected for processing (2)
web/default/src/components/data-table/toolbar.tsxweb/default/src/features/channels/components/channels-table.tsx
Important
📝 变更描述 / Description
新版默认前端,渠道搜索未添加防抖,以及中文输入拼音、未选中候选字时也会进入搜索,导致触发大量非预期搜索,给数据库造成压力,当前添加了防抖和中文输入状态的处理
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
(有在本地运行测试,中文输入过程不会触发多余搜索)

Summary by CodeRabbit