feat(settings): add "Rebuild semantic index" maintenance action

Drops and recreates the sqlite-vec tables at the current model dimension, then
re-queues every image for embedding. Fixes "dimension mismatch" search errors
that occur when the vector table was built for a different model/dimension (e.g.
after experimenting with 768-dim models against this 512-dim build).

The rebuild runs under the embedding worker's DB write lock and resets the job
queue inside a single transaction, so it can't interleave with an in-flight
embedding batch (per code review).
This commit is contained in:
2026-06-21 15:17:34 +01:00
parent 5870205047
commit f66fbe7931
7 changed files with 99 additions and 1 deletions
+3
View File
@@ -467,6 +467,7 @@ interface GalleryState {
openAppDataFolder: () => Promise<void>;
getDatabaseInfo: () => Promise<DatabaseInfo>;
vacuumDatabase: () => Promise<VacuumResult>;
rebuildSemanticIndex: () => Promise<number>;
getOrphanedThumbnailsInfo: () => Promise<OrphanedThumbnailsInfo>;
cleanupOrphanedThumbnails: () => Promise<CleanupOrphanedThumbnailsResult>;
retryFailedEmbeddings: (folderId: number) => Promise<void>;
@@ -1858,6 +1859,8 @@ export const useGalleryStore = create<GalleryState>((set, get) => ({
vacuumDatabase: () => invoke<VacuumResult>("vacuum_database"),
rebuildSemanticIndex: () => invoke<number>("rebuild_semantic_index"),
getOrphanedThumbnailsInfo: () => invoke<OrphanedThumbnailsInfo>("get_orphaned_thumbnails_info"),
cleanupOrphanedThumbnails: () => invoke<CleanupOrphanedThumbnailsResult>("cleanup_orphaned_thumbnails"),