Repository navigation
feat(scene): each layer has an identity the studio keeps while it runs - #213
Conversation
Quest-Claim: 72483bc6b5d392a8
Items carry a runtime Id, never saved and ignored by equality. The compositor keys keep-clear placers, parks, and grabs by it; glides pair by it; undo, redo, and a reload keep it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d reorder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Aligning a loaded history by content could not tell swapped or re-sourced layers apart; numbering each item in the file makes the link exact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Design change: a loaded history's item identities come from the history file, not from matching content. Rounds 1 and 2 of the local review each found a case where aligning a reloaded history's items to the collection by content gave a layer the wrong identity: a move (a removal plus an insertion), a swap of two layers of one source by two replacements, and a change of source. Each content rule left another case. The history file now saves each item's identity as a number ( At the round-3 checkpoint I compared this with the alternatives: keeping content matching (the class of findings above stays open), or giving up identity across a restart (every undo after a restart would start a layer's placer over, a regression from #194). Saved numbers are the simplest exact answer; the round-3 finding was a one-line bug in it, fixed. Taken under (Written by Claude Opus 5.5 with medium effort) |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
ℹ️ No critical issues. One minor leak is noted inline.
Approach: Sound. Keying placers by a runtime Id, kept by clones and minted fresh by copies, fixes #194's duplicate-swap at its cause instead of adding another matching heuristic. Saving ids in the history file is an exact answer to the alignment cases that matching by content kept missing.
Reviewed changes
I reviewed all 16 files at 72583e8. I followed every studio path that inserts or replaces items, the Move transition, portrait turning, and apply_outside.
Item.id/Id: a counter-made identity that serde skips andItem'sPartialEqleaves out.Collection::validaterefuses two items with the same identity.- Fresh identities on copies: Duplicate,
scene_copy, clip paste, and the watch window's layouts take a freshId. Add, drop, and guests go throughItem::new. I found no insert path that clones an item without one. The slot swap's twoset_items share an id only untilfinishvalidates. - Compositor keyed by
Id:keepers,parked, andgrabbedare keyed byId.followandrenamedare deleted.rememberprunes parked placers that no undo or redo can bring back. - Engine
moved: matches by identity across layers, so items brought back from a removal or from the top layer are noted. - History
idsandalign/recognize: the history file saves the numbers. On load, each number gets one freshId, and replaying undo and redo renames them to the collection's ids. On reload,Collection::recognizeandHistory::recognizerestore the running identities. - Glide: pairs by
id. The scene-to-scene Move transition (Compositor::moving) still pairs by resolved source and is unaffected.
claude-opus-5-5 | 𝕏
Its compositor parked the placer of a picture keeping clear that a layout dropped and never freed it, since only the engine called remember. Each new layout now remembers only the items it shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found. The watch window leak from the last review is fixed.
Reviewed changes
This run covers 2f1ba12, the one commit since the prior Pullfrog review at 72583e8.
- Watch window forgets dropped placers: after
recognize,Watch::rendercallsCompositor::rememberwith the ids of every item in the new layout. A keep-clear picture that a layout drops is parked at that render, then freed when the next layout arrives. - Regression test: added
watch::tests::a_dropped_picture_forgets_its_placer. It checks thatundonecannot bring back a placer once it has been forgotten. Thejust render-swfilter now runswatch::tests::on lavapipe.
claude-opus-5-5 | 𝕏
# Conflicts: # justfile # rs/moq-studio/src/watch.rs
…ng places glide Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found. The merge of
mainand the reflow key fix both look correct.
Reviewed changes
This run covers 195fa80 and e5b1905, the commits since the prior Pullfrog review at 5c771e4.
- Ported the watch window onto compositions:
collection(composition, size, &paths)gives each picture a freshId.Watch::renderstill callsrecognizeand thenrememberon the composition it applies, soa_dropped_picture_forgets_its_placerkeeps its meaning after the move toComposition. Thejust render-swfilter keeps a singletest(/^watch::tests::/), which also coversmain'splays_a_guest_where_the_studio_did. - Added identity to the reflow glide key:
reflownow keys slots by(id, source, visible, rect), so two tiles of one source that swap places start a glide. Nothing mints a freshIdper frame for scene items that feedreflow, so the new key cannot restart glides on every frame.duplicate_tiles_swapping_places_glidechecks each tile halfway between its two places.
claude-opus-5-5 | 𝕏

Implements and finishes quest/m1/item-identity.md, replacing the identity rules of moq-dev/studio#194's decisions 10 and 11.
Problem
Keep out of the way keeps a placer per layer, and nothing on an item said which layer it was.
compositor::followmatched placers to items after each edit by source, then saved rect, then nearest index, and the engine'smovedmatched undo and redo by scene, index, and source. Two layers of one source at one rect, as Duplicate makes them, traded placers when a layer was added under both: the new place of the first is nearest the old place of the second. An undo of Keep always on top started a fresh placer. Auto-layout's slot glide paired items by source, so duplicates in slots could glide from each other's places.Approach
Item.id(moq_scene::Id): a counter-made identity,#[serde(skip)], so the scene file never saves it and loading makes each fresh. A clone keeps it, so every edit made to an item, and every undo that puts one back, keeps it.Item'sPartialEqleaves it out, by an exhaustive destructure so a new field cannot slip past. Autosave, reload, and every change check behave as before.Item::new, loading, Duplicate, Duplicate scene, paste (Draft::paste), drop, Add, and a guest joining. Validation refuses two items under one identity, so a copy made without a fresh one fails loud rather than sharing a placer.HashMap<Id, _>.follow,renamed,Parked, and the source and rect a keeper kept to be found are gone.placement,grab,hold,redone, andundonetake anId. The read pass finds each item keeping clear by identity, even while its scene's slots glide.Compositor::rememberforgets those no undo or redo can bring back; the engine calls it after each edit with the collection's and the history's items (History::items). The watch window, with no history, calls it with each new composition's items, so a picture a composition drops loses its placer at the next. An undo that brings the layer back, from a removal or from the top layer, puts it back where it was.movedis by identity: a layer keeping clear that an undo, redo, or reload saved at another x or y, switched back on, or brought back. The rename and reorder bookkeeping (was_named,reordered) is gone.show.history.tomlgainsids, one list of numbers per entry naming each item it holds, so a load knows which mentions are one item through moves, swaps, and changes of source.History::from_tomlgives each number one fresh identity, thenHistory::alignrenames each to the identity the collection holds where an entry replaces or removes that item. The scene file saves none.Collection::recognizegives a reloaded scene file's items the identities of the items before, per layer: in order (a longest common run) by source and rect, then by source, then out of order, as a reorder by hand leaves them; a renamed scene is matched with the gone scene it shares most with.History::recognizegives the reloaded history's items no layer shows, such as a removed one, the identities the running history had, so its parked placer survives.glide.rs) pairs items by identity, and the compositor's reflow starts one when a slot's item changes, so duplicates swapping order glide. The watch window recognizes each new composition's collection against the last, so its slots still glide.Impact
moq/.show.history.tomlgains a top-levelidsarray. A file without it loads, each item new. A build from before this PR refuses a file with it, naming the file; the studio is unreleased, and deleting the file starts a new history.moq-scene(unreleased, no!):Id,Item.id,Collection::recognize,History::align,History::recognize,History::items,Compositor::remember;Compositor::placement(id),grab(Option<Id>, now),hold(id),redone(id, saved),undone(id, saved, now)take anIdin place of a scene, index, and source.Idis 8 bytes per item.rememberwalks the history's items after each edit only while a placer is parked (at most 100 entries).Alternatives
Change::Itemapplying keeps the old item's id): simpler history loading, but a swap into a slot, twoset_items, would trade identities.glidefor items whose ids differ: only the watch window needed it, and recognizing its layouts keeps duplicates apart there too.Caused by
Follow-ups
None. The quest file is deleted; nothing linked to it.
Validation
just cipasses at 72583e8: fmt, clippy, and 489 tests.just render-swpasses on lavapipe at 72583e8 (75 + 20 + 14 + 1), with all 75 moq-scene GPU tests, including the newcompositor::tests::duplicates_keep_their_own_placers: two cameras of one source at one rect, one in its slot (TopLeft) and one held by hand, keep their own placers as a hidden layer is added under both, as they swap order, and after a removal or Keep always on top that anundoneputs back (back in its slot); oncerememberleaves it out, a parked placer starts over. With feat: a layer that keeps out of the way #194's rule, the insert hands the held one's keeper to the one in its slot (the new place of each is nearest the other's old one).engine::tests::an_undo_puts_back_a_layer_keeping_clearpasses: through the real engine, an undo of a move by hand puts back the place, a redo holds, and an undo of a swap into a slot takes back the held placer.just shots build_keep_clear build_keep_clear_compact build_droppass; the facecam still glides off the HUD to the bottom right and BUILD draws it there, found by identity.edit::tests::every_point_of_a_history_keeps_its_identitiesmakes 60 random edits of one layer (copies alike but new, removals, moves, swaps by two changed replacements, changes of source, rect edits), then seeks to 40 random points: each has the identities it had. After a save and reload of the scene file and history, 80 more seeks check that each point holds the same items, each under one consistent new identity. It fails with the savedidsignored on load, and withHistory::aligntaken out.edit::tests::a_loaded_history_aligns_past_a_swap(fails without its fix) anda_reloaded_history_keeps_what_it_removed.collection::tests::a_reload_recognizes_each_item: an unchanged file's reload gets every identity back, duplicates included; a layer added under the duplicates, a moved one, a renamed scene, and a reorder by hand keep the rest themselves.glide::tests::duplicates_glide_from_their_own_places: two of one source swapping places each glide from their own.compositor::tests::duplicate_tiles_swapping_places_glide(lavapipe): two tiles of one source that swap order each glide from their own place, through the compositor's reflow, whose key now names each slot's item by identity. It fails with that key's identity held constant (each tile jumps). All 77 moq-scene GPU tests pass on lavapipe.engine::tests::an_undo_or_a_reload_moves_by_hand:movedby identity, across a swap of order in a renamed scene, and for a layer brought back from a removal or from the top layer.watch::tests::a_dropped_picture_forgets_its_placer(lavapipe, injust render-sw): a keep-clear picture a composition drops has its placer parked, then forgotten at the next composition. Ported onto feat(scene)!: the studio publishes a composition #146's composition after the merge ofmain; it fails with theremembercall taken out.main(feat(scene)!: the studio publishes a composition #146, feat: browser sources on macOS #206, feat(studio): markers on REVIEW, with a clip around each #209, refactor(scene): one readback for the compositor's small GPU reads #211, feat(studio): time both formats' encodes together #214):just cipasses (511 tests), and the moq-studio half ofjust render-swpasses on lavapipe (22 tests, includinga_dropped_picture_forgets_its_placerandplays_a_guest_where_the_studio_did).Decisions
Taken under
/quest-afkas my recommendation; each is open to overturn in review.followuses", but that rule trades duplicates when a layer is added under them, the bug this quest removes.recognizematches each layer's items in order (longest common run), then the rest out of order as feat: a layer that keeps out of the way #194 did. Rejected: the nearest-index rule alone, as planned.ids), so an undo after a restart or reload keeps each layer's own through moves, swaps, and changes of source. The quest said only that the scene file never saves them. Rejected: aligning by content (rounds 1 to 3 kept finding cases), and leaving a loaded history's items new (every undo after a restart would start a layer's placer over). Design change; also the round-3 review checkpoint, taken as continue.Compositor::remember), bounded by the history's 100 entries. Rejected: forgetting a placer once its item leaves the collection, which loses it before an undo of a removal.glide.rs.collection(composition, size, &paths)), thenrecognizegives back those the last composition showed. ✅ fresh per picture (rejected: keeping the picture's ownid, which a stored composition reuses across renders and duplicates when one item is placed twice, as the test fixture does, so validation would refuse it). The studio'sComposition::newkeeps its items' ids on the pictures it publishes; they are never serialized, so that is harmless.justfilenextest filter keeps this PR'stest(/^watch::tests::/), which coversmain'splays_a_guest_where_the_studio_didtoo. ✅ the prefix (rejected: listing each watch test, which a new one would slip past).Models
Size: M
Implementer: Claude Code, claude-opus-5-5, medium effort (arm A)
Implementer: Claude Code, claude-opus-5-5, medium effort (iterate, S, arm A)
Implementer: Claude Code, claude-opus-5-5 (iterate, S, arm A)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: e5b1905
Base: origin/main at 6c7da41
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1f72b-a5b9-7940-b3ac-318fb5966bd0, round 2Score: 10/10,
The production reflow key now includes item identity, resolving the prior finding, and the incremental changes introduce no new issues on code inspection; tests were not run.Rounds: 7; first round 3 (medium 3); findings 7 (medium 7): fixed 7, refuted 0, open 0
Findings: none
The last round's findings, at 195fa80:
rs/moq-scene/src/glide.rs:70:Include item identity in the production reflow key;In rs/moq-scene/src/compositor.rs, reflow now keys each slotted item by (id, source, visible, rect), and duplicate_tiles_swapping_places_glide checks that same-source tiles retain their own starting positions when reordered.Reviewer: Codex, gpt-6.1-sol, medium effort, shadow
Session:
01a1f411-c81a-76a0-81cb-ea841ff86287Rounds: 4; first round 1 (medium 1); findings 2 (medium 2): fixed 2, refuted 0, open 0