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

Function enrichLog

src/utils/sessionStorage.ts:5136–5183  ·  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

5134 * (no firstPrompt, no customTitle — e.g., metadata-only session files).
5135 */
5136async function enrichLog(
5137 log: LogOption,
5138 readBuf: Buffer,
5139): Promise<LogOption | null> {
5140 if (!log.isLite || !log.fullPath) return log
5141
5142 const meta = await readLiteMetadata(log.fullPath, log.fileSize ?? 0, readBuf)
5143
5144 const enriched: LogOption = {
5145 ...log,
5146 isLite: false,
5147 firstPrompt: meta.firstPrompt,
5148 gitBranch: meta.gitBranch,
5149 isSidechain: meta.isSidechain,
5150 teamName: meta.teamName,
5151 customTitle: meta.customTitle,
5152 summary: meta.summary,
5153 tag: meta.tag,
5154 agentSetting: meta.agentSetting,
5155 prNumber: meta.prNumber,
5156 prUrl: meta.prUrl,
5157 prRepository: meta.prRepository,
5158 projectPath: meta.projectPath ?? log.projectPath,
5159 }
5160
5161 // Provide a fallback title for sessions where we couldn't extract the first
5162 // prompt (e.g., large first messages that exceed the 16KB read buffer).
5163 // Previously these sessions were silently dropped, making them inaccessible
5164 // via /resume after crashes or large-context sessions.
5165 if (!enriched.firstPrompt && !enriched.customTitle) {
5166 enriched.firstPrompt = '(session)'
5167 }
5168 // Filter: skip sidechains and agent sessions
5169 if (enriched.isSidechain) {
5170 logForDebugging(
5171 `Session ${log.sessionId} filtered from /resume: isSidechain=true`,
5172 )
5173 return null
5174 }
5175 if (enriched.teamName) {
5176 logForDebugging(
5177 `Session ${log.sessionId} filtered from /resume: teamName=${enriched.teamName}`,
5178 )
5179 return null
5180 }
5181
5182 return enriched
5183}
5184
5185/**
5186 * Enriches enough lite logs from `allLogs` (starting at `startIndex`) to

Callers 1

enrichLogsFunction · 0.85

Calls 2

readLiteMetadataFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected