Skip to content

Extract site operations to @studio/common#3986

Merged
youknowriad merged 5 commits into
trunkfrom
extract-site-operations
Jun 30, 2026
Merged

Extract site operations to @studio/common#3986
youknowriad merged 5 commits into
trunkfrom
extract-site-operations

Conversation

@youknowriad

Copy link
Copy Markdown
Contributor

Proposed Changes

Behavior-preserving refactor. Moves local-site operations — create, edit, snapshots, sync, and blueprint-bundle extraction — into transport-agnostic modules under @studio/common/sites, so the same backend can power both the desktop app and the upcoming studio ui local web server.

The desktop side now delegates: site-server, cli-site-creator/cli-site-editor, and the preview + sync IPC handlers call the shared modules. The preview snapshot runner is replaced by a shared snapshot manager built on the cli-process helper, which retires execute-preview-command.ts. No user-facing change.

Independent of the sessions extraction PR; based on trunk. Part of splitting the studio ui proof-of-concept (#3953).

Testing Instructions

  • npm run typecheck clean for tools/common, apps/studio, apps/cli.
  • npm test -- apps/studio/src/modules/cli/lib/tests/cli-site-creator.test.ts apps/studio/src/tests/site-server.test.ts (8 tests pass).
  • Smoke: create a site (incl. from a blueprint zip), edit it, take/restore a snapshot, run a sync push/pull.

Pre-merge Checklist

  • Verify site create/edit, snapshots, and sync still work end-to-end in the desktop app.

… @studio/common

Moves the create/edit/snapshots/sync/blueprint-extract logic into transport-agnostic @studio/common/sites modules. The desktop's site-server, cli-site-creator/editor, and the preview + sync IPC handlers now delegate to them (the snapshot/preview runner is replaced by the shared snapshot manager over cli-process, retiring execute-preview-command). No behavior change; this is the shared backend the studio ui local server will reuse. Part of splitting #3953.

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

wpmobilebot commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 17ed791 vs trunk

app-size

Metric trunk 17ed791 Diff Change
App Size (Mac) 1315.63 MB 1315.63 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk 17ed791 Diff Change
load 1116 ms 1112 ms 4 ms ⚪ 0.0%

site-startup

Metric trunk 17ed791 Diff Change
siteCreation 6495 ms 6517 ms +22 ms ⚪ 0.0%
siteStartup 6565 ms 6573 ms +8 ms ⚪ 0.0%

Results are median values from multiple test runs.

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

youknowriad and others added 4 commits June 29, 2026 13:17
Keeps each module's functional description; drops the "shared between the desktop app and the studio ui server" commentary that described the refactor rather than the code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- blueprint-extract: reuse the guarded createBlueprintTempDir/removeBlueprintTempDir from @studio/common/lib/blueprint-bundle instead of bare fs.rm, restoring the temp-dir path-prefix guard that the renderer-invokable cleanup dropped (and removing the duplicated temp lifecycle).
- create: use crypto.randomUUID() for the blueprint temp filename (Date.now() could collide on concurrent creates).
- sync: await the push temp-dir cleanup so short-lived hosts don't orphan multi-hundred-MB archives.
- ipc-handlers: restore the explicit Promise<ExtractedBlueprintBundle> return type on the extractBlueprintBundle handler (AGENTS.md).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
index.ts doubled as a topic file holding listSites/startSite/stopSite rather than a package root, so importing @studio/common/sites gave only those three ops. Now each site op lives in its own concern file: listSites -> list.ts (used by the desktop site-server), startSite/stopSite -> lifecycle.ts (CLI one-shot start/stop, for the studio ui server — the desktop runs sites via its own long-lived SiteServer). No re-export barrel, matching the repo's deep-import convention and avoiding eager-loading heavy deps.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@youknowriad youknowriad merged commit 83f8c8c into trunk Jun 30, 2026
11 checks passed
@youknowriad youknowriad deleted the extract-site-operations branch June 30, 2026 09:36
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