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

Function loadAllProjectsMessageLogsFull

src/utils/sessionStorage.ts:3979–4017  ·  view source on GitHub ↗
(
  limit?: number,
)

Source from the content-addressed store, hash-verified

3977}
3978
3979async function loadAllProjectsMessageLogsFull(
3980 limit?: number,
3981): Promise<LogOption[]> {
3982 const projectsDir = getProjectsDir()
3983
3984 let dirents: Dirent[]
3985 try {
3986 dirents = await readdir(projectsDir, { withFileTypes: true })
3987 } catch {
3988 return []
3989 }
3990
3991 const projectDirs = dirents
3992 .filter(dirent => dirent.isDirectory())
3993 .map(dirent => join(projectsDir, dirent.name))
3994
3995 const logsPerProject = await Promise.all(
3996 projectDirs.map(projectDir => getLogsWithoutIndex(projectDir, limit)),
3997 )
3998 const allLogs = logsPerProject.flat()
3999
4000 // Deduplicate — same session+leaf can appear in multiple project dirs.
4001 // This path creates one LogOption per leaf, so use sessionId+leafUuid key.
4002 const deduped = new Map<string, LogOption>()
4003 for (const log of allLogs) {
4004 const key = `${log.sessionId ?? ''}:${log.leafUuid ?? ''}`
4005 const existing = deduped.get(key)
4006 if (!existing || log.modified.getTime() > existing.modified.getTime()) {
4007 deduped.set(key, log)
4008 }
4009 }
4010
4011 // deduped values are fresh from getLogsWithoutIndex — safe to mutate
4012 const sorted = sortLogs([...deduped.values()])
4013 sorted.forEach((log, i) => {
4014 log.value = i
4015 })
4016 return sorted
4017}
4018
4019export async function loadAllProjectsMessageLogsProgressive(
4020 limit?: number,

Callers 1

Calls 6

readdirFunction · 0.85
getLogsWithoutIndexFunction · 0.85
sortLogsFunction · 0.85
setMethod · 0.80
getProjectsDirFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected