MCPcopy
hub / github.com/codeaashu/claude-code / loadAllProjectsMessageLogsProgressive

Function loadAllProjectsMessageLogsProgressive

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

Source from the content-addressed store, hash-verified

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

Callers 2

ResumeConversationFunction · 0.85

Calls 7

readdirFunction · 0.85
getSessionFilesLiteFunction · 0.85
enrichLogsFunction · 0.85
forEachMethod · 0.80
getProjectsDirFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected