Repository navigation
testing: split a closure-free PlacedFrame out of Placed (#373, PR A) - #408
Merged
Merged
Conversation
`Placed::draw(self)` consumes the frame, so a harness that wants to ask a frame after drawing it had to copy what it needed out first (the test rig keeps `(path, rect)` and `(path, id)` lists for this). The query data (nodes, ids, prims, roots, the kept handle and the context) now lives in `testing::PlacedFrame`, which has no closures; `Placed<A>` holds it beside the draw, drag, dismiss and window closures and derefs to it, so every query (`at`, `try_at`, `overlays`, `overlay`, `expect_overlay`, `menu_open`, `diff`, `overflowing`, `node`, `rect`, `nodes`, `shell`, `dump`) is defined once, on the frame. `testing::keep_frames(&layout)` asks a layout to keep each frame it draws, and `testing::take_frame(&layout)` takes it: `draw` moves the frame there instead of dropping it, nothing cloned. The hand-off is a thread-local keyed by the layout, not a field of the layout's state, because a frame's paint closures are not `Send` and `LayoutState` is. Painting a node's text, icon or image now borrows its prim and puts it back, instead of consuming it, so the frame still answers `text()` after the draw. No behaviour change; the public methods of `Placed` keep their signatures (`diff` now takes any frame, which a `&Placed<A>` derefs to). Part of #373. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…the new docs for prose Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Owner
Author
|
User review (2026-11-19): the thread-local hand-over is rejected. Use design (a): |
# Conflicts: # src/draw.rs
…and-over The kept frame reached a test through a thread-local keyed by the layout's scope, behind a flag in Kept (keep_frames / take_frame). Draw now returns the PlacedFrame it drew, after its paint closures ran: a test keeps it in its own harness state, and an app ignores it. No global, no flag, and LayoutState stays Send. Removed: testing::keep_frames, testing::take_frame, Kept.keep_frame, the KEPT_FRAMES thread-local, and LayoutState::scope, which only the hand-over used. keep_frames' doctest moves to Placed::draw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
# Conflicts: # src/draw.rs
Owner
Author
|
Approved by the user on its tests, after the rework to a returned frame (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging. |
samitbasu
added a commit
that referenced
this pull request
Nov 19, 2026
…nswers #408 landed with Placed::draw answering its PlacedFrame, and without the keep_frames / take_frame hand-over this branch was built on. The driver now stores the frame its draw closure answers: Driver::whole_frame's closure answers the frame its layout's draw answered, and Driver::new's does so for the view. LayoutState::scope, which only the hand-over used, is gone with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
This was referenced Nov 19, 2026
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.
Part of #373 (PR A of the split in the design note).
What
testing::PlacedFrameholds a laid-out frame's query data: nodes, ids, prims, roots, the kept handle and the context. It has no closures.Placed<A>holds aPlacedFramebeside its draw, drag, dismiss and window closures, and derefs to it. Every query is defined once, on the frame:at,try_at,overlays,overlay,overlay_with,expect_overlay,menu_open(_with),diff,overflowing,node,rect,nodes,shell,len,dump.Placed::draw(..)returns thePlacedFrameit drew, after its paint closures have run. A test keeps it in its own harness state; an app ignores it. There is no global, no flag inKept, andLayoutStatestaysSend.text()after the draw.Review changes
The first version handed the frame over through a thread-local keyed by the layout's scope, behind
testing::keep_frames/testing::take_frameand aKept.keep_frameflag. The user rejected that, so all of it is gone, along withLayoutState::scope, which only the hand-over used.keep_frames' doctest is nowPlaced::draw's, keeping the returned frame in the harness state.Breaking changes
Placed::drawreturnsPlacedFrameinstead of(). A call used as a statement is unchanged. One whose value was used as(), such as amatcharm, needs a block; the frame bench was one.Placed's query methods keep their names and signatures.diffnow takes&PlacedFrame, which a&Placed<A>derefs to.New doc comments are marked
TODO(prose).Checks
cargo test -p eggshell-ui: everything passes (lib 316,it1617, doctests). No test file is changed.🤖 Generated with Claude Code
https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o