FE-591: Add Metrics: timeline picker, compiler, and drawer#8633
Draft
kube wants to merge 3 commits intocf/fe-532-implement-basic-experimentfrom
Draft
FE-591: Add Metrics: timeline picker, compiler, and drawer#8633kube wants to merge 3 commits intocf/fe-532-implement-basic-experimentfrom
kube wants to merge 3 commits intocf/fe-532-implement-basic-experimentfrom
Conversation
Introduces user-authored metric functions that run over each simulation frame and plot a single number on the timeline chart. - Schema: Metric type on SDCPN with Zod validation; round-trips via the file format (legacy files default to an empty list). - Compiler: compileMetric mirrors compileScenario's hardening (strict mode, shadowed globals, frozen prototype-less state), plus a buildMetricState helper that reshapes a frame's buffer into named tokens per place. - Timeline: metric picker in the header (Default + each metric) with Create/Edit/Manage IconButtons matching the scenarios picker pattern. When a metric is picked, useStreamingData streams a single series computed per frame; runtime errors render as NaN gaps, compile errors replace the chart with a message. - Drawers: CreateMetricDrawer and ViewMetricDrawer with a multi-line CodeEditor for the function body and live compile preview in the footer. Metrics CRUD added to MutationContext under the scenarioMutate guard so edits work in simulate mode. - SimulateView: Metrics tab enabled with a MetricList; sidebar mode lifted to EditorContext so the Manage button can open the tab. - Example: SIR model gains an "Infected Fraction" metric.
- Add a "Metric" label and widen the timeline picker to match the Scenario picker in simulation settings. - Truncate Select dropdown labels with ellipsis on overflow instead of wrapping, by applying min-width:0 on items and an ItemText style that clips the default label. - Dedent the SIR "Infected Fraction" example code so it renders at column 0 in the editor.
Introduces a second built-in view alongside the existing per-place
breakdown, aggregating token counts by color type. Places with no color
are collapsed into a single "Untyped" series.
- Replaces `timelineMetricId` with a discriminated `TimelineView` union
so native views and user metrics share one state field.
- Refactors useStreamingData to drive all three modes off a single
`{ series, extract }` config, unifying the frame loop.
- Picker now shows "Tokens per place", "Tokens per type", then each
metric; the Edit icon is only relevant for user-defined metrics.
- Legend is gated on series count (>= 2) rather than mode, so a
single-series per-type run also hides it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
4 tasks
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.

🌟 What is the purpose of this PR?
🔗 Related links
🚫 Blocked by
🔍 What does this change?
Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
turbo.json's have been updated to reflect this🐾 Next steps
🛡 What tests cover this?
❓ How to test this?
📹 Demo