MCPcopy Create free account
hub / github.com/WJX20/claude-code / loadAllProjectsMessageLogsProgressive

Function loadAllProjectsMessageLogsProgressive

src/utils/sessionStorage.ts:4019–4050  ·  view source on GitHub ↗
(
  limit?: number,
  initialEnrichCount: number = INITIAL_ENRICH_COUNT,
)

Source from the content-addressed store, hash-verified

4017}
4018
4019export async function loadAllProjectsMessageLogsProgressive(
4020 limit?: number,
4021 initialEnrichCount: number = INITIAL_ENRICH_COUNT,
4022): Promise<SessionLogResult> {
4023 const projectsDir = getProjectsDir()
4024
4025 let dirents: Dirent[]
4026 try {
4027 dirents = await readdir(projectsDir, { withFileTypes: true })
4028 } catch {
4029 return { logs: [], allStatLogs: [], nextIndex: 0 }
4030 }
4031
4032 const projectDirs = dirents
4033 .filter(dirent => dirent.isDirectory())
4034 .map(dirent => join(projectsDir, dirent.name))
4035
4036 const rawLogs: LogOption[] = []
4037 for (const projectDir of projectDirs) {
4038 rawLogs.push(...(await getSessionFilesLite(projectDir, limit)))
4039 }
4040 // Deduplicate — same session can appear in multiple project dirs
4041 const sorted = deduplicateLogsBySessionId(rawLogs)
4042
4043 const { logs, nextIndex } = await enrichLogs(sorted, 0, initialEnrichCount)
4044
4045 // enrichLogs returns fresh unshared objects — safe to mutate in place
4046 logs.forEach((log, i) => {
4047 log.value = i
4048 })
4049 return { logs, allStatLogs: sorted, nextIndex }
4050}
4051
4052/**
4053 * Loads message logs from all worktrees of the same git repository.

Callers 2

ResumeConversationFunction · 0.85

Calls 5

readdirFunction · 0.85
getSessionFilesLiteFunction · 0.85
enrichLogsFunction · 0.85
getProjectsDirFunction · 0.70

Tested by

no test coverage detected