Reintroduce a parent link on model nodes - #227
Merged
Merged
Conversation
Adds `parent` throughout the model: `null` at the root, and a precise, literal-preserving link up the tree for every item. Follows option B from the issue's investigation — nodes are derived from a root menu description plus an index path locating them within it, rather than from their own literal shape, so an item's type and its parent's type are computed independently instead of one referencing the other. Runtime construction is flipped from child-first to parent-first: a node is built before its items, which are then built with it as their parent via a callback. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Cut redundant clauses and drop the ModelRoot.parent comment: parent: null needs no explanation next to isRoot: true, which has none. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 16934e4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
marking-menu shipped the parent property in 0.10.1. It was dropped during the TypeScript migration, tracked by the (still unreleased) remove-item-parent changeset, before this change brought it back. Since that removal never reaches a release, drop its changeset and describe the actual delta from 0.10.1 instead: parent stays, now precisely typed, with null instead of undefined at the root. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
A consumer reading the changelog never saw parent removed; only the diff between released versions is visible to them. Describe the property directly instead of narrating its unreleased history. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
QuentinRoy
enabled auto-merge (squash)
September 3, 2026 19:27
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.
Fixes #167
Model nodes expose their sub-items but have no way back up: given an item, there's no way to find the menu it belongs to. This link existed before the TypeScript migration and was dropped there, since restoring it created a circular type: a node's type would reference its parent's type, which references it back.
This restores
parentby changing how a node's type is described. Instead of a node's own id, label and items, each node is now described by the whole menu it belongs to, plus a path locating it within that menu.parentis then the same lookup with the last step of the path dropped, so a node and its parent are derived independently from the menu description rather than one being defined in terms of the other. The root'sparentis alwaysnull.The runtime construction order changes to match: a node is built before its items, which are then built with it as their parent.
A menu built at runtime rather than described as a literal still works, but its items lose the precise typing, the same trade-off
idandlabelalready make in that case.You can check the new behavior directly:
Tests cover
parentat runtime, at every level, with the root having none, and what the type system knows about it for both a literal menu description and one built dynamically.