Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
dynamic_ui
What it is
The view an agent shows a person (execution.views.present in agent
sessions, DisplayResults in chat), as the web's dynamic-UI renderer draws
it. View and Widget are the source of truth: decoding into them is the
only validation, the model's JSON Schema comes from them through schemars,
and the web's TypeScript through specta.
Start here
src/view.rs:View,Widgetand their parts. A variant's doc comment is the model's guidance for it; it reaches ExecuteCode's description and theDisplayResultstool schema.src/query.rs: the list widget's filter, the web's Next SoupQuery.src/decode.rs:decode_viewanddeserialize_view. A field the types do not name is ignored.
Boundaries
- Depends on:
serde,serde_path_to_error,schemars,specta,nutype. - Used by:
agent_code_mode(execution.views.present, ExecuteCode's description),ai_tools(DisplayResults),agent_fold(view tool details and activity cards, built for wasm too).
Recipes
- Add a widget: add a
Widgetvariant with its doc comment, runjust gen-dynamic-ui-typesinapps/web, and add its arm toRenderinapps/web/src/features/dynamic-ui/render.tsx; the exhaustivematchfails to compile until you do. - Bound a value (a count, a range, a non-empty string): make it a
nutypenewtype so an out-of-range value fails to decode, and give the field a schemars attribute (range,length) so the model's schema shows the bound. nutype supports only schemars 0.8.
Checks
cargo test -p dynamic_ui;the_present_view_schema_is_pinnedsnapshots the model-facing schema with insta.just gen-dynamic-ui-typesinapps/web, then commitsrc/features/dynamic-ui/generatedandpackages/lexical-core/generated; CI's Check Specta Types step fails when they are stale.
Gotchas
- Problems name a place and what belongs there, never what the view holds:
they reach logs and the model with the failed call.
decode.rsdrops the value serde quotes. view.rsandquery.rsare exempt frommissing_docs: every doc comment there becomes a description in the schema ExecuteCode carries on every turn, so document only what guides the model.- The model's schema is a subset of what decodes:
notnegates a single clause there, while decoding takes any expression. A recursive field must stay optional or behind a list in the schema, or Gemini rejects every request carryingDisplayResults;ai_toolstests fail when one does not. - Paths stop at an internally tagged widget: serde buffers a tagged variant's fields, so a problem inside one names the widget, not the field.
- The browser never validates a view: every path decodes it on the server
first. Render views only from decoded data (a
DisplayResultsresult, a presented view's result, a stored activity card), never from the model's arguments.