Merge pull request #4186 from jeremymcs/fix/thinking-block-visibility
Fix thinking block overflow in tool-bearing turns
This commit is contained in:
commit
7b20ef8c0c
2 changed files with 12 additions and 4 deletions
|
|
@ -88,6 +88,7 @@ export class AssistantMessageComponent extends Container {
|
|||
(c) => (c.type === "text" && c.text.trim()) || (c.type === "thinking" && c.thinking.trim()),
|
||||
);
|
||||
const hasTextContent = message.content.some((c) => c.type === "text" && c.text.trim().length > 0);
|
||||
const hasToolContent = message.content.some((c) => c.type === "toolCall" || c.type === "serverToolUse");
|
||||
|
||||
if (hasVisibleContent) {
|
||||
this.contentContainer.addChild(new Spacer(1));
|
||||
|
|
@ -119,8 +120,9 @@ export class AssistantMessageComponent extends Container {
|
|||
color: (text: string) => theme.fg("thinkingText", text),
|
||||
italic: true,
|
||||
});
|
||||
// Keep assistant text/questions visible even when thinking traces are long.
|
||||
if (hasTextContent) {
|
||||
// Keep visible chat output readable when thinking traces are long.
|
||||
// Tool-bearing turns can stream text in a later assistant message.
|
||||
if (hasTextContent || hasToolContent) {
|
||||
thinkingMarkdown.maxLines = 8;
|
||||
}
|
||||
this.contentContainer.addChild(thinkingMarkdown);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,13 @@ test("assistant-message caps thinking block height when text content is present"
|
|||
|
||||
assert.match(
|
||||
src,
|
||||
/if \(hasTextContent\)\s*\{\s*thinkingMarkdown\.maxLines = 8;\s*\}/s,
|
||||
"assistant-message should cap visible thinking lines when assistant text also exists",
|
||||
/const hasToolContent = message\.content\.some\(\(c\) => c\.type === "toolCall" \|\| c\.type === "serverToolUse"\);/,
|
||||
"assistant-message should detect tool blocks in mixed turns",
|
||||
);
|
||||
|
||||
assert.match(
|
||||
src,
|
||||
/if \(hasTextContent \|\| hasToolContent\)\s*\{\s*thinkingMarkdown\.maxLines = 8;\s*\}/s,
|
||||
"assistant-message should cap visible thinking lines when assistant text exists or tool blocks are present",
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue