()
| 22 | * The path is computed once and cached in recordingState. |
| 23 | */ |
| 24 | export function getRecordFilePath(): string | null { |
| 25 | if (recordingState.filePath !== null) { |
| 26 | return recordingState.filePath |
| 27 | } |
| 28 | if (process.env.USER_TYPE !== 'ant') { |
| 29 | return null |
| 30 | } |
| 31 | if (!isEnvTruthy(process.env.CLAUDE_CODE_TERMINAL_RECORDING)) { |
| 32 | return null |
| 33 | } |
| 34 | // Record alongside the transcript. |
| 35 | // Each launch gets its own file so --continue produces multiple recordings. |
| 36 | const projectsDir = join(getClaudeConfigHomeDir(), 'projects') |
| 37 | const projectDir = join(projectsDir, sanitizePath(getOriginalCwd())) |
| 38 | recordingState.timestamp = Date.now() |
| 39 | recordingState.filePath = join( |
| 40 | projectDir, |
| 41 | `${getSessionId()}-${recordingState.timestamp}.cast`, |
| 42 | ) |
| 43 | return recordingState.filePath |
| 44 | } |
| 45 | |
| 46 | export function _resetRecordingStateForTesting(): void { |
| 47 | recordingState.filePath = null |
no test coverage detected