mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-12-03 12:32:02 +00:00
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
This commit is contained in:
parent
db993196cf
commit
c511627e87
4 changed files with 19 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import { formatCost } from './format.js'
|
|||
import { parseAllSessions } from './parser.js'
|
||||
import { getAllProviders } from './providers/index.js'
|
||||
import type { ProjectSummary, DateRange } from './types.js'
|
||||
import { patchStdoutForWindows } from './ink-win.js'
|
||||
|
||||
const ORANGE = '#FF8C42'
|
||||
const GREEN = '#5BF5A0'
|
||||
|
|
@ -448,6 +449,7 @@ export async function renderCompare(range: DateRange, provider: string): Promise
|
|||
return
|
||||
}
|
||||
|
||||
patchStdoutForWindows()
|
||||
const projects = await parseAllSessions(range, provider)
|
||||
const { waitUntilExit } = render(
|
||||
<CompareView projects={projects} onBack={() => process.exit(0)} />
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { CompareView } from './compare.js'
|
|||
import { getPlanUsageOrNull, type PlanUsage } from './plan-usage.js'
|
||||
import { planDisplayName } from './plans.js'
|
||||
import { join } from 'path'
|
||||
import { patchStdoutForWindows } from './ink-win.js'
|
||||
|
||||
type Period = 'today' | 'week' | '30days' | 'month' | 'all'
|
||||
type View = 'dashboard' | 'optimize' | 'compare'
|
||||
|
|
@ -805,6 +806,7 @@ export async function renderDashboard(period: Period = 'week', provider: string
|
|||
const filteredProjects = filterProjectsByName(await parseAllSessions(range, provider), projectFilter, excludeFilter)
|
||||
const planUsage = await getPlanUsageOrNull()
|
||||
const isTTY = process.stdin.isTTY && process.stdout.isTTY
|
||||
patchStdoutForWindows()
|
||||
if (isTTY) {
|
||||
const { waitUntilExit } = render(
|
||||
<InteractiveDashboard initialProjects={filteredProjects} initialPeriod={period} initialProvider={provider} initialPlanUsage={planUsage ?? undefined} refreshSeconds={refreshSeconds} projectFilter={projectFilter} excludeFilter={excludeFilter} />
|
||||
|
|
|
|||
14
src/ink-win.ts
Normal file
14
src/ink-win.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ function loadDriver(): boolean {
|
|||
`(underlying error: ${message})`
|
||||
return false
|
||||
} finally {
|
||||
restore()
|
||||
process.nextTick(restore)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue