Skip to content

feat(search): /api/sessions/messages/search for full-text message search - #329

Closed
RoyaLemonade wants to merge 6 commits into
ompweb-dev:mainfrom
RoyaLemonade:pr/message-search
Closed

RoyaLemonade wants to merge 6 commits into
ompweb-dev:mainfrom
RoyaLemonade:pr/message-search

Conversation

@RoyaLemonade

Copy link
Copy Markdown
Contributor

GET /api/sessions/search is already taken in v0.6.0 by the sidebar's relevance search, which streams
NDJSON { scores } batches for the session list - so this endpoint lives under a different path and
returns message hits, not scores. lib/session-search.ts (the ranking) is untouched.

Native clients can only filter the session list they already hold; finding a message that scrolled
out of view means opening sessions one by one. This adds a read-only endpoint and leaves the web UI
unchanged (a follow-up can consume it).

  • GET /api/sessions/messages/search?q=&limit=&cursor=.
  • Scans .jsonl files newest-first (newest session, newest line), so the most recent matches win
    when the budget runs out.
  • Bounded by construction: 5 s deadline (armed after the directory listing, so a large session folder
    cannot eat the scan budget), 64 MiB total / 16 MiB per file, 100 results max, 1 MiB max line; files
    above 64 MiB are skipped. At most two scans run per process; further requests get 429 +
    Retry-After.
  • partial plus an opaque, query-bound cursor resume the scan; the cursor points at a line start
    (only a single >1 MiB line is skipped), so it stays small and a rewritten file cannot make it skip
    or duplicate lines.
  • Matches user/assistant text blocks only (thinking and tool results are not searchable, like the web
    transcript), case-insensitive substring, and returns a one-line snippet with UTF-16
    matchStart/matchEnd plus session title/cwd/entryId/role/timestamp. Offsets are computed on the
    original text, so case mappings that change length cannot shift the highlight.
  • Input validated (query_required, query_too_long, invalid_limit, invalid_cursor,
    cursor_query_mismatch), Cache-Control: no-store, and 500 responses carry a generic message
    (details stay in the server log).
  • Auth is inherited from the existing /api/* password gate.
  • GET /api/app-info advertises capabilities.messageSearch: true, so native clients hide their
    message-search mode on a server without this route (it answers 404) instead of asking and failing.

Tests: lib/session-message-search.test.mjs (ordering, offsets, no tool results, pagination across
tiny chunk boundaries and line-aligned chunk edges, lines spanning several chunks, time/byte budget
resume, large-file skip, cursor binding, equal-mtime fallback, malformed lines, production listing,
route errors, 429 while both scan slots are taken).

Note: stacked on #324 - that PR adds GET /api/app-info and the capability object this
extends. Merge that one first; GitHub drops the parent commit from this diff afterwards.

Context: message search is used by the native Android client (separate PR to follow); the web UI can
adopt it later.

A native client needs to know which server-side features exist before it
offers them. GET /api/app-info rides the normal /api auth gate and returns
the package name, version and API level, never credentials or settings.
A native client keeps its radio asleep for the whole idle heartbeat, so a
per-connection interval is a battery win without touching the shared
browser stream. GET /api/events?heartbeat=<seconds> accepts 15-110 s and
falls back to the 30 s default for anything else; capabilities advertise
it as heartbeatParam.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d08d796-7a6a-40f7-8f47-679fd80c192e
Commits

Reviewing files that changed from the base of the PR and between 1317bf3 and 48adb30.

Files selected for processing: 10
  • CHANGELOG.md
  • app/api/app-info/route.ts
  • app/api/events/route.ts
  • app/api/sessions/messages/search/route.ts
  • lib/app-info-route.test.mjs
  • lib/event-stream-hub.test.mjs
  • lib/event-stream-hub.ts
  • lib/session-message-search.test.mjs
  • lib/session-message-search.ts
  • lib/web-auth.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@kilo-code-bot

kilo-code-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

📊 Overall: Like finding a unicorn in production — I didn't think clean PRs existed anymore, but here we are.

Files Reviewed (9 files)
  • CHANGELOG.md
  • app/api/app-info/route.ts
  • app/api/events/route.ts
  • app/api/sessions/messages/search/route.ts
  • lib/app-info-route.test.mjs
  • lib/event-stream-hub.test.mjs
  • lib/event-stream-hub.ts
  • lib/session-message-search.test.mjs
  • lib/session-message-search.ts

Reviewed by free · Input: 67.6K · Output: 1.5K · Cached: 193.7K

The handshake answers `name: "ompweb"`, which is not the npm package name;
the changelog now says so. Two coverage gaps from review: the proxy test
asserts `/api/app-info` sits behind the password gate, and a route-level test
sends `?heartbeat=60` and proves the keep-alive is not the fixed 30 s default.
@kahme247 kahme247 added the needs rebase Rebase onto current main; needs re-review label Nov 5, 2026
@kahme247

kahme247 commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

The Bun server/daemon architecture has landed on main, so this PR needs to be rebased and re-reviewed against the new architecture before it can be merged. Please rebase onto current main, resolve the conflicts, and request re-review once CI is green.

@RoyaLemonade

Copy link
Copy Markdown
Contributor Author

Superseded by #410, which carries the same change as a Bun-server PR against current main (this branch was written for the Next.js server and no longer applies).

The new PR keeps the scope of this one, with its own tests and a description of what changed. Closing this in favour of it.

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

Labels

needs rebase Rebase onto current main; needs re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants