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

Function getLogsWithoutIndex

src/utils/sessionStorage.ts:4702–4730  ·  view source on GitHub ↗

* Gets logs by loading all session files fully, bypassing the session index. * Use this when you need full message data (e.g., for /insights analysis).

(
  projectDir: string,
  limit?: number,
)

Source from the content-addressed store, hash-verified

4700
4701 */
4702async function getLogsWithoutIndex(
4703 projectDir: string,
4704 limit?: number,
4705): Promise<LogOption[]> {
4706 const sessionFilesMap = await getSessionFilesWithMtime(projectDir)
4707 if (sessionFilesMap.size === 0) return []
4708
4709 // If limit specified, only load N most recent files by mtime
4710 let filesToProcess: Array<{ path: string; mtime: number }>
4711 if (limit && sessionFilesMap.size > limit) {
4712 filesToProcess = [...sessionFilesMap.values()]
4713 .sort((a, b) => b.mtime - a.mtime)
4714 .slice(0, limit)
4715 } else {
4716 filesToProcess = [...sessionFilesMap.values()]
4717 }
4718
4719 const logs: LogOption[] = []
4720 for (const fileInfo of filesToProcess) {
4721 try {
4722 const fileLogOptions = await loadAllLogsFromSessionFile(fileInfo.path)
4723 logs.push(...fileLogOptions)
4724 } catch {
4725 logForDebugging(`Failed to load session file: ${fileInfo.path}`)
4726 }
4727 }
4728
4729 return logs
4730}
4731
4732/**
4733 * Reads the first and last ~64KB of a JSONL file and extracts lite metadata.

Callers 1

Calls 3

getSessionFilesWithMtimeFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected