2026-03-12 23:45:45 +02:00
# Chat Message Parts: Rendering Architecture
This folder contains renderers for chat message parts (text, tools, reasoning, placeholders) and shared tool presentation helpers.
Use this doc when you ask an agent to change tool/header/description behavior.
## High-level flow
- Message parts are rendered from `MessageBody.tsx` .
- There are two tool rendering paths:
- **Static grouped tools** -> `StaticToolRow` in `ProgressiveGroup.tsx`
- **Expandable tools** -> `ToolPart.tsx`
- Shared tool icon mapping is centralized in `toolPresentation.tsx` (`getToolIcon` ).
## Which file controls what
- `ProgressiveGroup.tsx`
- Renders grouped Activity rows and grouped static tools.
- Contains `StaticToolRow` .
- Contains static tool short description logic (`getToolShortDescription` ).
- If you want to change how `read/grep/perplexity/webfetch/...` look in compact/grouped mode, edit here.
- `ToolPart.tsx`
- Renders expandable tool rows (bash/edit/write/question/task + fallback).
- Controls expandable header title/description/diff stats/timer and expanded output body.
- If you want to change expandable tool layout, edit here.
2026-07-14 01:36:17 +03:00
- `taskToolModel.ts`
- Owns Task metadata parsing and child-session summary projection.
- `part.state.metadata.sessionId` is the only live identity contract between a Task and its child session.
- A running Task may briefly have no `sessionId` ; render it as waiting until the authoritative part update arrives. Never match parallel children by order, title, timestamp, or status.
- Part-level metadata and output parsing exist only for older persisted records and never override state metadata.
2026-03-12 23:45:45 +02:00
- `toolPresentation.tsx`
- Shared icon mapping for tool names (`getToolIcon` ).
- Used by both `ProgressiveGroup.tsx` and `ToolPart.tsx` .
- `toolRenderUtils.ts`
- Core classification helpers:
- `isExpandableTool`
- `isStaticTool`
- `isStandaloneTool`
- `getStaticGroupToolName`
- If a tool should switch between static vs expandable, change it here.
- `ReasoningPart.tsx`
- Thinking block UI (`ReasoningTimelineBlock` ), summary + optional duration.
- `JustificationBlock.tsx`
- Justification block wrapper over `ReasoningTimelineBlock` .
## Current important behavior
2026-07-10 14:51:33 +03:00
- `read` and `skill` are **static navigation tools** and render via `StaticToolRow` .
- Every other tool, including search/fetch, OpenCode built-ins, custom tools, plugins, and MCP tools, is **expandable** and renders through `ToolPart` .
2026-07-24 21:54:28 +03:00
- The managed `openchamber` plugin tool uses the expandable path and hides its broad protocol input. The plugin supplies the selected action's human description as the native tool title; the UI renders that metadata without owning an action map. The full versioned result envelope renders through the same neutral JSON summary/tree/raw views as other tools, without a tool-specific output card.
2026-07-10 14:51:33 +03:00
- `ToolPart` defers expanded content after a user toggle, preventing large tool input/output payloads from mounting during the initial chat render.
2026-03-12 23:45:45 +02:00
- Thinking/Justification duration is hidden in `sorted` mode (handled in `ReasoningPart.tsx` + `JustificationBlock.tsx` ).
## "I want to change description for Perplexity" (example recipe)
2026-07-10 14:51:33 +03:00
If task is: "change text shown near Read or Skill in compact mode":
2026-03-12 23:45:45 +02:00
1. Edit `ProgressiveGroup.tsx` -> `getToolShortDescription(activity)` .
2026-07-10 14:51:33 +03:00
2. Update the branch that handles `read` or `skill` in `StaticToolRow` .
3. Keep all other tool header/output behavior in `ToolPart.tsx` .
2026-03-12 23:45:45 +02:00
4. Keep icon changes (if any) in `toolPresentation.tsx` .
2026-07-10 14:51:33 +03:00
Why: only navigation tools use the compact static path; all other tools need observable input and output.
2026-03-12 23:45:45 +02:00
## "I want tool to become expandable" (example)
1. Update `toolRenderUtils.ts` :
2026-07-10 14:51:33 +03:00
- add/remove a tool name from `STATIC_TOOL_NAMES` only when it has a reliable direct in-app navigation action
2026-03-12 23:45:45 +02:00
2. Ensure `ToolPart.tsx` supports desired header + expanded output format for that tool.
3. Validate both modes (`sorted` and `live` ).
## Safe editing checklist
- Do not duplicate icon logic; keep it in `toolPresentation.tsx` .
- For static tool copy changes, prefer `ProgressiveGroup.tsx` first.
- For expanded output changes, edit `ToolPart.tsx` .
- After edits run:
- `bun run type-check`
- `bun run lint`
- `bun run build`
## Quick map of files in this folder
- Text: `AssistantTextPart.tsx` , `UserTextPart.tsx`
- Tools: `ToolPart.tsx` , `ProgressiveGroup.tsx` , `toolPresentation.tsx` , `toolRenderUtils.ts` , `ToolRevealOnMount.tsx`
- Reasoning/justification: `ReasoningPart.tsx` , `JustificationBlock.tsx`
2026-04-20 18:48:33 +03:00
- Status/placeholders: `WorkingPlaceholder.tsx` , `SessionActiveSpinner.tsx` , `MigratingPart.tsx` , `BusyDots.tsx`
2026-03-12 23:45:45 +02:00
- Utility renderers: `VirtualizedCodeBlock.tsx` , `MinDurationShineText.tsx`