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