@@ -83,6 +83,12 @@ constexpr const char *kFrameStyleAssistant =
8383 " AcpMessageWidget[role=\" assistant\" ][goalSet=\" true\" ] { background: rgba(180, 140, 50, 48); border: 1px solid rgba(180, 140, 50, 80); border-radius: 6px; }" ;
8484constexpr const char *kFrameStyleThought =
8585 " AcpMessageWidget[role=\" thought\" ] { background: palette(base); border-radius: 6px; }" ;
86+ // Extra left inset under "Thinking…". Not in the layout margins — those wrap
87+ // the header too. Italic glyphs also overhang their advance by a few px, so
88+ // wrap width must leave that slack inside the viewport or the last letters
89+ // clip and QTextBrowser opens a horizontal scroll range.
90+ constexpr int kThoughtBrowserPadLeft = 4 ;
91+ constexpr int kThoughtItalicRightSlack = 4 ;
8692constexpr const char *kFrameStyleSystem =
8793 " AcpMessageWidget[role=\" system\" ] { background: rgba(180, 140, 50, 32); border: 1px solid rgba(180, 140, 50, 60); border-radius: 6px; }" ;
8894
@@ -219,7 +225,10 @@ AcpMessageWidget::AcpMessageWidget(QString role, QWidget *parent)
219225 m_layout->addWidget (m_thoughtHeader);
220226
221227 m_browser = new QTextBrowser (this );
222- m_browser->setStyleSheet (QStringLiteral (" QTextBrowser { background: transparent; border: none; font-style: italic; padding-left: 4px; }" ));
228+ m_browser->setStyleSheet (
229+ QStringLiteral (" QTextBrowser { background: transparent; border: none; "
230+ " font-style: italic; padding-left: %1px; }" )
231+ .arg (kThoughtBrowserPadLeft ));
223232 m_browser->setOpenExternalLinks (true );
224233 configureBubbleBrowser (m_browser);
225234 // QTextDocument paragraphs carry an implicit ~12px bottom margin even
@@ -535,12 +544,16 @@ void AcpMessageWidget::refitBrowserHeight()
535544 // already have unless we just collapsed to header-only above.
536545 return ;
537546 }
547+ int textW = w;
548+ if (m_thoughtHeader) {
549+ textW = qMax (0 , w - kThoughtBrowserPadLeft - kThoughtItalicRightSlack );
550+ }
538551 QTextDocument *doc = m_browser->document ();
539552 // Force a full layout pass for the current width before measuring —
540553 // QTextDocument under-reports height for freshly-set multi-line text
541554 // until the layout engine has run, which clips an expanded thought down
542555 // to roughly its first line.
543- const int browserH = qMax (0 , static_cast <int >(std::ceil (layoutDocumentHeight (doc, w ))));
556+ const int browserH = qMax (0 , static_cast <int >(std::ceil (layoutDocumentHeight (doc, textW ))));
544557 m_browser->setFixedHeight (browserH);
545558 bubbleH += browserH;
546559 setFixedHeight (bubbleH);
0 commit comments