Skip to content

Conversation

zhogu
Copy link

@zhogu zhogu commented Sep 5, 2025

This pull request introduces support for displaying and streaming "reasoning" content alongside chat messages in the chat plugin. The changes ensure that both message and reasoning fields are handled throughout the chat flow, from API response parsing to UI rendering. Additionally, the message folding logic is simplified and improved to better handle long messages and reasoning sections.

Reasoning support in chat messages:

  • Added an optional reasoning field to the ChatMessage type, allowing reasoning content to be stored and displayed with each chat message.
  • Updated the message streaming logic in chatStreamRequest to parse and append both message and reasoning content from API responses, ensuring that reasoning is incrementally updated in the chat store. [1] [2]
  • Modified the chat store's updateLastChatMessage method to update the entire ChatMessage object (including reasoning), rather than just the message string. [1] [2]

UI improvements for message folding and reasoning display:

  • Refactored the Message component to display reasoning content in a collapsible section, removed the expand prop, and improved the logic for folding/unfolding long messages and reasoning.
  • Updated message rendering in MessageGroup to use the new Message component signature without the expand prop.

API enhancements:

  • Added a new postStream method to the API utility to support streaming POST requests with optional authorization, improving flexibility for future API interactions.

@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 11:32
Copilot

This comment was marked as outdated.

Copy link

@Copilot 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

This PR adds support for displaying and streaming reasoning content alongside chat messages in the chat plugin. The key changes include adding a reasoning field to chat messages, updating the streaming logic to handle reasoning content, and refactoring the UI to display reasoning in a collapsible section.

  • Added optional reasoning field to ChatMessage type and updated streaming logic to parse and append both message and reasoning content
  • Refactored the Message component to display reasoning content in a collapsible section and simplified message folding logic
  • Updated chat store methods to handle complete ChatMessage objects instead of just message strings

Reviewed Changes

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

File Description
contrib/chat-plugin/src/libs/state.ts Added optional reasoning field to ChatMessage type and updated updateLastChatMessage to handle full ChatMessage objects
contrib/chat-plugin/src/libs/api.ts Enhanced streaming logic to parse and handle both message and reasoning content from API responses
contrib/chat-plugin/src/app/ChatHistory.tsx Refactored Message component to display reasoning in collapsible section and simplified folding logic

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

hippogr

This comment was marked as resolved.

@zhogu zhogu merged commit 139f28f into dev Sep 10, 2025
1 check passed
This was referenced Sep 15, 2025
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.

3 participants