fix(layout): wire topbar search input to search query param (#205) - #206
Conversation
|
| Filename | Overview |
|---|---|
| packages/frontend/src/components/Layout.tsx | Adds the URL-backed topbar and service filtering, but navigation cancellation still leaves a stale debounce race. |
| packages/frontend/src/pages/CloudConsoleHomePage.tsx | Reads the shared search parameter and consistently filters console service cards. |
| packages/frontend/src/features/cloud-console/CloudConsoleSections.tsx | Adds an explicit empty state for filtered and naturally empty service grids. |
| packages/frontend/src/features/cloud-console/types.ts | Extends ServiceGrid props with the optional search text used by its empty state. |
| packages/api/src/routes/clouds.search.test.ts | Adds focused route and adapter regression coverage for the resource search parameter. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Input[Topbar input] --> Timer[300 ms debounce]
Timer --> URL[search query parameter]
URL --> Nav[Sidebar service filter]
URL --> Home[Console service grid]
Local[Resource toolbar search] --> Query[Cloud Explorer resource query]
Reviews (5): Last reviewed commit: "fix(layout): wire topbar search to servi..." | Re-trigger Greptile
| const commit = useCallback((value: string) => { | ||
| setSearchParams( | ||
| (prev) => { | ||
| const next = new URLSearchParams(prev) | ||
| if (value) { | ||
| next.set('search', value) | ||
| } else { | ||
| next.delete('search') | ||
| } | ||
| return next | ||
| }, | ||
| {replace: true}, | ||
| ) | ||
| }, [setSearchParams]) |
There was a problem hiding this comment.
Resource query remains disconnected
When a user searches from a Cloud Explorer page, commit only updates the URL while DynamicResourceView continues querying with its independent local search state, so the resource list is neither refetched nor filtered.
Knowledge Base Used: Cloud Explorer interface
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Addressed the review feedback in commit \e17a12:
|
|
Pushed commit \9638c4b\ addressing the review findings:
|
|
Pushed commit \80d89dc: when navigating to a new pathname before the debounce timer fires, the draft is now explicitly restored from the destination route's \search\ query parameter, ensuring the controlled input never displays an uncommitted filter string on an unfiltered view. |
|
Hi @amasen02 Thanks for the careful debounce and URL synchronization work. The follow-up fixes for Escape, navigation, and stale timers are appreciated. Before we can merge this, the branch needs to be rebased on current More importantly, the issue describes global search across services or resources. The current implementation only applies the topbar query to the resource list of the active Cloud Explorer service. On Console Home, the service cards and sidebar do not react, so the topbar still has no visible search result there. Could you please keep Please update the tests for the current contracts and include manual verification for Console Home, Cloud Explorer resource filtering, navigation during a pending debounce, and Escape clearing. Once that is rebased and green, this will be in a good position to merge. |
…loci-io#205) Signed-off-by: amasen02 <amasen02@users.noreply.github.com>
80d89dc to
23dabc6
Compare
|
Hi @fredpena, Thank you for the detailed and constructive architectural guidance! All points have been addressed in commit
Verification Evidence:
|
| useEffect(() => { | ||
| if (debounceRef.current) { | ||
| clearTimeout(debounceRef.current) | ||
| debounceRef.current = null | ||
| } | ||
| const urlSearch = searchParams.get('search') ?? '' | ||
| setDraft(urlSearch) | ||
| }, [location.pathname]) |
There was a problem hiding this comment.
Stale debounce survives navigation
When navigation commits immediately before the pending 300 ms timer expires, the timer writes the previous route's search value into the destination URL before these passive effects cancel it, replacing the destination's intended search state and filtering with stale text.
Knowledge Base Used: Cloud Explorer interface
|
Hi @amasen02 Thanks for the thorough follow-through on the architecture feedback, all four points are addressed and I verified each independently rather than just from the description: the rebase is clean, DynamicResourceView is back to upstream so resource filtering stays scoped to the active service, the test uses the current metadata shape, and global search now filters the sidebar and Console Home catalog rather than sharing state with the resource filter. Tried it live: typing "dynamo" narrows both the sidebar and the Console Home cards to DynamoDB and updates the URL, Escape clears it. |
Summary
Fixes #205 — the top nav search bar had no
onChangehandler and was entirely uncontrolled.Root Cause
Layout.tsxused a bare<input>with no value, no handler, and no URL integration.Solution
Extracted a
TopbarSearchcontrolled component that:?search=URL query param (survives refresh/nav viauseSearchParams){replace: true}to avoid per-keystroke history entriesaria-labelfor screen-reader accessibilityTests
4 new regression tests in
packages/api/src/routes/clouds.search.test.ts(bun):?search=tolistResourcesundefinedwhen no param suppliedAll 729 existing API tests continue to pass. TypeScript (
tsc --noEmit) reports 0 errors.Checklist