fix: a tree playground page, and the two bugs building it exposed - #3
Merged
Conversation
Standing instruction from the user: always update the examples. 0.3.0 shipped tree data, a bubble menu and inline editing with tests, docs and a spec, and no way to click any of it. ## The page examples/playground/tree.html, over three shapes: nested children, flat rows with two parents, and lazy children. It has the bubble menu, inline editing on three columns with different rules, a language switcher, a "refuse every edit" toggle for watching rollback, and live nested set counters that make the model legible: eight nodes for six distinct rows is what "one row, two placements" looks like. examples/react-remote/App.tsx gains a tree section, so the tree API is type-checked with the rest and cannot drift. ## The two bugs it found Neither was caught by 269 tests, because tests construct a component once and an application changes props. - A changed `dataSource` prop never reached the engine. The guard compared the new prop against a helper that reads the current props, so it compared the prop against itself, which is always equal, and setDataSource was never called. Present since 0.1.0. - Changing the tree's input shape left every row a root. The controller chose between nested children and parent references when it was built. It now asks on every normalise, which is also better than the rebuild I tried first: that cascaded, because plugins are fixed at engine creation, so the engine kept a reference to a controller that had just been destroyed. A third came out of the fix: always supplying loadChildren made every expand fetch an empty list and replace real children with it. Loading now runs only for a node that declared children and has none. Regression tests for all three, plus the CI example job now boots the new page. The rule is written into .agents/rules/agent_execution_standards.md and the tree spec's task list, so it is planned at stage 4 rather than remembered. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ndm72nQiMLvEqekHNJuAV
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.
What and why
Standing instruction: always update the examples. 0.3.0 shipped tree data, a bubble menu and inline
editing with tests, docs and a spec, and no way to click any of it.
Building the page found two defects that 269 tests had missed, because a test constructs a
component once and an application changes props.
The page
examples/playground/tree.html, over three shapes: nested children, flat rows with two parents,and lazy children. Bubble menu, inline editing on three columns with different rules, a language
switcher, a "refuse every edit" toggle for watching rollback, and live nested set counters that
make the model legible. Eight nodes for six distinct rows is what "one row, two placements" looks
like.
examples/react-remote/App.tsxgains a tree section, so the tree API is type-checked with the rest.The bugs
A changed
dataSourceprop never reached the engine. The guard compared the new prop against ahelper that reads the current props, so it compared the prop against itself, which is always equal,
and
setDataSourcewas never called. Present since 0.1.0.Changing the tree's input shape left every row a root. The controller chose between nested
children and parent references when it was built. It now asks on every normalise, which is better
than the rebuild I tried first: that cascaded, because plugins are fixed at engine creation, so the
engine kept a reference to a controller that had just been destroyed.
Expanding a node with children present fetched an empty list and replaced them. Fallout of the
fix above, since
loadChildrenbecame always-supplied. Loading now runs only for a node thatdeclared children and has none.
Regression tests for all three.
Semver classification
TreeControllerOptionsgained an optionalmode, which is additive.Verification
Driven in a browser: switching to "Flat, with two parents" shows
Shared.pdfunder both folders,expanding one leaves the other shut, and the bubble menu hides "Add child" on a file.
Self-review
dataSourceswap fix is exactly this seam working as documented for the first time.examples/stays out of the tarball.Documentation
CHANGELOG.mdunder Unreleased, naming both bugs and that the examples found themexamples/playground/README.mdgains the page and four things to tryspecs/tree-data/tasks.mdgains an Examples section.agents/rules/agent_execution_standards.mdmakes it a rule, so it is planned at stage 4rather than remembered
workflow.ai.ymlnot affected; the sync scripts still pass with--check