Skip to content

Conversation

@roblourens
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings January 22, 2026 23:27
@roblourens roblourens enabled auto-merge (squash) January 22, 2026 23:27
@roblourens roblourens self-assigned this Jan 22, 2026
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 22, 2026
Copy link
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 adds comprehensive unit tests for ChatThinkingContentPart and fixes an ordering issue where markdown/thinking content was rendered before tool invocations when the content arrived while the thinking section was collapsed.

Changes:

  • Added 1043 lines of unit tests covering lazy rendering, display modes (Collapsed, CollapsedPreview, FixedScrolling), state management, content updates, and DOM structure
  • Fixed ordering bug by making setupThinkingContainer use lazy rendering when collapsed, ensuring markdown and tool items render in the order they arrive
  • Introduced discriminated union type ILazyItem with variants ILazyToolItem and ILazyThinkingItem to handle both tool and thinking items in the lazy rendering queue

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatThinkingContentPart.test.ts New test file with comprehensive coverage of ChatThinkingContentPart functionality, including regression tests for the ordering bug
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatThinkingContentPart.ts Refactored lazy rendering system to support both tool and thinking items, ensuring correct DOM ordering when content arrives while collapsed
Comments suppressed due to low confidence (2)

src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatThinkingContentPart.test.ts:951

  • The comment on line 951 is confusing. It says "When the id is the same, hasSameContent returns true (other.id !== this.id is false)" but the test name and assertion expect false to be returned. Looking at the implementation (line 946 in the source: return other?.id !== this.id), when the IDs are the same, other.id !== this.id evaluates to false, so the method returns false. The comment should be clarified to: "When the id is the same, other.id !== this.id is false, so hasSameContent returns false"
			// When the id is the same, hasSameContent returns true (other.id !== this.id is false)

src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatThinkingContentPart.test.ts:724

  • The test name says "BUG: markdown renders before tools" but this PR fixes that bug, so the test should now be passing and verifying the correct behavior. Consider updating the test name to reflect that this test now validates the fix works correctly, rather than documenting the bug's existence. For example: "markdown via updateThinking should preserve order with lazy tool items (regression test)"
		test('markdown via updateThinking should preserve order with lazy tool items (BUG: markdown renders before tools)', () => {

Comment on lines +800 to +804
// BUG: Currently markdown is always first because it's not lazy
assert.ok(tool1Index < markdownIndex,
`BUG: Tool1 (index ${tool1Index}) should come BEFORE markdown (index ${markdownIndex}) ` +
`because tool1 was appended first. Current DOM order indicates markdown is eagerly ` +
`placed first regardless of arrival order.`);
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The comment on lines 800-804 suggests the bug still exists ("BUG: Currently markdown is always first"), but this PR fixes the bug. Since the assertion expects tool1 to come before markdown (and should now pass with the fix), update this comment to reflect that this is now the correct behavior and the test validates the fix works. For example: "With the fix, tool1 should come before markdown because it was appended first."

This issue also appears in the following locations of the same file:

  • line 951
  • line 724

Copilot uses AI. Check for mistakes.
@roblourens roblourens merged commit 01c4716 into main Jan 22, 2026
27 of 28 checks passed
@roblourens roblourens deleted the roblou/testy-marmot branch January 22, 2026 23:49
eleanorjboyd pushed a commit to eleanorjboyd/vscode that referenced this pull request Jan 23, 2026
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