ADR 0227: Deliver terminal capabilities before text layout
- Status: Accepted for M-TUI implementation
- Date: 2026-11-12
Context
The design says plugins can branch on
Caps.cluster, but its App contract gives
view only a size and the runtime consumes
capability-probe replies. Merely remeasuring final strips cannot
recover text already clipped by a widget under another policy, or
repair its cursor and hit-region geometry.
A C/interpreter reproduction confirmed an input ending in
👩💻x placed its cursor at column5 under both policies
although the cluster policy displays it in3 cells. A click on the
visible second tab could select the first tab, and a four-cell
input lost an emoji that fits under the cluster policy.
Decision
Add Event.Capabilities(Caps) to the existing pure
event vocabulary. start queues the initial snapshot
before input delivery; when the startup probe freezes,
tick delivers the negotiated snapshot before
rendering. The event uses ordinary update/effect handling and does
not introduce another callback, effectful view or dynamic
registry. An app stores the relevant policy in its ordinary model
and passes it to its plugins.
Provide explicit policy helpers alongside the existing default
conveniences: line_policy, width_policy,
canvas_policy, and policy-aware widget and Markdown
entry points. They select widths before wrapping, slicing,
clipping, cursor placement and hit-region construction. Cached
views rebuild when policy changes. The existing helpers retain
their documented default scalar policy; this is the same
convenience distinction as span and
span_policy.
Runtime normalization remains a final sanitation/measurement boundary. It is not an application layout engine and cannot reconstruct discarded content. Apps drawing their own text use the delivered policy before layout too.
Verification
Maintain startup/probe delivery and idle regressions, both-policy input cursor, small-width emoji clipping and tab-hit checks, border alignment, Markdown cache invalidation, and the actual app consumers. Preserve actual-Presented approval guards and full-prompt rejection of clipped content. All remain differential.