fix: rebuild FTS5 index after bulk observation import (fixes #1631) (#1632)

Imported observations were invisible to the MCP search tool because the
FTS5 content table was not reliably updated during bulk import. The import
handler now calls rebuildObservationsFTSIndex() after inserting new
observations, ensuring the full-text search index is consistent.

A new SessionStore.rebuildObservationsFTSIndex() method encapsulates the
FTS5 rebuild command and is a no-op when the observations_fts table does
not exist (e.g. FTS5 unavailable on Windows).
This commit is contained in:
Octopus
2026-04-09 07:16:55 +08:00
committed by GitHub
parent 6461d718f2
commit f7fd2221c8
2 changed files with 24 additions and 0 deletions
@@ -391,6 +391,13 @@ export class DataRoutes extends BaseRouteHandler {
stats.observationsSkipped++;
}
}
// Rebuild FTS index so imported observations are immediately searchable.
// The FTS5 content table relies on triggers for incremental updates, but
// those triggers may not have fired correctly for all import paths.
if (stats.observationsImported > 0) {
store.rebuildObservationsFTSIndex();
}
}
// Import prompts (depends on sessions)