Chat search: multi-room listing no longer advises a chunk-losing --after #71

Merged
eureka merged 2 commits from eureka/chat-listing-continuation into main 2026-11-17 03:46:25 +00:00
Owner

Closes follow-up gamecult-chat:follow_up:chat-search-listing-cursor in part (the lossy advice); the owner fix is specified below and not built here.

Defect

huginn chat search with no texts lists chunks oldest-first by ts_start_ms and, when truncated, printed --after <last.ts_end_ms + 1>. --after keeps chunks whose span ends at or after the instant. Across rooms the spans overlap (r1 [1..10], r2 [5..20], r3 [6..8], top_k=1: page 1 = r1, --after 11 returns r2 and skips r3). Chunks in one room do not overlap, so single-room paging is correct.

This PR

render::chat_hits takes one_room; the CLI passes rooms.len() == 1. A truncated listing of one room keeps the --after line; any other listing says --after cannot continue several rooms and to list one --room at a time. Test: chat_search_prints_cited_messages_and_sends_its_selectors covers one room, none named, two named. cargo clippy --workspace --all-targets -- -D warnings clean on the pinned 1.95.0 (with #72's one-line fix applied; main alone is red there).

Spec for the owner fix (not in this PR)

  • Owner: the daemon's chat listing (search_chat, ChatIndex::chat_scroll), not the renderer. The continuation is a typed ChatCursor { ts_start_ms, after_event_id } carried in ChatQuery.cursor and returned in ChatHits.next; the CLI prints --cursor <token>, --after stays a time filter only.
  • Qdrant order_by ts_start_ms has no id tiebreak, so ties at one ts_start_ms need the scroll to start at start_from = ts_start_ms inclusive and skip hits up to and including after_event_id in a stable (room, first_event_id) order; the fake index must order the same way.
  • Wire change: ChatQuery and ChatHits gain an optional field; schemas under schemas/ regenerate; daemon and CLI deploy together (daemon first).
  • Also fold in: chat_hit filtering a boundary chunk to nothing leaves truncated true with fewer than k hits (compute truncation after the filter, or continue from the last scrolled chunk, not the last printed). Bodies already print on one line with \n escaped.
  • Cost: ~5 files (wire.rs, sources/mod.rs, index/qdrant.rs, index/fakes.rs, CLI) plus a deploy; not a one-sitting small fix, hence the guard here.
Closes follow-up `gamecult-chat:follow_up:chat-search-listing-cursor` in part (the lossy advice); the owner fix is specified below and not built here. ## Defect `huginn chat search` with no texts lists chunks oldest-first by `ts_start_ms` and, when truncated, printed `--after <last.ts_end_ms + 1>`. `--after` keeps chunks whose span *ends* at or after the instant. Across rooms the spans overlap (r1 [1..10], r2 [5..20], r3 [6..8], top_k=1: page 1 = r1, `--after 11` returns r2 and skips r3). Chunks in one room do not overlap, so single-room paging is correct. ## This PR `render::chat_hits` takes `one_room`; the CLI passes `rooms.len() == 1`. A truncated listing of one room keeps the `--after` line; any other listing says `--after` cannot continue several rooms and to list one `--room` at a time. Test: `chat_search_prints_cited_messages_and_sends_its_selectors` covers one room, none named, two named. `cargo clippy --workspace --all-targets -- -D warnings` clean on the pinned 1.95.0 (with #72's one-line fix applied; main alone is red there). ## Spec for the owner fix (not in this PR) - Owner: the daemon's chat listing (`search_chat`, `ChatIndex::chat_scroll`), not the renderer. The continuation is a typed `ChatCursor { ts_start_ms, after_event_id }` carried in `ChatQuery.cursor` and returned in `ChatHits.next`; the CLI prints `--cursor <token>`, `--after` stays a time filter only. - Qdrant `order_by ts_start_ms` has no id tiebreak, so ties at one `ts_start_ms` need the scroll to start at `start_from = ts_start_ms` inclusive and skip hits up to and including `after_event_id` in a stable (room, first_event_id) order; the fake index must order the same way. - Wire change: `ChatQuery` and `ChatHits` gain an optional field; schemas under `schemas/` regenerate; daemon and CLI deploy together (daemon first). - Also fold in: `chat_hit` filtering a boundary chunk to nothing leaves `truncated` true with fewer than k hits (compute truncation after the filter, or continue from the last scrolled chunk, not the last printed). Bodies already print on one line with `\n` escaped. - Cost: ~5 files (wire.rs, sources/mod.rs, index/qdrant.rs, index/fakes.rs, CLI) plus a deploy; not a one-sitting small fix, hence the guard here.
A truncated listing printed --after <last.ts_end+1>. Listing is ordered by chunk
start and chunks of different rooms overlap in time, so the next page skipped any
chunk starting before that instant and ending before it. Inside one room chunks do
not overlap, so the advice stays; with several rooms (or none named) the CLI now
says to list one room at a time.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Soul found the wire comment (and the published schema carrying it) still told every
caller to narrow with the last hit's ts_end_ms + 1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
eureka merged commit 917430ce99 into main 2026-11-17 03:46:25 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/Huginn!71
No description provided.