* 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, )
| 5291 | * (no firstPrompt, no customTitle — e.g., metadata-only session files). |
| 5292 | */ |
| 5293 | async function enrichLog( |
| 5294 | log: LogOption, |
| 5295 | readBuf: Buffer, |
| 5296 | ): Promise<LogOption | null> { |
| 5297 | if (!log.isLite || !log.fullPath) return log |
| 5298 | |
| 5299 | const meta = await readLiteMetadata(log.fullPath, log.fileSize ?? 0, readBuf) |
| 5300 | |
| 5301 | const enriched: LogOption = { |
| 5302 | ...log, |
| 5303 | isLite: false, |
| 5304 | firstPrompt: meta.firstPrompt, |
| 5305 | gitBranch: meta.gitBranch, |
| 5306 | isSidechain: meta.isSidechain, |
| 5307 | teamName: meta.teamName, |
| 5308 | customTitle: meta.customTitle, |
| 5309 | summary: meta.summary, |
| 5310 | tag: meta.tag, |
| 5311 | agentSetting: meta.agentSetting, |
| 5312 | prNumber: meta.prNumber, |
| 5313 | prUrl: meta.prUrl, |
| 5314 | prRepository: meta.prRepository, |
| 5315 | projectPath: meta.projectPath ?? log.projectPath, |
| 5316 | } |
| 5317 | |
| 5318 | // Provide a fallback title for sessions where we couldn't extract the first |
| 5319 | // prompt (e.g., large first messages that exceed the 16KB read buffer). |
| 5320 | // Previously these sessions were silently dropped, making them inaccessible |
| 5321 | // via /resume after crashes or large-context sessions. |
| 5322 | if (!enriched.firstPrompt && !enriched.customTitle) { |
| 5323 | enriched.firstPrompt = '(session)' |
| 5324 | } |
| 5325 | // Filter: skip sidechains and agent sessions |
| 5326 | if (enriched.isSidechain) { |
| 5327 | logForDebugging( |
| 5328 | `Session ${log.sessionId} filtered from /resume: isSidechain=true`, |
| 5329 | ) |
| 5330 | return null |
| 5331 | } |
| 5332 | if (enriched.teamName) { |
| 5333 | logForDebugging( |
| 5334 | `Session ${log.sessionId} filtered from /resume: teamName=${enriched.teamName}`, |
| 5335 | ) |
| 5336 | return null |
| 5337 | } |
| 5338 | |
| 5339 | return enriched |
| 5340 | } |
| 5341 | |
| 5342 | /** |
| 5343 | * Enriches enough lite logs from `allLogs` (starting at `startIndex`) to |
no test coverage detected