( db: DatabaseAdapter, id: string, dbPath: string, options?: ListSessionsOptions )
| 47 | } |
| 48 | |
| 49 | function buildSession( |
| 50 | db: DatabaseAdapter, |
| 51 | id: string, |
| 52 | dbPath: string, |
| 53 | options?: ListSessionsOptions |
| 54 | ): AnalysisSessionDTO | null { |
| 55 | const meta = getSessionMeta(db) |
| 56 | if (!meta) return null |
| 57 | |
| 58 | const overview = options?.resolveOverview ? options.resolveOverview(db, id) : undefined |
| 59 | const info = overview ? buildSessionInfo(meta, overview, getSummaryCount(db)) : getSessionInfo(db) |
| 60 | if (!info) return null |
| 61 | |
| 62 | let memberAvatar: string | null = null |
| 63 | if (meta.type === 'private') { |
| 64 | memberAvatar = getPrivateChatMemberAvatar(db, meta.name, meta.ownerId) |
| 65 | } |
| 66 | |
| 67 | let dto: AnalysisSessionDTO = { ...info, id, dbPath, memberAvatar, aiConversationCount: 0 } |
| 68 | if (options?.enrichSession) { |
| 69 | dto = options.enrichSession(dto) |
| 70 | } |
| 71 | return dto |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * List all valid sessions, sorted by importedAt descending. |
no test coverage detected