From 49df4c2e9ed2dee3845d8d89f9053f86d5f7c4d4 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Mon, 7 Sep 2026 20:33:34 +0100 Subject: [PATCH] fix(web): surgical DOM patch for tool rows to stop flashing Patch deltas on existing rows now swap just the affected element via replaceWith() instead of tearing down and rebuilding the entire transcript. Stops the visible flash and preserves text selection. Co-Authored-By: Claude Opus 4.6 --- web/src/structured.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/web/src/structured.ts b/web/src/structured.ts index 4390e27..82db8f2 100644 --- a/web/src/structured.ts +++ b/web/src/structured.ts @@ -551,6 +551,19 @@ export function createStructuredConnection( rows.push(delta.row); } else { rows[i] = delta.row; + // Surgical DOM swap: replace just this row's element instead of + // tearing down and rebuilding the entire transcript, which causes + // visible flashing and breaks text selection. + const oldEl = rowEls.get(delta.row.id); + if (oldEl) { + const newEl = buildRowElement(delta.row); + if (newEl) { + oldEl.replaceWith(newEl); + rowEls.set(delta.row.id, newEl); + } + syncAvailableCommands(); + return; + } } } else { const i = rowIndex.get(delta.id);