From 740cc5b7323f91cd077c2eaa9d07c1b5d66db8a2 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 1 Jul 2026 03:18:33 -0700 Subject: [PATCH] fix(ui): localize expired pairing QR notice --- ui/src/ui/chat/grouped-render.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/src/ui/chat/grouped-render.ts b/ui/src/ui/chat/grouped-render.ts index 4b8c5e5bc18..94d918192df 100644 --- a/ui/src/ui/chat/grouped-render.ts +++ b/ui/src/ui/chat/grouped-render.ts @@ -1702,16 +1702,19 @@ const MAX_JSON_AUTOPARSE_CHARS = 20_000; * Size-capped to prevent render-loop DoS from large JSON messages. */ function detectJson(text: string): { parsed: unknown; pretty: string } | null { - const t = text.trim(); + const trimmed = text.trim(); // Enforce size cap to prevent UI freeze from multi-MB JSON payloads - if (t.length > MAX_JSON_AUTOPARSE_CHARS) { + if (trimmed.length > MAX_JSON_AUTOPARSE_CHARS) { return null; } - if ((t.startsWith("{") && t.endsWith("}")) || (t.startsWith("[") && t.endsWith("]"))) { + if ( + (trimmed.startsWith("{") && trimmed.endsWith("}")) || + (trimmed.startsWith("[") && trimmed.endsWith("]")) + ) { try { - const parsed = JSON.parse(t); + const parsed = JSON.parse(trimmed); return { parsed, pretty: JSON.stringify(parsed, null, 2) }; } catch { return null;