Conversation
Studio resolves preview URLs from a hardcoded Shopify convention, so a theme routing collections at /shop/:handle or articles at /journal/:handle cannot be navigated from the page selector. Add the shared contract for a theme-declared route map: ThemeRoutes, keyed by the page types a single pattern can address, and resolveThemeRoute to expand one pattern against route params. Patterns rather than prefixes because Shopify addresses an article as /blogs/:blog/:article and Forward as /journal/:article — a prefix can express the segment but cannot drop one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Claude finished @hta218's task in 1m 29s —— View job Claude finished the reviewTasks
ReviewThis is a clean, well-scoped addition. A few notes, none blocking:
Tests (
API reports
Scope / conventions
Not verified: I was not able to run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #518 — the SDK half.
What
Studio resolves a page's preview URL from a hardcoded Shopify convention, so a theme that routes differently cannot be navigated from the page selector. Forward is the first such theme:
/shop/:handlefor collections,/journal/:handlefor articles.This adds the shared contract a theme uses to declare its own routes:
ThemeRoutes—Partial<Record<ThemeRoutePageType, string>>, a map of page type to URL pattern. A theme declares only what differs; consumers fall back to today's Shopify convention for every key left out, so Hydrogen themes are unaffected.ThemeRoutePageType—Exclude<PageType, '*' | 'CUSTOM'>.*matches every page type rather than naming one, andCUSTOMpages carry their own full path, so neither can be given a pattern.resolveThemeRoute(pattern, params)— expands one pattern, returningnullwhen the pattern is not an absolute path or a:paramhas no value, so a caller falls back to its default instead of navigating to a literal/journal/:handle.Patterns rather than prefixes, as the issue argues: Shopify addresses an article as
/blogs/:blog/:articleand Forward as/journal/:article. A prefix can expressjournalbut cannot drop the blog segment.Both
@weaverse/hydrogenand@weaverse/nextalready re-export the whole@weaverse/schemasurface, soresolveThemeRoutereaches Builder through@weaverse/hydrogenwith no extra wiring — visible in theruntime-exports.api.mddiff.What is deliberately not here
routes?: ThemeRoutesonHydrogenThemeSchema/WeaverseNextThemeSchema. I wrote it, then backed it out: internal@weaverse/*deps resolve through the public npm registry rather than as workspace links (.npmrc, commit73b71ba7), and neither package's tsconfig maps@weaverse/schemato local source. Both fail to compile against aThemeRoutesthat is not published yet:So that field lands in a follow-up once
@weaverse/schemaships this export. Nothing about the theme-side payload is blocked in the meantime —loadThemeSettingsalready spreads the whole theme schema into the design-mode payload (weaverse-client.ts:772), so a theme that setsroutestoday reaches Studio with it; the follow-up only adds type safety for theme authors.Builder consumption.
getDefaultPagePrefixand its three call sites live inWeaverse/builderand change separately, as the issue notes.Open questions from the issue
I asked Codex to review the proposal first, but the connector is not configured for this repo, so these are my calls and worth a second opinion:
ThemeRoutePageTypecurrently admits every non-*, non-CUSTOMpage type, includingINDEX,BLOG,ALL_PRODUCTS, andCOLLECTION_LIST. That is wider than the four keys the issue sketches. Wider seemed right — a theme that renames/collectionsneedsCOLLECTION_LISTtoo — but it does let a theme declare a pattern for a page type Studio never resolves by handle.COLLECTIONgets Shopify defaults for everything else, silently. The alternative is to reject a partial map, which seems worse for the clone-a-starter case this is meant to serve.:paramonly — no optional segments, no wildcards. That covers both shapes in the issue; anything more is speculative until a theme needs it.Verification
turbo run typecheck --force— 6/6 passpnpm run test— 8/8 tasks,@weaverse/schema72 tests (7 new)biome check .— 147 files, cleanNote: commits used
--no-verify; the pnpm wrapper on this machine cannot fetch its engine, which breaks the lefthookcheckhook. The gates above ran through a workingpnpmshim.🤖 Generated with Claude Code
Recreated from Weaverse/weaverse-sdk#532, which was auto-closed when its head branch was removed during the repository rename. Original discussion is on that PR.