Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vs/workbench/contrib/chat/browser/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { IWorkbenchLayoutService } from '../../../services/layout/browser/layout
import { IViewsService } from '../../../services/views/common/viewsService.js';
import { IChatAgentCommand, IChatAgentData } from '../common/chatAgents.js';
import { IChatResponseModel } from '../common/chatModel.js';
import { IChatMode } from '../common/chatModes.js';
import { IParsedChatRequest } from '../common/chatParserTypes.js';
import { CHAT_PROVIDER_ID } from '../common/chatParticipantContribTypes.js';
import { IChatElicitationRequest, IChatLocationData, IChatSendRequestOptions } from '../common/chatService.js';
Expand Down Expand Up @@ -179,6 +180,7 @@ export interface IChatWidgetViewOptions {
enableWorkingSet?: 'explicit' | 'implicit';
supportsChangingModes?: boolean;
dndContainer?: HTMLElement;
defaultMode?: IChatMode;
}

export interface IChatViewViewContext {
Expand Down
24 changes: 11 additions & 13 deletions src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ActionViewItem, IActionViewItemOptions } from '../../../../base/browser
import * as aria from '../../../../base/browser/ui/aria/aria.js';
import { Button, ButtonWithIcon } from '../../../../base/browser/ui/button/button.js';
import { createInstantHoverDelegate, getDefaultHoverDelegate } from '../../../../base/browser/ui/hover/hoverDelegateFactory.js';
import { renderLabelWithIcons } from '../../../../base/browser/ui/iconLabel/iconLabels.js';
import { IAction } from '../../../../base/common/actions.js';
import { DeferredPromise } from '../../../../base/common/async.js';
import { CancellationToken } from '../../../../base/common/cancellation.js';
Expand All @@ -22,10 +23,11 @@ import { KeyCode } from '../../../../base/common/keyCodes.js';
import { Disposable, DisposableStore, IDisposable, MutableDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
import { ResourceSet } from '../../../../base/common/map.js';
import { Schemas } from '../../../../base/common/network.js';
import { autorun, IObservable, observableValue } from '../../../../base/common/observable.js';
import { autorun, IObservable, ISettableObservable, observableValue } from '../../../../base/common/observable.js';
import { isMacintosh } from '../../../../base/common/platform.js';
import { isEqual } from '../../../../base/common/resources.js';
import { ScrollbarVisibility } from '../../../../base/common/scrollable.js';
import { assertType } from '../../../../base/common/types.js';
import { URI } from '../../../../base/common/uri.js';
import { IEditorConstructionOptions } from '../../../../editor/browser/config/editorConfiguration.js';
import { EditorExtensionsRegistry } from '../../../../editor/browser/editorExtensions.js';
Expand Down Expand Up @@ -68,14 +70,14 @@ import { IThemeService } from '../../../../platform/theme/common/themeService.js
import { ISharedWebContentExtractorService } from '../../../../platform/webContentExtractor/common/webContentExtractor.js';
import { ResourceLabels } from '../../../browser/labels.js';
import { IWorkbenchAssignmentService } from '../../../services/assignment/common/assignmentService.js';
import { IChatEntitlementService } from '../../../services/chat/common/chatEntitlementService.js';
import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from '../../../services/editor/common/editorService.js';
import { AccessibilityVerbositySettingId } from '../../accessibility/browser/accessibilityConfiguration.js';
import { AccessibilityCommandId } from '../../accessibility/common/accessibilityCommands.js';
import { getSimpleCodeEditorWidgetOptions, getSimpleEditorOptions, setupSimpleEditorSelectionStyling } from '../../codeEditor/browser/simpleEditorOptions.js';
import { IChatAgentService } from '../common/chatAgents.js';
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { IChatEditingSession, ModifiedFileEntryState } from '../common/chatEditingService.js';
import { ChatEntitlement, IChatEntitlementService } from '../../../services/chat/common/chatEntitlementService.js';
import { IChatRequestModeInfo } from '../common/chatModel.js';
import { ChatMode, IChatMode, IChatModeService } from '../common/chatModes.js';
import { IChatFollowup } from '../common/chatService.js';
Expand All @@ -94,19 +96,17 @@ import { ChatAttachmentModel } from './chatAttachmentModel.js';
import { DefaultChatAttachmentWidget, ElementChatAttachmentWidget, FileAttachmentWidget, ImageAttachmentWidget, NotebookCellOutputChatAttachmentWidget, PasteAttachmentWidget, PromptFileAttachmentWidget, PromptTextAttachmentWidget, SCMHistoryItemAttachmentWidget, SCMHistoryItemChangeAttachmentWidget, SCMHistoryItemChangeRangeAttachmentWidget, ToolSetOrToolItemAttachmentWidget } from './chatAttachmentWidgets.js';
import { IDisposableReference } from './chatContentParts/chatCollections.js';
import { CollapsibleListPool, IChatCollapsibleListItem } from './chatContentParts/chatReferencesContentPart.js';
import { ChatTodoListWidget } from './chatContentParts/chatTodoListWidget.js';
import { ChatDragAndDrop } from './chatDragAndDrop.js';
import { ChatEditingShowChangesAction, ViewPreviousEditsAction } from './chatEditing/chatEditingActions.js';
import { ChatFollowups } from './chatFollowups.js';
import { ChatSelectedTools } from './chatSelectedTools.js';
import { ChatTodoListWidget } from './chatContentParts/chatTodoListWidget.js';
import { IChatViewState } from './chatWidget.js';
import { ChatImplicitContext } from './contrib/chatImplicitContext.js';
import { ChatRelatedFiles } from './contrib/chatInputRelatedFilesContrib.js';
import { resizeImage } from './imageUtils.js';
import { IModelPickerDelegate, ModelPickerActionItem } from './modelPicker/modelPickerActionItem.js';
import { IModePickerDelegate, ModePickerActionItem } from './modelPicker/modePickerActionItem.js';
import { assertType } from '../../../../base/common/types.js';
import { renderLabelWithIcons } from '../../../../base/browser/ui/iconLabel/iconLabels.js';

const $ = dom.$;

Expand All @@ -118,7 +118,8 @@ export interface IChatInputStyles {
listBackground: string;
}

interface IChatInputPartOptions {
export interface IChatInputPartOptions {
defaultMode?: IChatMode;
renderFollowups: boolean;
renderStyle?: 'compact';
menus: {
Expand Down Expand Up @@ -310,7 +311,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
private _onDidChangeCurrentChatMode: Emitter<void>;
readonly onDidChangeCurrentChatMode: Event<void>;

private readonly _currentModeObservable = observableValue<IChatMode>('currentMode', ChatMode.Ask);
private readonly _currentModeObservable: ISettableObservable<IChatMode>;
public get currentModeKind(): ChatModeKind {
const mode = this._currentModeObservable.get();
return mode.kind === ChatModeKind.Agent && !this.agentService.hasToolsAgent ?
Expand Down Expand Up @@ -441,11 +442,11 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
this._onDidChangeCurrentLanguageModel = this._register(new Emitter<ILanguageModelChatMetadataAndIdentifier>());
this._onDidChangeCurrentChatMode = this._register(new Emitter<void>());
this.onDidChangeCurrentChatMode = this._onDidChangeCurrentChatMode.event;
this._currentModeObservable.set(ChatMode.Ask, undefined);
this.inputUri = URI.parse(`${Schemas.vscodeChatInput}:input-${ChatInputPart._counter++}`);
this._chatEditsActionsDisposables = this._register(new DisposableStore());
this._chatEditsDisposables = this._register(new DisposableStore());
this._attemptedWorkingSetEntriesCount = 0;
this._currentModeObservable = observableValue<IChatMode>('currentMode', this.options.defaultMode ?? ChatMode.Agent);

this._register(this.editorService.onDidActiveEditorChange(() => {
this._indexOfLastOpenedContext = -1;
Expand Down Expand Up @@ -798,13 +799,10 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
const storageKey = this.getDefaultModeExperimentStorageKey();
const hasSetDefaultMode = this.storageService.getBoolean(storageKey, StorageScope.WORKSPACE, false);
if (!hasSetDefaultMode) {
const isFree = this.entitlementService.entitlement === ChatEntitlement.Free;
const defaultModeKey = isFree ? 'chat.defaultModeFree' : 'chat.defaultMode';
const defaultLanguageModelKey = isFree ? 'chat.defaultLanguageModelFree' : 'chat.defaultLanguageModel';
const isAnonymous = this.entitlementService.anonymous;
Promise.all([
this.experimentService.getTreatment(defaultModeKey),
this.experimentService.getTreatment(defaultLanguageModelKey),
this.experimentService.getTreatment('chat.defaultMode'),
this.experimentService.getTreatment('chat.defaultLanguageModel'),
]).then(([defaultModeTreatment, defaultLanguageModelTreatment]) => {
if (isAnonymous) {
// be deterministic for anonymous users
Expand Down
20 changes: 14 additions & 6 deletions src/vs/workbench/contrib/chat/browser/chatQuick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,29 @@ import { disposableTimeout } from '../../../../base/common/async.js';
import { CancellationToken } from '../../../../base/common/cancellation.js';
import { Emitter, Event } from '../../../../base/common/event.js';
import { MarkdownString } from '../../../../base/common/htmlContent.js';
import { autorun } from '../../../../base/common/observable.js';
import { Disposable, DisposableStore, IDisposable, MutableDisposable } from '../../../../base/common/lifecycle.js';
import { autorun } from '../../../../base/common/observable.js';
import { Selection } from '../../../../editor/common/core/selection.js';
import { IMarkdownRendererService } from '../../../../platform/markdown/browser/markdownRenderer.js';
import { MenuId } from '../../../../platform/actions/common/actions.js';
import { localize } from '../../../../nls.js';
import { MenuId } from '../../../../platform/actions/common/actions.js';
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
import { ILayoutService } from '../../../../platform/layout/browser/layoutService.js';
import { IMarkdownRendererService } from '../../../../platform/markdown/browser/markdownRenderer.js';
import product from '../../../../platform/product/common/product.js';
import { IQuickInputService, IQuickWidget } from '../../../../platform/quickinput/common/quickInput.js';
import { editorBackground, inputBackground, quickInputBackground, quickInputForeground } from '../../../../platform/theme/common/colorRegistry.js';
import product from '../../../../platform/product/common/product.js';
import { EDITOR_DRAG_AND_DROP_BACKGROUND } from '../../../common/theme.js';
import { IChatEntitlementService } from '../../../services/chat/common/chatEntitlementService.js';
import { IViewsService } from '../../../services/views/common/viewsService.js';
import { ChatModel, isCellTextEditOperation } from '../common/chatModel.js';
import { ChatMode } from '../common/chatModes.js';
import { IParsedChatRequest } from '../common/chatParserTypes.js';
import { IChatProgress, IChatService } from '../common/chatService.js';
import { ChatAgentLocation } from '../common/constants.js';
import { IQuickChatOpenOptions, IQuickChatService, showChatView } from './chat.js';
import { ChatWidget } from './chatWidget.js';
import { IChatEntitlementService } from '../../../services/chat/common/chatEntitlementService.js';

export class QuickChatService extends Disposable implements IQuickChatService {
readonly _serviceBrand: undefined;
Expand Down Expand Up @@ -229,7 +230,14 @@ class QuickChat extends Disposable {
ChatWidget,
ChatAgentLocation.Chat,
{ isQuickChat: true },
{ autoScroll: true, renderInputOnTop: true, renderStyle: 'compact', menus: { inputSideToolbar: MenuId.ChatInputSide, telemetrySource: 'chatQuick' }, enableImplicitContext: true },
{
autoScroll: true,
renderInputOnTop: true,
renderStyle: 'compact',
menus: { inputSideToolbar: MenuId.ChatInputSide, telemetrySource: 'chatQuick' },
enableImplicitContext: true,
defaultMode: ChatMode.Ask
},
{
listForeground: quickInputForeground,
listBackground: quickInputBackground,
Expand Down
11 changes: 6 additions & 5 deletions src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { Emitter, Event } from '../../../../base/common/event.js';
import { FuzzyScore } from '../../../../base/common/filters.js';
import { IMarkdownString, MarkdownString } from '../../../../base/common/htmlContent.js';
import { Iterable } from '../../../../base/common/iterator.js';
import { combinedDisposable, Disposable, DisposableStore, IDisposable, MutableDisposable, thenIfNotDisposed, toDisposable } from '../../../../base/common/lifecycle.js';
import { KeyCode } from '../../../../base/common/keyCodes.js';
import { combinedDisposable, Disposable, DisposableStore, IDisposable, MutableDisposable, thenIfNotDisposed, toDisposable } from '../../../../base/common/lifecycle.js';
import { ResourceSet } from '../../../../base/common/map.js';
import { Schemas } from '../../../../base/common/network.js';
import { autorun, observableFromEvent, observableValue } from '../../../../base/common/observable.js';
Expand Down Expand Up @@ -53,13 +53,13 @@ import { IWorkspaceContextService, WorkbenchState } from '../../../../platform/w
import { EditorResourceAccessor } from '../../../../workbench/common/editor.js';
import { IEditorService } from '../../../../workbench/services/editor/common/editorService.js';
import { ViewContainerLocation } from '../../../common/views.js';
import { ChatEntitlement, IChatEntitlementService } from '../../../services/chat/common/chatEntitlementService.js';
import { IWorkbenchLayoutService, Position } from '../../../services/layout/browser/layoutService.js';
import { IViewsService } from '../../../services/views/common/viewsService.js';
import { checkModeOption } from '../common/chat.js';
import { IChatAgentCommand, IChatAgentData, IChatAgentService } from '../common/chatAgents.js';
import { ChatContextKeys } from '../common/chatContextKeys.js';
import { applyingChatEditsFailedContextKey, decidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey, hasUndecidedChatEditingResourceContextKey, IChatEditingService, IChatEditingSession, inChatEditingSessionContextKey, ModifiedFileEntryState } from '../common/chatEditingService.js';
import { ChatEntitlement, IChatEntitlementService } from '../../../services/chat/common/chatEntitlementService.js';
import { IChatLayoutService } from '../common/chatLayoutService.js';
import { IChatModel, IChatResponseModel } from '../common/chatModel.js';
import { IChatModeService } from '../common/chatModes.js';
Expand All @@ -84,7 +84,7 @@ import { ChatTreeItem, ChatViewId, IChatAcceptInputOptions, IChatAccessibilitySe
import { ChatAccessibilityProvider } from './chatAccessibilityProvider.js';
import { ChatAttachmentModel } from './chatAttachmentModel.js';
import { ChatTodoListWidget } from './chatContentParts/chatTodoListWidget.js';
import { ChatInputPart, IChatInputStyles } from './chatInputPart.js';
import { ChatInputPart, IChatInputPartOptions, IChatInputStyles } from './chatInputPart.js';
import { ChatListDelegate, ChatListItemRenderer, IChatListItemTemplate, IChatRendererDelegate } from './chatListRenderer.js';
import { ChatEditorOptions } from './chatOptions.js';
import { ChatViewPane } from './chatViewPane.js';
Expand Down Expand Up @@ -683,7 +683,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
const renderFollowups = this.viewOptions.renderFollowups ?? false;
const renderStyle = this.viewOptions.renderStyle;
this.createInput(this.container, { renderFollowups, renderStyle });
this.input.setChatMode(this.lastWelcomeViewChatMode ?? ChatModeKind.Ask);
this.input.setChatMode(this.lastWelcomeViewChatMode ?? ChatModeKind.Agent);
}
}

Expand Down Expand Up @@ -2012,7 +2012,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
}

private createInput(container: HTMLElement, options?: { renderFollowups: boolean; renderStyle?: 'compact' | 'minimal' }): void {
const commonConfig = {
const commonConfig: IChatInputPartOptions = {
renderFollowups: options?.renderFollowups ?? true,
renderStyle: options?.renderStyle === 'minimal' ? 'compact' : options?.renderStyle,
menus: {
Expand All @@ -2026,6 +2026,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
supportsChangingModes: this.viewOptions.supportsChangingModes,
dndContainer: this.viewOptions.dndContainer,
widgetViewKindTag: this.getWidgetViewKindTag(),
defaultMode: this.viewOptions.defaultMode
};

if (this.viewModel?.editing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.js';
import { ChatContextKeys } from '../../chat/common/chatContextKeys.js';
import { IChatEditingSession, ModifiedFileEntryState } from '../../chat/common/chatEditingService.js';
import { ChatModel, ChatRequestRemovalReason, IChatRequestModel, IChatTextEditGroup, IChatTextEditGroupState, IResponse } from '../../chat/common/chatModel.js';
import { ChatMode } from '../../chat/common/chatModes.js';
import { IChatService } from '../../chat/common/chatService.js';
import { IChatRequestVariableEntry } from '../../chat/common/chatVariableEntries.js';
import { ChatAgentLocation } from '../../chat/common/constants.js';
Expand Down Expand Up @@ -1337,7 +1338,8 @@ export class InlineChatController2 implements IEditorContribution {
enableWorkingSet: 'implicit',
rendererOptions: {
renderTextEditsAsSummary: _uri => true
}
},
defaultMode: ChatMode.Ask
},
{ editor: this._editor, notebookEditor },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { isResponseVM } from '../../chat/common/chatViewModel.js';
import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_RESPONSE_FOCUSED, inlineChatBackground, inlineChatForeground } from '../common/inlineChat.js';
import { HunkInformation, Session } from './inlineChatSession.js';
import './media/inlineChat.css';
import { ChatMode } from '../../chat/common/chatModes.js';

export interface InlineChatWidgetViewState {
editorViewState: ICodeEditorViewState;
Expand Down Expand Up @@ -164,6 +165,7 @@ export class InlineChatWidget {
return true;
},
dndContainer: this._elements.root,
defaultMode: ChatMode.Ask,
..._options.chatWidgetViewOptions
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IInstantiationService } from '../../../../platform/instantiation/common
import { ILogService } from '../../../../platform/log/common/log.js';
import { IChatWidgetViewOptions } from '../../chat/browser/chat.js';
import { IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.js';
import { ChatMode } from '../../chat/common/chatModes.js';
import { isResponseVM } from '../../chat/common/chatViewModel.js';
import { INotebookEditor } from '../../notebook/browser/notebookBrowser.js';
import { ACTION_REGENERATE_RESPONSE, ACTION_REPORT_ISSUE, ACTION_TOGGLE_DIFF, CTX_INLINE_CHAT_OUTER_CURSOR_POSITION, MENU_INLINE_CHAT_SIDE, MENU_INLINE_CHAT_WIDGET_SECONDARY, MENU_INLINE_CHAT_WIDGET_STATUS } from '../common/inlineChat.js';
Expand Down Expand Up @@ -95,6 +96,7 @@ export class InlineChatZoneWidget extends ZoneWidget {
renderDetectedCommandsWithRequest: true,
...options?.rendererOptions
},
defaultMode: ChatMode.Ask
}
});
this._disposables.add(this.widget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ITerminalInstance, type IXtermTerminal } from '../../../terminal/browse
import { TerminalStickyScrollContribution } from '../../stickyScroll/browser/terminalStickyScrollContribution.js';
import './media/terminalChatWidget.css';
import { MENU_TERMINAL_CHAT_WIDGET_INPUT_SIDE_TOOLBAR, MENU_TERMINAL_CHAT_WIDGET_STATUS, TerminalChatCommandId, TerminalChatContextKeys } from './terminalChat.js';
import { ChatMode } from '../../../chat/common/chatModes.js';

const enum Constants {
HorizontalMargin = 10,
Expand Down Expand Up @@ -141,7 +142,8 @@ export class TerminalChatWidget extends Disposable {
telemetrySource: 'terminal-inline-chat',
executeToolbar: MenuId.ChatExecute,
inputSideToolbar: MENU_TERMINAL_CHAT_WIDGET_INPUT_SIDE_TOOLBAR,
}
},
defaultMode: ChatMode.Ask
}
},
);
Expand Down
Loading