Skip to content

feat(resource-collection): Add resource collections support with UI, persistence and indexing - #727

Merged
haiphucnguyen merged 8 commits into
mainfrom
feature/add-resource-collection
Sep 23, 2026
Merged

haiphucnguyen merged 8 commits into
mainfrom
feature/add-resource-collection

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Summary

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.

How to Test

./gradlew test

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING guide
  • My branch is up to date with main
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

Additional Notes

…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.
Copilot AI lite review requested due to automatic review settings September 23, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical persistence, indexing, UI, and chat-context issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 8 High severity · 6 Medium severity

Open (14)
What changed in this PR

Adds reusable resource collections with persistent storage, container-aware RAG indexing, chat selection, and desktop management UI.

Changes:

  • Adds collection models, repositories, services, dialogs, navigation, and localization.
  • Refactors indexing, state, watching, and events around project/collection containers.
  • Updates chat persistence, source management, notifications, and tests.
File Summary
shared/​src/​test/​kotlin/​io/​askimo/​core/​rag/​watching/​FileWatcherOverloadTest.kt Tests file-watcher overload behavior.
shared/​src/​test/​kotlin/​io/​askimo/​core/​rag/​watching/​FileWatcherErrorReportingTest.kt Tests watcher error reporting.
shared/​src/​test/​kotlin/​io/​askimo/​core/​rag/​indexing/​HybridIndexerTest.kt Tests container-aware indexing.
shared/​src/​test/​kotlin/​io/​askimo/​core/​chat/​domain/​LocalFoldersKnowledgeSourceConfigEqualityTest.kt Tests local-folder source configuration equality.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​watching/​FileWatcher.kt Implements container-scoped file watching.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​watching/​FileChangeHandler.kt Handles file changes and container events.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​state/​IndexStateRepository.kt Provides container-scoped index-state queries.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​state/​IndexStateManager.kt Manages container index state.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​state/​IndexFileStateTable.kt Stores container-scoped file state.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​UrlIndexingCoordinator.kt Coordinates URL indexing for containers.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​providers/​UrlIndexingProvider.kt Provides URL indexing implementations.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​providers/​LocalFoldersIndexingProvider.kt Provides folder indexing implementations.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​providers/​LocalFilesIndexingProvider.kt Provides file indexing implementations.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​LocalFoldersIndexingCoordinator.kt Coordinates folder indexing.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​LocalFilesIndexingCoordinator.kt Coordinates file indexing.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​IndexingCoordinatorProvider.kt Defines the container-aware coordinator API.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​IndexingCoordinatorFactory.kt Creates container-aware coordinators.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​HybridIndexer.kt Orchestrates container indexing.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​indexing/​BaseLocalIndexingCoordinator.kt Provides shared local indexing coordination.
shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​container/​IndexingContainer.kt Defines project and collection containers.
shared/​src/​main/​kotlin/​io/​askimo/​core/​providers/​ChatRequestTransformers.kt Updates chat request identity handling.
shared/​src/​main/​kotlin/​io/​askimo/​core/​event/​user/​IndexingEvent.kt Defines container-aware indexing events.
shared/​src/​main/​kotlin/​io/​askimo/​core/​event/​internal/​ReIndexEvent.kt Defines container re-index requests.
shared/​src/​main/​kotlin/​io/​askimo/​core/​event/​internal/​KnowledgeSourceWatchToggledEvent.kt Defines container watch toggles.
shared/​src/​main/​kotlin/​io/​askimo/​core/​event/​internal/​KnowledgeSourceRescanRequestedEvent.kt Defines container rescan requests.
shared/​src/​main/​kotlin/​io/​askimo/​core/​event/​internal/​IndexRemovalEvent.kt Defines container index removal.
shared/​src/​main/​kotlin/​io/​askimo/​core/​event/​internal/​IndexingRequestedEvent.kt Defines container indexing requests.
shared/​src/​main/​kotlin/​io/​askimo/​core/​event/​internal/​ContainerDeletedEvent.kt Handles container deletion events.
shared/​src/​main/​kotlin/​io/​askimo/​core/​context/​AppContext.kt Updates indexer integration references.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​service/​ResourceCollectionService.kt Provides collection operations and indexing lifecycle.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​service/​ProjectService.kt Migrates project operations to container events.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​repository/​ResourceSegmentRepository.kt Makes segment persistence container-aware.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​repository/​ChatSessionRepository.kt Persists active collection selections.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​domain/​ResourceSegmentsTable.kt Defines container-scoped segment storage.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​domain/​ResourceCollection.kt Defines the resource collection model and table.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​domain/​ChatSession.kt Adds persisted collection selections.
shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​domain/​ChatMessage.kt Adds message collection metadata.
gradle.properties Updates the project version.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​View.kt Integrates collection screens.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​shell/​NavigationSidebar.kt Adds collection navigation.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionsViewModel.kt Manages collection list state.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionDetailViewModel.kt Manages collection detail and indexing state.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​NewResourceCollectionDialog.kt Creates resource collections.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​EditResourceCollectionDialog.kt Edits resource collections.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​DeleteResourceCollectionDialog.kt Confirms collection deletion.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​project/​ProjectViewModel.kt Migrates project indexing integration.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​project/​ProjectsView.kt Updates project presentation.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​project/​NewProjectDialog.kt Uses shared source components.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​project/​EditProjectDialog.kt Uses shared source diff handling.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​Main.kt Integrates collection navigation and screens.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​UrlInputDialog.kt Provides shared URL input UI.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​RagSourcesTreeWithPreview.kt Provides a preview-enabled source tree.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​RagSourcesTree.kt Provides shared source-tree behavior.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​KnowledgeSourceRow.kt Renders reusable source rows.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​KnowledgeSourceModels.kt Defines shared source models.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​KnowledgeSourceIndexDiff.kt Centralizes source indexing diffs.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​KnowledgeSourceBrowser.kt Provides source browsing.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​knowledgesource/​AddReferenceMaterialDialog.kt Provides container-agnostic source selection.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​di/​DesktopRagModule.kt Registers RAG indexing dependencies.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​di/​DesktopModule.kt Registers collection services and view models.
desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​chat/​ProjectSidePanel.kt Updates project indexing controls.
desktop-shared/​src/​main/​resources/​i18n/​messages.properties Adds English collection strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_zh_TW.properties Adds Traditional Chinese strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_zh_CN.properties Adds Simplified Chinese strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_vi_VN.properties Adds Vietnamese strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_pt_BR.properties Adds Brazilian Portuguese strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_ko_KR.properties Adds Korean strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_ja_JP.properties Adds Japanese strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_fr.properties Adds French strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_es.properties Adds Spanish strings.
desktop-shared/​src/​main/​resources/​i18n/​messages_de.properties Adds German strings.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​shell/​NotificationComponents.kt Displays container indexing notifications.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​shell/​NavigationSidebar.kt Adds shared collection sidebar state.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​plan/​PlansGalleryView.kt Updates plan presentation.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​common/​components/​ResourceCollectionStatus.kt Renders collection index status.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​chat/​ProjectIndexStateManager.kt Uses container index-state lookup.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​chat/​ChatView.kt Integrates collection-aware chat indexing.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​chat/​ChatState.kt Adds collection selection state.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​chat/​ChatActions.kt Adds collection selection actions.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​agent/​AgentView.kt Updates agent presentation.
cli/​src/​main/​kotlin/​io/​askimo/​cli/​graal/​AskimoFeature.kt Registers native-image types.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical and moderate issues remain in collection indexing, watcher lifecycle, UI loading, and cleanup.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 7 High severity · 3 Medium severity

Open (10)
Resolved since last review (6)
Previously missed (1)

In code that hasn't changed since last review

Low severity Document or remove indexing triggered during creation

shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​service/​ResourceCollectionService.kt:42

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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved indexing cleanup, ordering, persistence, retrieval consistency, and UI issues block approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 10 High severity · 3 Medium severity

Open (13)
Resolved since last review (2)
Previously missed (6)

In code that hasn't changed since last review

Medium severity Emit index events only after successful saves

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​EditResourceCollectionDialog.kt:139

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).

Medium severity Navigate away only after successful deletion

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionDetailView.kt:306

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.

Medium severity Run collection updates on the IO dispatcher

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionDetailViewModel.kt:137

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.

Medium severity Start watchers for newly created folder sources

shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​service/​ResourceCollectionService.kt:78

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.

Medium severity Persist READY status before emitting completion

shared/​src/​main/​kotlin/​io/​askimo/​core/​rag/​RagIndexer.kt:605

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.

Low severity Document asynchronous indexing during creation

shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​service/​ResourceCollectionService.kt:42

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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 9 High severity · 1 Medium severity

Open (10)
Resolved since last review (9)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Failed collection deletion incorrectly navigates back

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionDetailView.kt:306

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.

Medium severity Persisted index status is not restored to progress state

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionDetailViewModel.kt:100

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical indexing and persistence-ordering defects, alongside related UI and lifecycle issues, remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 7 High severity · 1 Medium severity

Open (8)
Resolved since last review (6)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Loaded collection index status is not restored

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionDetailViewModel.kt:100

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved critical and moderate issues remain across persistence, index isolation, event handling, and UI flows.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 8 High severity · 1 Medium severity

Open (9)
Resolved since last review (4)
Previously missed (4)

In code that hasn't changed since last review

Medium severity Use per-run IDs for terminal indexing notifications

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​shell/​NotificationComponents.kt:189

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.

Medium severity Restore index progress from persisted collection status

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionDetailViewModel.kt:100

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.

Medium severity Keep the creation dialog mounted for its success screen

desktop/​src/​main/​kotlin/​io/​askimo/​desktop/​resourcecollection/​ResourceCollectionsView.kt:288

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.

Medium severity Remove deleted collections from active chat sessions

shared/​src/​main/​kotlin/​io/​askimo/​core/​chat/​service/​ResourceCollectionService.kt:204

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.

Comment on lines +450 to +453
onSave = { id, name, description, knowledgeSources ->
val saved = onUpdateCollection(id, name, description, knowledgeSources)
if (saved) showEditDialog = false
saved
Comment on lines +245 to +249
val updated = ResourceCollectionsTable.update({ ResourceCollectionsTable.id eq collectionId }) {
it[ResourceCollectionsTable.name] = name
it[ResourceCollectionsTable.description] = description
it[knowledgeSourcesConfig] = KnowledgeSourceSerializer.serialize(knowledgeSources)
it[updatedAt] = Instant.now()
Comment on lines +367 to +373
ResourceCollectionsTable.update({ ResourceCollectionsTable.id eq collection.id }) {
it[name] = collection.name
it[description] = collection.description
it[knowledgeSourcesConfig] = KnowledgeSourceSerializer.serialize(collection.knowledgeSources)
it[updatedAt] = collection.updatedAt
it[syncedAt] = nowStr
it[isSystemCollection] = if (collection.isSystemCollection) 1 else 0
@haiphucnguyen
haiphucnguyen merged commit 0cdf7a7 into main Sep 23, 2026
8 of 10 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/add-resource-collection branch September 23, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants