Skip to content

Fix topic message search refresh behavior - #1847

Open
rahulbsw wants to merge 9 commits into
kafbat:mainfrom
rahulbsw:issue-999-stop-search-refresh
Open

Fix topic message search refresh behavior#1847
rahulbsw wants to merge 9 commits into
kafbat:mainfrom
rahulbsw:issue-999-stop-search-refresh

Conversation

@rahulbsw

@rahulbsw rahulbsw commented May 12, 2026

Copy link
Copy Markdown
Contributor

Resolves #999

Summary

  • keep the messages search field as a local draft until Refresh is clicked
  • stop clearing the search field from reloading results immediately
  • add regression coverage for the clear-and-refresh flow

Testing

  • pnpm exec tsc --noEmit
  • pnpm exec eslint src/components/Topics/Topic/Messages/Filters/Filters.tsx src/components/Topics/Topic/Messages/Filters/tests/Filters.spec.tsx src/components/common/Search/Search.tsx src/lib/hooks/useMessagesFilters.ts
  • pnpm exec jest --runInBand --runTestsByPath src/components/Topics/Topic/Messages/Filters/tests/Filters.spec.tsx

Summary by CodeRabbit

  • Improvements

    • Search input now supports a configurable debounce and better synchronization between the input, search state, and the q URL parameter.
    • Refresh now applies the current search value, updating URL params accordingly.
    • Clear and search/icon state are handled more consistently, and URL changes occur at refresh as intended.
  • Tests

    • Updated and expanded tests to verify debounced search behavior, clear/reset timing, and correct URL query param updates.

@rahulbsw
rahulbsw requested a review from a team as a code owner May 12, 2026 03:29
@kapybro kapybro Bot added status/triage Issues pending maintainers triage status/triage/manual Manual triage in progress status/triage/completed Automatic triage completed and removed status/triage Issues pending maintainers triage labels May 12, 2026
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5ea915b-041e-4cbd-97d3-1bb651132470

📥 Commits

Reviewing files that changed from the base of the PR and between 43da136 and f6608a3.

📒 Files selected for processing (1)
  • frontend/src/components/Topics/Topic/Messages/Filters/Filters.tsx
💤 Files with no reviewable changes (1)
  • frontend/src/components/Topics/Topic/Messages/Filters/Filters.tsx

📝 Walkthrough

Walkthrough

Search input behavior and filter refresh are refactored to decouple search typing from URL updates. The Search component now accepts a debounceMs prop, useMessagesFilters centralizes URL/store synchronization, and Filters keeps local search state until Refresh applies it.

Changes

Search and Filter Refresh Behavior

Layer / File(s) Summary
Search component debounce parameterization
frontend/src/components/common/Search/Search.tsx
SearchProps gains optional debounceMs (default 500). Search synchronizes showIcon and input value with controlled value and q URL state, and its change handler now works with string values, updates the input ref, and writes q/page when uncontrolled.
useMessagesFilters search synchronization
frontend/src/lib/hooks/useMessagesFilters.ts
Adds syncSearchValue(params, value) to keep stringFilter aligned in the URL and messages-filter store. setSearch and refreshData(nextSearch) both use the shared sync path, and refreshData still toggles r in the same update.
Filters component search state management
frontend/src/components/Topics/Topic/Messages/Filters/Filters.tsx
Introduces local searchValue state synchronized from hook search, switches Search to a controlled input with debounceMs={0}, and passes searchValue into refreshData on refresh.
Test infrastructure and refresh behavior
frontend/src/components/Topics/Topic/Messages/Filters/__tests__/Filters.spec.tsx, frontend/src/components/common/Search/__tests__/Search.spec.tsx
Updates test mocks and helpers to observe URL search params directly, adds coverage for clearing search without immediate URL changes, and verifies Search’s query updates and clear-button behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested labels: scope/frontend

Suggested reviewers: Haarolean

Poem

🐰 I nibble the query and hold it in place,
Then Refresh makes truth appear in its space.
A gentle debounce, a button that waits,
The URL follows when the user dictates.

🚥 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 Clearly describes the topic message search refresh fix.
Linked Issues check ✅ Passed Implements the clear-and-refresh behavior requested in #999 and adds regression coverage.
Out of Scope Changes check ✅ Passed The changes stay focused on search refresh behavior and supporting tests, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@github-actions github-actions 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.

Hi rahulbsw! 👋

Welcome, and thank you for opening your first PR in the repo!

Please wait for triaging by our maintainers.

Please take a look at our contributing guide.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/components/common/Search/Search.tsx`:
- Around line 47-61: The debounced handleChange captures the outer searchParams
and can overwrite concurrent URL updates; update the branch that calls
setSearchParams to use the functional updater form of setSearchParams (instead
of mutating the captured searchParams) so you compute the new URLSearchParams
from the previous state, set 'q' to nextValue and reset 'page' to '1' only if a
page param exists, then return the new params; locate this logic in the
handleChange callback inside the useDebouncedCallback and modify it to derive
and return a fresh URLSearchParams based on the previous params.
🪄 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: d619a9f2-58e2-4f91-88aa-48231730b29d

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf06dd and d2bf2b4.

📒 Files selected for processing (4)
  • frontend/src/components/Topics/Topic/Messages/Filters/Filters.tsx
  • frontend/src/components/Topics/Topic/Messages/Filters/__tests__/Filters.spec.tsx
  • frontend/src/components/common/Search/Search.tsx
  • frontend/src/lib/hooks/useMessagesFilters.ts

Comment thread frontend/src/components/common/Search/Search.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/triage/completed Automatic triage completed status/triage/manual Manual triage in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop search button automatically refreshes result table

1 participant