From ecccff62f3f15502badb2a3d5cd72a56eea283cc Mon Sep 17 00:00:00 2001 From: can1357 Date: Mon, 15 Jun 2026 16:52:06 +0200 Subject: [PATCH] fix(coding-agent/advisor): fixed collapsed advisor notes to wrap instead of two-line truncation - Removed the collapsed-mode truncation branch that forced advisor message cards to restrict bodies to two lines. - Added a regression test covering long collapsed advisor notes to ensure they wrap at narrow widths instead of being cut short. - Updated the package changelog to document the collapsed advisor note wrapping fix. --- packages/coding-agent/CHANGELOG.md | 1 + .../coding-agent/src/advisor/__tests__/advisor.test.ts | 10 ++++++++++ .../src/modes/components/advisor-message.ts | 6 +----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 500e04943..883bb8ba9 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -22,6 +22,7 @@ - Session dump output now renders message history using the model's native dialect turn envelope instead of markdown role headings ### Fixed +- Fixed advisor message card notes getting truncated to two lines when the card is collapsed. - Fixed advisor context handling to automatically maintain its token budget by promoting the advisor model or compacting/restarting advisor context when needed, preventing advice from degrading on long sessions - Fixed `startup.quiet` leaving MCP and LSP startup status events visible during launch ([#2639](https://github.com/can1357/oh-my-pi/issues/2639)). diff --git a/packages/coding-agent/src/advisor/__tests__/advisor.test.ts b/packages/coding-agent/src/advisor/__tests__/advisor.test.ts index f6499825a..61ade18c0 100644 --- a/packages/coding-agent/src/advisor/__tests__/advisor.test.ts +++ b/packages/coding-agent/src/advisor/__tests__/advisor.test.ts @@ -332,5 +332,15 @@ describe("advisor", () => { const text = strip(card.render(30)); expect(text).toContain("truncated."); }); + + it("wraps long notes even when the message card is collapsed", async () => { + const uiTheme = await getThemeByName("dark"); + if (!uiTheme) throw new Error("theme unavailable"); + const note = + "This is a very long advisor note that will definitely exceed the restricted width constraint of thirty characters and should therefore wrap across multiple lines rather than getting truncated."; + const card = createAdvisorMessageCard({ notes: [{ note, severity: "concern" }] }, () => false, uiTheme); + const text = strip(card.render(30)); + expect(text).toContain("truncated."); + }); }); }); diff --git a/packages/coding-agent/src/modes/components/advisor-message.ts b/packages/coding-agent/src/modes/components/advisor-message.ts index c28db2fd8..ee42cb3b1 100644 --- a/packages/coding-agent/src/modes/components/advisor-message.ts +++ b/packages/coding-agent/src/modes/components/advisor-message.ts @@ -73,7 +73,7 @@ export function createAdvisorMessageCard( const w2 = Math.max(10, Math.min(NOTE_LINE_WIDTH, width) - quoteWidth); const paragraphs = entry.note.split("\n").filter(p => p.trim()); - let bodyLines: string[] = []; + const bodyLines: string[] = []; for (let i = 0; i < paragraphs.length; i++) { const p = paragraphs[i]; if (i === 0) { @@ -83,10 +83,6 @@ export function createAdvisorMessageCard( } } - if (!expanded && bodyLines.length > 2) { - bodyLines = [bodyLines[0], truncateToWidth(bodyLines.slice(1).join(" "), w2, Ellipsis.Unicode)]; - } - bodyLines.forEach((line, index) => { const prefix = index === 0 ? badge : ""; lines.push(` ${quote} ${prefix}${uiTheme.fg("toolOutput", replaceTabs(line))}`);