Skip to content

Fix blueprint local resource resolution when creating sites from the app#2935

Merged
sejas merged 1 commit intotrunkfrom
stu-1458-studio-local-blueprints-that-reference-local-resources-dont
Mar 27, 2026
Merged

Fix blueprint local resource resolution when creating sites from the app#2935
sejas merged 1 commit intotrunkfrom
stu-1458-studio-local-blueprints-that-reference-local-resources-dont

Conversation

@sejas
Copy link
Copy Markdown
Member

@sejas sejas commented Mar 27, 2026

Related issues

How AI was used in this PR

Claude was used to trace the blueprint path flow across renderer → IPC → CLI, identify the root cause (temp file losing original directory context), and implement the fix. All code was reviewed and tested manually.

Proposed Changes

  • Capture Blueprint full filesystem path when a user selects a blueprint file
  • Thread originalBlueprintPath through createSite IPC → SiteServer.create()createSiteViaCli()
  • Pass --original-blueprint-path new hidden CLI parameter so the CLI uses the original directory for resolving relative resources (e.g. ./koinonia.zip)

Testing Instructions

  1. Download a blueprint JSON file and a theme zip from the Linear issue (e.g. koinonia.zip) to the same directory (e.g. ~/Downloads/).
{
  "$schema": "https://playground.wordpress.net/blueprint-schema.json",
  "login": true,
  "siteOptions": {
    "blogname": "Koinonia"
  },
  "steps": [
    {
      "step": "resetData"
    },
    {
      "step": "installTheme",
      "themeData": {
        "resource": "bundled",
        "path": "./koinonia.zip"
      },
      "options": {
        "activate": true
      }
    }
  ]
}
  1. Start the app with npm start
  2. Create a new site using the file picker to select the blueprint.json local file
  3. Verify the theme installs correctly (the installTheme step resolves the local zip)
  4. Verify normal blueprint flows still work (gallery blueprints, deeplink blueprints)
local-blueprint-relative-path.mp4

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

When creating a site via the desktop app with a blueprint that references
local resources (e.g. "./koinonia.zip"), Playground couldn't find the files
because the blueprint was written to a temp file, losing the original
directory context. This threads the original blueprint file path from the
renderer through IPC to the CLI via a hidden --original-blueprint-path flag,
so relative resources resolve from the correct directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sejas sejas self-assigned this Mar 27, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing ef4f6ee vs trunk

app-size

Metric trunk ef4f6ee Diff Change
App Size (Mac) 1268.05 MB 1268.05 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk ef4f6ee Diff Change
load 1836 ms 1921 ms +85 ms 🔴 4.6%

site-startup

Metric trunk ef4f6ee Diff Change
siteCreation 8168 ms 8167 ms 1 ms ⚪ 0.0%
siteStartup 4329 ms 4815 ms +486 ms 🔴 11.2%

Results are median values from multiple test runs.

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

@sejas sejas requested a review from a team March 27, 2026 12:17
Copy link
Copy Markdown
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes make sense but I wonder if we could write the absolute paths in the tmp blueprint file, to avoid the new field.
It seems like a more contained change, with a clear intention.
What do you think?

Copy link
Copy Markdown
Member Author

sejas commented Mar 27, 2026

I think using a parameter is a better solution. The issue I see with copying other files is that it needs to work across many different steps, and copying them to /tmp could also cause us to hit disk size limits. Some themes or imports could be large.

The parameter is hidden, so it won’t be accessible directly from the CLI. The parameter solution is a solution suggested in STU-1458

Copy link
Copy Markdown
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using a parameter is a better solution. The issue I see with copying other files is that it needs to work across many different steps, and copying them to /tmp could also cause us to hit disk size limits. Some themes or imports could be large.

I meant changing the paths in the blueprints to be absolute paths instead of relative ones.
But the current approach works and it's clean, so LGTM 👍

@sejas sejas merged commit df41da2 into trunk Mar 27, 2026
15 checks passed
@sejas sejas deleted the stu-1458-studio-local-blueprints-that-reference-local-resources-dont branch March 27, 2026 16:56
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.

3 participants