fix(chat): cap claude reasoning blocks to keep chat visible
This commit is contained in:
parent
9a344ad6ca
commit
51fdd6e973
2 changed files with 13 additions and 3 deletions
|
|
@ -89,6 +89,10 @@ export class AssistantMessageComponent extends Container {
|
|||
);
|
||||
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");
|
||||
// Claude Code often emits long reasoning blocks ahead of user-visible text/tool
|
||||
// output in the same lifecycle. Keep chat output visible without requiring a
|
||||
// manual thinking toggle every turn.
|
||||
const shouldCapThinking = hasTextContent || hasToolContent || message.provider === "claude-code";
|
||||
|
||||
if (hasVisibleContent) {
|
||||
this.contentContainer.addChild(new Spacer(1));
|
||||
|
|
@ -122,7 +126,7 @@ export class AssistantMessageComponent extends Container {
|
|||
});
|
||||
// Keep visible chat output readable when thinking traces are long.
|
||||
// Tool-bearing turns can stream text in a later assistant message.
|
||||
if (hasTextContent || hasToolContent) {
|
||||
if (shouldCapThinking) {
|
||||
thinkingMarkdown.maxLines = 8;
|
||||
}
|
||||
this.contentContainer.addChild(thinkingMarkdown);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,13 @@ test("assistant-message caps thinking block height when text content is present"
|
|||
|
||||
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",
|
||||
/const shouldCapThinking = hasTextContent \|\| hasToolContent \|\| message\.provider === "claude-code";/,
|
||||
"assistant-message should derive a cap policy that also covers claude-code long reasoning traces",
|
||||
);
|
||||
|
||||
assert.match(
|
||||
src,
|
||||
/if \(shouldCapThinking\)\s*\{\s*thinkingMarkdown\.maxLines = 8;\s*\}/s,
|
||||
"assistant-message should cap visible thinking lines when the cap policy is active",
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue