mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-24 13:57:02 +00:00
The desktop app capped every read at 45s of TOTAL runtime, so a slow machine's warm `optimize` (52.5s on 0.9.20, 39.6s on main) was SIGKILLed mid-parse and the panel painted a red "timed out" that a 60s poll then reproduced forever. - cli.ts: the read timeout is now a no-output watchdog. The window restarts on every byte the child writes (serve: every frame carrying that request's id), so only a genuinely silent child times out. A 15-minute absolute ceiling still reaps a livelocked child. Every read spawn sets CODEBURN_PROGRESS=1 so a long parse heartbeats through it; progress lines are stripped from any surfaced stderr so they can never become the error message. - cli.ts: a timed-out child gets SIGTERM first and SIGKILL only after a 5s grace, on both the spawn and the serve branch. That lets the CLI's signal cleanup publish its partial parse and release the cross-process refresh lock instead of leaving both stale. - main.ts: the 10-minute cold floor now covers EVERY read while the first hydration is still running, not just the overview. Sections start polling the moment `ready` flips (which an overview error also does), and a 45s section spawn queued behind the cold parse was killed on arrival. - main.ts/renderer: a timeout raised while the hydration is still running is flagged `cold`, and the renderer keeps its indexing splash (and keeps the sections gated) instead of latching ready and painting CliErrorPanel. Only timeouts are flagged; a permission or nonzero failure still surfaces. - cli.ts/main.ts: the resident serve child's pid is recorded under userData and a serve orphaned by a previous crash is reaped at launch, after `ps` confirms the pid still belongs to a codeburn serve. - src/main.ts: `codeburn serve` exits explicitly once its stdin closes, so a handle outliving the transport cannot keep the child alive as an orphan.
23 lines
932 B
TypeScript
23 lines
932 B
TypeScript
import type { CliError, CodeburnBridge } from './types'
|
|
|
|
// The preload script (app/electron/preload.ts) exposes `window.codeburn` as the
|
|
// typed CodeburnBridge (methods resolve to CLI JSON or reject with a plain
|
|
// CliError).
|
|
declare global {
|
|
interface Window {
|
|
codeburn: CodeburnBridge
|
|
}
|
|
}
|
|
|
|
/** The typed bridge. Import this instead of touching `window` directly. */
|
|
export const codeburn: CodeburnBridge = window.codeburn
|
|
|
|
/** Coerce anything thrown across the IPC boundary into a CliError shape. */
|
|
export function normalizeCliError(err: unknown): CliError {
|
|
if (err && typeof err === 'object' && 'kind' in err && typeof (err as CliError).kind === 'string') {
|
|
const e = err as CliError
|
|
return { kind: e.kind, message: e.message ?? 'codeburn CLI error', ...(e.cold ? { cold: true as const } : {}) }
|
|
}
|
|
const message = err instanceof Error ? err.message : String(err)
|
|
return { kind: 'nonzero', message }
|
|
}
|