Skip to content

Run the desktop app on native PHP#198

Merged
priethor merged 6 commits into
mainfrom
priethor/desktop/native-php
May 15, 2026
Merged

Run the desktop app on native PHP#198
priethor merged 6 commits into
mainfrom
priethor/desktop/native-php

Conversation

@priethor

@priethor priethor commented May 15, 2026

Copy link
Copy Markdown
Collaborator

What

Part of #196

Desktop now boots the bundled WordPress site with host PHP and SQLite, not WordPress Playground. The snapshot step builds a real WordPress install, seeds Cortext, and includes the small runtime pieces the app needs for routing and desktop auth. This PR also adds a Playwright Electron smoke test and a GitHub Actions workflow for desktop-related changes.

Why

Playground was the bottleneck with the seeded DataViews workspace open. Running both paths on the same machine, against the same data, made the difference pretty clear:

Metric Playground (PHP-WASM) Native PHP
REST request ~600-1000 ms ~30-60 ms
Shell paint ~1 s ~80 ms
Cold launch (extract + boot) ~5-10 s ~3-5 s
Warm launch to ready ~1-2 s < 1 s
Snapshot build ~30 s ~18 s
Snapshot size ~40 MB ~30 MB

How

  • Starting php -S from Electron and waiting for it before loading the Cortext admin page.
  • Building snapshots from cached downloads of WordPress, wp-cli, and sqlite-database-integration.
  • Generating a fresh wp-config.php with random salts, CORTEXT_DESKTOP, WP_HOME, and WP_SITEURL.
  • Copying the desktop router and desktop-only autologin mu-plugin into the snapshot.
  • Removing blueprint.json and the Playground client from both build and runtime.
  • Running the desktop smoke test only when desktop-related paths change.

Trade-offs

  • The app now needs php on the host's PATH. Bundled PHP per architecture is still future work, not part of this PR.
  • The autologin mu-plugin fully bypasses auth_redirect. It is only for desktop snapshots and must never ship to a public WordPress site.
  • The smoke test stays narrow for now: extract, boot, mount the Cortext shell. It does not cover editor flows yet.

Testing Instructions

  1. Make sure PHP 8.1+ with pdo_sqlite is available on PATH. On macOS, brew install php is enough.
  2. From the repo root, run npm install && npm --prefix apps/desktop install && npm --prefix apps/desktop run snapshot. The build takes about 18 seconds; later runs use cached downloads.
  3. Launch with npm --prefix apps/desktop start. The window should reach Cortext admin in well under a second.
  4. Confirm no wp-login screen appears.
  5. Run npm --prefix apps/desktop run test:e2e. It should finish in about 7 seconds once the snapshot exists.

@priethor priethor merged commit efe6aeb into main May 15, 2026
10 checks passed
@priethor priethor deleted the priethor/desktop/native-php branch May 15, 2026 14:16
@priethor priethor added the area: desktop Desktop app, PHP runtime, snapshots, and desktop packaging. label May 15, 2026
@priethor priethor added this to the 0.1.0 milestone May 28, 2026
@priethor priethor added the type: enhancement Improvement to existing behavior. label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: desktop Desktop app, PHP runtime, snapshots, and desktop packaging. type: enhancement Improvement to existing behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant