mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
refactor(ui): simplify model button and optimize session index loading
- StatusBar model button: show model name instead of provider, click opens settings directly (scrolls to default model section), remove dropdown - SessionIndexSection: replace N serial pluginQuery calls with single batch API (GET /_web/sessions/index-stats), add IntersectionObserver lazy loading - Full-stack implementation: CLI route, Electron IPC/Worker, frontend adapters Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
783d61f742
commit
9bc0c4279d
15 files changed
+140
-109
No files matched your search
@@ -31,7 +31,9 @@ export {
|
||||
getFtsStatus,
|
||||
searchFts,
|
||||
rebuildFts,
|
||||
getAllIndexStats,
|
||||
} from './session-index-service'
|
||||
export type { SessionIndexStatusItem } from './session-index-service'
|
||||
|
||||
// Summary service
|
||||
export { generateSummary, generateAllSummaries } from './summary-service'
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
generateSessionIndex as coreGenerateSessionIndex,
|
||||
generateIncrementalSessionIndex as coreGenerateIncrementalSessionIndex,
|
||||
clearSessionIndex as coreClearSessionIndex,
|
||||
getSessionIndexStats,
|
||||
} from '@openchatlab/core'
|
||||
import { hasFtsTable, searchByFts, rebuildFtsIndex } from '../fts'
|
||||
import type { SessionRuntimeAdapter } from './adapters'
|
||||
@@ -51,3 +52,22 @@ export function rebuildFts(adapter: SessionRuntimeAdapter, sessionId: string) {
|
||||
const db = adapter.ensureWritable(sessionId)
|
||||
return rebuildFtsIndex(db)
|
||||
}
|
||||
|
||||
export interface SessionIndexStatusItem {
|
||||
sessionId: string
|
||||
hasIndex: boolean
|
||||
sessionCount: number
|
||||
}
|
||||
|
||||
export function getAllIndexStats(adapter: SessionRuntimeAdapter): SessionIndexStatusItem[] {
|
||||
const ids = adapter.listSessionIds()
|
||||
return ids.map((sessionId) => {
|
||||
try {
|
||||
const db = adapter.ensureReadonly(sessionId)
|
||||
const stats = getSessionIndexStats(db)
|
||||
return { sessionId, hasIndex: stats.hasIndex, sessionCount: stats.sessionCount }
|
||||
} catch {
|
||||
return { sessionId, hasIndex: false, sessionCount: 0 }
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user