codeburn/src/ink-win.ts
iamtoruk c511627e87 Fix dashboard hang and ExperimentalWarning on Windows
Strip Ink v7 DEC mode 2026 synchronized output markers (BSU/ESU) on
Windows. ConPTY does not implement this protocol and buffers
indefinitely, causing the dashboard to hang with no output. The patch
intercepts standalone BSU/ESU writes on stdout while preserving full
interactivity (keyboard, live refresh, cursor management).

Fix ExperimentalWarning timing: the process.emit patch was restored
synchronously in the finally block, but Node defers the warning via
process.nextTick. Delay restore by one tick so the patch is still
active when the warning fires.

Closes #195
2026-05-02 11:54:58 -07:00

14 lines
477 B
TypeScript

const BSU = '\x1b[?2026h'
const ESU = '\x1b[?2026l'
let patched = false
export function patchStdoutForWindows(): void {
if (process.platform !== 'win32' || patched) return
patched = true
const origWrite = process.stdout.write.bind(process.stdout)
process.stdout.write = function (chunk: unknown, ...args: unknown[]): boolean {
if (chunk === BSU || chunk === ESU) return true
return (origWrite as Function)(chunk, ...args)
} as typeof process.stdout.write
}