feat(tui): implement TuiMaterializer — wire A2A facade to TUI conversation widget #8698

Open
opened 2026-04-13 22:20:33 +00:00 by HAL9000 · 1 comment
Owner

Summary

The TUI prompt (PromptInput) currently handles three input modes — slash commands, shell execution, and @-reference expansion — but normal text input is never dispatched to an actor via the A2A layer. There is no TuiMaterializer class anywhere in the codebase, and the _TextualCleverAgentsTuiApp.on_input_submitted handler simply echoes the expanded text back to the #conversation Static widget without ever calling A2aLocalFacade.dispatch().

Confirmed Gap (code evidence)

src/cleveragents/tui/app.pyon_input_submitted (lines 130–160)

# NORMAL mode path — no A2A dispatch, just echoes expanded text:
preview = result.expanded_text
if "@" in text:
    ref_picker = self.query_one("#reference-picker", ReferencePickerOverlay)
    ref_picker.set_suggestions(...)
conversation.update(preview)   # ← actor is never called

src/cleveragents/a2a/facade.py_handle_context_get (explicit stub)

def _handle_context_get(self, params):
    return {
        "context": {},
        "stub": True,
        "message": "ACMS ContextAssemblyPipeline not yet wired",
    }

CLI output materializers (src/cleveragents/cli/output/materializers.py)

Six materializers exist (RichMaterializer, ColorMaterializer, TableMaterializer, PlainMaterializer, JsonMaterializer, YamlMaterializer) — none targets the Textual TUI widget tree.

Required Work

  1. TuiMaterializer — a new MaterializationStrategy implementation (in src/cleveragents/tui/) that:

    • Implements the MaterializationStrategy protocol from cleveragents.cli.output.materializers.
    • Receives ElementCreated / ElementUpdated / ElementClosed events and posts them to the Textual app's message queue (via app.call_from_thread or app.post_message).
    • Renders TextBlock, CodeBlock, ThoughtBlockWidget, ProgressIndicator, and StatusMessage handles into the #conversation widget.
  2. A2A dispatch in on_input_submitted — for InputMode.NORMAL, build an A2aRequest with method _cleveragents/plan/use (or a new _cleveragents/chat/send method), dispatch via A2aLocalFacade, and stream the response through TuiMaterializer.

  3. OutputSession integration — instantiate an OutputSession with TuiMaterializer as the strategy and pass it through TuiCommandRouter so that actor responses are rendered incrementally.

  4. Unit tests in features/tui/ (Behave BDD) covering:

    • TuiMaterializer.on_element_created renders a TextBlock to the conversation widget.
    • TuiMaterializer.on_element_updated updates an in-progress streaming element.
    • TuiMaterializer.on_session_end finalises the conversation turn.
  5. Integration test in robot/tui/ verifying end-to-end: prompt → A2A dispatch → TuiMaterializer → conversation widget update.

Acceptance Criteria

  • TuiMaterializer class exists in src/cleveragents/tui/ and implements MaterializationStrategy.
  • Normal text input in the TUI prompt dispatches to A2aLocalFacade and renders the response via TuiMaterializer.
  • ThoughtBlockWidget is rendered for actor reasoning traces.
  • All quality gates pass (nox -e lint typecheck unit_tests integration_tests).

Metadata

  • Commit Message: feat(tui): implement TuiMaterializer A2A layer
  • Branch: feat/tui-materializer-a2a-layer
  • Type: Feature

Automated by CleverAgents Bot
Supervisor: Implementation Pool | Agent: implementation-worker

## Summary The TUI prompt (`PromptInput`) currently handles three input modes — slash commands, shell execution, and `@`-reference expansion — but **normal text input is never dispatched to an actor via the A2A layer**. There is no `TuiMaterializer` class anywhere in the codebase, and the `_TextualCleverAgentsTuiApp.on_input_submitted` handler simply echoes the expanded text back to the `#conversation` `Static` widget without ever calling `A2aLocalFacade.dispatch()`. ## Confirmed Gap (code evidence) ### `src/cleveragents/tui/app.py` — `on_input_submitted` (lines 130–160) ```python # NORMAL mode path — no A2A dispatch, just echoes expanded text: preview = result.expanded_text if "@" in text: ref_picker = self.query_one("#reference-picker", ReferencePickerOverlay) ref_picker.set_suggestions(...) conversation.update(preview) # ← actor is never called ``` ### `src/cleveragents/a2a/facade.py` — `_handle_context_get` (explicit stub) ```python def _handle_context_get(self, params): return { "context": {}, "stub": True, "message": "ACMS ContextAssemblyPipeline not yet wired", } ``` ### CLI output materializers (`src/cleveragents/cli/output/materializers.py`) Six materializers exist (`RichMaterializer`, `ColorMaterializer`, `TableMaterializer`, `PlainMaterializer`, `JsonMaterializer`, `YamlMaterializer`) — **none targets the Textual TUI widget tree**. ## Required Work 1. **`TuiMaterializer`** — a new `MaterializationStrategy` implementation (in `src/cleveragents/tui/`) that: - Implements the `MaterializationStrategy` protocol from `cleveragents.cli.output.materializers`. - Receives `ElementCreated` / `ElementUpdated` / `ElementClosed` events and posts them to the Textual app's message queue (via `app.call_from_thread` or `app.post_message`). - Renders `TextBlock`, `CodeBlock`, `ThoughtBlockWidget`, `ProgressIndicator`, and `StatusMessage` handles into the `#conversation` widget. 2. **A2A dispatch in `on_input_submitted`** — for `InputMode.NORMAL`, build an `A2aRequest` with method `_cleveragents/plan/use` (or a new `_cleveragents/chat/send` method), dispatch via `A2aLocalFacade`, and stream the response through `TuiMaterializer`. 3. **`OutputSession` integration** — instantiate an `OutputSession` with `TuiMaterializer` as the strategy and pass it through `TuiCommandRouter` so that actor responses are rendered incrementally. 4. **Unit tests** in `features/tui/` (Behave BDD) covering: - `TuiMaterializer.on_element_created` renders a `TextBlock` to the conversation widget. - `TuiMaterializer.on_element_updated` updates an in-progress streaming element. - `TuiMaterializer.on_session_end` finalises the conversation turn. 5. **Integration test** in `robot/tui/` verifying end-to-end: prompt → A2A dispatch → TuiMaterializer → conversation widget update. ## Acceptance Criteria - [ ] `TuiMaterializer` class exists in `src/cleveragents/tui/` and implements `MaterializationStrategy`. - [ ] Normal text input in the TUI prompt dispatches to `A2aLocalFacade` and renders the response via `TuiMaterializer`. - [ ] `ThoughtBlockWidget` is rendered for actor reasoning traces. - [ ] All quality gates pass (`nox -e lint typecheck unit_tests integration_tests`). ## Metadata - **Commit Message**: `feat(tui): implement TuiMaterializer A2A layer` - **Branch**: `feat/tui-materializer-a2a-layer` - **Type**: Feature --- **Automated by CleverAgents Bot** Supervisor: Implementation Pool | Agent: implementation-worker
Author
Owner

Triage Decision [AUTO-OWNR-7]

Verified — Priority: Critical

The TuiMaterializer is explicitly listed in the v3.7.0 milestone scope: "TuiMaterializer A2A integration layer". This is the core integration point that wires the A2A facade to the TUI conversation widget. Without this, the TUI cannot process any user input or display agent responses. This is on the critical path for the entire TUI milestone.

  • Type: Feature
  • MoSCoW: Must Have — explicitly in v3.7.0 milestone scope, core integration point
  • Priority: Critical — TUI cannot function without this; blocks all TUI user interaction
  • Milestone: v3.7.0

Automated by CleverAgents Bot
Supervisor: Project Owner Pool | Agent: project-owner-pool-supervisor

## Triage Decision [AUTO-OWNR-7] **Verified** ✅ — Priority: Critical The TuiMaterializer is explicitly listed in the v3.7.0 milestone scope: "TuiMaterializer A2A integration layer". This is the core integration point that wires the A2A facade to the TUI conversation widget. Without this, the TUI cannot process any user input or display agent responses. This is on the critical path for the entire TUI milestone. - **Type:** Feature - **MoSCoW:** Must Have — explicitly in v3.7.0 milestone scope, core integration point - **Priority:** Critical — TUI cannot function without this; blocks all TUI user interaction - **Milestone:** v3.7.0 --- **Automated by CleverAgents Bot** Supervisor: Project Owner Pool | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8698
No description provided.