fix: UTF-8 terminal rendering — atob() decodes as Latin-1, not UTF-8
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 1m5s

atob() returns a "binary string" where each byte is a Latin-1 char code.
Multi-byte UTF-8 sequences (box-drawing, em dashes, arrows) were split
into separate Latin-1 codepoints, producing mojibake. Now reconstructs
the raw byte array and decodes via TextDecoder('utf-8') before writing
to xterm.js.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-17 13:00:29 -04:00
parent 1d61b1faf2
commit 9fce0b6c1e

View File

@ -114,8 +114,14 @@ export function useTerminal(sessionId: string): UseTerminalReturn {
} }
try { try {
const decoded = atob(b64data); // atob() returns Latin-1 — each byte becomes a char code 0x000xFF.
terminal.write(decoded); // We must reconstruct the raw bytes, then decode as UTF-8.
const binaryStr = atob(b64data);
const bytes = new Uint8Array(binaryStr.length);
for (let i = 0; i < binaryStr.length; i++) {
bytes[i] = binaryStr.charCodeAt(i);
}
terminal.write(new TextDecoder().decode(bytes));
} catch { } catch {
// Fallback: write raw if not valid base64 // Fallback: write raw if not valid base64
terminal.write(b64data); terminal.write(b64data);