fix(server): auto-generate session index after import

After streaming or incremental import, automatically generate the
session index (chat_session table) so the frontend does not show
the "generate index" prompt when entering a conversation.
This commit is contained in:
digua committed 2026-05-18 20:21:30 +08:00
1 parent 7b29b34e9a
commit f78077655f
1 file changed
+15
@@ -16,6 +16,7 @@ import {
analyzeIncrementalImport as sharedAnalyzeIncremental,
incrementalImport as sharedIncrementalImport,
} from '@openchatlab/node-runtime'
import { generateSessionIndex, generateIncrementalSessionIndex } from '@openchatlab/core'
import type {
StreamImportResult,
StreamImportDeps,
@@ -90,6 +91,13 @@ function buildStreamImportDeps(dbManager: DatabaseManager, onProgress?: ImportPr
}
},
onProgress: onProgress ?? (() => {}),
postImportHook(db) {
try {
generateSessionIndex(db)
} catch {
/* non-fatal: frontend can regenerate via generate-index route */
}
},
generateSessionId,
}
}
@@ -164,6 +172,13 @@ function buildIncrementalDeps(dbManager: DatabaseManager, onProgress?: ImportPro
return openBetterSqliteDatabase(dbPath, { readonly: readonly ?? false, nativeBinding })
},
onProgress: onProgress ?? (() => {}),
postImportHook(db) {
try {
generateIncrementalSessionIndex(db)
} catch {
/* non-fatal */
}
},
}
}