From d97a96493cd72e1a8a552fe46ca48e207ca193b9 Mon Sep 17 00:00:00 2001 From: cursive <44798535+Cursivez@users.noreply.github.com> Date: Fri, 2 Jan 2026 17:32:36 +0800 Subject: [PATCH] fix(tui): Strip OSC 8 hyperlink sequences in visibleWidth (#396) --- packages/tui/src/utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/tui/src/utils.ts b/packages/tui/src/utils.ts index 1e87722b..1a7b7767 100644 --- a/packages/tui/src/utils.ts +++ b/packages/tui/src/utils.ts @@ -108,7 +108,10 @@ export function visibleWidth(str: string): number { clean = clean.replace(/\t/g, " "); } if (clean.includes("\x1b")) { + // Strip SGR codes (\x1b[...m) and cursor codes (\x1b[...G/K/H/J) clean = clean.replace(/\x1b\[[0-9;]*[mGKHJ]/g, ""); + // Strip OSC 8 hyperlinks: \x1b]8;;URL\x07 and \x1b]8;;\x07 + clean = clean.replace(/\x1b\]8;;[^\x07]*\x07/g, ""); } // Calculate width