Skip to content

Take the iframe leader chord only from the frame holding focus - #1556

Merged
nedtwigg merged 2 commits into
mainfrom
iframe-leader-focus-gate
Nov 3, 2026
Merged

nedtwigg merged 2 commits into
mainfrom
iframe-leader-focus-gate

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Nov 3, 2026

Copy link
Copy Markdown
Member

The leader chord now counts only from the frame holding focus, as a press report already does.

A framed page shares its shim's origin, so it can post any shim message with no gesture. leader ended passthrough for any live proxy origin, so a page in a background pane could take the terminal being typed into out of passthrough, and the typed keys then acted as command-mode shortcuts.

One gate, in the panel. IframePanel's listener now answers leader as well as pointerdown, and both pass one test: the sender is this panel's frame, and that frame holds document.activeElement. A message from any other frame moves no focus, selection, or mode. The Wall's second window listener and the registry of live proxy origins, which only that listener read, are gone. S303 covers both messages.

The other shim messages stay ungated. location, navigate, open-window, and theme-request reach only the sender's own pane: its header, its URL behind the same external-origin gate, a prompt that takes no keyboard and needs a click, and read-only theme values. None reaches selection or mode.

What this does not change. The gate cannot tell the shim from the page, so a page that holds focus can still post leader. docs/specs/security.md -> "Known gaps" now says so, next to the line on a frame focusing itself.

Testing

  • pnpm test at the root and tsc -b in lib pass. One earlier root run failed on a connection reset in a relay transport test, which this PR does not touch; the relay package passed alone, and the root suite passed on rerun.
  • Each gate condition's test goes red with that condition removed.
  • In the real Wall, in headless Chromium through innerdogfood, with real key events:
    • Before the change, a background frame's message took focus off the terminal, and a typed - split a pane.
    • After it, the same message leaves the terminal focused, and - reaches the terminal.
    • A real click enters the frame, and the real dual-tap chord from that frame returns to command mode, where - splits a pane.

Not run: the shipped Tauri and VS Code apps, and any WebKit build, for this change.

🤖 Generated with Claude Code

nedtwigg and others added 2 commits November 3, 2026 06:59
A framed page shares its shim's origin and can post the leader message with no
gesture, so a page in a background pane could end passthrough on the terminal
being typed into and turn the typed keys into shortcuts. The leader channel and
the press report now share one check, isFromFocusedFrame: the message's source
must be the frame holding this document's focus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The leader listener's only reason for a registry of live origins was accepting
any grant, and only the frame holding focus may now send it. Its panel already
hears that frame, so leader and pointerdown share one test there: this panel's
frame, holding focus. That also restores the tie to the panel, which a check
against whichever frame holds focus had dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 411ad66
Status: ✅  Deploy successful!
Preview URL: https://a408fc88.mouseterm.pages.dev
Branch Preview URL: https://iframe-leader-focus-gate.mouseterm.pages.dev

View logs

@nedtwigg
nedtwigg merged commit 49cae41 into main Nov 3, 2026
19 checks passed
@nedtwigg
nedtwigg deleted the iframe-leader-focus-gate branch November 3, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants