Conversation
Send preview_theme_id on storefront renderer requests so theme dev does not rely solely on preview state persisted in the storefront session cookie. Preserve an explicit preview_theme_id from the incoming browser query string when present. Also clean preview_theme_id from mismatch retry and proxied redirect locations so stale/internal render params are not sent back to localhost browsers. Co-authored-by: OpenAI Codex <codex@openai.com>
|
/snapit |
|
🫰✨ Thanks @frandiox! Your snapshot has been published to npm. Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260508082501Caution After installing, validate the version by running |
There was a problem hiding this comment.
Pull request overview
This PR updates the theme dev storefront rendering flow to always include preview_theme_id in Storefront Renderer (SFR) requests (while preserving a preview_theme_id explicitly provided by the browser), and ensures redirects don’t leak internal rendering params back to the browser—helping reduce theme ID mismatch loops when session/cookie preview state becomes unreliable.
Changes:
- Always append
preview_theme_id=<devThemeId>to SFR render requests unless the incoming query already specifiespreview_theme_id. - Patch 3xx rendering responses after header patching and strip
preview_theme_id(along with existing internal params) from redirectLocationheaders. - Drop stale
preview_theme_idfrom the mismatch-retry redirect URL so retries aren’t pinned to an incorrect theme.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/theme/src/cli/utilities/theme-environment/storefront-renderer.ts | Injects preview_theme_id into SFR request URLs when absent. |
| packages/theme/src/cli/utilities/theme-environment/storefront-renderer.test.ts | Updates/extends tests to assert preview_theme_id injection and preservation behavior. |
| packages/theme/src/cli/utilities/theme-environment/proxy.ts | Applies header patching before returning 3xx and strips preview_theme_id from redirect locations. |
| packages/theme/src/cli/utilities/theme-environment/proxy.test.ts | Adds coverage for redirect Location rewriting/removal of internal params. |
| packages/theme/src/cli/utilities/theme-environment/html.ts | Removes stale preview_theme_id from mismatch-retry redirects. |
| packages/theme/src/cli/utilities/theme-environment/html.test.ts | Adds assertions for passing themeId into render calls and dropping stale preview_theme_id on mismatch retry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| params.append('preview_theme_id', themeId) | ||
| } | ||
|
|
||
| // The Section Rendering API takes precendence over the Block Rendering API. |
WHY are these changes introduced?
Related #7344, and maybe #7494
Not sure yet if this fixes the problems, though.
WHAT is this pull request doing?
Send preview_theme_id on storefront renderer requests so theme dev does not rely solely on preview state persisted in the storefront session cookie. Preserve an explicit preview_theme_id from the incoming browser query string when present.
Also clean preview_theme_id from mismatch retry and proxied redirect locations so stale/internal render params are not sent back to localhost browsers.
How to test your changes?
Post-release steps
Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add