0301. Semantic TUI accessibility and automation tree
- Status: Accepted
- Date: 2026-11-28
Context
TUI tests and agents drive screens through geometry
(Rects, row text, border widths). A one-column border
change breaks scripts, and nothing proves that an ADR-0225
approval prompt was shown unclipped before the user (or agent)
confirms.
Decision
Pure Tenon, no capabilities, no Rust (ADR-0291).
tui.typesgainsA11yRole(Input | List | Table | Modal | Button | DiffHunk | Pane | Status),A11yNode(id, role, rect, label, focused, disabled, value_summary, clipped_chars, presented_complete) andScreen.a11y_nodes.composeandempty_screenleave it[]; every existingwith { .. }caller is unchanged. Nodes are optional metadata, never rendered.tui.a11ybuilds, attaches (add_nodeadds cells outside the frame toclipped_charsand clearspresented_complete), queries (find_by_id,find_by_role,resolve), maps a node to its hitTarget(focus_target), guards typing (type_target: enabled, focused, <= 4096 B) and asserts (expect_visible_unclipped).snapshot_stremits compact JSON, omitting default fields, truncating labels (24) and values (32).approval_gate(screen, modal_id)/approval_presented_completeare true only when the modal exists, has area, and hasclipped_chars == 0 && presented_complete, and everyDiffHunknode on the screen is also unclipped and presented. A clipped prompt refuses approval until scrolled or enlarged; presentation of hunks stays anchored toPresented(frame)(ADR-0225) viais_hunk_presented..tuiscenarios gainfocus @id(".."),type @role("..") ".."andexpect @id("..") visible unclipped. Focus is reached with Tab traversal (bounded byfocus_order), so scripts exercise the real runtime routing. A first semantic line renders the initial frame.- Widgets emit nodes through opt-in helpers
(
tui_widgets.a11y,tui_forms.a11y,tui_diff.a11y,tui_cards.a11y); existingBlock/Layer/Screenconstructors and calls are untouched. Forms and diffs derive node rects from the hits they already emit, so selectors survive border/size shifts. Secrets are masked.
Consequences
Screenhas one more field; the only literals were intui.typesandtui.compose.tuistays free of ajsondependency: adding it would stale 42tenon.lockfiles outside this package.snapshot(screen)therefore returns the JSONstr; callers that depend onjsonusejson.parse(snapshot_str(s))for aValue.clipped_charsis in cells (rows x width) for rows, columns for single-line widgets. Per-hunk accounting renders the diff once at scroll 0 (<= 2048 rows).- Pre-existing
Capsliterals intui_formsandtui_diffunit tests lackedbackground, so those suites did not compile; they are fixed here.