-
Notifications
You must be signed in to change notification settings - Fork 110
H-5770: Add PlaybackContext for real-time simulation playback #8295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
kube
wants to merge
10
commits into
main
Choose a base branch
from
cf/h-5770-simulation-computeplayback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,141
−271
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a676139 to
2c55788
Compare
2c55788 to
558a7bb
Compare
558a7bb to
da55643
Compare
This was referenced Jan 27, 2026
da55643 to
1ea2c35
Compare
Introduce a new PlaybackContext that handles viewing simulation frames at real-time speed based on dt, separate from the computation speed. - Create playback/context.ts with PlaybackContextValue type - Create playback/provider.tsx with requestAnimationFrame-based playback - Move currentViewedFrame from SimulationContext to PlaybackContext - Update all consumers to use PlaybackContext for frame viewing - SimulationContext now only handles computation/generation of frames - PlaybackContext advances frames at real-time speed (60Hz max) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ider - Add playback controls popover matching Figma design with three sections: - "When pressing play" options (UI only for now) - Playback speed selection (1x to Max/Infinity) - "Stopping conditions" options (UI only for now) - Update playback speeds to [1, 2, 5, 10, 30, 60, 120, Infinity] - Add formatPlaybackSpeed() helper for display formatting - Add useStableCallback hook for stable function references - Refactor PlaybackProvider to use stable getters instead of refs - Use ToolbarButton component for settings button consistency - Tweak arc firing animation duration and stroke width Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Introduces three play modes: - viewOnly: Only plays existing frames, no computation (available when simulation is complete) - computeBuffer: Computes minimally when < 100 frames ahead - computeMax: Computes as fast as possible while playing When simulation completes, automatically switches to viewOnly mode and disables the compute options. When simulation is running, viewOnly is disabled. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Split BottomBar into Edition/Linting and Playback segments with 20px gap - Reorder SimulationControls: Stop | Play | Timeline | Settings - Add vertical dividers between control groups Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use motion/react library to animate the BottomBar panels when content changes (e.g., when simulation starts/stops). This provides smooth enter/exit animations for buttons, dividers, and timeline controls. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add @testing-library/react, @testing-library/dom, and jsdom as devDependencies - Create provider.test.tsx with 28 tests covering PlaybackProvider behavior - Tests use a mock SimulationContext factory pattern for isolation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add isComputeAvailable context flag for when simulation can compute more frames - Change isViewOnlyAvailable to be true when there are any computed frames - Update simulation controls to use isComputeAvailable for compute mode buttons - Add Motion animations to BottomPanel for smooth open/close transitions
94d3084 to
a9c8342
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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
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?
Introduce a new PlaybackContext that handles viewing simulation frames at real-time speed based on
dt, separate from the computation speed. This allows the simulation to be computed as fast as possible while the visualization plays back at the correct real-time speed. Playback and simulation are now synchronized - pausing playback pauses simulation generation, and resuming playback resumes generation.🔗 Related links
🚫 Blocked by
Nothing
🔍 What does this change?
playback/context.tswithPlaybackContextValuetype defining playback state and actionsplayback/provider.tsxwithrequestAnimationFrame-based playback loopcurrentViewedFramefromSimulationContexttoPlaybackContextPlaybackContextfor frame viewingSimulationContextnow only handles computation/generation of framesPlaybackContextadvances frames at real-time speed (60Hz max) based ondtuseStableCallbackhook: Extract commonuseRef+useEffectpattern for stable callback referencesPre-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:
None
🐾 Next steps
None
🛡 What tests cover this?
❓ How to test this?
yarn devdt📹 Demo
N/A