Repository navigation
fix: reclaim DSL prop controls only from child-control slots - #64
Merged
Merged
Conversation
ruflet#48 made every builder take a control back from its block when the
control was passed as a prop, but it walked every Hash and Array prop,
data: included. A control the app only references, such as
`column { t = text("0"); button(content: text("+"), data: { target: t }) }`,
was removed from its block, which v0.0.23 never did.
Reclaim now only looks at child-control slots: a prop whose value is a
control or a list of controls, which is the wire shape of every child prop
(content:, title:, actions:, controls:/children:, tabs:, markers:, ...).
Hash values are value objects and data: is opaque, so a control referenced
from them stays where its block put it.
App blocks also kept owning their children after they returned, so reusing
a block child in a later prop (often after the parent was mounted) silently
took it out of that parent. A block now releases its children when it
returns, as WidgetBuilder blocks effectively did, and a mounted control is
never taken out of the app's roots.
This was referenced Nov 7, 2026
AdamMusa
pushed a commit
that referenced
this pull request
Nov 7, 2026
Brings in #64 (reclaim only from child-control slots), #65 and #66 (Dropdown change event name and spellings) and #68 (inline date pickers in DSL blocks). Conflicts: - Page.presented_control?: #68 and this branch both exempt inline date pickers; kept this branch's inline_overlay? rule (any presented overlay built with inline: true), which #68's new tests also pass. - PropControls.reclaim: kept #64's child-slot walk and mounted-control rule together with this branch's last-first order; the comment covers both. Page#claim_prop_control now passes its value as a one-slot props hash, since reclaim reads props. - Dropdown contract and its test file: both sides' additions kept. ruflet_core 186/186 files (1039 runs), ruflet_rails 16/16, ruflet_record 5/5; ruflet_server and ruflet only the two environment-specific failures that also fail on main here. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MqfxcsDiEUZngybe9L72JQ
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.
Problem
The v0.0.23 → main compatibility audit found a regression from #48 (
PropControls.reclaim) on an undocumented but plausible path.PropControls.each_controlwalked every Hash and Array prop, includingdata:. A control the app only references was taken out of the block that built it:labelis a column child (thetext("+")was also duplicated, which is the bug fix: keep DSL prop controls out of block children #48 fixed).[button].labelis gone from the screen and lives only inside the button'sdata.The same finding also covered reuse after a block has returned. App/Kernel blocks kept owning their children, so passing a block child to a later prop silently mutated a parent that was already built, even one already mounted:
Ruflet.column { ... }(WidgetBuilder) blocks did not have this problem: they copy their list into the node. So the two block forms also disagreed.Audit evidence:
compat/risk/probes/p01h_reclaim_edges.rb. Baselinecol_children_after_reuseis["shared","other"]and main is["other"]. The baseline tree keepstext(0)in the column and main drops it.Why it matters for existing apps
data:is the application's own payload. Storing a control reference in it (a target to update, a label to toggle) is a normal pattern, and it worked in v0.0.23. After #48 the control silently disappears from the layout with no error. The reuse case changes an already-mounted parent behind the app's back, and the next full patch (reconnect,register_page_patch) then drops the control on the client.Fix
packages/ruflet_core/lib/ruflet_ui/ruflet/ui/prop_controls.rbcontent:,title:,leading:,appbar:,actions:,controls:/children:,tabs:, and extension lists such asmarkers:,rods:andlayers:.data:(OPAQUE_PROP_KEYS) is never a slot, whatever its shape.KEYWORDS) has names only, no types, so it cannot say which keys hold controls. A hand list of names would need about 70 core names plus every extension's own. I instrumented reclaim over the whole test suite and all 183 doc examples: every reclaim it took was a top-level control or a direct array element, from more than 30 different keys. The only Hash-nested reclaims were the two fix: keep DSL prop controls out of block children #48 tests that useddata:. Recognising the protocol shape covers all of these, with no list to keep in sync.PropControls.release(list)clears implicit ownership when a block returns. App blocks call it inensure(dsl.rb), and WidgetBuilder calls it on its nested list. That is what WidgetBuilder already did in effect, so both block forms now agree. Reclaim also skips a control that is already mounted (runtime_pageset), so a mounted root is never taken out of the app's roots. Reclaim inside an open block is unchanged, so every fix: keep DSL prop controls out of block children #48 case still works:column { t = text("x"); row { container(content: t) } }.No change to how apps are written. The cases #48 fixed (content/title/actions/children duplicated as siblings) stay fixed.
Tests
packages/ruflet_core/test/dsl_reclaim_control_slots_test.rb(12 tests):data:references kept inRuflet.column, bare Kernel,DSL.appblocks/roots andpage.mount;data:holding a control or a list; the mounted wire carries+once; a unit test of the slot rule; reuse after a block returned (Kernel, mounted and unmounted); App and WidgetBuilder agreeing after an inner block returned; a mounted app root staying a root.dsl_block_prop_children_test.rb: two fix: keep DSL prop controls out of block children #48 tests asserteddata:reclaim.test_builder_block_does_not_duplicate_controls_in_a_deeply_nested_hash(adata:hash) now asserts the referenced control stays, and is renamed..._keeps_a_control_referenced_from_a_nested_data_hash. The ancestor-reclaim test drops its incidentaldata: { label: top }, and its two-level assertions are unchanged.ruflet_core,ruflet_server,ruflet(CLI) andruflet_rails, each run per file.PropControlsunder the embedded mruby VM (tools/embedded_vm_harness/build/embedded_mruby). It loads and behaves the same.Doc-example harness
I ran all 183 documented examples on this branch and compared them with the v0.0.23 baseline outputs, ignoring
tree_probe: 0 differ (180 identical, 3 skipped, as on main). No example changed behaviour.The audit probe
p01h_reclaim_edgesnow matches baseline.col_children_after_reuseis["shared","other"]andtext(0)stays in the column. The one remaining difference is the duplicatedtext("+")sibling that #48 removed on purpose.