feat(chat): add generative UI blocks for maps and action buttons#6163
feat(chat): add generative UI blocks for maps and action buttons#6163eulicesl wants to merge 14 commits intoBasedHardware:mainfrom
Conversation
Create LangChain tools that let the LLM render rich UI components inline in chat: map cards with location data, and tappable action buttons for follow-up questions. (cherry picked from commit dbac65b)
(cherry picked from commit ff511e9)
Add create_map_ui and create_action_buttons_ui to CORE_TOOLS so the LLM can autonomously decide when to show rich UI. Extract ui_blocks from agent config after streaming, following the same pattern as chart_data. (cherry picked from commit 0ce919d)
(cherry picked from commit 62f9ec8)
(cherry picked from commit 4536876)
Define GenUiBlockType enum (map, actionButtons) and GenUiBlock class with JSON serialization. Add uiBlocks list to ServerMessage for rendering generative UI components in chat. (cherry picked from commit 24d100b)
MapCardWidget renders a static map image with title/description, tappable to open native maps. ActionButtonsWidget renders a Wrap of pill-shaped buttons that send follow-up messages when tapped. (cherry picked from commit d855f17)
Render GenUiBlocks after chart data in AI messages. Add map shimmer loading state when the LLM is thinking about locations. Thread sendMessage callback through NormalMessageWidget for action buttons. (cherry picked from commit 08ee7c1)
Greptile SummaryThis PR adds generative UI (GenUI) blocks to the Omi chat experience, enabling the LLM to render inline map cards and action-button rows alongside text responses. The backend introduces two new LangChain tools ( Key changes:
Issues found:
Confidence Score: 4/5Safe to merge after fixing the un-awaited async map-launch call, which silently drops exceptions on devices without a maps app One P1 issue remains: the onTap callback in MapCardWidget discards the Future returned by MapsUtil.launchMap, so any exception from the map launcher (e.g., no supported app installed) is silently swallowed. All previous review concerns have been addressed cleanly. The rest of the PR — context isolation, enum serialization, unknown-type filtering, localization — is solid. app/lib/pages/chat/widgets/genui_widgets.dart — MapCardWidget.onTap needs await + error handling Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Router as chat.py
participant Agent as agentic.py
participant Ctx as context.py
participant Tools as genui_tools.py
participant App as Flutter
User->>Router: POST send_message
Router->>Agent: execute_agentic_chat_stream
Agent->>Ctx: set agent_config_context with configurable dict
Agent->>Tools: invoke create_map_ui or create_action_buttons_ui
Tools->>Ctx: get agent_config_context
Ctx-->>Tools: configurable dict reference
Tools->>Tools: append block to configurable ui_blocks list
Tools-->>Agent: confirmation string
Agent->>Agent: read configurable ui_blocks after task completes
Agent-->>Router: callback_data including ui_blocks
Router-->>User: Message JSON with ui_blocks
User->>App: ServerMessage.fromJson
App->>App: parse GenUiBlock list, drop unknown types
App-->>User: render MapCardWidget or ActionButtonsWidget
Reviews (2): Last reviewed commit: "fix(chat): tighten genui review follow-u..." | Re-trigger Greptile |
|
Final readiness note for maintainers:
This PR is intentionally scoped and ready for maintainer review. |
|
Addressed the two remaining GenUI findings on the latest head:
Validation re-run on the updated branch:
Latest fix commit:
|
Summary
ui_blocksthrough the agentic pipeline and chat response modelWhat changed
Backend
create_map_uiandcreate_action_buttons_uitoolsui_blocksfrom the agent/configurable path and pass them through the chat routerMessagemodel withui_blocksApp
GenUiBlock/GenUiBlockTypeparsing toServerMessageMapCardWidgetandActionButtonsWidgetValidation
python3 -m py_compile ...on touched backend filesuv run --no-project --with pytest python -m pytest tests/unit/test_genui_tools.py -qflutter analyze --no-fatal-infos ...on touched app files and testsflutter test test/unit/genui_message_test.dart test/widgets/genui_widgets_test.dartNotes
mainbackend/utils/retrieval/agentic.pysoui_blocksare read from the existingconfigurableobjectfeat/genui-chat-clean-room; the oldfeat/genui-chatbranch should be retired as the review surface