(home: string)
| 33 | } |
| 34 | |
| 35 | export async function listSessions(home: string): Promise<SessionSummary[]> { |
| 36 | const sessionsDir = join(home, 'sessions'); |
| 37 | const buckets = await readdir(sessionsDir, { withFileTypes: true }).catch(() => []); |
| 38 | const index = await readSessionIndex(home); |
| 39 | const out: SessionSummary[] = []; |
| 40 | for (const bucket of buckets) { |
| 41 | if (!bucket.isDirectory()) continue; |
| 42 | const bucketDir = join(sessionsDir, bucket.name); |
| 43 | const sessionDirs = await readdir(bucketDir, { withFileTypes: true }).catch(() => []); |
| 44 | for (const entry of sessionDirs) { |
| 45 | if (!entry.isDirectory() || !SESSION_ID_RE.test(entry.name)) continue; |
| 46 | const sessionDir = join(bucketDir, entry.name); |
| 47 | const workDir = index.get(entry.name)?.workDir ?? ''; |
| 48 | const summary = await tryReadSummary(sessionDir, entry.name, workDir); |
| 49 | if (summary !== null) out.push(summary); |
| 50 | } |
| 51 | } |
| 52 | // Imported debug bundles live under <home>/imported/<importId>/ and surface |
| 53 | // in the same list, tagged so the UI can filter them. |
| 54 | for (const importId of await listImportedIds(home)) { |
| 55 | const dir = importedDirOf(home, importId); |
| 56 | const meta = await readImportMeta(home, importId); |
| 57 | const workDir = meta?.manifest?.workspaceDir ?? ''; |
| 58 | const summary = await tryReadSummary(dir, importId, workDir, { imported: true, importMeta: meta }); |
| 59 | if (summary !== null) out.push(summary); |
| 60 | } |
| 61 | out.sort((a, b) => b.updatedAt - a.updatedAt); |
| 62 | return out; |
| 63 | } |
| 64 | |
| 65 | export async function readSessionDetail(home: string, sessionId: string): Promise<SessionDetail | null> { |
| 66 | if (isImportId(sessionId)) return readImportedDetail(home, sessionId); |
no test coverage detected