Skip to content

feat(dashboard): Search Inbox items, Automations, and memories through /api/search - #4106

Merged
BYK merged 3 commits into
mainfrom
feat/omni-search-inbox-automations
Nov 23, 2026
Merged

BYK merged 3 commits into
mainfrom
feat/omni-search-inbox-automations

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Step 2 of #4095. Cmd+K now sends one GET /api/search?q=&sources=inboxItems,automations,memories request for each typed query. Before, it sent a list search to /api/inbox-items?q=, /api/automations?q=, and /api/user-pages/memory/memories?q=.

What matches. Each source still matches the text that Cmd+K matched before:

  • Inbox items: title and body.
  • Automations: title, instruction, skill, and event trigger. A pasted Automation id or dashboard URL also matches.
  • Memories: the memory text.

A word matches when it starts a word of the text, so results show while the last word is still half typed. A typo in an Inbox item or Automation title still matches when the trigram overlap is above the pg_trgm default threshold, for example one missing letter in a longer word. An untitled Automation shows the same title as on the Automations list.

One ranking. The parts that memory recall already used are now in packages/junior/src/search/:

  • typed-query.ts turns typed text into a prefix tsquery, a fuzzy text, and tokens for id matches.
  • text-match.ts builds the SQL for prefix and fuzzy matches and their ranks (ts_rank_cd, word_similarity), and holds the capped rank window.
  • match-ranking.ts dense-ranks each match leg (exact, lexical, fuzzy, vector) and fuses the legs with reciprocal rank fusion.

rankMemoryMatches now calls the same fusion, and memory's withDenseRanks moved here. Each source works like memory recall: its GIN indexes find the matches, it keeps a capped window of the newest matches, and it ranks only those.

Memories. The memories source is memory recall itself. searchTypedMemories in the memory store runs the same lexical (ts_rank_cd) and pgvector legs, fused by rankMemoryMatches, with recall's vector cutoff. Its one change for typed text is that each query word also matches the words it starts. It reads active public memory only, as the Memories page does: private memories, other Users' memories, and archived, superseded, or expired memories never show. The vector leg embeds the typed text once per search. When the embedding fails, words alone match.

Indexes.

  • Migration 0163 adds the pg_trgm extension. A self-hosted database now needs it as well as pgvector, and the docs say so.
  • Migration 0164 builds four GIN indexes with CONCURRENTLY: a weighted simple tsvector document for each table (title weighted A, other text B), and a gin_trgm_ops index on each lowercase title.
  • The Automation indexes are partial (status <> 'deleted').
  • Memories use the existing junior_memory_memories_search_idx and vector index.

Shaped for an agent tool. omniSearch in chat/omni-search/search.ts runs the search, outside the HTTP route. Each source applies its own page's access rule there: the viewer's own Inbox, the Automations that the viewer owns or that are shared to them, and public memory. An Omni Search tool for Junior can call the same function later. This PR does not add the tool.

Open items:

  • Embeddings (the vector leg) for Inbox items and Automations need an embedding pipeline and a backfill for each source.
  • With junior_inbox_items in the big-table list, the versions poll shows a full scan on junior_inbox_items_open_action_owner_idx. It has a named allowance here and needs its own fix.
  • To-dos are the next step of the issue.
Desktop Mobile
Dark Cmd+K results for "revie", dark, desktop Cmd+K results for "revie", dark, mobile
Light Cmd+K results for "revie", light, desktop Cmd+K results for "revie", light, mobile

via @BYK.

--

View Session [Sentry]

Add GET /api/search?q=&sources=, which Cmd+K reads once for each typed
query instead of two list searches. It still matches Inbox item bodies
and Automation instructions, skills, and event triggers, not only titles.

Each source filters with GIN indexes: a weighted simple-config tsvector
for word-prefix matches, and a pg_trgm title index for typos. It ranks a
capped window of the newest matches. The ranks of each match leg fuse
with the shared search ranking that memory recall now uses too. The
search runs in omniSearch, outside the route, with each source's own
page access rule.

Refs #4095

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from BYK November 23, 2026 16:31
@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 23, 2026 5:05pm UTC

Request Review

@blacksmith-sh

This comment has been minimized.

@BYK
BYK enabled auto-merge (squash) November 23, 2026 16:41
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

19 screenshot changes — 15 changed · 4 added · 0 removed

Review screenshots in Frameshift

Conversation Event Log · Mobile
Conversation Event Log · Mobile
Changed
Conversation Long Transcript Memory · Desktop
Conversation Long Transcript Memory · Desktop
Changed
Conversation Title · Desktop
Conversation Title · Desktop
Changed
Inbox Palette Feedback · Desktop
Inbox Palette Feedback · Desktop
Changed
Inbox Palette Feedback · Mobile
Inbox Palette Feedback · Mobile
Changed
Inbox Palette Feedback Light · Desktop
Inbox Palette Feedback Light · Desktop
Changed
Show 9 more changed screenshots
Inbox Palette Feedback Light · Mobile
Inbox Palette Feedback Light · Mobile
Changed
Inbox Palette Pages · Desktop
Inbox Palette Pages · Desktop
Changed
Inbox Palette Pages · Mobile
Inbox Palette Pages · Mobile
Changed
Inbox Palette Pages Light · Desktop
Inbox Palette Pages Light · Desktop
Changed
Inbox Palette Pages Light · Mobile
Inbox Palette Pages Light · Mobile
Changed
Lead Home · Mobile
Lead Home · Mobile
Changed
System Cache Health 24h · Desktop
System Cache Health 24h · Desktop
Changed
System Cache Health Stale · Desktop
System Cache Health Stale · Desktop
Changed
System Cache Warming Refill · Desktop
System Cache Warming Refill · Desktop
Changed

sentry-junior Bot and others added 2 commits November 23, 2026 17:03
Cmd+K's Memories group now reads the memories source of /api/search
with its other searched groups, in one request. The source runs the
hybrid word and vector search of automatic recall over active public
memory, with recall's vector cutoff, and matches word prefixes so a
half-typed word still finds its memory.

Co-Authored-By: BYK <[email protected]>
@sentry-junior sentry-junior Bot changed the title feat(dashboard): Search Inbox items and Automations through /api/search feat(dashboard): Search Inbox items, Automations, and memories through /api/search Nov 23, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a6ae7fe. Configure here.

const tsquery = sql`(
SELECT COALESCE(
string_agg(quote_literal(term), ' | ')::tsquery,
string_agg(${queryTerm}, ' | ')::tsquery,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stemmed prefix search breaks typeahead

Medium Severity

Typed memory search adds :* to lexemes from to_tsvector('english'), so the prefix is applied after stemming. Half-typed inflected words then miss the stored stem: runn does not match running (run), then the full word matches again. Inbox and Automations avoid this with simple. Cmd+K can drop a memory while the last word is still being typed.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a6ae7fe. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #4119. Typed search now adds a simple word-prefix leg on memory text, from its own partial GIN index, fused with the english and vector legs. runn finds "running" while the word is still half typed. Agent recall doesn't change.

@BYK
BYK merged commit bc798f7 into main Nov 23, 2026
54 checks passed
@BYK
BYK deleted the feat/omni-search-inbox-automations branch November 23, 2026 17:21
BYK added a commit that referenced this pull request Nov 23, 2026
…d+K search (#4119)

Follow-up to #4106, part of #4095.

**Half-typed words.** Typed memory search added `:*` to `english` stems,
so a half-typed inflected word missed its memory: `runn` did not match
"running" (stem `run`) until the word was complete. Typed search now
adds a `simple` word-prefix leg, the same match that Inbox items and
Automations use. It reads a new partial GIN index on active rows
(`0166_memory_prefix_index`, created `CONCURRENTLY`). Its rank is fused
with the `english` and vector legs in the shared ranking, so it adds a
parallel statement and no serial round. The `english` leg goes back to
recall's exact stem match. Agent recall does not change.

**Embedding calls.**
- The vector leg runs only when the typed text has 3 or more characters.
Shorter text matches by words alone.
- The query embedding is cached in the state adapter for 10 minutes,
keyed by model and normalized text. Typing the same text again makes no
model call.
- Each embedding call adds its cost to a daily `junior_stats` counter
(`search` / `embedding_cost_micro_usd`, one row per model). A search has
no Conversation to bill. One short query costs a fraction of a
micro-USD, so plain rounding would store 0 every time. The new
`usdToMicroUsdUnbiased` in `db/micro-usd.ts` rounds up with the chance
of the fraction, so the daily total in whole micro-USD stays right on
average. The write runs beside the vector query.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Afdfa7bbd318b8b6ac1a5022815b6670e -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Afdfa7bbd318b8b6ac1a5022815b6670e)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Afdfa7bbd318b8b6ac1a5022815b6670e/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
sentry-junior Bot added a commit that referenced this pull request Nov 25, 2026
…twork idle

#3589 and #3974 wrapped a hover in
`toPass` to retry around a race in the page, and #4049
later found that one of those retries hid a real race. Specs also wait
for network idle (#4011, #4106), which is a guess about
timing: the versions poll and other background reads keep the network
busy.

test-architecture:check gets dashboard-e2e-retry-loop and
dashboard-e2e-network-idle rules for specs and helpers. Their baselines
are today's 9 and 13 uses, so only a change that adds one fails.

Refs #4341

Co-Authored-By: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — a6ae7fe8 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant