Fix active-pane detection via activeElement polling

After exhausting event-based approaches that all failed in WebView2:
- per-leaf onpointerdown: xterm.js stopPropagation
- document-capture pointerdown: only first event ever delivered
- document-capture mousedown/click: never delivered at all
- document-capture focusin: silently fails
- term.onFocus: no such xterm.js API

The bulletproof fallback: poll document.activeElement every 250ms
and call orch.setActive on its closest [data-leaf-id] ancestor.
No DOM events involved. Verified working with automation: clicking
pane 2 turns its border blue, clicking pane 1 moves the border to
pane 1, etc.

XtermPane gained an onFocus prop (still wired through LeafPane) as a
secondary signal that might fire in some configurations, but the
polling is the actual fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-22 15:43:30 +01:00
parent 4fd613438c
commit f5f788652e
3 changed files with 38 additions and 15 deletions

View file

@ -214,6 +214,7 @@
}}
onSpawn={onPaneSpawned}
onInput={onTerminalInput}
onFocus={() => orch.setActive(leaf.id)}
{onDataReceived}
{focusTrigger}
/>