Skip to content

[TBB] Thinking block UI improvements: Label title, collapse timing, height cap, and section parsing fix#191

Merged
jdneo merged 6 commits into
mainfrom
tori/thinking-label
May 14, 2026
Merged

[TBB] Thinking block UI improvements: Label title, collapse timing, height cap, and section parsing fix#191
jdneo merged 6 commits into
mainfrom
tori/thinking-label

Conversation

@xinyi-gong
Copy link
Copy Markdown
Member

@xinyi-gong xinyi-gong commented May 14, 2026

Changes

Use Label instead of ChatMarkupViewer for thinking block header title

  • Replace ChatMarkupViewer with a lightweight SWT Label for the ThinkingBlock header title ("Thinking...", "Thinking completed", etc.)
  • The header title is plain text with no markdown formatting, so ChatMarkupViewer (which initializes a full Markdown parser, hyperlink detectors, and CSS stylesheets) is unnecessary overhead
  • Register the Label with ChatFontService to keep chat font synchronization
  • Add SWT.WRAP and updateTitleWidthHint() to handle long titles correctly on resize
image

Resolves #178

Fix title generation fallback showing "cancelled" instead of "completed"

  • When thinking/generateTitle returns empty or fails, the thinking block previously showed "Thinking cancelled" — but the thinking itself completed successfully, only the title generation failed
  • Changed fallback to showCompleted("Thinking completed") instead of showCancelled()
  • Added .exceptionally() handler to catch request errors, preventing the block from getting stuck in SEALED state

Before:
image

After:
image

Collapse thinking block immediately when thinking ends

Previously, the thinking block stayed expanded until the thinking title generation response arrived, which could take several seconds. During this gap the block showed "Thinking completed" but remained open, which felt unresponsive.

Now the block collapses as soon as thinking output stops.

Cap thinking body height during streaming with auto-scroll

During streaming, the thinking block body is now wrapped in a ScrolledComposite with a max height of 180px. This prevents long thinking output from pushing the chat view unboundedly downward.

  • Body height grows dynamically with content up to the cap, avoiding initial blank space
  • Auto-scrolls to bottom as new content arrives
  • User can scroll up to read earlier content; any scroll interaction disables auto-scroll
  • Auto-scroll re-enables when the user scrolls back to the bottom
  • On seal/cancel, the ScrolledComposite is unwrapped and body becomes a direct child, so post-finalization expand shows full content without scrollbar or scroll-wheel interception
image

Fix ghost section from inline bold at streaming fragment boundary

Fixed a bug where inline bold text (e.g. combined with The Ship of Theseus and its...) could appear as a spurious section title with a bullet point at the end of the thinking block.
image

Root cause: TITLE_PATTERN required Title to be followed by \n or end-of-string ($), but did not require it to be at the start of a line. When a streaming fragment happened to end right after The Ship of Theseus, the $ anchor matched the buffer end, creating a ghost ThinkingSection. Subsequent fragments appended more text, making the match disappear — but the widget was never cleaned up.

Fix: Added (?:^|\n) anchor to require Title to appear at line start or string start. Added unit tests covering inline bold, mixed inline+standalone, and title-at-start scenarios.

@xinyi-gong xinyi-gong changed the title [TBB] Use Label for thinking block header title and fix title generation fallback [TBB] Thinking block UI improvements: Label title, collapse timing, height cap, and section parsing fix May 14, 2026
Base automatically changed from ethan/thinking-ui to main May 14, 2026 08:24
@xinyi-gong xinyi-gong force-pushed the tori/thinking-label branch from e78e353 to fda550b Compare May 14, 2026 08:32
@xinyi-gong xinyi-gong force-pushed the tori/thinking-label branch from fda550b to de108f5 Compare May 14, 2026 08:34
Copilot AI review requested due to automatic review settings May 14, 2026 09:20
@xinyi-gong xinyi-gong force-pushed the tori/thinking-label branch from de108f5 to 599bdd2 Compare May 14, 2026 09:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the “Thinking” block UX in the chat UI by reducing header rendering overhead, making completion/collapse behavior more responsive, capping streaming height with scroll support, and fixing section parsing that could create “ghost” sections during streaming.

Changes:

  • Replaced the thinking header title rendering with a lightweight Label (instead of ChatMarkupViewer) and kept chat font synchronization.
  • Collapses the thinking block immediately on seal, adds a streaming-only height cap via ScrolledComposite with auto-scroll behavior, and unwraps the scroller on seal/cancel.
  • Fixes section title parsing to require **Title** to be at line start; adds unit tests covering inline-bold and boundary cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ThinkingTurnWidget.java Updates seal/title-finalization flow and adds an exception fallback for title generation failures.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ThinkingBlock.java Swaps header title to Label, adds streaming scroller/height cap + auto-scroll, collapses on seal, and tightens section title parsing.
com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/ThinkingBlockParseTest.java Adds regression tests for inline-bold parsing and title-at-start behavior.

Copy link
Copy Markdown
Contributor

@ethanyhou ethanyhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a solid improvement. Just some nit comments. Thanks!

@jdneo jdneo merged commit a9856ca into main May 14, 2026
4 checks passed
@jdneo jdneo deleted the tori/thinking-label branch May 14, 2026 10:19
@jdneo
Copy link
Copy Markdown
Member

jdneo commented May 15, 2026

#202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate whether to use MarkupViewer or Label to render a thinking block title

4 participants