Skip to content

FE-1500: add Preview quick simulation and compact timeline - #9361

Merged
kube merged 0 commit into
codex/fe-1500-viewerfrom
codex/fe-1500-viewer-simulation
Sep 5, 2026
Merged

FE-1500: add Preview quick simulation and compact timeline#9361
kube merged 0 commit into
codex/fe-1500-viewerfrom
codex/fe-1500-viewer-simulation

Conversation

@kube

@kube kube commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Before this PR, PetrinautPreview showed a static marking. Running a scenario needed the full editor with its language server, because the simulation provider lowered scenario code through the language client alone.

PetrinautPreview gains an optional Quick Simulation mode. The host passes precompiled HIR artifacts and bounded run settings; the preview gains scenario configuration, compact playback controls, and a timeline that expands above the playback bar while frames exist. No language tooling is mounted.

9360.mp4

Links

Changes

Simulation provider

  • SimulationProvider accepts a compiler and an initialConfiguration

    SimulationCompiler is the compilation surface without an LSP: requestHirArtifacts and requestScenarioHir.
    requestScenarioHir takes the ad-hoc synthesis context and the scenario id a host with precompiled artifacts keys its lookup by.

  • useScenarioHir takes an options object

    requestScenarioHir and adHocContext.
    The provider injects the preview compiler; the settings panel and the experiments drawer keep the language client default.

  • requireScenario resolves missing or stale selections to the model's first scenario

    The selection normalizes back through controlled navigation. The full editor keeps its "No scenario" flow.

  • PlaybackProvider accepts an initialSpeed

Preview

  • quickSimulation prop on PetrinautPreview

    hirArtifacts, scenarioHirById, dt, maxTime, allowedPlaybackSpeeds, defaultPlaybackSpeed, parameterBounds, workerFactory.
    Artifacts are validated against the model before mounting and served through a compiler adapter.

  • Playback bar is a flat bordered box, square, opaque, without shadow

    It hugs its controls until frames arrive, then widens and expands upward into the timeline, and collapses on reset.
    Animation follows the animations preference and prefers-reduced-motion.
    At widths down to the 177px oEmbed minimum the control row scrolls horizontally.

  • SimulationTimeline extracted from the editor's timeline chart with a showLegend prop

    The editor keeps its legend, the preview hides it.

Known issues

  • validatePreviewQuickSimulation throws during render when artifacts do not match the model

    Hosts regenerate artifacts with the model and may add an error boundary.

Test coverage

  • quick-simulation.test.ts:

    Validation, playback-option resolution, compiler adapter.

  • react/simulation/provider.test.ts:

    requireScenario policy.

  • preview-quick-simulation-controls.test.tsx:

    Timeline expansion and rAF-driven playback.

  • react/playback/provider.test.tsx, navigation-adapter.test.ts:

    Initial speed cases and mode pinning.

How to test

  • Render <PetrinautPreview quickSimulation={...} /> with artifacts from yarn workspace @apps/petrinaut-website examples:generate
  • Quick Simulation > pick a scenario, adjust a parameter
  • Play

    Expect playback to advance and the timeline to expand

  • Playback settings

    Expect speeds limited to the allow-list

  • Reset

    Expect timeline collapsed

@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
hash Ready Ready Preview Sep 5, 2026 4:30pm UTC
petrinaut Ready Ready Preview Sep 5, 2026 4:30pm UTC
petrinaut-docs Ready Ready Preview Sep 5, 2026 4:30pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
hashdotdesign-tokens Ignored Ignored Preview Sep 5, 2026 4:30pm UTC

Request Review

@cursor

cursor Bot commented Aug 26, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches simulation initialization, scenario URL normalization, and worker/compiler wiring in embeds; misaligned precompiled artifacts fail at render time, but the full editor path is largely unchanged behind optional props.

Overview
Adds an optional Quick Simulation mode to PetrinautPreview so embed hosts can run named scenarios without Monaco/LSP by passing precompiled net and per-scenario HIR plus bounded run settings (dt, maxTime, playback speeds, parameter bounds).

When quickSimulation is set, the preview mounts SimulationProvider with a static compiler adapter, pins navigation to simulate mode, and shows a header Quick Simulation popover (scenario/parameters, no “no scenario”) plus a bottom playback bar that reuses editor SimulationControls and an extracted SimulationTimeline (legend hidden). The bar widens and reveals the timeline once frames exist, then collapses on reset.

Simulation stack changes: SimulationProvider gains injectable SimulationCompiler, initialConfiguration, and requireScenario (defaults missing/stale scenario IDs to the first scenario and normalizes host navigation; editor behavior unchanged). useScenarioHir accepts an optional requestScenarioHir and passes scenarioId for artifact lookup. PlaybackProvider / PetrinautCanvasProvider accept initialPlaybackSpeed. SimulationProvider is exported from @hashintel/petrinaut/react; PetrinautPreviewQuickSimulation from the preview entry. Docs and a patch changeset cover the feature.

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

@github-actions github-actions Bot added 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 labels Aug 26, 2026
Comment thread libs/@hashintel/petrinaut/src/react/simulation/provider.tsx Outdated
Comment thread libs/@hashintel/petrinaut/src/ui/preview/petrinaut-preview.tsx Outdated
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from f40fdea to 1498756 Compare August 27, 2026 01:23
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from 1498756 to c9ddd26 Compare August 27, 2026 01:47
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from c9ddd26 to 33257bc Compare August 27, 2026 02:33
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from 33257bc to 7b6cd41 Compare August 28, 2026 03:04
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from 697492e to 99f5b63 Compare August 30, 2026 03:34
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from 99f5b63 to 98f28e3 Compare August 30, 2026 17:09
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from 98f28e3 to 8f66f47 Compare August 30, 2026 17:24
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from 8f66f47 to f217c44 Compare August 31, 2026 01:03
@kube
kube force-pushed the codex/fe-1500-viewer-simulation branch from f217c44 to 305c7b5 Compare August 31, 2026 02:14
Comment thread libs/@hashintel/petrinaut/src/ui/preview/preview-quick-simulation-controls.tsx Outdated
@semgrep-code-hashintel

Copy link
Copy Markdown

Semgrep found 3 detect-replaceall-sanitization findings:

Detected a call to replaceAll() in an attempt to HTML escape the string value .replaceAll("&", "&amp;") .replaceAll('"', "&quot;") .replaceAll("'", "&#39;") .replaceAll("<", "&lt;"). Manually sanitizing input through a manually built list can be circumvented in many situations, and it's better to use a well known sanitization library such as sanitize-html or DOMPurify.

Semgrep found 1 regex_dos finding:

  • apps/petrinaut-website/src/main/app/brunch-demo/brunch-endpoint.ts

Ensure that the regex used to compare with user supplied input is safe from regular expression denial of service.

Comment thread libs/@hashintel/petrinaut/src/ui/preview/preview-quick-simulation-controls.tsx Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Preflight validation does not detect mismatched HIR artifacts as documented, and required-scenario normalization lacks integration coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds optional precompiled Quick Simulation support to the embedded Petrinaut preview.

Changes:

  • Adds scenario configuration, playback controls, and compact timeline.
  • Introduces compiler injection, required-scenario normalization, and initial playback speed.
  • Adds tests, user documentation, and a package changeset.
File summaries
File Description
.changeset/petrinaut-preview-quick-simulation.md Records the publishable feature.
libs/@hashintel/petrinaut/docs/preview.md Documents Quick Simulation.
src/react/index.ts Exports simulation APIs.
src/react/petrinaut-provider-layers.tsx Threads initial playback speed.
src/react/playback/provider.tsx Initializes configured playback speed.
src/react/playback/provider.test.tsx Tests initial speed.
src/react/simulation/provider.tsx Adds compiler injection and scenario policy.
src/react/simulation/provider.test.ts Tests scenario selection helper.
src/react/simulation/use-scenario-hir.ts Supports injected HIR requests.
src/ui/preview/index.ts Exports Quick Simulation type.
src/ui/preview/navigation-adapter.ts Pins preview navigation mode.
src/ui/preview/navigation-adapter.test.ts Tests simulation mode pinning.
src/ui/preview/petrinaut-preview.tsx Composes Quick Simulation providers and UI.
src/ui/preview/preview-quick-simulation-controls.tsx Adds compact controls and timeline.
src/ui/preview/preview-quick-simulation-controls.test.tsx Tests timeline expansion.
src/ui/preview/quick-simulation.ts Defines validation and compiler adapter.
src/ui/preview/quick-simulation.test.ts Tests Quick Simulation helpers.
src/ui/views/Editor/panels/BottomPanel/subviews/simulation-timeline/content.tsx Extracts reusable timeline content.
src/ui/views/Editor/panels/BottomPanel/subviews/simulation-timeline/main.tsx Uses extracted timeline.
src/ui/views/Editor/panels/SimulateView/experiments/experiment-scenario-run.tsx Adopts the HIR options API.
Review details
  • Files reviewed: 20/20 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread libs/@hashintel/petrinaut/src/ui/preview/quick-simulation.ts Outdated
Comment thread libs/@hashintel/petrinaut/src/react/simulation/provider.tsx Outdated
Comment thread libs/@hashintel/petrinaut/src/ui/preview/preview-quick-simulation-controls.tsx Outdated

@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 c5d89e5. Configure here.

Comment thread libs/@hashintel/petrinaut/src/ui/preview/petrinaut-preview.tsx Outdated
@kube

kube commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator Author

Not actually merged. A bad rebase from my side briefly pushed this branch at its own base, so GitHub saw no commits between them, marked the PR merged and deleted the branch. Nothing landed in `main`. The branch is restored with its five commits and the work continues in #9546.

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

Labels

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

Development

Successfully merging this pull request may close these issues.

2 participants