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