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

Function renameRecordingForSession

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

Source from the content-addressed store, hash-verified

80 * the file so getSessionRecordingPaths() can find it by the resumed session ID.
81 */
82export async function renameRecordingForSession(): Promise<void> {
83 const oldPath = recordingState.filePath
84 if (!oldPath || recordingState.timestamp === 0) {
85 return
86 }
87 const projectsDir = join(getClaudeConfigHomeDir(), 'projects')
88 const projectDir = join(projectsDir, sanitizePath(getOriginalCwd()))
89 const newPath = join(
90 projectDir,
91 `${getSessionId()}-${recordingState.timestamp}.cast`,
92 )
93 if (oldPath === newPath) {
94 return
95 }
96 // Flush pending writes before renaming
97 await recorder?.flush()
98 const oldName = basename(oldPath)
99 const newName = basename(newPath)
100 try {
101 await rename(oldPath, newPath)
102 recordingState.filePath = newPath
103 logForDebugging(`[asciicast] Renamed recording: ${oldName} → ${newName}`)
104 } catch {
105 logForDebugging(
106 `[asciicast] Failed to rename recording from ${oldName} to ${newName}`,
107 )
108 }
109}
110
111type AsciicastRecorder = {
112 flush(): Promise<void>

Callers 3

onSelectFunction · 0.85
REPLFunction · 0.85

Calls 6

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

Tested by

no test coverage detected