Uh oh!
There was an error while loading. Please reload this page.
fix(command-palette): surface record search hits from /api/v1/search (#3371) - #2772
Merged
Merged
Conversation
…3371) The ⌘K command palette only ran a per-object `find({ $search })` fanout (the metadata-driven ADR-0061 search), which misses records that only the global search index (`PinyinSearchPlugin` at `/api/v1/search`) knows about. So typing a well-known record name returned no records even though the backend served them. - types: add `GlobalSearchHit` / `GlobalSearchResult` and an optional `DataSource.searchAll(query, { limit, objects })`. - data-objectstack: implement `searchAll` against `GET /api/v1/search?q=`, unwrapping the `{ query, hits }` envelope and degrading a 404 (plugin absent) to an empty result. - react: `useRecordSearch` prefers `searchAll` when the data source exposes it, mapping ranked hits and scoping them to the app's searchable objects; it falls back to the per-object fanout otherwise. - app-shell: render the record hits grouped by object in the palette. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011s54R8tmaqmvj6xjLPfv7c
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
os-zhuang
marked this pull request as ready for review
July 21, 2026 13:54
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixesobjectstack-ai/objectstack#3371.
Problem
In the Console command palette (⌘K), searching a well-known record name returned no records — e.g. typing
Wayne(with aWayne Enterprisesaccount and aWayne Q1 Expansionopportunity) surfaced only an unrelated report, never the account/opportunity. Meanwhile the backend was healthy:GET /api/v1/search?q=Waynereturned the records correctly.Root cause
The palette's record search (
useRecordSearch) fanned out a per-objectfind({ $search })request to each nav object — the metadata-driven per-object search (ADR-0061). That path does not consult the platform's global search index (PinyinSearchPlugin, served at/api/v1/search), so records that only the global index resolves were silently missing. The palette never called the unified endpoint that actually works.Fix
Wire the palette to the platform's global search endpoint, preferring it over the fanout:
@object-ui/types— addGlobalSearchHit/GlobalSearchResultand an optionalDataSource.searchAll(query, { limit, objects }).@object-ui/data-objectstack— implementsearchAllagainstGET /api/v1/search?q=. It trims/encodes the term, forwardslimit+objectsscoping, unwraps the{ query, hits }(and{ success, data }) envelope, normalizes hits, and degrades a404(search plugin absent on the backend) to an empty result instead of throwing.@object-ui/react—useRecordSearchnow preferssearchAllwhen the data source exposes it: it maps the server-ranked hits, scopes them to the app's searchable (nav) objects, preserves the server ranking (floating an exact-id paste to the top), and keeps the existing debounce / stale-run guarding. WhensearchAllis absent (mock/test adapters, non-ObjectStack backends) it falls back to the original per-object fanout, so existing behavior is unchanged.@object-ui/app-shell— the palette renders the record hits grouped by object (per the issue's ask), alongside the existing metadata results, with the searching pulse on the leading group.Why not just fix the fanout?
The global endpoint is the authoritative, cross-object search the backend already ranks; the per-object
$searchroute is a narrower, per-object matcher. Routing global affordances (⌘K, the search page) through/api/v1/searchis what the issue requests and matches how the backend is designed to serve global search.Testing
packages/data-objectstack/src/searchAll.test.ts(new) — URL/params, envelope unwrap, empty-query short-circuit,404→ empty, non-404 error propagation, malformed-hit dropping.packages/react/src/hooks/__tests__/useRecordSearch.test.ts— newglobal searchAll endpointsuite: preferssearchAlloverfind, forwards the whitelist asobjectsscope, drops out-of-scope hits, floats exact-id paste, surfaces errors.@object-ui/react+@object-ui/data-objectstacksuites and the ADR-0054 ratchet test pass (525 tests).type-checkpasses fordata-objectstack,react, andapp-shell; ESLint clean (no new errors).A changeset is included (
patchfor the affected packages).🤖 Generated with Claude Code
https://claude.ai/code/session_011s54R8tmaqmvj6xjLPfv7c
Generated by Claude Code