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);