MCPcopy Create free account
hub / github.com/Noumena-Network/code / runAltScreenRecoveryCapture

Function runAltScreenRecoveryCapture

src/ink/tmuxResetSequence.test.ts:293–332  ·  view source on GitHub ↗
(
  recoveryPreamble: string,
  diff: Diff,
  name: string,
)

Source from the content-addressed store, hash-verified

291}
292
293async function runAltScreenRecoveryCapture(
294 recoveryPreamble: string,
295 diff: Diff,
296 name: string,
297): Promise<{ mid: string; final: string }> {
298 const tmpDir = mkdtempSync(join(tmpdir(), 'code-tmux-alt-screen-recovery-'))
299 try {
300 const preamblePath = join(tmpDir, `${name}.preamble.seq`)
301 const diffPath = join(tmpDir, `${name}.diff.seq`)
302 const midReadyPath = join(tmpDir, `${name}.mid.ready`)
303 const donePath = join(tmpDir, `${name}.done.ready`)
304 writeFileSync(preamblePath, recoveryPreamble)
305 writeFileSync(diffPath, serializeDiff(diff))
306
307 const session = createIsolatedTmuxSession({
308 command:
309 `bash -lc '` +
310 `printf "\\033[?1049h"; ` +
311 `printf "OLD1\\nOLD2\\nOLD3"; ` +
312 `cat ${shellQuote(preamblePath)}; ` +
313 `touch ${shellQuote(midReadyPath)}; ` +
314 `sleep 1; ` +
315 `cat ${shellQuote(diffPath)}; ` +
316 `touch ${shellQuote(donePath)}; ` +
317 `sleep 5` +
318 `'`,
319 width: 80,
320 height: 10,
321 })
322 liveSessions.push(session)
323
324 await waitForFile(midReadyPath)
325 const mid = capturePane(session, { startLine: -40 })
326 await waitForFile(donePath)
327 const final = capturePane(session, { startLine: -40 })
328 return { mid, final }
329 } finally {
330 rmSync(tmpDir, { recursive: true, force: true })
331 }
332}
333
334async function runNormalScreenRepaintBelowPromptCapture(
335 initialDiff: Diff,

Callers 1

Calls 6

rmSyncFunction · 0.90
capturePaneFunction · 0.85
serializeDiffFunction · 0.70
waitForFileFunction · 0.70
shellQuoteFunction · 0.50

Tested by

no test coverage detected