2026 03 06 Tool Renderer Library Design

Documentation for Plans

Tool Renderer Library — Design Document

Date: 2026-03-06
Session: 187+
Status: Design (pending approval)


1. Problem Statement

The current chat UI presents tool outputs in a crowded, unpolished way:

User need: Each tool should have a dedicated component that renders its output in a clear, scannable, user-friendly way. Code should be segregated and maintainable.


2. Current Architecture

lib-unified-chat
  └── lib-unified-message
        └── lib-tool-use-card [toolCall]
              ├── .tool-header (name, icon, status, duration)
              └── .tool-details (when expanded)
                    └── lib-tool-renderer-host [toolCall]
                          └── switch by toolName:
                                - browser → BrowserRenderer
                                - screen-capture → ScreenCaptureRenderer
                                - shell → ShellRenderer
                                - search → SearchRenderer
                                - delegation → DelegationRenderer
                                - default → DefaultRenderer (raw JSON / key-value)

Tools without dedicated renderers (fall to DefaultRenderer):


3. Proposed Architecture

3.1 Tool Renderer Library Structure

libs/libs-ai/vitto-chat/src/lib/
├── components/
│   └── tool-renderers/
│       ├── tool-renderer-host/          # Dispatcher (unchanged)
│       ├── default-renderer/            # Fallback (improved)
│       ├── renderers/
│       │   ├── browser-renderer/
│       │   ├── shell-renderer/
│       │   ├── search-renderer/
│       │   ├── delegation-renderer/
│       │   ├── screen-capture-renderer/
│       │   ├── module-generation-renderer/   # NEW: start + check
│       │   ├── http-request-renderer/        # NEW
│       │   ├── computer-use-renderer/       # NEW: start/check/intervene
│       │   ├── error-renderer/               # NEW: LLM/tool failures
│       │   └── ...
│       └── shared/                            # NEW: shared primitives
│           ├── tool-status-badge/
│           ├── tool-phase-indicator/
│           └── tool-error-panel/

3.2 Module Generation Renderer (Priority 1)

Input: start_module_generation or check_module_generation tool call

Output shape (from backend):

Component design:

3.3 Error Renderer (Priority 2)

Trigger: When toolCall.success === false or output contains error / ERROR: pattern

Design:

3.4 Tool Use Card Improvements

3.5 Registry Pattern

ToolRendererHost dispatches by toolName:

// tool-renderer-host.component.ts
readonly rendererType = computed(() => {
  const name = this.toolCall().toolName;
  if (['start_module_generation', 'check_module_generation'].includes(name)) return 'module-generation';
  if (['start_computer_use', 'check_computer_use_status', 'computer_use_intervene'].includes(name)) return 'computer-use';
  if (name === 'http_request') return 'http-request';
  // ... existing mappings
  return 'default';
});

Each new renderer is a standalone component in renderers/ with a single responsibility.


4. Design Principles

  1. User-first: Show what the user cares about (status, result, error) — not raw JSON
  2. Progressive disclosure: Summary by default; optional "Show raw" for developers
  3. Segregated code: One renderer per tool (or tool family); one file per component
  4. Shared primitives: Reuse ToolStatusBadge, ToolPhaseIndicator, ToolErrorPanel across renderers
  5. Consistent styling: Use --chat-* variables, same spacing/typography as other chat components

5. Implementation Plan (High-Level)

Phase Scope Deliverables
1 Module generation ModuleGenerationRendererComponent, ToolRendererHost mapping, friendly names
2 Error handling ErrorRendererComponent or enhance DefaultRenderer for failures
3 Layout improvements Tool card spacing, subtitle logic, condensed summary
4 Additional tools HTTP, computer-use, MCP tools as needed

6. File Changes Summary

File Action
tool-renderer-host.component.ts Add module-generation, error, http-request mappings
tool-use-card.component.ts Add friendly names for module gen tools; improve subtitle
renderers/module-generation-renderer/ NEW — component + template + styles
renderers/error-renderer/ NEW — component for failed tool calls
shared/tool-status-badge/ NEW — optional shared primitive
unified-message.component.scss Increase spacing in unified-message__tools
default-renderer.component.* Improve layout; avoid raw JSON as primary view

7. Approval

Design ready for implementation. Please confirm before proceeding.