From f799aaf564575ba9da3c133d228b7df29ab241b9 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Tue, 8 Sep 2026 15:37:50 +0100 Subject: [PATCH] fix(maestro): restore focus after surgical tool-row patch The patch path did a DOM replaceWith and returned early, skipping the focus-restoration logic in rebuildTranscript. Now saves and restores tool-head focus within the surgical swap. Co-Authored-By: Claude Opus 4.6 --- web/src/structured.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/src/structured.ts b/web/src/structured.ts index 56f046f..3651215 100644 --- a/web/src/structured.ts +++ b/web/src/structured.ts @@ -634,10 +634,15 @@ export function createStructuredConnection( // visible flashing and breaks text selection. const oldEl = rowEls.get(delta.row.id); if (oldEl) { + const active = document.activeElement as HTMLElement | null; + const hadToolFocus = active?.classList.contains("st-tool-head") && oldEl.contains(active); const newEl = buildRowElement(delta.row); if (newEl) { oldEl.replaceWith(newEl); rowEls.set(delta.row.id, newEl); + if (hadToolFocus) { + newEl.querySelector(".st-tool-head")?.focus(); + } } syncAvailableCommands(); return;