FE-1672: Hold the simulation timeline still while it is off screen - #9656
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
9f36f62 to
43755e4
Compare
PR SummaryLow Risk Overview Chart data building is incremental instead of recomputing the full run every frame: Simulation docs note that closing the timeline stops work until reopen. Reviewed by Cursor Bugbot for commit b923f68. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟢 Approval recommended
The visibility gating, incremental data handling, tests, documentation, and changeset are consistent and complete.
Pull request overview
Pauses off-screen Petrinaut timelines and incrementally extends chart data to reduce unnecessary work.
Changes:
- Gates frame reads and chart redraws using viewport visibility.
- Adds incremental run and stacked-data builders with tests.
- Updates simulation documentation and release notes.
File summaries
| File | Description |
|---|---|
use-streaming-data.ts |
Adds resumable frame-stream pausing. |
content.tsx |
Pauses hidden simulation timelines. |
chart.tsx |
Skips paused updates and uses incremental builders. |
chart-data.ts |
Implements incremental chart-data construction. |
chart-data.test.ts |
Tests builder behavior and resets. |
actual.tsx |
Pauses hidden actual-execution timelines. |
use-element-on-screen.ts |
Adds viewport intersection tracking. |
docs/simulation.md |
Documents closed-panel behavior. |
.changeset/timeline-holds-still-off-screen.md |
Records the patch release. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
43755e4 to
2fa14e3
Compare
A closed bottom panel is moved off the viewport rather than unmounted, so the timeline went on reading every frame of a run and repainting an invisible canvas: 172 repaints over four seconds of playback with the panel shut. An IntersectionObserver on the chart's container holds both the reads and the drawing while it is off screen; opening the panel again catches up in one batch. Closing the panel during a 200-node run now takes playback from 33 to 46 frames per second. The chart's columns are also extended rather than rebuilt: a stacked chart re-summed the whole run on every frame, which on 500 series a thousand frames in was half a million additions to move the chart on by one column.
2fa14e3 to
b923f68
Compare
Summary
Before this PR, a closed bottom panel was moved off the viewport rather than unmounted, so the simulation timeline went on reading every frame and repainting a chart nobody could see. A stacked chart also re-summed the whole run on every frame to move on by one column.
A timeline that is off screen now stops reading frames and stops drawing until it comes back, and the chart's columns are extended as frames arrive rather than rebuilt from the start of the run.
Measured against the built website in headless Chromium, driving a ring net through a run, with frame intervals sampled from
requestAnimationFrameand repaints counted on the chart canvas.Before
9656-before.mp4
After
9656-after.mp4
Links
Changes
useElementOnScreenreports whether an element overlaps the viewportTest coverage
chart-data.test.ts:@hashintel/petrinautunit suite.How to test