Part of #54. Depends on the token-set expansion (#56) only in the sense that it's most useful once there's more to restyle — the API itself is independent.
Problem
Hosts with runtime theme switching (crush swaps its theme when the model provider changes) have no way to restyle an existing surface. The only path is rebuilding via a2tea.Render(...) with new WithStyles, which discards user input state — typed TextField text, checkbox/choice selections, slider positions, open modals, focus position. Losing a half-filled form to a theme swap is not acceptable for the crush bridge.
Proposal
// SetStyles replaces the surface's style set. Safe to call at any time; the
// next View() renders with the new styles. Component state (field values,
// focus, modal/tab state) is untouched.
func (s *Surface) SetStyles(st Styles)
- Apply the same zero-value glyph backfill as
NewSurface so hosts can't blank the chrome.
- Extend the
render.Model interface (alongside SetSize/Focus/Blur/Focused) so hosts holding models by interface can restyle without a type assert. Note: this widens the interface — a2tea is pre-1.0 and the only known implementer is Surface, so do it now before that stops being true.
- Test: build a surface, mutate input state,
SetStyles with a colored theme, assert (a) state and FieldValues() unchanged, (b) rendered output reflects the new styles.
Host-side usage (crush)
refreshStyles → for each live, non-retired surface model: model.SetStyles(sty.A2UI) and bump the item version. Tracked on the crush side in docs/proposals/a2ui-mcp.md §1.
Part of #54. Depends on the token-set expansion (#56) only in the sense that it's most useful once there's more to restyle — the API itself is independent.
Problem
Hosts with runtime theme switching (crush swaps its theme when the model provider changes) have no way to restyle an existing surface. The only path is rebuilding via
a2tea.Render(...)with newWithStyles, which discards user input state — typedTextFieldtext, checkbox/choice selections, slider positions, open modals, focus position. Losing a half-filled form to a theme swap is not acceptable for the crush bridge.Proposal
NewSurfaceso hosts can't blank the chrome.render.Modelinterface (alongsideSetSize/Focus/Blur/Focused) so hosts holding models by interface can restyle without a type assert. Note: this widens the interface — a2tea is pre-1.0 and the only known implementer isSurface, so do it now before that stops being true.SetStyleswith a colored theme, assert (a) state andFieldValues()unchanged, (b) rendered output reflects the new styles.Host-side usage (crush)
refreshStyles→ for each live, non-retired surface model:model.SetStyles(sty.A2UI)and bump the item version. Tracked on the crush side indocs/proposals/a2ui-mcp.md§1.