Overview
This issue is part of implementing Claude Code-style formatting (#171). We need to create a formatter module that handles different display formats (List, Preview, Detail) according to Claude Code's visual style.
Requirements
Formatter Types
-
List Formatter
- Single-line display with newlines replaced by spaces
- Tool executions as
ToolName(args)
- Long arguments truncated with
…
- Example:
Bash(git commit -m "feat: enhance...")
-
Preview Formatter
- Multi-line with Claude Code markers
- First few lines followed by
… +XX lines (ctrl+r to expand)
- Format:
⏺ ToolName(arguments)
⎿ Result content
More content
… +XX lines (ctrl+r to expand)
-
Detail Formatter
- Complete content without truncation
- All markers and formatting preserved
- No
… +XX lines truncation
Implementation Details
Create new file: src/output/formatter.rs
use crate::schemas::tool_parser::{ParsedMessage, ToolExecution};
pub enum DisplayFormat {
List,
Preview { max_lines: usize },
Detail,
}
pub struct ClaudeCodeFormatter {
format: DisplayFormat,
}
impl ClaudeCodeFormatter {
pub fn new(format: DisplayFormat) -> Self { }
pub fn format_message(&self, parsed: &ParsedMessage) -> String { }
pub fn format_tool_execution(&self, tool: &ToolExecution) -> String { }
pub fn format_thinking_block(&self, content: &str) -> String { }
}
// Utility functions
pub fn truncate_with_ellipsis(text: &str, max_len: usize) -> String { }
pub fn format_line_count(count: usize) -> String { }
pub fn indent_content(content: &str, level: usize) -> String { }
Special Characters
⏺ (U+23FA) - Record button for actions
⎿ (U+23BF) - Circuit ground for results
✻ (U+273B) - Teardrop-spoked asterisk for thinking
… (U+2026) - Horizontal ellipsis for truncation
Formatting Rules
- Indentation: 2 spaces after
⎿
- Line truncation:
- List view: ~100 chars max
- Preview: configurable (default 5 lines)
- Argument truncation: Show first part +
... for long arguments
Testing
- Unit tests for each formatter type
- Tests for special character handling
- Tests for multi-byte character safety (Japanese, emojis)
- Edge cases (empty content, very long lines)
Acceptance Criteria
Dependencies
References
Overview
This issue is part of implementing Claude Code-style formatting (#171). We need to create a formatter module that handles different display formats (List, Preview, Detail) according to Claude Code's visual style.
Requirements
Formatter Types
List Formatter
ToolName(args)…Bash(git commit -m "feat: enhance...")Preview Formatter
… +XX lines (ctrl+r to expand)Detail Formatter
… +XX linestruncationImplementation Details
Create new file:
src/output/formatter.rsSpecial Characters
⏺(U+23FA) - Record button for actions⎿(U+23BF) - Circuit ground for results✻(U+273B) - Teardrop-spoked asterisk for thinking…(U+2026) - Horizontal ellipsis for truncationFormatting Rules
⎿...for long argumentsTesting
Acceptance Criteria
Dependencies
References