fix(terminal): Reconnect button swallowed by xterm's link-layer canvas #71
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/reconnect"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Reconnect button at the centre of a disconnected terminal pane did nothing.
Diagnosis
The button was never broken — the click never reached it.
xterm's webgl addon creates an
xterm-link-layercanvas spanning the whole pane with an inlinez-index: 2andpointer-events: auto. Nothing between that canvas and the overlay creates a stacking context — every ancestor (.xterm-screen,.xterm,.terminal-mount,.terminal-body) isz-index: auto— so xterm's internal z-indices escaped their container and competed directly with.disconnected-overlay'sz-index: auto(= 0). The canvas won every hit test.That canvas is transparent (it only paints link underlines), which is why the failure looked so strange: the overlay and its button render perfectly, you click dead centre, and nothing happens.
Measured on the unfixed build:
document.elementFromPoint()at the button's centre returnedxterm-link-layer, not the button.WebSocketconstructor instrumented, clicking Reconnect produced zero connection attempts.There's a nice irony in the existing comment above the overlay markup, which worried that a permanently-present overlay "would swallow clicks meant for the terminal." The real relationship was inverted: the terminal was swallowing the overlay's clicks.
Fix
One line —
isolation: isolateon.terminal-mount.This scopes xterm's layers to the mount rather than bidding the overlay above a number xterm owns. Hardcoding
z-index: 12would work today but is brittle: xterm's own CSS already reaches 11 (the scrollbar), and that's free to change on any upgrade — silently, with this exact invisible-but-broken failure mode.Verification
The suite is
environment: 'node'with no DOM, so it structurally cannot catch this. Verified by driving the real UI in a browser (server seeded with a fake worker/session so the pane lands in the disconnected state):ws://…/api/workers/w1/sessions/s1/terminal.xterm-link-layer— the terminal still receives its own clicks — and xterm's internal layer order (5, 2, auto) is unchanged. Isolation scoped those layers without reordering them.Caveats
lz referenced this pull request2026-07-17 17:20:42 +02:00