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

Function loadCaptures

scripts/tmux/tmux-viewer/session-loader.ts:107–142  ·  view source on GitHub ↗

* Load all captures from a session directory * Checks captures/ subdirectory first, falls back to session directory

(sessionDir: string)

Source from the content-addressed store, hash-verified

105 * Checks captures/ subdirectory first, falls back to session directory
106 */
107async function loadCaptures(sessionDir: string): Promise<Capture[]> {
108 // Try captures/ subdirectory first, then fall back to session directory
109 const capturesSubdir = path.join(sessionDir, 'captures')
110 let capturesDir = sessionDir
111
112 try {
113 const stats = await fs.stat(capturesSubdir)
114 if (stats.isDirectory()) {
115 capturesDir = capturesSubdir
116 }
117 } catch {
118 // captures/ subdirectory doesn't exist, use session directory
119 }
120
121 const files = await fs.readdir(capturesDir)
122 const captureFiles = files
123 .filter(isCaptureFile)
124 .sort()
125
126 const captures: Capture[] = []
127
128 for (const filename of captureFiles) {
129 const filePath = path.join(capturesDir, filename)
130 const content = await fs.readFile(filePath, 'utf-8')
131 const { frontMatter, body } = parseFrontMatter(content)
132
133 captures.push({
134 path: filePath,
135 filename,
136 frontMatter,
137 content: body,
138 })
139 }
140
141 return captures
142}
143
144/**
145 * Build a unified timeline from commands and captures

Callers 1

loadSessionFunction · 0.85

Calls 2

parseFrontMatterFunction · 0.85
readFileMethod · 0.80

Tested by

no test coverage detected