Skip to content

Make chat search fast and reliable using only its dedicated index - #993

Merged
ReganBell merged 2 commits into
mainfrom
codex/search-index-only
Sep 8, 2026
Merged

Make chat search fast and reliable using only its dedicated index#993
ReganBell merged 2 commits into
mainfrom
codex/search-index-only

Conversation

@ReganBell

@ReganBell ReganBell commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Chat search can time out because it repeatedly searches both the dedicated index and legacy entry history for each visible conversation. It also loads legacy history again to resolve result metadata. This change searches only session_entry_search, batches the visible-session filter, and returns participant-specific metadata directly with each hit.

Two ordered migrations first install transactional indexing for inserts, edits, and deletes, then fill missing historical rows, including holes below the highest indexed sequence. The trigger also covers older writers during rollout or rollback. The backfill and coverage audit exclude indexed rows before parsing payloads, confirmed with EXPLAIN; text extraction runs once per missing row. Backfill runs as one transaction and may take minutes on large histories; it must finish in the separate migration task before promotion. The repair script now measures actual gaps; the delayed, best-effort turn-end indexer is removed. Participant visibility windows and project membership checks remain enforced.

The search dialog invalidates stale requests immediately when the query changes or closes, keeps the 150 ms debounce, and ignores ordinary Enter while loading. Server failures no longer incorrectly tell the user their connection is broken.

Validation: 97 affected unit/API/UI regression tests and all 53 Postgres store tests passed, plus root and web typechecks, lint, formatting, and the web build. Independent migration/concurrency and authorization/UI reviews completed. Live browser QA used the real local core, web stack, and Postgres: new user/assistant messages, prefix searches, empty results, and rapid query changes. On that small synthetic dataset, API requests took 2–16 ms, excluding debounce. Slack pool connection checks failed, so this web-specific QA used the supported no-Slack dev mode.

Demo uses only synthetic data. Before: original UI with a deliberately failed search API (to reproduce the error presentation, not to benchmark the old backend). After: successful search against real local Postgres. A persistent hosted dev demo is impractical because it requires the local authenticated core/database.

Before After
Original failure presentation Working indexed search

@ReganBell
ReganBell merged commit 75b7190 into main Sep 8, 2026
20 checks passed
@ReganBell
ReganBell deleted the codex/search-index-only branch September 8, 2026 21:53
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.

2 participants