Skip to content

Conversation

@lyzno1
Copy link
Contributor

@lyzno1 lyzno1 commented Sep 20, 2025

Summary

  • Added collapsible think block support for AI assistant messages
  • Supports both <think> and <details> tags for compatibility
  • Integrated seamlessly with existing StreamdownMarkdown component

Implementation Details

Components Created

  • ThinkBlockHeader: Displays thinking status with animated loading indicator, supports expand/collapse functionality
  • ThinkBlockContent: Renders think block content using Streamdown with smooth transitions

Core Features

  • Automatic detection of <think> and <details> tags at the beginning of messages
  • Real-time streaming support with "thinking" status animation
  • Auto-expands when thinking starts for better user experience
  • Smooth animations for expand/collapse transitions
  • Full internationalization support (en, zh, ja, fr, es, vi)

Technical Approach

The implementation extends the existing StreamdownMarkdown component to:

  1. Extract think block content from the message
  2. Render think blocks separately with appropriate styling
  3. Maintain streaming capabilities for both think and main content
  4. Handle incomplete/unclosed tags during streaming

Test Plan

  • Tested with <think> tags
  • Tested with <details> tags
  • Verified streaming behavior
  • Tested expand/collapse functionality
  • Verified all language translations display correctly

🤖 Generated with Claude Code

lyzno1 and others added 2 commits September 20, 2025 12:36
- Created ThinkBlockHeader component with expand/collapse functionality
- Created ThinkBlockContent component for rendering think content
- Enhanced StreamdownMarkdown to detect and extract <think> and <details> tags
- Added automatic expansion when streaming starts
- Integrated think block support in Answer component

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Added translations for think block status messages:
- thinking: Thinking.../思考中...
- stopped: Stopped/已停止
- completed: Thought for/思考完成

Supported languages: en, zh, ja, fr, es, vi

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings September 20, 2025 04:38
@lyzno1
Copy link
Contributor Author

lyzno1 commented Sep 20, 2025

@Eric-Guo cc : )

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds collapsible think block support for AI assistant messages to enhance user experience by providing visibility into AI reasoning processes. The implementation supports both <think> and <details> tags for compatibility and integrates seamlessly with the existing streaming markdown component.

  • Added ThinkBlockHeader and ThinkBlockContent components for rendering collapsible think blocks
  • Extended StreamdownMarkdown component to extract and handle think block content
  • Added internationalization support for think block status text across 6 languages

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
i18n/lang/common.*.ts Added translations for thinking states (thinking, stopped, completed)
app/components/chat/think-block/think-block-header.tsx Header component with status display and toggle functionality
app/components/chat/think-block/think-block-content.tsx Content component for rendering think block markdown
app/components/chat/think-block/index.tsx Barrel export for think block components
app/components/chat/answer/index.tsx Updated to pass streaming status to StreamdownMarkdown
app/components/base/streamdown-markdown.tsx Enhanced to detect and render think blocks with streaming support

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Eric-Guo
Copy link
Contributor

Eric-Guo commented Sep 20, 2025

UI is good, I only suggest like 7d177ce, using upstream changed Streamdown component, so every chat can using only one Streamdown component to save some memory, also such Streamdown will running much effective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants