feat: stream progress notifications from query-mode ingest_paper - #27
Merged
Conversation
Query-mode ingest_paper (query=..., max_papers=N) runs a search plus a batched embed and index upsert — 30-60s of silence in Claude Desktop today. assist_draft already streams progress when the client passes a progressToken; this gives ingest the same treatment. bulk_ingest takes an optional progress callback (same shape as DraftService.assist) and reports its embed and index phases; _do_ingest builds the callback via the existing _maybe_progress_callback and emits a 'searching...' event before the search. Single-id mode stays silent — it's sub-second. The embedder call is a single batched request, so progress advances by phase (0/N+1 embedding all N, N/N+1 indexing) rather than faking a per-paper tick over one atomic call.
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 free
to 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.
What
Query-mode
ingest_paper(query=..., max_papers=N)runs a search plus a batched embed and an index upsert — 30–60s of silence in Claude Desktop today.assist_draftalready streams progress when the client passes aprogressToken; this gives ingest parity.LibraryService.bulk_ingestgains an optionalprogresscallback (same(done, total, message)shape asDraftService.assist) and reports its embed and index phases._do_ingestbuilds the callback via the existing_maybe_progress_callback(server)and emits asearching...event before the search. Single-id mode stays silent — it's a sub-second single fetch + embed.ingest_papertool description updated to mention progress streaming (parity withassist_draft).Honest progress, not faked per-paper ticks
The issue sketched "once per paper as embeddings complete," assuming N parallel embeds. The implementation does a single batched
embedder.embed(texts)call (priced by token, one round-trip). Rather than fake a per-paper tick over one atomic call, progress advances by phase:0/(N+1)while embedding all N,N/(N+1)while indexing,N+1/(N+1)done. The total still conveys the paper count; the message names the phase. Reverting to per-paper embeds purely to animate a bar would regress the batching optimization.Closes #6.
Test plan
ruff check src tests— cleanmypy src— cleanpytest -q --strict-markers— 527 passed, 14 skippedtest_library_service.pycases: progress sequence[(0,3),(2,3),(3,3)]for 2 papers with the right phase messages; no-callback path unchanged; empty input emits nothing