Skip to content

Windows: Relay embedded pages' error and network reports - #1005

Merged
AllTerrainDeveloper merged 1 commit into
trunkfrom
fix/editor-network-reports
Oct 13, 2026
Merged

AllTerrainDeveloper merged 1 commit into
trunkfrom
fix/editor-network-reports

Conversation

@AllTerrainDeveloper

@AllTerrainDeveloper AllTerrainDeveloper commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What

An admin page embedded in a native window — an iframeContent window, or embedAdminPage(), which is how the Posts app shows the block editor — never reached os.iframe.network-completed or os.iframe.error. The editor's REST, autosave and Heartbeat traffic and its JavaScript errors were invisible to devtools and to any other subscriber of those hooks.

Why

The chromeless bridge inside the embedded page already posts os-iframe-network (every fetch/XHR) and os-iframe-error (every uncaught error) to the shell. But only handleWindowMessage in src/window/iframe-bridge.ts relayed them, and it routes messages from Window.iframe — which is null for a native window. The native-window message handler in buildIframeContentRender() (src/native-windows.ts) forwarded identity, location, os-bridge-* and window-channel messages, but not these two.

Fix

  • New src/window/iframe-reports.ts — relayIframeReport( windowId, data ) builds the IFRAME_ERROR / IFRAME_NETWORK_COMPLETED payloads (moved verbatim from iframe-bridge.ts, headers-only-when-observed behaviour kept).
  • iframe-bridge.ts calls it instead of building the payloads inline (no behaviour change for iframe windows).
  • native-windows.ts calls it for its embedded iframe, behind the same checks it already applies (message from this iframe's contentWindow) plus same-origin, matching the bridge's trust boundary. windowId is the owning native window.
  • Hook docblocks in src/hooks.ts and the hook table in docs/javascript-reference.md now say both kinds of frame are covered.

Testing

  • New src/window/iframe-reports.test.ts (payload normalisation, non-reports ignored).
  • tests/vitest/embed-admin-page.test.ts: an embedded page's network and error reports reach the hooks tagged with the window; reports from another frame, another origin, or after teardown are ignored. The two positive cases fail without the native-windows.ts change.
  • Full suite: 535 files / 6,700 tests pass; tsc --noEmit clean; eslint clean (only the existing file-length warnings).
  • Manual, on a local site: open the Posts app → Add Post, then call wp.apiFetch() inside the editor. Before: no os.iframe.network-completed for the editor window. After: every editor request fires it, tagged desktop-mode-posts….

🤖 Generated with Claude Code

Open WordPress Playground Preview

An admin page embedded in a native window — an `iframeContent` window
or `embedAdminPage()`, which is how the Posts app shows the block
editor — runs the chromeless bridge, which posts `os-iframe-network`
for every fetch/XHR and `os-iframe-error` for every uncaught error.
Only iframe windows relayed those to `os.iframe.network-completed` and
`os.iframe.error`: `handleWindowMessage` routes messages from
`Window.iframe`, which is null for a native window. So the editor's
REST, autosave and Heartbeat traffic and its JavaScript errors never
reached devtools or any other subscriber.

Move the relay into `src/window/iframe-reports.ts` and call it from
both paths, so embedded pages dispatch the same hooks with the same
payloads, tagged with their window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 70f2fc4 into trunk Oct 13, 2026
7 checks passed
@AllTerrainDeveloper
AllTerrainDeveloper deleted the fix/editor-network-reports branch October 13, 2026 10:51
AllTerrainDeveloper added a commit that referenced this pull request Oct 14, 2026
* Wallpapers: Add the Pulse Monitor wallpaper and widget

A PixiJS ECG wired to the site, as a canvas wallpaper (`wp-pulse`) and
a widget (`desktop-mode/pulse`) that ship in one bundle and share one
engine, one signal hub and one settings bag.

Every request the shell makes or sees is a labelled beat: wp.os.fetch,
raw fetch/XHR, sendBeacon, fetch/XHR inside admin windows, in-window
navigations and form posts, WordPress Heartbeat, assets, window events,
input, messages, toasts, uploads and errors. A Heartbeat-relayed server
feed (includes/pulse-monitor.php) adds what only the server sees:
visitors, bots, comments, publishes, orders, logins, API calls, cron,
other people's admin traffic, and the listener's own block-editor
requests, which the shell cannot observe.

Failed beats are drawn amber and say why ("request · 404", "heartbeat ·
timeout", "PVC: slow responses"). The rhythm is a health diagnosis —
sinus, PVCs, atrial fibrillation, ventricular tachycardia, flatline —
capped by kind of trouble so that only failing requests reach VT.
Latency samples from hidden tabs are ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Pulse Monitor: Hear the block editor live; keep VT for failing sites

The block editor's windows are cross-origin isolated, and the shell's
window bridge does not re-dispatch their `os-iframe-network` reports as
`os.iframe.network-completed` — so the editor's REST, autosave and
Heartbeat traffic never reached the trace in real time. Read those
reports straight off the message (same-origin, sent by one of the
desk's own iframes) and drop the server-side workaround that relayed
the listener's own editor requests one Heartbeat tick late.

The diagnosis now requires substantial failure (~16 % of requests)
before drawing ventricular tachycardia, and failure or slowness before
fibrillation; abnormal beats print the reason that justified the
rhythm. A slow, misconfigured site with a few 404s used to read as VT
"caused by" slowness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Pulse Monitor: Beat for requests in windows without the bridge

A window page that never reached `admin_footer` — a 404, a fatal error —
has no chromeless bridge, so its fetch/XHR were never reported. Count
those from the frame's resource timing instead, and keep skipping it
for bridged pages, which report their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Pulse Monitor: Hear windows through os.iframe.network-completed

Since #1005 the shell relays the chromeless bridge's network reports
for admin pages embedded in native windows too, so the block editor's
traffic reaches the hook. Subscribe to it again instead of reading the
bridge's messages directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Pulse Monitor: Address review; reserved band, Issues window, widget settings

Review fixes (both passes on #1006):
- PHP feed: drop the @SInCE tags; one openstation_pulse_read_log() for
  the writer and the Heartbeat relay; relay everything after a log reset;
  only comments, reviews, pingbacks and trackbacks beat (not order notes);
  skip WP-CLI; drop the unused `load` field; document the write cost and
  the best-effort (lock-free) log in the docblock and docs.
- Signals: release each window document's taps on pagehide or when its
  frame goes away; cancel the follow-up scan on teardown; ignore requests
  the page cancelled itself (the chromeless bridge now reports
  `aborted`, relayed on os.iframe.network-completed).
- Diagnosis: cap a request at 10 s and need 20 samples for p95, so one
  long call cannot make the site look slow.
- Audio context only while sound is on; paused or reduced-motion monitors
  drop beats instead of queueing them; the alarm pauses with the trace.
- Labels positioned with physical left/top (RTL); readout clear of the
  docked pill; the widget gear is an <os-button variant="ghost">, and its
  dialog closes with the widget.
- docs/data-model.md lists openstation_pulse_log and _listeners.

New:
- Work area reservations (wp.os.workArea.reserve / reservedRectOf /
  placementRectOf, Experimental): a band nothing may use — maximize,
  snap, new windows, icons, widgets and notes stay out, and dragging,
  resizing and pinned positions stop at it.
- Wallpaper layout setting: whole wallpaper, or a reserved top band
  (56–300 px, 88 by default; off on phones).
- Issues window (click the numbers in the band or widget, a settings
  button, or the command palette): the diagnosis itemised with Site
  Health links, and every failure with URL, method, status and window.
- The widget keeps its own settings; the trace survives browser
  resizes; smaller numbers; a clock icon on the response time; the
  settings dialog's headings use the dialog's colour tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant