fix(maestro): preserve web tool patch state

This commit is contained in:
Miguel Palhas
2026-09-05 08:53:22 +01:00
parent d55d92d58a
commit 443800bd79
2 changed files with 109 additions and 0 deletions
+6
View File
@@ -159,10 +159,16 @@ export function createStructuredConnection(
function remountRow(row: TranscriptRow): void {
const old = rowEls.get(row.id);
const oldToolHead = old?.querySelector<HTMLButtonElement>(".st-tool-head") ?? null;
const wasExpanded = oldToolHead?.getAttribute("aria-expanded") === "true";
const restoreFocus = document.activeElement === oldToolHead;
const el = buildTranscriptRow(row, approvalStateFor(row));
rowEls.set(row.id, el);
if (old) old.replaceWith(el);
else rowsEl.appendChild(el);
const newToolHead = el.querySelector<HTMLButtonElement>(".st-tool-head");
if (wasExpanded) newToolHead?.click();
if (restoreFocus) newToolHead?.focus();
}
function applySnapshot(snapshot: { rows: TranscriptRow[] }): void {