feat: fold assistant process details#120
Open
zhudatou630 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces shared helpers and UI logic to collapse completed assistant “process” content (thinking/tool calls and intermediate messages) into a “Process details” disclosure, while keeping the final answer visible and hiding empty completed thinking blocks to improve scanability of long conversations.
Changes:
- Added
lib/message-display.tsutilities to filter/hide empty completed thinking blocks and split assistant blocks into “answer” vs “process”. - Updated
MessageViewto use the new displayable-block filtering and skip rendering empty completed assistant messages. - Updated
ChatWindowrendering to group intermediate messages and non-answer assistant blocks under a collapsible “Process details” section.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lib/message-display.ts | New helper utilities for filtering/splitting assistant content blocks and counting tool calls. |
| lib/message-display.test.mjs | Unit tests for the new message-display helper behavior. |
| components/MessageView.tsx | Uses displayable-block filtering and hides empty completed assistant messages. |
| components/ChatWindow.tsx | Adds folding/grouping UI and logic to keep final answers visible while collapsing process details. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+22
to
+31
| export function splitFinalAssistantBlocks( | ||
| message: AssistantMessage, | ||
| options: DisplayOptions = {}, | ||
| ): { answerBlocks: AssistantContentBlock[]; processBlocks: AssistantContentBlock[] } { | ||
| const blocks = getDisplayableAssistantBlocks(message, options); | ||
| return { | ||
| answerBlocks: blocks.filter(isFinalAnswerBlock), | ||
| processBlocks: blocks.filter((block) => !isFinalAnswerBlock(block)), | ||
| }; | ||
| } |
Comment on lines
+47
to
+52
| function assistantTextLength(message: AgentMessage): number { | ||
| if (message.role !== "assistant") return 0; | ||
| return ((message as AssistantMessage).content ?? []) | ||
| .filter((block) => block.type === "text") | ||
| .reduce((sum, block) => sum + block.text.trim().length, 0); | ||
| } |
Comment on lines
+98
to
+100
| <button | ||
| onClick={() => setExpanded((v) => !v)} | ||
| style={{ |
Comment on lines
296
to
300
| const time = showTimestamp ? formatTime(message.timestamp) : null; | ||
| const blocks = message.content ?? []; | ||
| const blocks = getDisplayableAssistantBlocks(message, { isStreaming }); | ||
| const [hovered, setHovered] = useState(false); | ||
| const [copied, setCopied] = useState(false); | ||
| const streamStartRef = useRef<number | null>(null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Long tool-heavy conversations become hard to scan when every intermediate thinking/tool block stays fully expanded. Folding completed process details keeps the answer readable without losing access to the underlying work.
Validation