Skip to content

Implement Claude Code formatting in UI Detail view #198

@mkusaka

Description

@mkusaka

Overview

Implement Claude Code-style formatting for the Detail view in the interactive UI. This view shows the full message content with proper Claude Code formatting for tool executions and thinking blocks, without any truncation.

Context

Following the display patterns identified in #171, this issue focuses on implementing the Detail view formatting, which displays complete message content with Claude Code's specific formatting markers.

Implementation Details

Affected Components

  • src/interactive_ratatui/ui/components/message_detail.rs

Formatting Requirements

Tool Execution Display

  • Tool executions should be formatted as:
    ⏺ ToolName(arguments)
    ⎿ [complete tool result content]
    
  • Use the formatter module from feat: Create formatter module for Claude Code-style output #195 to format tool executions
  • Results should be indented with 2 spaces after the ⎿ marker
  • Show complete tool results without truncation

Thinking Block Display

  • Thinking blocks should be formatted as:
    ✻ Thinking...
    [complete thinking content]
    
  • Display full thinking content without truncation

Message Content Display

  • Regular message content should be displayed with all line breaks preserved
  • No truncation - show complete message content
  • Support scrolling for long messages

Implementation Steps

  1. Update message_detail.rs:

  2. Content Processing:

    • Parse the raw_json field from SearchResult
    • Identify tool_use blocks and format them
    • Preserve all formatting and indentation
    • Handle multiple tool executions in sequence
  3. Scrolling Support:

    • Maintain existing scrolling functionality
    • Ensure formatted content scrolls properly
    • Update line counting to account for formatted content

Example Detail Display

File: ~/.claude/projects/myproject/session_2024.jsonl
Session: abc-123-def
Time: 2024-01-01 12:00:00
Role: assistant

I'll help you search for information about the latest Rust features and create a summary document.

⏺ WebSearch(query="rust 1.75 new features async traits")
⎿ Search Results:
  
  1. **Rust 1.75.0 Released** - Official Rust Blog
     URL: https://blog.rust-lang.org/2024/01/01/Rust-1.75.0.html
     Summary: Rust 1.75 introduces async fn in traits, allowing trait definitions to include
     async methods. This has been one of the most requested features...
  
  2. **Async Traits in Rust 1.75** - Rust Magazine
     URL: https://rustmagazine.com/async-traits-1.75
     Summary: Deep dive into the new async trait feature, including examples and migration
     guides from the async-trait crate...
  
  3. **What's New in Rust 1.75** - Dev.to
     URL: https://dev.to/rust/whats-new-rust-175
     Summary: Comprehensive overview of all new features including const generics improvements,
     pattern matching enhancements, and the headline async traits feature...

Based on the search results, I can see that Rust 1.75 has introduced several significant features. Let me read the official announcement for more details.

⏺ Read(file_path="/tmp/rust_175_features.md")
⎿ # Rust 1.75.0 Release Notes
  
  ## Major Features
  
  ### Async Functions in Traits
  One of the most anticipated features has finally landed. You can now write:
  
  ```rust
  trait AsyncIterator {
      type Item;
      async fn next(&mut self) -> Option<Self::Item>;
  }

This eliminates the need for the async-trait crate in many cases, though some
advanced use cases may still benefit from it.

Const Generic Improvements

  • Better type inference for const generics
  • Support for const expressions in more contexts
  • Improved error messages

Pattern Matching Enhancements

  • New pattern syntax for matching ranges
  • Exhaustiveness checking improvements
  • Better performance for large match expressions

Library Improvements

Standard Library

  • New methods on Option and Result
  • Performance improvements to HashMap
  • Additional Iterator combinators

Tooling

  • Cargo now supports workspace inheritance for more fields
  • Rustdoc improvements for async traits
  • Better diagnostics for lifetime errors

Now I'll create a summary document with this information.

⏺ Write(file_path="/home/user/rust_175_summary.md", content="# Rust 1.75 Feature Summary\n\n## Overview\nRust 1.75.0 brings several long-awaited features, with async functions in traits being the headline addition.\n\n## Key Features\n\n### 1. Async Functions in Traits\nYou can now define async methods directly in trait definitions:\n\nrust\ntrait AsyncIterator {\n type Item;\n async fn next(&mut self) -> Option<Self::Item>;\n}\n\n\n### 2. Const Generic Improvements\n- Enhanced type inference\n- Broader const expression support\n- Clearer error messages\n\n### 3. Pattern Matching Enhancements\n- New range matching syntax\n- Better exhaustiveness checking\n- Performance optimizations\n\n## Migration Guide\nIf you're currently using the async-trait crate, you can now migrate many uses to native async traits. However, some advanced scenarios (like traits with associated types used as trait objects) may still require the crate.\n\n## Resources\n- Official Release Notes\n- Async Traits RFC\n- Migration Guide\n")
⎿ File created successfully at /home/user/rust_175_summary.md

I've created a comprehensive summary of Rust 1.75's new features. The document highlights the major additions, particularly async functions in traits, which has been one of the most requested features in the Rust community. The summary also covers const generic improvements and pattern matching enhancements, along with a brief migration guide for projects currently using the async-trait crate.

[End of message - Press 'q' to return]


## Testing
- Verify tool execution formatting matches Claude Code style exactly
- Test with messages containing multiple tool executions
- Ensure scrolling works correctly with formatted content
- Test with very long tool outputs
- Verify thinking block formatting
- Check that all content is displayed without truncation

## Dependencies
- Depends on #195 (formatter module) being completed first
- Uses SearchResult.raw_json field for parsing message content

## Related Issues
- #171 - Original Claude Code formatting specification
- #193 - Tool execution parser
- #195 - Formatter module implementation
- #196 - List view formatting
- #197 - Preview view formatting

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions