(sessionId: string)
| 206 | } |
| 207 | |
| 208 | export function getTranscriptPathForSession(sessionId: string): string { |
| 209 | // When asking for the CURRENT session's transcript, honor sessionProjectDir |
| 210 | // the same way getTranscriptPath() does. Without this, hooks get a |
| 211 | // transcript_path computed from originalCwd while the actual file was |
| 212 | // written to sessionProjectDir (set by switchActiveSession on resume/branch) |
| 213 | // — different directories, so the hook sees MISSING (gh-30217). CC-34 |
| 214 | // made sessionId + sessionProjectDir atomic precisely to prevent this |
| 215 | // kind of drift; this function just wasn't updated to read both. |
| 216 | // |
| 217 | // For OTHER session IDs we can only guess via originalCwd — we don't |
| 218 | // track a sessionId→projectDir map. Callers wanting a specific other |
| 219 | // session's path should pass fullPath explicitly (most save* functions |
| 220 | // already accept this). |
| 221 | if (sessionId === getSessionId()) { |
| 222 | return getTranscriptPath() |
| 223 | } |
| 224 | const projectDir = getProjectDir(getOriginalCwd()) |
| 225 | return join(projectDir, `${sessionId}.jsonl`) |
| 226 | } |
| 227 | |
| 228 | // 50 MB — session JSONL can grow to multiple GB (inc-3930). Callers that |
| 229 | // read the raw transcript must bail out above this threshold to avoid OOM. |
no test coverage detected