MCPcopy Create free account
hub / github.com/Noumena-Network/code / loadAllProjectsMessageLogsProgressive

Function loadAllProjectsMessageLogsProgressive

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

Source from the content-addressed store, hash-verified

4239}
4240
4241export async function loadAllProjectsMessageLogsProgressive(
4242 limit?: number,
4243 initialEnrichCount: number = INITIAL_ENRICH_COUNT,
4244): Promise<SessionLogResult> {
4245 const projectsDir = getProjectsDir()
4246
4247 let dirents: Dirent[]
4248 try {
4249 dirents = await readdir(projectsDir, { withFileTypes: true })
4250 } catch {
4251 return { logs: [], allStatLogs: [], nextIndex: 0 }
4252 }
4253
4254 const projectDirs = dirents
4255 .filter(dirent => dirent.isDirectory())
4256 .map(dirent => join(projectsDir, dirent.name))
4257
4258 const rawLogs: LogOption[] = []
4259 for (const projectDir of projectDirs) {
4260 rawLogs.push(...(await getSessionFilesLite(projectDir, limit)))
4261 }
4262 // Deduplicate — same session can appear in multiple project dirs
4263 const sorted = deduplicateLogsBySessionId(rawLogs)
4264
4265 const { logs, nextIndex } = await enrichLogs(sorted, 0, initialEnrichCount)
4266
4267 // enrichLogs returns fresh unshared objects — safe to mutate in place
4268 logs.forEach((log, i) => {
4269 log.value = i
4270 })
4271 return { logs, allStatLogs: sorted, nextIndex }
4272}
4273
4274/**
4275 * 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