Skip to content

Extract site REST proxy, media MIME, and installed-app detection to @studio/common#3955

Merged
youknowriad merged 4 commits into
trunkfrom
extract-shared-libs-to-common
Jun 26, 2026
Merged

Extract site REST proxy, media MIME, and installed-app detection to @studio/common#3955
youknowriad merged 4 commits into
trunkfrom
extract-shared-libs-to-common

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Proposed Changes

Three small, independent shared-lib extractions, each rewiring exactly one desktop spot to delegate to @studio/common:

  • Site REST proxylib/wordpress-rest.ts (desktop wordpress-rest-api.ts becomes a thin SiteServer resolver).
  • Local-media MIMElib/media-mime.ts (used in ipc-handlers.ts).
  • Installed editor/terminal detectionlib/user-settings/installed-apps.ts (desktop is-installed.ts is now a re-export; its test moves to @studio/common).

Behavior is unchanged except one hardening that ships with the shared REST proxy: the request.path branch now validates the resolved URL stays within the site’s own REST root, closing a latent SSRF (an absolute URL in path could previously redirect the request to an arbitrary host with the site’s auth headers).

Independent of the other split PRs; based directly on trunk. Part of splitting the studio ui proof-of-concept (#3953).

Testing Instructions

  • npm run typecheck clean for tools/common and apps/studio.
  • Tests: shared installed-apps (20), desktop wordpress-rest-api (3), installed-apps-api + open-file-in-ide (23) — all pass.

Pre-merge Checklist

  • Confirm the desktop REST proxy + IDE detection still behave as before.

…studio/common

Three small, independent shared libs, each rewiring one desktop spot to delegate: the WordPress REST proxy (wordpress-rest-api.ts), local-media MIME lookup (ipc-handlers.ts), and installed editor/terminal detection (is-installed.ts, now a re-export; its test moves to @studio/common). Behavior is unchanged except one hardening that comes with the shared REST proxy: its request.path branch now validates the resolved URL stays within the site's own REST root, closing a latent SSRF. Part of splitting the studio ui PoC (#3953).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Completes the media-mime extraction: ipc-handlers imports getLocalMediaMimeType from @studio/common/lib/media-mime and drops its inline copy.

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

wpmobilebot commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 657e993 vs trunk

app-size

Metric trunk 657e993 Diff Change
App Size (Mac) 1311.91 MB 1311.94 MB +0.02 MB ⚪ 0.0%

site-editor

Metric trunk 657e993 Diff Change
load 1039 ms 1072 ms +33 ms ⚪ 0.0%

site-startup

Metric trunk 657e993 Diff Change
siteCreation 6475 ms 6496 ms +21 ms ⚪ 0.0%
siteStartup 6962 ms 7524 ms +562 ms 🔴 8.1%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

youknowriad and others added 2 commits June 25, 2026 15:00
These explained the extraction ("now lives in @studio/common", "shared between desktop and the local server") rather than the code; the shared-module headers keep a one-line description.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@youknowriad youknowriad merged commit 167141e into trunk Jun 26, 2026
11 checks passed
@youknowriad youknowriad deleted the extract-shared-libs-to-common branch June 26, 2026 17:06
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