MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / runViewer

Function runViewer

scripts/tmux/tmux-viewer/index.tsx:116–202  ·  view source on GitHub ↗
(
  sessionName: string,
  jsonMode: boolean,
  replayMode: boolean,
  exportGif: string | boolean,
  frameDelay: number | undefined,
  fontSize: number | undefined,
  projectRoot: string
)

Source from the content-addressed store, hash-verified

114}
115
116async function runViewer(
117 sessionName: string,
118 jsonMode: boolean,
119 replayMode: boolean,
120 exportGif: string | boolean,
121 frameDelay: number | undefined,
122 fontSize: number | undefined,
123 projectRoot: string
124): Promise<void> {
125 // Load session data
126 let data
127 try {
128 data = await loadSession(sessionName, projectRoot)
129 } catch (error) {
130 console.log(red(`Error: ${(error as Error).message}`))
131 console.log('')
132 console.log('Available sessions:')
133 const sessions = await listSessions(projectRoot)
134 for (const s of sessions) {
135 console.log(` ${s}`)
136 }
137 process.exit(1)
138 }
139
140 // JSON mode - output and exit
141 if (jsonMode) {
142 const jsonOutput = sessionToJSON(data)
143 console.log(JSON.stringify(jsonOutput, null, 2))
144 process.exit(0)
145 }
146
147 // GIF export mode
148 if (exportGif) {
149 const outputPath = typeof exportGif === 'string'
150 ? exportGif
151 : getSuggestedFilename(data)
152
153 console.log(cyan(`Exporting session "${sessionName}" to GIF...`))
154 console.log(dim(` Frames: ${data.captures.length}`))
155 console.log(dim(` Delay: ${frameDelay ?? 1500}ms per frame`))
156 console.log(dim(` Output: ${outputPath}`))
157 console.log('')
158
159 try {
160 const result = await renderSessionToGif(data, {
161 outputPath,
162 frameDelay,
163 fontSize,
164 })
165 console.log(cyan(`✓ GIF exported successfully: ${result}`))
166 process.exit(0)
167 } catch (error) {
168 console.log(red(`✗ Failed to export GIF: ${(error as Error).message}`))
169 process.exit(1)
170 }
171 }
172
173 // Interactive TUI mode

Callers 1

mainFunction · 0.85

Calls 6

loadSessionFunction · 0.90
listSessionsFunction · 0.90
sessionToJSONFunction · 0.90
getSuggestedFilenameFunction · 0.90
renderSessionToGifFunction · 0.90
renderMethod · 0.65

Tested by

no test coverage detected