Skip to content

FE-1500: add versioned examples and read-only pages - #9362

Open
kube wants to merge 5 commits into
claude/fe-1500-navigationfrom
codex/fe-1500-examples
Open

FE-1500: add versioned examples and read-only pages#9362
kube wants to merge 5 commits into
claude/fe-1500-navigationfrom
codex/fe-1500-examples

Conversation

@kube

@kube kube commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Publishes seven Petrinaut models as immutable, versioned website examples: a catalog page, canonical /examples/<slug>/versions/<revision> pages rendering the full Petrinaut component read-only, and app-like URL navigation for the example pages and the local demo. Stacked on the controlled-navigation PR.

🔗 Related links

🔍 What does this change?

  • Adds the model sources under src/examples/models/v1 and deterministic precompiled HIR runtime artifacts under src/examples/generated/v1, produced by scripts/generate-example-artifacts.ts (examples:generate / examples:check).
  • Adds the catalog: metadata (titles, playback config, parameter bounds), a cached model loader, and a runtime-artifact loader.
  • Adds /examples and canonical example routes that render <Petrinaut readonly presentationProfile="review"> from an in-memory read-only document handle.
  • Encodes app locations in search params (navigation-search.ts): mode, section, resource, scenario, subnet, selection, and creation-drawer overlays, with push for destinations and replace for normalization.
  • Routes the local-storage demo: net identity moves into the URL and the demo threads a navigation controller, so mode, selection, drawers, and net switches are Back/Forward destinations.
  • Per-key search validation runs through zod (already a dependency): enum and string fallbacks are .optional().catch(undefined) schemas, and the "type:id" selection encoding is a bidirectional z.codec. Cross-field rules (pair completeness, overlay precedence, tri-state scenario) stay plain code.
  • The codec laws are property-tested with fast-check: decoding never throws on generated garbage, encode(decode(s)) is a fixed point (what the embed redirect relies on), and every decodable state survives encode then decode.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

  • The industrial-gas-supply-sdcpn slug is reserved in the catalog but not yet published.

🛡 What tests cover this?

  • New: catalog.test.ts (every catalog entry loads, every scenario has generated HIR, one immutable snapshot per revision), navigation-search.test.ts, navigation-search.property.test.ts (fast-check codec laws over generated search inputs), readonly-example-handle.test.ts, -index.test.tsx, local-storage-demo-app.test.tsx.
  • CI: examples:check fails when the generated artifacts do not match the models.

❓ How to test this?

  1. Checkout the branch and run yarn workspace @apps/petrinaut-website dev.
  2. Open /examples, pick an example, select items, switch subnets, open a creation drawer.
  3. Confirm the URL tracks each step and Back/Forward walk the same states, and that editing is not possible.

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 29, 2026 8:19pm
petrinaut Ready Ready Preview Aug 29, 2026 8:19pm
petrinaut-docs Ready Ready Preview Aug 29, 2026 8:19pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 29, 2026 8:19pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs August 26, 2026 23:24 Inactive
@cursor

cursor Bot commented Aug 26, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches public example routes and depends on checked-in HIR staying aligned with petrinaut-core compilation; URL navigation changes affect back/forward behavior for the demo and embeds, though coverage is mostly website-scoped and tested.

Overview
Adds a versioned demo library on the Petrinaut website: seven SDCPN models under models/v1, a lightweight catalog metadata layer (playback limits, parameter bounds, no heavy imports), and cached loaders for models plus precompiled HIR in generated/v1.

A new generate-example-artifacts script compiles each example through petrinaut-core (model HIR + per-scenario HIR) and writes checked-in JSON; examples:generate / examples:check keep artifacts in sync with the models in CI.

/examples lists examples in a catalog UI; per-example routes render the full Petrinaut UI as read-only (presentationProfile="review") via a stable in-memory createJsonDocHandle keyed by slug@revision. The PR description also wires URL search-param navigation (mode, selection, drawers) for example pages and the editable local demo, with zod validation and fast-check property tests on the search codec.

Unit tests assert every catalog entry loads, scenario parameters sit within declared bounds, generated HIR covers all scenarios, and loaders return singleton snapshots per revision.

Reviewed by Cursor Bugbot for commit 51ca609. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread apps/petrinaut-website/src/examples/catalog.ts
Comment thread apps/petrinaut-website/src/routes/examples.$slug.index.tsx
Comment thread apps/petrinaut-website/src/routes/index.tsx
@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 29, 2026
@kube
kube force-pushed the codex/fe-1500-examples branch from 43734e1 to a45a711 Compare August 29, 2026 00:17
@github-actions github-actions Bot removed area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 29, 2026
@kube kube changed the title FE-1500: Add versioned examples and embed routes FE-1500: add versioned examples and read-only pages Aug 29, 2026
@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs August 29, 2026 14:28 Inactive
@github-actions github-actions Bot added the area/deps Relates to third-party dependencies (area) label Aug 29, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 51ca609. Configure here.

void navigate({
replace: history === "replace",
search: (previous) => applyFullNavigationUpdate(previous, update),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Example routes drop queued navigations

Medium Severity

Example onNavigate applies each Petrinaut updater to the router’s committed previous search instead of the host’s latest pending location. Sequential updates in the same event, or before the router commits, can drop earlier changes, so the URL no longer tracks selection, drawers, or subnet switches and Back/Forward can skip states.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 51ca609. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps area/deps Relates to third-party dependencies (area)

Development

Successfully merging this pull request may close these issues.

1 participant