Skip to content

SB-028: Part-aware message model and rendering dispatch #88

@dugshub

Description

@dugshub

Summary

Replace the flat chat.Message{Role, Content} with a part-aware model. handleResponse() dispatches by StreamChunk.Type to accumulate structured parts. renderMessage() dispatches per part type to the right component (ToolCallBlock, DiffBlock, CodeBlock, ErrorBlock, markdown).

Scope

In:

  • MessagePart type with PartText, PartThinking, PartToolCall, PartError
  • ToolCallPart struct with ID, Name, DisplayType, State, Result, Error
  • Message.Parts []MessagePart replacing flat Content string
  • handleResponse() dispatching by chunk type to accumulate parts
  • renderMessage() dispatching per part to correct component
  • Tool call rendering by DisplayType: diff->DiffBlock, code->CodeBlock, bash->CodeBlock, generic->ToolCallBlock
  • Thinking parts as dim collapsed text
  • Backward compat: Raw field for gallery mode

Out:

  • Streaming markdown optimization (SB-013 — additive later)
  • Interactive tool call expansion/collapse (future)
  • Iteration status display (skip for MVP)

Key Files

app/cli/internal/chat/model.go   # MODIFY — Message, MessagePart types, handleResponse dispatch
app/cli/internal/chat/view.go    # MODIFY — renderMessage per-part dispatch

Acceptance Criteria

  • Chat model accumulates text chunks into text parts
  • Chat model accumulates thinking chunks into thinking parts
  • Tool start creates a tool_call part with State=Running
  • Tool end updates matching part with State=Complete, fills Result
  • renderMessage dispatches per part type
  • display_type "diff" renders DiffBlock
  • display_type "bash" renders CodeBlock with shell language
  • display_type "code" renders CodeBlock with file path
  • display_type "generic" renders ToolCallBlock
  • Thinking parts render as dim text
  • Error parts render as ErrorBlock
  • Gallery mode (Raw: true) still works
  • Demo mode still works

Depends On

SB-027

Spec

docs/specs/2026-03-22-message-parts.md (Phases 3-4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestepic:EP-008Message Parts — Part-Aware Chat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions