Skip to content

Commit d37a00c

Browse files
Copilotjrieken
andauthored
Fix: disposed ChatThinkingContentPart returned by getLastThinkingPart causing DisposableStore error (#296927)
* Initial plan * fix: set isActive=false on ChatThinkingContentPart dispose to prevent DisposableStore error Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
1 parent e492669 commit d37a00c

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@ ${this.hookCount > 0 ? `EXAMPLES WITH BLOCKED CONTENT (from hooks):
15261526
}
15271527

15281528
override dispose(): void {
1529+
this.isActive = false;
15291530
if (this.markdownResult) {
15301531
this.markdownResult.dispose();
15311532
this.markdownResult = undefined;

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,25 @@ suite('ChatThinkingContentPart', () => {
983983
assert.strictEqual(part.getIsActive(), false, 'Should be inactive after markAsInactive');
984984
});
985985

986+
test('dispose should set isActive to false', () => {
987+
const content = createThinkingPart('**Active thinking**');
988+
const context = createMockRenderContext(false);
989+
990+
const part = instantiationService.createInstance(
991+
ChatThinkingContentPart,
992+
content,
993+
context,
994+
mockMarkdownRenderer,
995+
false
996+
);
997+
998+
assert.strictEqual(part.getIsActive(), true, 'Should start as active');
999+
1000+
part.dispose();
1001+
1002+
assert.strictEqual(part.getIsActive(), false, 'Should be inactive after dispose');
1003+
});
1004+
9861005
test('collapseContent should collapse the part', () => {
9871006
const content = createThinkingPart('**Content**\nSome detailed reasoning that differs from the title');
9881007
const context = createMockRenderContext(false);

0 commit comments

Comments
 (0)