Repository navigation
feat(ui): index documents in the background with an honest time left - #6265
Draft
kovtcharov wants to merge 4 commits into
Draft
kovtcharov wants to merge 4 commits into
kovtcharov wants to merge 4 commits into
Conversation
The library indexes an upload's temp copy and chats index the original. The cache key includes the path, so a first chat read every page again, images included: 40 minutes on a 790-page library that was already done. A cache entry for the same bytes and chunking is now reused from any path.
Adding seven PDFs took 28 minutes and a first chat another 30: most adds blocked until indexed, nothing showed once the library closed, and a chat read a file the library was already reading, from page one, silently. Adding a document now returns at once from the library, file browser, drag and drop, folders and Retry, and each indexes on its own. A line above the chat shows N of M done, one bar and the time left, and opens the library, which shows the same plus the file in hand. The estimate is measured per phase on this machine and covers later phases and queued files. It shows nothing until there are enough samples, a lower bound while a phase is unmeasured, and "taking longer than expected" in place of a frozen number. A chat leaves documents that are indexing, cancelled or failed out of the turn and says so; the agent's own index tools report the running index instead of starting another. Cancel now reaches queued documents, Retry and automatic re-indexing, and a restart mid-index stays visible.
Each row sized its bar to its status text, so Cancel sat at a different spot on every line. The bar now takes the row and Cancel stays at its end, in either direction.
5 tasks
3 tasks
rezamuliawijaya
pushed a commit
to rezamuliawijaya/gaia
that referenced
this pull request
Nov 7, 2026
A document edited after it was indexed kept answering from its old text: indexing it again said "already indexed" and changed nothing, and only a new session picked up the edit. Now indexing an edited document re-indexes it, and an unchanged one still returns at once without re-embedding. Open PRs amd#6265 and amd#6286 rework background indexing but don't touch this already-indexed check, so they don't overlap with this fix. ## Test plan - [ ] `python -m pytest tests/unit/rag/test_edited_document_reindex.py tests/unit/rag/test_retrieval_bench_harness.py` - [ ] In `gaia chat`, index a text file and ask about it; edit the file, ask the agent to index it again, and the answer reflects the edit - [ ] Index an unchanged file twice; the second call reports it is already indexed <details> <summary>🔍 Technical details</summary> - `RAGSDK` keeps `file_content_keys` (the `_content_key` of the indexed bytes), set on both publish paths and cleared in `remove_document` (which LRU eviction uses) and the `reindex_document` rollback snapshot. - A repeat `index_document` hashes the file outside the lock; a mismatch calls `reindex_document`, which now passes the progress/wait callbacks through. The hash, not mtime/size, is the check, so a same-size edit with a restored timestamp is caught (tested). - The two race re-checks now compare keys: another writer's index of different bytes is replaced instead of being reported as current. - A locked file (Windows exclusive open) reports `file_locked` and keeps its index rather than being dropped. - `RAGToolsMixin.index_document` short-circuits only when the new `is_current()` agrees. - The `replaced_document` retrieval hard case should flip fail→pass; the gate reports that as information, and the baseline JSON is left for the next real run. - Regression hunt: every rag/index/document unit test plus the flagship's document tests pass (2376 + 382); the one pdfium-thread failure in the baseline run didn't reproduce. </details> Closes amd#4738
kovtcharov-amd
added a commit
to huong8373tt-beep/gaia
that referenced
this pull request
Nov 7, 2026
A document edited after it was indexed kept answering from its old text: indexing it again said "already indexed" and changed nothing, and only a new session picked up the edit. Now indexing an edited document re-indexes it, and an unchanged one still returns at once without re-embedding. Open PRs amd#6265 and amd#6286 rework background indexing but don't touch this already-indexed check, so they don't overlap with this fix. ## Test plan - [ ] `python -m pytest tests/unit/rag/test_edited_document_reindex.py tests/unit/rag/test_retrieval_bench_harness.py` - [ ] In `gaia chat`, index a text file and ask about it; edit the file, ask the agent to index it again, and the answer reflects the edit - [ ] Index an unchanged file twice; the second call reports it is already indexed <details> <summary>🔍 Technical details</summary> - `RAGSDK` keeps `file_content_keys` (the `_content_key` of the indexed bytes), set on both publish paths and cleared in `remove_document` (which LRU eviction uses) and the `reindex_document` rollback snapshot. - A repeat `index_document` hashes the file outside the lock; a mismatch calls `reindex_document`, which now passes the progress/wait callbacks through. The hash, not mtime/size, is the check, so a same-size edit with a restored timestamp is caught (tested). - The two race re-checks now compare keys: another writer's index of different bytes is replaced instead of being reported as current. - A locked file (Windows exclusive open) reports `file_locked` and keeps its index rather than being dropped. - `RAGToolsMixin.index_document` short-circuits only when the new `is_current()` agrees. - The `replaced_document` retrieval hard case should flip fail→pass; the gate reports that as information, and the baseline JSON is left for the next real run. - Regression hunt: every rag/index/document unit test plus the flagship's document tests pass (2376 + 382); the one pdfium-thread failure in the baseline run didn't reproduce. </details> Closes amd#4738
Contributor
Author
|
Left as a draft, nothing pushed: merging main conflicts in 12 files, and resolving them would mean rebuilding parts of this feature rather than merging it. What is in the way:
The description's own open items still stand too: the estimate has only run against recorded progress, and the packaged app has not been checked for double indexing. This needs a fresh pass on current main by someone who can run it against real PDFs. |
This branch has not been deployed
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.
Adding seven PDFs blocked for 28 minutes, nothing showed once the library closed, and a chat could start reading a file the library was already reading. Adding a document now returns at once and each one indexes in the background, with one bar and the time left above the chat and in the library. The estimate is measured per phase on this machine, shows nothing until it has enough samples, and says "taking longer than expected" rather than freezing on a number.
Includes the commit from the reuse-indexing PR, which should merge first.
Known limits: a restart shows interrupted work but doesn't resume it, thresholds are untuned against real PDFs, and the Arabic wording needs a native speaker's review. The estimate has only run against recorded progress so far, and the packaged app's sidecar still needs a check for double indexing.
Eval category to watch:
rag_quality, because the agent's own index tools now report a running index instead of starting one.Test plan
cd src/gaia/apps/webui && npm test && npm run test:rtl