Skip to content

semantics: a Semantics around a control names the control's own node (ADR-0407) - #3269

Merged
vanyastaff merged 11 commits into
mainfrom
claude/project-thread-f2wym8
Nov 30, 2026
Merged

vanyastaff merged 11 commits into
mainfrom
claude/project-thread-f2wym8

Conversation

@vanyastaff

@vanyastaff vanyastaff commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Requested by Vanya · project thread

Summary

A control is now named one way, whatever it is: Semantics::label around it names the control's own node. Flutter 3.50.1 gets this right for a switch (Semantics(label: …, child: Switch(…)) is one switch named by the label) and wrong for a button: ButtonStyleButton, RawMaterialButton and RawChip are containers, so a label around one is a second node with no action above the button, and a screen reader stops twice (applications record it; ADR-0407 links two reports). Flutter's naming builders are uneven too: Checkbox.semanticLabel, none on Switch or Radio. FLUI built every control's Description (ADR-0322 §1) as Semantics::container(true), so even the switch case made a nameless control, which is why #3264 needed a semantic_label per widget. ADR-0407 fixes it at the two seams every control goes through:

  • A description forms the node its Flutter counterpart forms. Description::new(role) is an annotation, Description::container(role) is Semantics(container: true), Description::merging(role) is MergeSemantics, chosen by the constructor and held in one private enum. Toggles, CupertinoButton, a cupertino tab item, a tappable carousel item and an enabled ListTile are annotations; RawButton, the ButtonStyleButton family, the FAB, chips and a chip's delete button are containers; tabs and navigation destinations merge. Each cites its line in flutter/flutter@3.50.1.
  • A Semantics that holds only a control names the control's node (sole_control_it_names in the assembly, SemanticsConfiguration::absorb_enclosing). An annotation control joins it as in Flutter; a container control's node takes it, where Flutter forms the label's node above. The label reads first ("Send Go"). A Semantics over a control and other content stays above them, and a button stays apart from the content beside it.
  • One identifier and one enablement per node. absorb carries an identifier, first wins, as Flutter's does (semantics.dart:6954); two different identifiers are two nodes, and a disabled control does not join a node that offers a user action.

ADR-0407 has a table of every place it departs from Flutter and why (a labelled button, the one naming path, a disabled ListTile, two identifiers, an identifier alone, a disabled control beside an action). ADR-0322 §6, ADR-0240 §1 and §4, ADR-0332 §4 and flui-semantics' ARCHITECTURE state the new rule. The builders that only set a control's name and are still on main (Checkbox::semantic_label, Slider::label) are listed in docs/gaps.md and go in the next small PR; Disclosure::label, which replaces the name its content gives, stays.

Cost: Description stays at most 16 bytes. No element, render node or allocation is added: the fold reuses the node the control already forms. The heap-counted perf targets of flui, flui-rendering, flui-widgets, flui-material and flui-cupertino pass under FLUI_PERF_BASELINE=check in release with the CI feature set. The assembly reads one more condition per annotated node, so main's callgrind lane may move instructions slightly.

Verification

  • cargo fmt --all; clippy --all-targets -D warnings on flui-semantics, flui-rendering, flui-widgets, flui-material and flui-cupertino; tests of those and of flui-testing and flui-objects
  • New behaviour fails without the change, each seen by hand: flui-rendering's an_annotation_around_a_control_alone_names_the_controls_node fails with the fold removed and with the label read after the button's (left: "Go Send"); named_by_semantics::a_label_around_a_control_names_the_controls_own_node (Switch, disabled Switch, Checkbox, Radio, enabled ListTile, ElevatedButton, FAB, FilterChip) fails with a toggle a container, with the fold removed and with absorb dropping the identifier; raw_button::a_label_around_a_raw_button_names_the_buttons_node fails with the fold removed; a_disabled_toggle_does_not_join_a_row_that_taps fails with the disabled refusal removed.
  • Public API: SemanticsConfiguration::absorb_enclosing is new in flui-semantics, called by the assembly. Description lives in the #[doc(hidden)] __private::node.
  • ADR-0407, docs/gaps.md
  • changelog.d/claude-project-thread-f2wym8.md

Expectations changed

  • flui-semantics the_identifier_is_exported_unannounced_unmerged_and_no_boundary is renamed …_no_boundary_and_joins_first_wins. Its "a parent absorbing the node takes its label, not its identifier" claim is now "a parent with none takes the identifier, and not as text", plus a first-wins claim. The old expectation stated the rule ADR-0407 replaces.
  • flui-rendering an_identifier_names_only_the_node_its_configuration_forms is renamed an_identifier_names_the_node_its_configuration_forms_or_joins. The group now carries note-id from its absorbed contributor, for the same reason. The bare identifier now sits before the note, so the test would see a bare identifier that wrongly joined.
  • named_by_semantics::a_label_around_a_container_control_is_a_node_above_it and raw_button::a_label_around_a_raw_button_is_a_node_above_it are replaced by the rows and the test above: they pinned Flutter's two-node shape, which ADR-0407 §2 now refuses.

Review

Read at a89bce8 by review-before-merge at tier fable (seven readers, a Fable judge). No mutation run (cargo-gamma is not installed in this container); each fix below was taken out by hand and its test seen to fail. The design read (mode: "design") was not run separately, because of the project's two-round limit; the records lens read the ADRs. Seven findings were confirmed and none rejected. Answered at e58f4d7:

  1. The dropped-identifier rule was still taught by eight records. Fixed, and the whole class with it: the absorb merge table, the docs of Semantics::identifier, MergeSemantics::identifier and RenderMergeSemantics::set_identifier, ADR-0332 §4, changelog.d/semantics-identifier.md, the content-roles fragment and the flui-driver spec evidence all state the joined identifier now. rg for the old phrasings finds nothing.
  2. A toggle's identifier was lost silently when the node it joins names itself. Fixed at the seam. A node publishes one identifier, so two different identifiers are two nodes: can_absorb and can_join refuse a configuration named otherwise than the node or a sibling, and that configuration keeps its own node and id. This is a departure from Flutter, which keeps the first id and drops the other; it is recorded in ADR-0407's counterparts table. A MergeSemantics still takes everything. Pinned by a_toggle_keeps_its_identifier_whatever_names_the_node_above_it (fails with the refusal removed) and by a new claim in the flui-semantics identifier table.
  3. A row template that repeats a toggle's id now clashes among rows. Kept on purpose: a control that joins its row names the row, which is Flutter's tree. ADR-0240 §4, ADR-0407 §2 and the changelog say so and give the form to use instead (name each row, which then keeps the control apart).
  4. A disabled toggle folds enabled: false into the node above, while ListTile departs. Kept on purpose, with the reason now in ADR-0407 §1. The node that absorbs a disabled toggle reads as that toggle, which is what the label around it names. The tile's departure exists because a tile is a row of content whose state would otherwise read as the list's. Pinned by the "a disabled Switch" row.
  5. and 6. The forms of CupertinoButton, the enabled ListTile, the FAB, FilterChip and RawButton had no test. Fixed: rows in named_by_semantics.rs, plus button::a_label_around_a_button_names_the_buttons_own_node (cupertino) and raw_button::a_label_around_a_raw_button_is_a_node_above_it (widgets). Each was seen to fail with its control flipped to the other form. The carousel item and the cupertino tab item get no row, because their parent forces separate nodes either way (ADR-0407 §1).
  6. container() guarding against downgrading a merge. Fixed by shape: the form is a constructor (Description::new, container, merging), so no later call can change it.

Round 2 read the fixes at e58f4d7 with the same workflow and tier (the last round the project allows). The judge confirmed five findings and two nits, and rejected three (a disabled ListTile, the chip forms, carousel and tab rows), each ruled out by a line. Answered at 29ff2a8, read by the author alone:

  1. can_join compared identifiers without the has_been_annotated guard can_absorb has, so a bare-identifier sibling was refused. Fixed by one owner of the rule: keeps_apart, read by both and guarded by has_been_annotated.
  2. A disabled toggle joining an InkWell row made the row read as disabled and refuse its tap. Fixed at the seam: a disabled configuration does not join a node that offers a user action, as a descendant or a sibling. A node that is itself disabled still absorbs the actions below it, as before (an_ordinary_merge_keeps_its_actions). Pinned by a_disabled_toggle_does_not_join_a_row_that_taps, which fails with the refusal removed, and a claim in the identifier table.
  3. The identifier builders of the toggles, CupertinoButton and EditableText still said "the node the control forms". Fixed: each states the node its semantics form or join.
  4. ADR-0407 Context cited flui-material: buttons and selection controls run on the scenario tester; Switch, Radio and a chip's delete button can be named #3264 and a semantic_label it no longer depends on. Fixed.
  5. The bare-identifier claim never reached the path it named (its parent had an id). Fixed: the parent has none and the claim asserts it stays without one.
  6. and 7. Nits: assembly-level tests of sibling identifiers under MergeSemantics are left for the next small PR (the configuration table covers can_join); the stale "as before" wording went with the rewrite.

After round 2, the owner asked that this not copy Flutter where Flutter is weak. The change at fe7753d (the labelled-container fold, the one naming path, ADR-0407 rewritten with its departures table) came after both rounds the project allows, so it was read by the author alone against "Before each push": no user code or allocation on the new path; the fold applies only to an annotation that is none of a boundary, a merge, a merge part, a node with explicit children or a node the clips hide, whose one child fragment is a formed node of a content-named role, and that can_absorb accepts (so a second tap, a second identifier or a disabled control beside an action still splits); a lazy item's stamped position moves onto the control's node; nested annotations (a tooltip and a label around one button) fold one after the other. The automated review of the pull request is the second reader for it.

Architecture

Notes

https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK


Generated by Claude Code

… takes it, first wins

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
… its Flutter counterpart is a container

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…nd a container button keeps its own

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…R-0322 §6 and ADR-0240 §1 state the new rule

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
@vanyastaff vanyastaff self-assigned this Nov 30, 2026
…rm is its constructor; the records state the joined identifier

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…07 states the identifier refusal, the disabled toggle and the row template

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…odes; the identifier docs of the controls state the joined node

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
… disabled node above still absorbs them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…node, a button's or a chip's too; ADR-0407 lists where it departs from Flutter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
@vanyastaff vanyastaff changed the title semantics: a label around a control names it, as in Flutter (ADR-0407) semantics: a Semantics around a control names the control's own node (ADR-0407) Nov 30, 2026
@vanyastaff
vanyastaff merged commit 04e9e42 into main Nov 30, 2026
19 checks passed
@vanyastaff
vanyastaff deleted the claude/project-thread-f2wym8 branch November 30, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants