MCPcopy
hub / github.com/claude-code-best/claude-code / renameRecordingForSession

Function renameRecordingForSession

src/utils/asciicast.ts:57–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55 * the file so getSessionRecordingPaths() can find it by the resumed session ID.
56 */
57export async function renameRecordingForSession(): Promise<void> {
58 const oldPath = recordingState.filePath
59 if (!oldPath || recordingState.timestamp === 0) {
60 return
61 }
62 const projectsDir = join(getClaudeConfigHomeDir(), 'projects')
63 const projectDir = join(projectsDir, sanitizePath(getOriginalCwd()))
64 const newPath = join(
65 projectDir,
66 `${getSessionId()}-${recordingState.timestamp}.cast`,
67 )
68 if (oldPath === newPath) {
69 return
70 }
71 // Flush pending writes before renaming
72 await recorder?.flush()
73 const oldName = basename(oldPath)
74 const newName = basename(newPath)
75 try {
76 await rename(oldPath, newPath)
77 recordingState.filePath = newPath
78 logForDebugging(`[asciicast] Renamed recording: ${oldName} → ${newName}`)
79 } catch {
80 logForDebugging(
81 `[asciicast] Failed to rename recording from ${oldName} to ${newName}`,
82 )
83 }
84}
85
86type AsciicastRecorder = {
87 flush(): Promise<void>

Callers 3

onSelectFunction · 0.85
REPLFunction · 0.85

Calls 6

getOriginalCwdFunction · 0.85
getSessionIdFunction · 0.85
renameFunction · 0.85
sanitizePathFunction · 0.70
logForDebuggingFunction · 0.70
flushMethod · 0.45

Tested by

no test coverage detected