Skip to content

Commit 49b5f6e

Browse files
authored
tool calls in dropdown and thinking headers (#279094)
* tool calls in dropdown and thinking headers * remove some extra code * remove async * some localize changes * address some comments * hygiene * model call, instead of title service * map for titles, don't generate llm title if we only find one header summary * store titles in the part itself
1 parent 0a2707c commit 49b5f6e

File tree

8 files changed

+405
-164
lines changed

8 files changed

+405
-164
lines changed

src/vs/workbench/contrib/chat/browser/chat.contribution.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,14 +747,14 @@ configurationRegistry.registerConfiguration({
747747
},
748748
'chat.agent.thinking.collapsedTools': {
749749
type: 'string',
750-
default: 'readOnly',
751-
enum: ['none', 'all', 'readOnly'],
750+
default: product.quality !== 'stable' ? 'always' : 'withThinking',
751+
enum: ['off', 'withThinking', 'always'],
752752
enumDescriptions: [
753-
nls.localize('chat.agent.thinking.collapsedTools.none', "No tool calls are added into the collapsible thinking section."),
754-
nls.localize('chat.agent.thinking.collapsedTools.all', "All tool calls are added into the collapsible thinking section."),
755-
nls.localize('chat.agent.thinking.collapsedTools.readOnly', "Only read-only tool calls are added into the collapsible thinking section."),
753+
nls.localize('chat.agent.thinking.collapsedTools.off', "Tool calls are shown separately, not collapsed into thinking."),
754+
nls.localize('chat.agent.thinking.collapsedTools.withThinking', "Tool calls are collapsed into thinking sections when thinking is present."),
755+
nls.localize('chat.agent.thinking.collapsedTools.always', "Tool calls are always collapsed, even without thinking."),
756756
],
757-
markdownDescription: nls.localize('chat.agent.thinking.collapsedTools', "When enabled, tool calls are added into the collapsible thinking section according to the selected mode."),
757+
markdownDescription: nls.localize('chat.agent.thinking.collapsedTools', "Controls how tool calls are displayed in relation to thinking sections."),
758758
tags: ['experimental'],
759759
},
760760
'chat.disableAIFeatures': {

src/vs/workbench/contrib/chat/browser/chatContentParts/chatCollapsibleContentPart.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ import { $ } from '../../../../../base/browser/dom.js';
77
import { ButtonWithIcon } from '../../../../../base/browser/ui/button/button.js';
88
import { Codicon } from '../../../../../base/common/codicons.js';
99
import { Emitter } from '../../../../../base/common/event.js';
10-
import { IMarkdownString } from '../../../../../base/common/htmlContent.js';
11-
import { Disposable, IDisposable } from '../../../../../base/common/lifecycle.js';
10+
import { IMarkdownString, MarkdownString } from '../../../../../base/common/htmlContent.js';
11+
import { Disposable, IDisposable, MutableDisposable } from '../../../../../base/common/lifecycle.js';
1212
import { autorun, IObservable, observableValue } from '../../../../../base/common/observable.js';
1313
import { localize } from '../../../../../nls.js';
1414
import { IChatRendererContent } from '../../common/chatViewModel.js';
1515
import { ChatTreeItem } from '../chat.js';
1616
import { IChatContentPart, IChatContentPartRenderContext } from './chatContentParts.js';
17+
import { renderFileWidgets } from '../chatInlineAnchorWidget.js';
18+
import { IChatMarkdownAnchorService } from './chatMarkdownAnchorService.js';
19+
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
20+
import { IMarkdownRenderer } from '../../../../../platform/markdown/browser/markdownRenderer.js';
21+
import { IRenderedMarkdown } from '../../../../../base/browser/markdownRenderer.js';
1722

1823

1924
export abstract class ChatCollapsibleContentPart extends Disposable implements IChatContentPart {
2025

2126
private _domNode?: HTMLElement;
27+
private readonly _renderedTitleWithWidgets = this._register(new MutableDisposable<IRenderedMarkdown>());
2228

2329
protected readonly _onDidChangeHeight = this._register(new Emitter<void>());
2430
public readonly onDidChangeHeight = this._onDidChangeHeight.event;
@@ -114,4 +120,26 @@ export abstract class ChatCollapsibleContentPart extends Disposable implements I
114120
this.updateAriaLabel(this._collapseButton.element, title, this.isExpanded());
115121
}
116122
}
123+
124+
125+
// Render collapsible dropdown title with widgets
126+
protected setTitleWithWidgets(content: MarkdownString, instantiationService: IInstantiationService, chatMarkdownAnchorService: IChatMarkdownAnchorService, chatContentMarkdownRenderer: IMarkdownRenderer): void {
127+
if (this._store.isDisposed || !this._collapseButton) {
128+
return;
129+
}
130+
131+
const result = chatContentMarkdownRenderer.render(content);
132+
result.element.classList.add('collapsible-title-content');
133+
134+
renderFileWidgets(result.element, instantiationService, chatMarkdownAnchorService, this._store);
135+
136+
const labelElement = this._collapseButton.labelElement;
137+
labelElement.textContent = '';
138+
labelElement.appendChild(result.element);
139+
140+
const textContent = result.element.textContent || '';
141+
this.updateAriaLabel(this._collapseButton.element, textContent, this.isExpanded());
142+
143+
this._renderedTitleWithWidgets.value = result;
144+
}
117145
}

0 commit comments

Comments
 (0)