fix: keep assistant text visible when thinking traces are long

Cap thinking trace render height when assistant text is present so interactive questions remain visible.\n\nFixes #4181.
This commit is contained in:
Jeremy 2026-04-14 09:01:20 -05:00
parent 1a8ba9a43b
commit e78eacb40e

View file

@ -54,6 +54,7 @@ export class AssistantMessageComponent extends Container {
const hasVisibleContent = message.content.some(
(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);
if (hasVisibleContent) {
this.contentContainer.addChild(new Spacer(1));
@ -81,12 +82,15 @@ export class AssistantMessageComponent extends Container {
}
} else {
// Thinking traces in thinkingText color, italic
this.contentContainer.addChild(
new Markdown(content.thinking.trim(), 1, 0, this.markdownTheme, {
color: (text: string) => theme.fg("thinkingText", text),
italic: true,
}),
);
const thinkingMarkdown = new Markdown(content.thinking.trim(), 1, 0, this.markdownTheme, {
color: (text: string) => theme.fg("thinkingText", text),
italic: true,
});
// Keep assistant text/questions visible even when thinking traces are long.
if (hasTextContent) {
thinkingMarkdown.maxLines = 8;
}
this.contentContainer.addChild(thinkingMarkdown);
if (hasVisibleContentAfter) {
this.contentContainer.addChild(new Spacer(1));
}