Skip to content

Add global keyword search field to the site header - #467

Draft
rnambaale wants to merge 5 commits into
mainfrom
feat/global-search
Draft

rnambaale wants to merge 5 commits into
mainfrom
feat/global-search

Conversation

@rnambaale

@rnambaale rnambaale commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds the frontend for the backend's new GET /search endpoint (keyword mode): a search field in the top navigation that searches coaching sessions, goals, actions, agreements and topics and links each hit to where it lives in the app. Results render in a dropdown under the field with keyboard navigation, load-more pagination, and inline loading, empty and error states.

GitHub Issue: [Resolves] refactor-group/refactor-platform-rs#404

Changes

  • src/types/search.ts - hit tagged union with Option-wrapped nullable fields, typed error codes, a parser that drops unknown hit types, and splitSnippet so <mark> markers render as text nodes, never HTML.
  • src/lib/api/search.ts - SearchApi.search returning a neverthrow ResultAsync<SearchResponse, SearchError>; useSearch hook with 250 ms debounce, AbortController cancellation, reset to page one on query or filter change, and cursor-based loadMore.
  • src/lib/utils/search-hit-href.ts - maps hits to routes: sessions to their page, actions to the actions panel with highlight, goals to their creating session's goals panel or the dashboard, agreements and topics to their session.
  • src/components/ui/search/ - GlobalSearch (cmdk-based field, ⌘K / / focus shortcut, skeleton loading rows, empty and error states) and SearchSnippet.
  • src/components/ui/site-header.tsx - renders the field between the sidebar toggle and the right-hand nav.
  • src/components/ui/command.tsx - fixes the shared CommandItem disabled selector. cmdk 1.x always emits data-disabled="false", so data-[disabled] matched every item and made results unclickable; now data-[disabled=true].
  • Tests for the parser, URL helper, hook (debounce, abort, error mapping, load more, filter reset) and component.

Screenshots / Videos Showing UI Changes

Screenshot 2026-09-23 at 3 03 24 PM

Testing Strategy

  • npm run test — new suites under __tests__/types/search.test.ts, __tests__/lib/utils/search-hit-href.test.ts, __tests__/lib/api/search.test.tsx, __tests__/components/ui/search/.
  • Manually against a backend with the search PR: type two or more characters in the header field, confirm results appear after a short pause, click and Enter both navigate, Escape clears, ⌘K focuses the field from outside an input.
  • Verify the trailing-space opt-out of prefix matching still works (plann vs plann).
  • Verify agreement and topic hits are clickable; they are rendered disabled if the response lacks coaching_session_id.

Concerns

describe any concerns that might be worth mentioning or discussing

@rnambaale
rnambaale marked this pull request as draft September 23, 2026 11:56
@rnambaale rnambaale self-assigned this Sep 23, 2026
@rnambaale rnambaale added the feature work Specifically implementing a new feature label Sep 23, 2026
@rnambaale rnambaale added this to the 1.0.0-beta3 milestone Sep 23, 2026
@rnambaale
rnambaale requested a review from jhodapp September 23, 2026 12:24
@jhodapp jhodapp modified the milestones: 1.0.0-beta3, 1.0.0-beta4 Sep 24, 2026
Adds a GET /search client with typed errors, a debounced and cancellable
useSearch hook with cursor-based load-more, and a header search field
that renders snippet highlights as text nodes and deep-links hits to
their session panels.

Also fixes the shared CommandItem disabled selector: cmdk 1.x always
emits data-disabled="false", so data-[disabled] matched every item and
made results unclickable.
@jhodapp jhodapp moved this to 🏗 In progress in Refactor Coaching Platform Sep 26, 2026
@jhodapp jhodapp changed the title feat(search): add global keyword search field to the site header Add global keyword search field to the site header Sep 26, 2026
jhodapp and others added 4 commits September 26, 2026 10:23
Renames session_display_title to session_title on action and agreement
hits, drops display_title from session hits in favour of title, and
unescapes HTML entities in snippet segments now that the backend escapes
stored text before adding <mark> markers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature work Specifically implementing a new feature

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

2 participants