MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / getChatSessionList

Function getChatSessionList

packages/core/src/query/session-queries.ts:479–499  ·  view source on GitHub ↗
(db: DatabaseAdapter)

Source from the content-addressed store, hash-verified

477 * Timeline list of chat sessions with first message id and summary.
478 */
479export function getChatSessionList(db: DatabaseAdapter): ChatSessionItem[] {
480 if (!hasTable(db, 'segment')) return []
481 try {
482 return db
483 .prepare(
484 `SELECT
485 cs.id,
486 cs.start_ts as startTs,
487 cs.end_ts as endTs,
488 cs.message_count as messageCount,
489 cs.summary,
490 (SELECT mc.message_id FROM message_context mc
491 WHERE mc.segment_id = cs.id ORDER BY mc.message_id LIMIT 1) as firstMessageId
492 FROM segment cs
493 ORDER BY cs.start_ts ASC`
494 )
495 .all() as unknown as ChatSessionItem[]
496 } catch {
497 return []
498 }
499}
500
501/**
502 * Load messages for a chat session (for summary generation).

Callers 2

generateAllSummariesFunction · 0.90

Calls 3

hasTableFunction · 0.90
allMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected