Skip to content

feat: Super Search — global command palette (Cmd+K)#81

Merged
Systemsaholic merged 14 commits intomainfrom
feature/super-search
Mar 22, 2026
Merged

feat: Super Search — global command palette (Cmd+K)#81
Systemsaholic merged 14 commits intomainfrom
feature/super-search

Conversation

@Systemsaholic
Copy link
Copy Markdown
Owner

@Systemsaholic Systemsaholic commented Mar 22, 2026

Summary

  • Global command palette (Cmd+K) in the admin navbar that searches across trips and contacts instantly
  • New unified GET /api/v1/search?q=<term>&limit=5 endpoint with proper access control via TripAccessService and ContactAccessService
  • Rich result rows: trip name + ref number + status badge + dates, contact name + email + phone
  • "View all" navigates to filtered table view (/trips?search=term, /contacts?search=term)
  • 300ms debounce, min 2 chars, shouldFilter={false} for server-driven results

Files Changed (14 commits)

  • Backend: SearchModule, SearchService, SearchController, SearchQueryDto — parallel search with Promise.allSettled()
  • Frontend: SuperSearchDialog (Dialog + Command), useSearch hook, TopNav wiring
  • Shared types: SearchResponseDto, TripSearchResult, ContactSearchResult
  • List pages: Trips + contacts pages now support ?search= URL param with Suspense boundary

Test plan

  • Open admin, click Search button or press Cmd+K — dialog opens
  • Type 2+ chars — results appear after 300ms debounce
  • Verify trips show: name, ref number, status badge, dates
  • Verify contacts show: name, email, phone
  • Click a trip result — navigates to trip detail, dialog closes
  • Click a contact result — navigates to contact detail, dialog closes
  • Click "View all trip results" — navigates to /trips?search=term in table view
  • Press Escape — dialog closes
  • Type 1 char — no search fires
  • Clear input after searching — stale results don't flash

Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added unified search dialog accessible via Cmd+K/Ctrl+K to find trips and contacts across the app.
    • Search results display grouped by trips and contacts with relevant details and status information.
  • Improvements

    • Search queries now reflected in page URLs for shareable filtered views.
    • Trip and contact pages automatically sync with URL search parameters.

Systemsaholic and others added 14 commits March 22, 2026 09:54
Fixes type mismatch where getTripStatusVariant() expects TripStatus
but received plain string from the base SearchResultItem interface.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
"View all" from Super Search now navigates to /trips?search=term or
/contacts?search=term. List pages read the param on mount, pre-fill
the search input, and filter results. Trips page switches to table
view when search param is present.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
useState only captures initial value once — useSearchParams resolves
async in Next.js, so the initial render has empty params. Use useEffect
to sync urlSearch into both searchInput and filters when it resolves.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Next.js 15 requires useSearchParams() to be inside a Suspense boundary
for static page generation. Wrap trips and contacts pages with Suspense.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tailfire-client Ready Ready Preview, Comment Mar 22, 2026 5:00pm
tailfire-ota Ready Ready Preview, Comment Mar 22, 2026 5:00pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 779021a9-4c77-49c6-a55a-fe236a751d6e

📥 Commits

Reviewing files that changed from the base of the PR and between 225ce68 and d2416f0.

📒 Files selected for processing (12)
  • apps/admin/src/app/contacts/page.tsx
  • apps/admin/src/app/trips/page.tsx
  • apps/admin/src/components/layout/super-search-dialog.tsx
  • apps/admin/src/components/layout/top-nav.tsx
  • apps/admin/src/hooks/use-search.ts
  • apps/api/src/app.module.ts
  • apps/api/src/search/dto/search.dto.ts
  • apps/api/src/search/search.controller.ts
  • apps/api/src/search/search.module.ts
  • apps/api/src/search/search.service.ts
  • packages/shared-types/src/api/index.ts
  • packages/shared-types/src/api/search.types.ts

📝 Walkthrough

Walkthrough

The PR introduces a unified global search feature accessible via keyboard shortcut. It updates the contacts and trips pages to synchronize URL search parameters with UI state, adds a new Super Search Dialog component in the top navigation, creates a backend search endpoint that concurrently searches trips and contacts, and exports shared TypeScript types defining search result structures.

Changes

Cohort / File(s) Summary
Admin UI - Page Wrappers
apps/admin/src/app/contacts/page.tsx, apps/admin/src/app/trips/page.tsx
Wrapped pages with Suspense boundaries and added URL-driven search synchronization. Both pages now read the search query parameter and update internal state (searchInput, filters.search) when the URL changes. Trips page additionally switches to table view when search is active.
Admin UI - Search Dialog & Integration
apps/admin/src/components/layout/super-search-dialog.tsx, apps/admin/src/components/layout/top-nav.tsx
Added new SuperSearchDialog component with Cmd+K/Ctrl+K keyboard shortcut support, integrated into TopNav with a searchOpen state to control dialog visibility and closure.
Admin Frontend - Search Hook
apps/admin/src/hooks/use-search.ts
New useSearch hook that debounces queries by 300ms and performs GET requests to the /search endpoint via TanStack React Query, only executing when query length ≥ 2 characters.
API - Search Module
apps/api/src/search/search.controller.ts, apps/api/src/search/search.service.ts, apps/api/src/search/dto/search.dto.ts, apps/api/src/search/search.module.ts, apps/api/src/app.module.ts
Introduced new SearchModule with a controller exposing GET /search, a service performing concurrent searches across trips and contacts with partial failure handling, and DTOs for query validation (requiring minimum 2-character query, optional limit 1–10, default 5).
Shared Types
packages/shared-types/src/api/search.types.ts, packages/shared-types/src/api/index.ts
Added new search type definitions including SearchResultType, TripSearchResult, ContactSearchResult, SearchResultGroup, and SearchResponseDto with discriminated union types for typed search results.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant TopNav as TopNav Component
    participant Dialog as SuperSearchDialog
    participant Hook as useSearch Hook
    participant API as Search API
    participant Services as Trip/Contact Services
    
    User->>TopNav: Press Cmd+K or click search
    TopNav->>Dialog: Open dialog
    User->>Dialog: Type search query
    Dialog->>Hook: useSearch(query)
    Hook->>Hook: Debounce for 300ms
    Hook->>API: GET /search?q=query
    API->>Services: Concurrent search trips & contacts
    Services-->>API: Return results
    API-->>Hook: SearchResponseDto
    Hook-->>Dialog: Results with trips & contacts
    Dialog->>User: Display grouped results
    User->>Dialog: Click result item
    Dialog->>Dialog: Navigate via router.push()
    Dialog->>TopNav: Close dialog
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

Possibly related PRs

Poem

🔍 A rabbit hops through code so fine,
With Cmd+K, the searches align!
Trips and contacts dance in sync,
From frontend views to database's link—
One global search makes all dreams rhyme! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/super-search

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 and usage tips.

Tip

CodeRabbit can approve the review once all CodeRabbit's comments are resolved.

Enable the reviews.request_changes_workflow setting to automatically approve the review once all CodeRabbit's comments are resolved.

@Systemsaholic Systemsaholic merged commit 67036c2 into main Mar 22, 2026
3 of 4 checks passed
@Systemsaholic Systemsaholic deleted the feature/super-search branch March 22, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant