Skip to content

Fix single tool calls getting stuck inside thinking parts#323059

Merged
justschen merged 3 commits into
mainfrom
justin/xurkitree
Jun 26, 2026
Merged

Fix single tool calls getting stuck inside thinking parts#323059
justschen merged 3 commits into
mainfrom
justin/xurkitree

Conversation

@justschen

Copy link
Copy Markdown
Collaborator

Problem

When a thinking/"Working" section contains exactly one tool call (and no reasoning text), that tool should be promoted to the top level instead of staying nested inside the collapsed thinking part. In several cases it stayed stuck:

  1. Multi-child tools — the promotion bailed out whenever the tool's rendered DOM had more than one child element, so terminal/search/edit tools (command + output, etc.) never got promoted.
  2. Late completionfinalizeTitleIfDefault() is one-shot, so if the tool hadn't reported Completed/Cancelled at that exact instant, promotion was skipped and never retried.
  3. Lost original positionsingleItemInfo (which records where to move the tool back to) gets wiped whenever the item count isn't 1, so a transient sibling item or eager rendering left us with undefined and nothing to promote.

Fix

  • Removed the childElementCount > 1 guard so a lone tool is promoted regardless of tool type.
  • When the tool isn't complete yet at finalize, observe its state and promote it once it completes (instead of giving up permanently).
  • Persist each tool's original position (toolOriginalPositionByCallId) so a lone tool can always be reconstructed and promoted, even after a sibling came and went.

Net result: a single tool call is reliably promoted to the top level regardless of its type, DOM shape, or completion timing.

Adds regression tests covering all three cases.

A thinking/"Working" section with exactly one tool call should promote that
tool to the top level instead of leaving it nested inside the collapsed part.
It stayed stuck in three cases:

- Multi-child tools: promotion bailed when the tool's DOM had more than one
  child element, so terminal/search/edit tools never got promoted.
- Late completion: finalizeTitleIfDefault() is one-shot, so if the tool was
  not yet Completed/Cancelled at that instant, promotion was skipped forever.
- Lost original position: singleItemInfo gets wiped whenever the item count
  isn't 1, so a transient sibling or eager rendering left undefined behind.

Fix:
- Remove the childElementCount > 1 guard so a lone tool is promoted regardless
  of tool type.
- Observe the tool's state and promote once it completes instead of giving up.
- Persist each tool's original position so a lone tool can always be
  reconstructed and promoted.

Adds regression tests covering all three cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 26, 2026 02:15
@justschen justschen marked this pull request as draft June 26, 2026 02:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a UX issue in the chat “thinking/Working” container where a single tool invocation could remain incorrectly nested inside the collapsed thinking section instead of being promoted back to the top-level response content. The change improves reliability across different tool DOM shapes, completion timing, and transient item-count changes during streaming.

Changes:

  • Record each tool call’s original DOM position by toolCallId and use it to reconstruct promotion state when singleItemInfo is missing.
  • Retry single-item promotion when the lone tool finishes after finalizeTitleIfDefault() runs by observing tool completion.
  • Add regression tests covering multi-child tool DOM, late completion, and transient sibling wipeout scenarios.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.ts Makes lone-tool promotion resilient by persisting original placement, removing multi-child guard, and retrying promotion upon tool completion.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatThinkingContentPart.test.ts Adds regression tests for the three previously failing promotion cases.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Low

justschen and others added 2 commits June 25, 2026 19:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@justschen justschen marked this pull request as ready for review June 26, 2026 02:23
@justschen justschen enabled auto-merge (squash) June 26, 2026 02:30
@justschen justschen merged commit ebd256a into main Jun 26, 2026
29 checks passed
@justschen justschen deleted the justin/xurkitree branch June 26, 2026 02:56
@vs-code-engineering vs-code-engineering Bot added this to the 1.127.0 milestone Jun 26, 2026
justschen added a commit that referenced this pull request Jun 26, 2026
…323184)

Revert "Fix single tool calls getting stuck inside thinking parts (#323059)"

This reverts commit ebd256a.
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.

3 participants