Repository navigation
demos: a snapshot holds the window's layout, so seeks back are fast - #675
Merged
Merged
Conversation
…gain A demo snapshot now keeps how the window was arranged — the app's places as `layout.zon` would remember them, the seed tree, each place's size and view, the floats and the documents' panes — and a restore puts it back, instead of refusing a window arranged otherwise and replaying from the keyframe.
foxnne
force-pushed
the
demos/layout-snapshot
branch
from
October 19, 2026 23:01
2dd372d to
6981e91
Compare
foxnne
marked this pull request as ready for review
October 19, 2026 23:13
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.
Follow-up to #669 and #634 (no plan step).
What changes
Seeking back in the tour is fast again. #669 took the tour's mid-tour keyframes out, so each chapter carries on in the window the last one left. But a snapshot didn't hold the layout:
restoreturned away any snapshot taken in another arrangement (layoutPrint). So a seek back across the sidebar split, the float or its close went past every snapshot and replayed from the keyframe. That cost up to ~195 replay frames, ~8 displayed frames at the player's budget.Now a demo snapshot (
Demo.Snapshot) holds how the window was arranged, and a restore puts it back:layout.zonwould remember them (Editor.collectSavedRegions: extents, assignments, orders, Single/Multiple, splits, floats), kept as ZON sorted by name. They are put back withLayout.State.clearArrangement(new:resetLayoutwithout forgetting widget sizes, the seed tree or the floats) followed byEditor.applySavedRegions. A float the snapshot had keeps its window and moves back to where it was. The others go.DockLayout.Snapshot, ZON), rebuilt only when it differs._size/_shown/_open/_peek(it comes back shut or open at rest, with no ease) and the host's selection (which view a place shows, and which tab is in front in a pane). The explorer is still opened or shut byexplorer_closed, as before.Workbench.arrangement/Workbench.arrange(new) record which panes there are, the one in front and their tree (panes.zon's form). Each document's grouping is set back as well. A restore no longer refuses a document that has moved to another pane. Where the app arranges the panes (FIZZY_WORKSPACES=1), a restore still refuses a different set of panes.Anything already the same is left alone, so a restore within one arrangement does what it did before.
layoutPrintno longer gates a restore. It is now part of the stage's fingerprint, so a seek that lands on a wrongly arranged window counts as a mismatch. It no longer counts a float that is flying shut (layout.zondoesn't either). That was the one mismatch the stronger fingerprint turned up.Seek times
Measured with the tour's seeks in
tests/demos.zig(the same random and chapter-start seeks both times), headless, ReleaseFast, on this Mac. "Frames" are the replay runs a seek needed; wall time is the whole seek.After this PR, every seek in that run landed from a snapshot. On main, 12 of the 24 replayed from the keyframe.
SDK impact
Host.clearSelectionForKey, besidesetSelectionForKey, so the app stops writing the Host's selection map directly. The fingerprint is unchanged (test-sdk-versionpasses), and plugins see the method at the next SDK release.Workbench,Layout.StateandDemoare not on the plugin boundary.Verified
scripts/check-fmt.sh,zig build,zig build test,zig build test-integration(81/81 steps),zig build check-web,zig build test-sdk-version.tests/demos.zignow fails a seek back that replays from the keyframe when its scene has a snapshot before the moment (it fails on main), and its fingerprint check now covers the layout.test-integration)check-webonlyReview (code-review, medium)
Fixed:
restoreArrangementnow does everything that can fail first (parsing the ZON, building the seed tree, the panes viaWorkbench.arrange, which is all or nothing), then changes things. It also runs before anything else inrestore, so a failure leaves the app as it was and the seek falls back to an earlier snapshot.State.forgetWidgetSize, now public).Host.clearSelectionForKey.Left as is:
animated = true. That only enables later splits and closes to slide; a tree built from a snapshot starts at rest.loadTreedoes the same.layoutPrint's gate before this.FIZZY_WORKSPACES=1the same panes in another order are refused. That mode is behind a flag, and a refusal just replays.The seek times above were measured before the review fixes, which change only how a restore that differs is ordered.
Follow-ups
🤖 Generated with Claude Code