MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / listSessions

Function listSessions

apps/vis/server/src/lib/session-store.ts:35–63  ·  view source on GitHub ↗
(home: string)

Source from the content-addressed store, hash-verified

33}
34
35export 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
65export async function readSessionDetail(home: string, sessionId: string): Promise<SessionDetail | null> {
66 if (isImportId(sessionId)) return readImportedDetail(home, sessionId);

Callers 2

sessionsRouteFunction · 0.90

Calls 8

listImportedIdsFunction · 0.90
importedDirOfFunction · 0.90
readImportMetaFunction · 0.90
tryReadSummaryFunction · 0.85
readSessionIndexFunction · 0.70
getMethod · 0.65
readdirFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected