From 95b05ca64425f62b4ea851b679098b4293bd1e64 Mon Sep 17 00:00:00 2001 From: can1357 Date: Thu, 12 Feb 2026 15:25:13 +0100 Subject: [PATCH] fix(coding-agent): add Bun runtime errata guard for OSC sequence width bug Detects known Bun.stringWidth mishandling of OSC sequences at startup and exits with a clear upgrade message instead of crashing in the TUI render path. Fixes #31 --- packages/coding-agent/src/cli.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/coding-agent/src/cli.ts b/packages/coding-agent/src/cli.ts index fea8044d7..e6e512f38 100755 --- a/packages/coding-agent/src/cli.ts +++ b/packages/coding-agent/src/cli.ts @@ -6,6 +6,14 @@ import { type CommandEntry, run } from "@oh-my-pi/pi-utils/cli"; import { APP_NAME, VERSION } from "./config"; +// Detect known Bun errata that cause TUI crashes (e.g. Bun.stringWidth mishandling OSC sequences). +if (Bun.stringWidth("\x1b[0m\x1b]8;;\x07") !== 0) { + process.stderr.write( + `error: Bun runtime errata detected (v${Bun.version}). Please update Bun: bun upgrade\n`, + ); + process.exit(1); +} + process.title = APP_NAME; const commands: CommandEntry[] = [