(sessionId: string)
| 233 | } |
| 234 | |
| 235 | export function getTranscriptPathForSession(sessionId: string): string { |
| 236 | // When asking for the CURRENT session's transcript, honor sessionProjectDir |
| 237 | // the same way getTranscriptPath() does. Without this, hooks get a |
| 238 | // transcript_path computed from originalCwd while the actual file was |
| 239 | // written to sessionProjectDir (set by switchActiveSession on resume/branch) |
| 240 | // — different directories, so the hook sees MISSING (gh-30217). CC-34 |
| 241 | // made sessionId + sessionProjectDir atomic precisely to prevent this |
| 242 | // kind of drift; this function just wasn't updated to read both. |
| 243 | // |
| 244 | // For OTHER session IDs we can only guess via originalCwd — we don't |
| 245 | // track a sessionId→projectDir map. Callers wanting a specific other |
| 246 | // session's path should pass fullPath explicitly (most save* functions |
| 247 | // already accept this). |
| 248 | if (sessionId === getSessionId()) { |
| 249 | return getTranscriptPath() |
| 250 | } |
| 251 | const projectDir = getProjectDir(getOriginalCwd()) |
| 252 | return join(projectDir, `${sessionId}.jsonl`) |
| 253 | } |
| 254 | |
| 255 | // 50 MB — session JSONL can grow to multiple GB (inc-3930). Callers that |
| 256 | // read the raw transcript must bail out above this threshold to avoid OOM. |
no test coverage detected