MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / enrichLog

Function enrichLog

source code/utils/sessionStorage.ts:5025–5072  ·  view source on GitHub ↗

* Enriches a lite log with metadata from its JSONL file. * Returns the enriched log, or null if the log has no meaningful content * (no firstPrompt, no customTitle — e.g., metadata-only session files).

(
  log: LogOption,
  readBuf: Buffer,
)

Source from the content-addressed store, hash-verified

5023 * (no firstPrompt, no customTitle — e.g., metadata-only session files).
5024 */
5025async function enrichLog(
5026 log: LogOption,
5027 readBuf: Buffer,
5028): Promise<LogOption | null> {
5029 if (!log.isLite || !log.fullPath) return log
5030
5031 const meta = await readLiteMetadata(log.fullPath, log.fileSize ?? 0, readBuf)
5032
5033 const enriched: LogOption = {
5034 ...log,
5035 isLite: false,
5036 firstPrompt: meta.firstPrompt,
5037 gitBranch: meta.gitBranch,
5038 isSidechain: meta.isSidechain,
5039 teamName: meta.teamName,
5040 customTitle: meta.customTitle,
5041 summary: meta.summary,
5042 tag: meta.tag,
5043 agentSetting: meta.agentSetting,
5044 prNumber: meta.prNumber,
5045 prUrl: meta.prUrl,
5046 prRepository: meta.prRepository,
5047 projectPath: meta.projectPath ?? log.projectPath,
5048 }
5049
5050 // Provide a fallback title for sessions where we couldn't extract the first
5051 // prompt (e.g., large first messages that exceed the 16KB read buffer).
5052 // Previously these sessions were silently dropped, making them inaccessible
5053 // via /resume after crashes or large-context sessions.
5054 if (!enriched.firstPrompt && !enriched.customTitle) {
5055 enriched.firstPrompt = '(session)'
5056 }
5057 // Filter: skip sidechains and agent sessions
5058 if (enriched.isSidechain) {
5059 logForDebugging(
5060 `Session ${log.sessionId} filtered from /resume: isSidechain=true`,
5061 )
5062 return null
5063 }
5064 if (enriched.teamName) {
5065 logForDebugging(
5066 `Session ${log.sessionId} filtered from /resume: teamName=${enriched.teamName}`,
5067 )
5068 return null
5069 }
5070
5071 return enriched
5072}
5073
5074/**
5075 * Enriches enough lite logs from `allLogs` (starting at `startIndex`) to

Callers 1

enrichLogsFunction · 0.85

Calls 2

readLiteMetadataFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected