Skip to content

feat(sandbox): resilient path-param picker with homepage-link discovery - #5089

Merged
JonasJesus42 merged 2 commits into
mainfrom
category-picker-fallback
Jul 23, 2026
Merged

JonasJesus42 merged 2 commits into
mainfrom
category-picker-fallback

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

What is this contribution about?

The sandbox preview URL path-param picker only worked for VTEX PDPs; on other stores it showed an empty/dead modal or degraded to a bare text input. This makes it app-agnostic: params are classified (product/category), and when the site's configured loaders (VTEX category tree, Algolia/Magento product search) come up empty or absent, it falls back to scraping the site's own homepage — and drilling one listing page — for real category and product URLs via the existing preview-fetch proxy (allowlist widened to same-origin GETs). Results render side by side as Categorias | Produtos with product thumbnails; empty product searches are seeded with generic color terms, free-text entry strips surrounding slashes, and auto-fill only commits from primary sources (never a fallback), fixing a bug where a Category param auto-filled a PDP.

Screenshots/Demonstration

Granado (Magento, no working search loader) now lists real categories on the left and products with thumbnails on the right; clicking navigates to a valid PLP/PDP. Verified live in the studio dev sandbox.

How to Test

  1. bun run dev, open the studio and a sandbox whose page uses a dynamic route (e.g. Granado /{granado/}?*, or a VTEX store's category * / PDP :slug/p).
  2. Click the violet path chip in the preview URL bar — the modal opens with Categorias | Produtos (or the loader-driven results where configured).
  3. Pick an entity (or type a value) → the preview navigates to the real page; leading slashes are stripped. bun test apps/mesh/src/web/components/sandbox/preview/path-param-picker.test.ts (56 pass).

Migration Notes

None.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

Summary by cubic

Makes the sandbox preview URL path-param picker app-agnostic and resilient. It now prefers loader results and only falls back to homepage-link discovery, drilling a category listing to find real categories and products.

  • New Features

    • Gates the homepage-links fallback; queried only after primary loaders return no options or error.
    • Drills into the first category listing during homepage discovery to collect embedded products; categories come from the homepage nav.
    • Seeds empty product searches with four generic color terms to show results with fewer requests.
  • Bug Fixes

    • Auto-fill now tries primary sources in priority order and never commits from fallbacks; prevents wrong-kind fills.
    • Strips surrounding slashes on free-text entry.
    • Hardens the preview-fetch allowlist to same-origin paths only (rejects missing/invalid paths, //, .., \); tests cover fallback gating, homepage parsing, embedded products, and input normalization.

Written for commit 68ca75a. Summary will update on new commits.

Review in cubic

JonasJesus42 and others added 2 commits July 23, 2026 02:22
Make the preview URL path-param picker work app-agnostically: classify
category params, and when the configured loaders (VTEX category tree,
Algolia/Magento product search) come up empty or absent, fall back to
scraping the site's own homepage (and drilling one listing page) for real
category and product URLs via the preview-fetch proxy — grouped side by
side as Categorias | Produtos with product thumbnails. Also seeds empty
product searches with generic color terms, strips surrounding slashes on
free-text entry, and only auto-fills from primary sources.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…rill target

- Only query the homepage-links fallback once primaries are exhausted, so
  opening the picker on a healthy loader-backed page no longer fires the
  homepage + drill fetches (splits primary/fallback useQueries).
- Drill into the first CATEGORY (a listing page) instead of home[0], which is a
  product when the homepage embeds shelves — a PDP has no shelf to scrape.
- Trim GENERIC_SEED_TERMS 8→4 to halve the empty-term product-search fan-out.
- Correct buildPreviewFetchPath JSDoc (any same-origin path, not a 2-path
  allowlist); un-export module-private siteLinksSource; drop duplicate
  "checkout" in NON_CATEGORY_SEGMENTS.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@JonasJesus42
JonasJesus42 merged commit e23f1c7 into main Jul 23, 2026
15 checks passed
@JonasJesus42
JonasJesus42 deleted the category-picker-fallback branch July 23, 2026 07:38
decocms Bot pushed a commit that referenced this pull request Jul 23, 2026
PR: #5089 feat(sandbox): resilient path-param picker with homepage-link discovery
Bump type: minor

- decocms (apps/mesh/package.json): 4.102.0 -> 4.103.0

Deploy-Scope: both
rafavalls added a commit that referenced this pull request Jul 23, 2026
Only conflict was apps/mesh/src/web/components/sandbox/preview/preview.tsx,
where main's new preview "display model" (#5084 production fallback while the
dev server wakes, #5089 resilient path-param picker, #5086 confirm-before-
auto-start) collided with this branch's header-portal redesign of the same
toolbar.

Resolution: keep the redesign's structure (urlControls / moreMenu extracted and
portaled into the panel header via headerSlot) and adopt main's display model:
- showPreviewToolbar now follows main's visibility — shown once an iframe
  surface is active (sandbox when the daemon is up, or the production fallback
  while it wakes) instead of `daemonReady && previewState.kind === "iframe"`.
- canVisualEdit uses `display.mode === "sandbox"`.
- "Open in new tab" resolves the URL via `iframeSrc ?? display.iframeBase`
  (previewState.previewUrl no longer exists under the display model).
Main's toolbar-internal changes were pure re-indentation (verified against the
base diff), so the extracted urlControls/moreMenu already carry them; main's
other features (waking pill, confirm dialog) live outside the toolbar and
auto-merged.

Verified: tsc across all workspaces, oxlint (0), knip (clean), format.
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.

1 participant