You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(resource-collection): Add resource collections support with UI, persistence and indexing - #727
Add the resource collection, that let user can enable the RAG feature on-demand in chat conversation
Related Issue(s)
Type of Change
🐛 Bug fix
✨ New feature
💥 Breaking change
📝 Documentation
♻️ Refactor (no functional change)
🧪 Tests
🔧 Chore / tooling / CI
What Changed & Why
Implement UI screens, dialogs and navigation for managing resource collections.
Add ResourceCollection domain model, repository and service for persistence.
Rename events to use containerId and containerType (ContainerDeletedEvent, IndexRemovalEvent, IndexingRequestedEvent, ReIndexEvent, etc.).
Refactor indexing coordinators, state manager and database schema to use container abstraction instead of project only.
Update all view models, services and tests to work with the new container API.
BREAKING CHANGE: All event types and indexing APIs now use containerId and containerType instead of projectId. The ProjectIndexer class has been removed; RagIndexer replaces it for all indexing operations.
…persistence and indexing
- Implement UI screens, dialogs and navigation for managing resource collections.
- Add ResourceCollection domain model, repository and service for persistence.
- Rename events to use containerId and containerType (ContainerDeletedEvent, IndexRemovalEvent, IndexingRequestedEvent, ReIndexEvent, etc.).
- Refactor indexing coordinators, state manager and database schema to use container abstraction instead of project only.
- Update all view models, services and tests to work with the new container API.
BREAKING CHANGE: All event types and indexing APIs now use containerId and containerType instead of projectId. The ProjectIndexer class has been removed; RagIndexer replaces it for all indexing operations.
The API documentation says creation does not trigger indexing, but this method emits IndexingRequestedEvent whenever sources are present below. That contradiction can cause callers to add a second indexing request or assume creation is cheap/synchronous; document the asynchronous trigger (or remove the trigger if the note is intended).
onSave is asynchronous in both callers (ResourceCollectionsViewModel.updateCollection and the detail ViewModel), but this immediately posts add/remove index events without knowing whether the database update succeeded. A failed save can therefore remove or index sources that are still present in the persisted collection, leaving RAG state inconsistent. Emit the diff only after a successful update (or make onSave return/await the result).
deleteCollection() returns false when the row cannot be deleted and records an error, but this callback ignores the result and always navigates away. A failed deletion therefore hides the error and leaves the collection in the list; only call onBack() after a successful deletion.
The collection update is executed directly on the coroutine scope passed from Compose, which is normally the UI dispatcher, while updateCollection performs a synchronous database transaction. Editing collection metadata or sources can therefore block the UI; run this repository call in withContext(Dispatchers.IO) like the delete/toggle paths below.
This issue also appears on line 175 of the same file.
A collection created with initial local-folder sources is indexed with watchForChanges = false. The collection list does not start another indexing request, so its folder watchers are never started unless the user later opens the detail view (where a separate effect posts a new request). This makes the default watchForChanges = true setting ineffective for newly created collections; use the source watch settings/start watching during the initial request.
The completed event is emitted before updateContainerProgress persists READY. ResourceCollectionsViewModel refreshes the list in response to that event, so its database read can race ahead of the status write and leave the collection displayed as INDEXING/NOT_STARTED until an unrelated refresh. Persist/update the progress before emitting the terminal event.
This note says creation never triggers indexing, but the implementation below posts IndexingRequestedEvent whenever initial sources are present. The contract is now misleading for callers and documentation; update the note to describe the asynchronous indexing behavior (or remove the event if the note is intended).
deleteCollection() returns false when deletion fails (and stores an error), but this callback ignores the result and always calls onBack(). A transient database failure therefore closes the detail view and hides the error while leaving the collection undeleted. Navigate back only when the returned Boolean is true.
Persisted index status is not restored to progress state
The persisted ResourceCollection.indexStatus/indexError is loaded into currentCollection but never copied into indexProgress. Opening an already-indexed collection while no embedding model is configured (so the LaunchedEffect cannot request indexing) leaves the panel in NOT_STARTED and displays “Waiting to start indexing” instead of the persisted READY/FAILED state.
The ViewModel ignores the persisted ResourceCollection.indexStatus/indexError when loading. After an app restart—especially without an embedding model, so the screen does not request indexing—an actually READY or FAILED collection is shown as NOT_STARTED because indexProgress remains at its default. Initialize the progress snapshot from the loaded collection here.
Terminal events now use the same stable ID as queued/started events. After one indexing run has produced a completed or failed card, a later run for the same container replaces that card and upsertIndexingEvent treats it as already counted, so the new result does not increment the unread badge. Include a per-run identifier for terminal notifications while retaining lifecycle deduplication within a run.
Restore index progress from persisted collection status
The collection already carries persisted indexStatus/indexError, but this load path only assigns currentCollection and leaves indexProgress at its default NOT_STARTED. Reopening a collection after restart (especially with no embedding model configured, so no new indexing event is emitted) shows it as not indexed even when the list says READY; hydrate indexProgress from the loaded collection here.
Keep the creation dialog mounted for its success screen
Closing the local dialog immediately after creation unmounts NewResourceCollectionDialog, so its success screen can never be displayed. Leave it mounted after onCreateCollection; the dialog's success-screen Close action should perform the dismissal.
Remove deleted collections from active chat sessions
Deleting the collection row does not remove its ID from chat_sessions.active_resource_collection_ids. Resuming one of those sessions leaves a selected-but-missing collection persisted and can keep stale collection state in the retriever-selection path; clear deleted collection references from sessions as part of this operation.
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
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.
Summary
Add the resource collection, that let user can enable the RAG feature on-demand in chat conversation
Related Issue(s)
Type of Change
What Changed & Why
BREAKING CHANGE: All event types and indexing APIs now use containerId and containerType instead of projectId. The ProjectIndexer class has been removed; RagIndexer replaces it for all indexing operations.
How to Test
./gradlew testScreenshots / Recordings (if applicable)
Checklist
main./gradlew spotlessApplyand./gradlew detektlocally./gradlew testand all tests passgit commit -sAdditional Notes