Skip to content

Add Personal WP desktop relay access#3746

Draft
akirk wants to merge 12 commits into
WordPress:trunkfrom
akirk:personal-wp-desktop-relay-sw
Draft

Add Personal WP desktop relay access#3746
akirk wants to merge 12 commits into
WordPress:trunkfrom
akirk:personal-wp-desktop-relay-sw

Conversation

@akirk
Copy link
Copy Markdown
Member

@akirk akirk commented Jun 3, 2026

What

Adds desktop access for Personal WP sessions so a site running on a phone can be opened from a desktop through the deployed relay.

Flow

  1. The user opens Personal WP on their phone and starts desktop access from Site Tools.
  2. The phone creates a relay session on the deployed site and starts polling /relay/{sessionId}/poll.
  3. The phone shows a share URL and short access code. The desktop can either open the share URL directly or enter the code at /connect.
  4. The desktop viewer loads the shared site through /relay/{sessionId}/request/....
  5. The relay stores each desktop HTTP request until the phone picks it up through its poll loop.
  6. The phone forwards the request into the running Playground instance, posts the response back to /relay/{sessionId}/response/{requestId}, and the relay returns it to the desktop browser.
  7. While the desktop viewer is open, it registers the existing Playground service worker and maps scoped URLs such as /scope:default/... to the relay request path. This keeps WordPress navigations, redirects, AJAX, forms, and direct scoped requests attached to the phone-backed session.
  8. Static assets such as WordPress CSS, JS, fonts, and images are read directly from the phone’s Playground filesystem and sent back in parallel. Dynamic requests still go through the serialized PHP request path.

Implementation

  • Adds relay.php for session creation, host polling, guest request waiting, and response delivery.
  • Adds a TunnelHost on the phone side that processes relay requests against the active Playground client.
  • Adds a desktop viewer for shared sessions and a short-code /connect flow.
  • Rewrites relayed HTML, CSS, script URL literals, and Location headers so requests stay inside the tunnel.
  • Uses a service-worker mapping for shared desktop sessions so direct /scope:default/... requests do not time out waiting for a local desktop Playground runtime.
  • Handles unsupported install-blueprint postMessages with a visible desktop notice instead of silently failing.
  • Adds a disconnect affordance in the desktop viewer’s connection pill.

Testing

  • npm exec nx run playground-remote:typecheck
  • npm exec nx run playground-personal-wp:typecheck
  • npm exec nx run playground-personal-wp:test
  • php -l packages/playground/personal-wp/public/relay.php

Notes

This is intended for short-lived desktop use with the phone nearby. While a desktop relay viewer is connected, scoped Personal WP traffic for the origin is routed to the phone-backed relay session.

@akirk akirk force-pushed the personal-wp-desktop-relay-sw branch from 8fd6b9e to c6230d6 Compare June 6, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant