Skip to content

feat(overlay): show HTML pages on the Mac presenting a session - #793

Merged
umputun merged 12 commits into
masterfrom
remote-html-overlays
Oct 21, 2026
Merged

umputun merged 12 commits into
masterfrom
remote-html-overlays

Conversation

@umputun

@umputun umputun commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

an HTML page opened on a session another Mac presents now opens on the presenting Mac, the same way a program overlay already does. Before this, a page on such a session was refused with OverlayHtmlError.presenter.

The placement rule is the program overlay's: the page goes to the presenter when its target pane reports follower on the origin (every existing pane for a session-wide page), and stays local otherwise. Pages already open stay where they are.

  • URL pages (--url) load directly on the presenting Mac, with its own --persistent storage. A loopback URL is refused, since it names a server on the origin.
  • File pages (--html) are served from the origin. The presenting Mac runs ssh -T <origin> agtermctl session overlay page-serve <token>, a single-use claim bound to the page and the presenter, and loads the page and the files inside its --cwd grant through an agterm-page:// scheme handler, on demand, in bounded chunks. The page's data-agterm tags and agterm.request calls go over the same channel. Commands execute on the origin, using the page's origin-side defaults, and overlay submit answers the caller there.
  • On the origin the slot is reserved and the page id is registered as usual, so result --page and --html --block work unchanged. close ends the origin reservation immediately and asks the presenter to close the page; resize, reload, navigate back|forward and hide|show|toggle are sent to the presenter as requests. tree lists the page with remote: true and the state the presenter reports back (load state, address, title, history, hidden).
  • Ending: a presenter that refuses the page, or a lost presenter, ends it dismissed on the origin, keeping an answer already submitted. Losing the page channel or missing the 30 second claim window ends only the page.
  • An older presenter keeps the refusal, gated on the page kinds in its hello. An open request too large for one presentation frame is refused before anything is reserved.

The new command is session.overlay.page.serve, plumbing for the presenting Mac and refused from a page bridge. The user guide, command reference, agent skill, ARCHITECTURE.md and the control API rules are updated, and the plan is in docs/plans/completed/20261021-remote-html-overlays.md.

ControlServerRemotePresentationTests covers a file page handed to the presenter end to end, with both app roles in one process using the real agtermctl helpers: the page's stylesheet fetched through the channel, a bridge submit recorded as the origin page's result, state mirrored back, presenter loss, and an older presenter keeping the refusal.

the branch also carries a zmx fix found through a flaky CI test: zmx binds a new session's socket and then listens, and zmx list deletes a socket that refuses a connection as stale, so a probe in between (the session host lists right after it starts session creation) can leave the daemon running but unreachable. scripts/zmx-patches/0003-atomic-socket-publish.patch stages the socket in .s/<pid>, which listing skips, and hard-links it to the session name once it listens. Upstream 7f0ffdb still has the window. This is a candidate cause of the intermittent SessionHostFishSeamTests failures, not a proven one.

Add HtmlPageSchemeHandler, which serves agterm-page://<page-id>/<path>
from an async source, so a page whose files live on another Mac loads in
WebKit as if they were local. Each request runs in its own task and is
cancelled when WebKit stops it; a request for another page id never
reaches the source.

The hosted tests prove the transport the remote page design relies on:
relative stylesheets, images and ES modules, fetch, pushState and
back/forward all work on the custom scheme.

Adds the implementation plan for showing HTML overlays on a presenting Mac.
Add the page frames a presentation stream carries (request, rejected,
close, closed, command, state), with the page's full source separate from
its display identity, sequence-numbered commands and bounded state.

Add the page channel's own frames and codec: resource transfers and bridge
calls multiplexed by request id, bridge payloads carried as raw JSON so
only the origin decodes them, chunk bodies capped at 64 KiB.

Add session.overlay.page.serve, the claim a presenter's helper makes for
a page's channel, refused from a page's bridge and unsupported by default
for other hosts.

Add the replica page source a presenter shows, allowed to load only from
its own agterm-page origin, and the tree fields that mark a remote page,
a replica and a reservation's page id. Until the presenter side exists,
a page request is answered with page.rejected.
A page opened on a session another Mac presents now goes to that Mac
under the program overlay placement rule: the slot is reserved here, the
page's outcome registered pending, and a page.request sent with a
single-use claim token. When the rule keeps the page here (this Mac
leads, or roles are unknown or mixed) it opens locally; a presenter
without page support keeps the old refusal, and a loopback URL is
refused because it names a server on this Mac.

The origin mirrors what the presenter reports into htmlOverlays (marked
remote) and remoteOverlays (pageID). Hide, show and toggle on a remote
page are requests with sequence numbers: the reply and the next toggle
use a pending request until the presenter echoes it, then the reported
state. Close, resize, presenter loss, rejection and session removal end
or update the page, keeping an answer already submitted.

claimRemotePage admits a channel token once, within its deadline and for
the presenter it was handed to; RemotePageResources limits a channel's
file reads to the page's grant.
the origin adopts the helper's claimed connection as a page channel: it
serves the page file and files inside its grant off the main actor in
bounded chunks, relays bridge requests against the page's live place,
and ends only that page on helper loss, bad input or overload, keeping
the presenter. resource and bridge requests have separate nonblocking
limits, and every admitted transfer ends in one terminal frame.
`agtermctl session overlay page-serve <token>` claims a handed-over page
and copies its channel between stdio and the app untouched; a refused
claim exits 1. RemoteSession.pageServeCommand builds the `ssh -T` argv
with the same PATH chain as the presentation stream.
…g Mac

the presenter places a handed-over page in the mapped slot under its own
page id. a file page loads through the agterm-page scheme, its files and
bridge requests carried by a page-serve channel to the origin; a URL page
loads directly with no helper. origin commands (hide/show, reload,
back/forward, browser, resize) are applied and mirrored back as page
state with the applied sequence, and every way the page leaves its slot
tells the origin once. a socket submit on a replica is refused.
…g Mac

reload and back/forward on the origin reach the presenter; browser does
for a URL page, while finder and browser on a file page are refused with
"page is shown on another Mac". a gone presenter answers viewerGone.
bare overlay result answers the page's noResult, and overlay text/copy
its noRead, ahead of the remote program answers.
both roles run in one process over the real zmx present stream and the
real page-serve helper: a --js --cwd file page loads its stylesheet and
submits through its channel into the origin's ledger, the origin reads
the viewer's page state, presenter loss dismisses the page and tears down
the replica and helper, and a presenter without the page kinds keeps the
refusal.
control-api rules, the bundled skill, the site guide and command
reference, and ARCHITECTURE describe the page handoff: placement, the
page-serve channel, the origin's per-command answers for a remote page,
the remote/replica/pageID read-back and failure handling. the plan moves
to completed.
a page whose open request did not fit one presentation frame failed the
offer, so the hub dropped the presenter with every page it showed while
the open answered ok. The request is now encoded first and refused with
"page too large to show on another Mac" before anything is reserved.

replica sources lose their unread grant flag, and the page-serve resource
frame and mirrored page state lose revision fields nothing consumed. The
cancel-before-head test now holds the origin's answer, so a slot freed at
cancel time or released twice fails it.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 21:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Deploying agterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: ab3c7eb
Status: ✅  Deploy successful!
Preview URL: https://81c4ef40.agterm.pages.dev
Branch Preview URL: https://remote-html-overlays.agterm.pages.dev

View logs

the test waited for a real WebKit load of http://127.0.0.1:9/a to fail
before measuring, and on the CI runner that load did not settle in 10 s.
A file replica served by the fake page origin gives the same baseline
without the network; the measured writes and assertions are unchanged.
zmx binds a new session's socket path and then listens, and zmx list,
attach and the commands that connect to a session delete a path that
refuses a connection as stale. A probe between bind and listen can unlink
the new socket and leave the daemon running unreachable; the session host
lists right after it spawns a creator, so supervised creation is exposed.
This is a candidate cause of the intermittent SessionHostFishSeamTests
failures on CI.

Patch 0003 binds and listens in .s/<pid> beside the sessions, a directory
listing in every zmx version skips, then hard-links the socket to the
session name. The link refuses an existing name, so a losing creator gets
the AddressInUse a bind gave it and never removes the winner's socket.
A staged path too long for sockaddr_un keeps the old direct bind. Upstream
HEAD still has the window.
@umputun
umputun merged commit 4883f9b into master Oct 21, 2026
8 checks passed
@umputun
umputun deleted the remote-html-overlays branch October 21, 2026 23:25
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