Skip to content

Commit aa33e55

Browse files
authored
chat list options for coding agent and other modes (microsoft#258701)
chat list options for coding agetn and such
1 parent 88df70b commit aa33e55

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export interface IChatListItemRendererOptions {
121121
readonly noHeader?: boolean;
122122
readonly editableCodeBlock?: boolean;
123123
readonly renderDetectedCommandsWithRequest?: boolean;
124+
readonly restorable?: boolean;
125+
readonly editable?: boolean;
124126
readonly renderTextEditsAsSummary?: (uri: URI) => boolean;
125127
readonly referencesExpandedWhenEmptyResponse?: boolean | ((mode: ChatModeKind) => boolean);
126128
readonly progressMessageAtBottomOfResponse?: boolean | ((mode: ChatModeKind) => boolean);

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,11 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
193193

194194
constructor(
195195
editorOptions: ChatEditorOptions,
196-
private readonly rendererOptions: IChatListItemRendererOptions,
196+
private rendererOptions: IChatListItemRendererOptions,
197197
private readonly delegate: IChatRendererDelegate,
198198
private readonly codeBlockModelCollection: CodeBlockModelCollection,
199199
overflowWidgetsDomNode: HTMLElement | undefined,
200200
private viewModel: IChatViewModel | undefined,
201-
private disableEdits: boolean = false,
202201
@IInstantiationService private readonly instantiationService: IInstantiationService,
203202
@IConfigurationService private readonly configService: IConfigurationService,
204203
@ILogService private readonly logService: ILogService,
@@ -222,6 +221,10 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
222221
this._toolInvocationCodeBlockCollection = this._register(this.instantiationService.createInstance(CodeBlockModelCollection, 'tools'));
223222
}
224223

224+
public updateOptions(options: IChatListItemRendererOptions): void {
225+
this.rendererOptions = { ...this.rendererOptions, ...options };
226+
}
227+
225228
get templateId(): string {
226229
return ChatListItemRenderer.ID;
227230
}
@@ -555,9 +558,11 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
555558
const isLockedToCodingAgent = ChatContextKeys.lockedToCodingAgent.getValue(templateData.contextKeyService);
556559
templateData.checkpointContainer.classList.toggle('hidden', isResponseVM(element) || !this.configService.getValue<boolean>(ChatConfiguration.CheckpointsEnabled) || isLockedToCodingAgent);
557560

561+
const checkpointEnabled = this.configService.getValue<boolean>(ChatConfiguration.CheckpointsEnabled) && this.rendererOptions.restorable;
562+
558563
// Only show restore container when we have a checkpoint and not editing
559564
const shouldShowRestore = this.viewModel?.model.checkpoint && !this.viewModel?.editing && (index === this.delegate.getListLength() - 1);
560-
templateData.checkpointRestoreContainer.classList.toggle('hidden', !shouldShowRestore || !this.configService.getValue<boolean>(ChatConfiguration.CheckpointsEnabled) || isLockedToCodingAgent);
565+
templateData.checkpointRestoreContainer.classList.toggle('hidden', !shouldShowRestore || checkpointEnabled);
561566

562567
const editing = element.id === this.viewModel?.editing?.id;
563568
const isInput = this.configService.getValue<string>('chat.editRequests') === 'input';
@@ -568,7 +573,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
568573
templateData.requestHover.classList.toggle('editing', editing && isInput);
569574
templateData.requestHover.classList.toggle('hidden', (!!this.viewModel?.editing && !editing) || isResponseVM(element));
570575
templateData.requestHover.classList.toggle('expanded', this.configService.getValue<string>('chat.editRequests') === 'hover');
571-
templateData.requestHover.classList.toggle('checkpoints-enabled', this.configService.getValue<boolean>(ChatConfiguration.CheckpointsEnabled));
576+
templateData.requestHover.classList.toggle('checkpoints-enabled', checkpointEnabled);
572577
templateData.elementDisposables.add(dom.addDisposableListener(templateData.rowContainer, dom.EventType.CLICK, (e) => {
573578
const current = templateData.currentElement;
574579
if (current && this.viewModel?.editing && current.id !== this.viewModel.editing.id) {
@@ -737,7 +742,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
737742
this._onDidRerender.fire(templateData);
738743
}
739744

740-
if (this.configService.getValue<string>('chat.editRequests') !== 'none' && !this.disableEdits) {
745+
if (this.configService.getValue<string>('chat.editRequests') !== 'none' && this.rendererOptions.editable) {
741746
templateData.elementDisposables.add(dom.addDisposableListener(templateData.rowContainer, dom.EventType.KEY_DOWN, e => {
742747
const ev = new StandardKeyboardEvent(e);
743748
if (ev.equals(KeyCode.Space) || ev.equals(KeyCode.Enter)) {
@@ -1363,7 +1368,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
13631368
const markdownPart = templateData.instantiationService.createInstance(ChatMarkdownContentPart, markdown, context, this._editorPool, fillInIncompleteTokens, codeBlockStartIndex, this.renderer, this._currentLayoutWidth, this.codeBlockModelCollection, {});
13641369
if (isRequestVM(element)) {
13651370
markdownPart.domNode.tabIndex = 0;
1366-
if (this.configService.getValue<string>('chat.editRequests') === 'inline' && !this.disableEdits) {
1371+
if (this.configService.getValue<string>('chat.editRequests') === 'inline' && this.rendererOptions.editable) {
13671372
markdownPart.domNode.classList.add('clickable');
13681373
markdownPart.addDisposable(dom.addDisposableListener(markdownPart.domNode, dom.EventType.CLICK, (e: MouseEvent) => {
13691374
if (this.viewModel?.editing?.id === element.id) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
575575
}
576576

577577
this.renderWelcomeViewContentIfNeeded();
578-
this.createList(this.listContainer, { ...this.viewOptions.rendererOptions, renderStyle });
578+
this.createList(this.listContainer, { editable: !isInlineChat(this) && !isQuickChat(this), ...this.viewOptions.rendererOptions, renderStyle });
579579

580580
const scrollDownButton = this._register(new Button(this.listContainer, {
581581
supportIcons: true,
@@ -996,7 +996,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
996996
this._codeBlockModelCollection,
997997
overflowWidgetsContainer,
998998
this.viewModel,
999-
isInlineChat(this) || isQuickChat(this),
1000999
));
10011000

10021001
this._register(this.renderer.onDidClickRequest(async item => {
@@ -1624,6 +1623,9 @@ export class ChatWidget extends Disposable implements IChatWidget {
16241623
this.viewModel.setInputPlaceholder(localized);
16251624
}
16261625
this.inputEditor.updateOptions({ placeholder: localized });
1626+
1627+
this.renderer.updateOptions({ restorable: false, editable: false });
1628+
this.tree.rerender();
16271629
}
16281630

16291631
public unlockFromCodingAgent(): void {
@@ -1642,6 +1644,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
16421644

16431645
// Also clear the editor's placeholder immediately for immediate visual feedback
16441646
this.inputEditor.updateOptions({ placeholder: undefined });
1647+
this.renderer.updateOptions({ restorable: true, editable: true });
1648+
this.tree.rerender();
16451649
}
16461650

16471651
public get isLockedToCodingAgent(): boolean {

0 commit comments

Comments
 (0)