4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import * as dom from 'vs/base/browser/dom' ;
7
+ import { DEFAULT_FONT_FAMILY } from 'vs/base/browser/fonts' ;
7
8
import { IHistoryNavigationWidget } from 'vs/base/browser/history' ;
8
- import { ActionViewItem , IActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems' ;
9
9
import * as aria from 'vs/base/browser/ui/aria/aria' ;
10
10
import { Checkbox } from 'vs/base/browser/ui/toggle/toggle' ;
11
11
import { IAction } from 'vs/base/common/actions' ;
12
+ import { Codicon } from 'vs/base/common/codicons' ;
12
13
import { Emitter } from 'vs/base/common/event' ;
13
14
import { HistoryNavigator } from 'vs/base/common/history' ;
14
15
import { Disposable , DisposableStore } from 'vs/base/common/lifecycle' ;
15
16
import { isMacintosh } from 'vs/base/common/platform' ;
16
17
import { URI } from 'vs/base/common/uri' ;
18
+ import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration' ;
17
19
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions' ;
18
20
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditor/codeEditorWidget' ;
19
21
import { IDimension } from 'vs/editor/common/core/dimension' ;
@@ -23,31 +25,33 @@ import { IModelService } from 'vs/editor/common/services/model';
23
25
import { HoverController } from 'vs/editor/contrib/hover/browser/hover' ;
24
26
import { localize } from 'vs/nls' ;
25
27
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
28
+ import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem' ;
29
+ import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
26
30
import { HiddenItemStrategy , MenuWorkbenchToolBar } from 'vs/platform/actions/browser/toolbar' ;
27
- import { MenuId } from 'vs/platform/actions/common/actions' ;
31
+ import { IMenuService , MenuId , MenuItemAction } from 'vs/platform/actions/common/actions' ;
28
32
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
29
33
import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
34
+ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
30
35
import { registerAndCreateHistoryNavigationContext } from 'vs/platform/history/browser/contextScopedHistoryWidget' ;
31
36
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
32
37
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection' ;
33
38
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
39
+ import { INotificationService } from 'vs/platform/notification/common/notification' ;
34
40
import { defaultCheckboxStyles } from 'vs/platform/theme/browser/defaultStyles' ;
35
41
import { asCssVariableWithDefault , checkboxBorder , inputBackground } from 'vs/platform/theme/common/colorRegistry' ;
36
- import { DEFAULT_FONT_FAMILY } from 'vs/base/browser/fonts ' ;
42
+ import { IThemeService } from 'vs/platform/theme/common/themeService ' ;
37
43
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration' ;
38
44
import { AccessibilityCommandId } from 'vs/workbench/contrib/accessibility/common/accessibilityCommands' ;
39
- import { ChatSubmitEditorAction , ChatSubmitSecondaryAgentEditorAction } from 'vs/workbench/contrib/chat/browser/actions/chatActions' ;
40
- import { IChatExecuteActionContext , SubmitAction } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions' ;
45
+ import { ChatSubmitSecondaryAgentEditorAction } from 'vs/workbench/contrib/chat/browser/actions/chatActions' ;
46
+ import { CancelAction , IChatExecuteActionContext , SubmitAction } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions' ;
41
47
import { IChatWidget } from 'vs/workbench/contrib/chat/browser/chat' ;
42
48
import { ChatFollowups } from 'vs/workbench/contrib/chat/browser/chatFollowups' ;
43
49
import { ChatAgentLocation , IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
44
50
import { CONTEXT_CHAT_INPUT_CURSOR_AT_TOP , CONTEXT_CHAT_INPUT_HAS_FOCUS , CONTEXT_CHAT_INPUT_HAS_TEXT , CONTEXT_IN_CHAT_INPUT } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
45
- import { chatAgentLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
46
51
import { IChatFollowup } from 'vs/workbench/contrib/chat/common/chatService' ;
47
52
import { IChatResponseViewModel } from 'vs/workbench/contrib/chat/common/chatViewModel' ;
48
53
import { IChatHistoryEntry , IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService' ;
49
54
import { getSimpleCodeEditorWidgetOptions , getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions' ;
50
- import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration' ;
51
55
52
56
const $ = dom . $ ;
53
57
@@ -139,7 +143,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
139
143
@IContextKeyService private readonly contextKeyService : IContextKeyService ,
140
144
@IConfigurationService private readonly configurationService : IConfigurationService ,
141
145
@IKeybindingService private readonly keybindingService : IKeybindingService ,
142
- @IAccessibilityService private readonly accessibilityService : IAccessibilityService
146
+ @IAccessibilityService private readonly accessibilityService : IAccessibilityService ,
143
147
) {
144
148
super ( ) ;
145
149
@@ -368,8 +372,9 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
368
372
} ,
369
373
hiddenItemStrategy : HiddenItemStrategy . Ignore , // keep it lean when hiding items and avoid a "..." overflow menu
370
374
actionViewItemProvider : ( action , options ) => {
371
- if ( action . id === SubmitAction . ID ) {
372
- return this . instantiationService . createInstance ( SubmitButtonActionViewItem , { widget } satisfies IChatExecuteActionContext , action , options ) ;
375
+ if ( ( action . id === SubmitAction . ID || action . id === CancelAction . ID ) && action instanceof MenuItemAction ) {
376
+ const dropdownAction = this . instantiationService . createInstance ( MenuItemAction , { id : 'chat.moreExecuteActions' , title : localize ( 'notebook.moreExecuteActionsLabel' , "More..." ) , icon : Codicon . chevronDown } , undefined , undefined , undefined ) ;
377
+ return this . instantiationService . createInstance ( ChatSubmitDropdownActionItem , action , dropdownAction ) ;
373
378
}
374
379
375
380
return undefined ;
@@ -482,40 +487,57 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
482
487
}
483
488
}
484
489
485
- class SubmitButtonActionViewItem extends ActionViewItem {
486
- private readonly _tooltip : string ;
490
+ function getLastPosition ( model : ITextModel ) : IPosition {
491
+ return { lineNumber : model . getLineCount ( ) , column : model . getLineLength ( model . getLineCount ( ) ) + 1 } ;
492
+ }
487
493
494
+ // This does seems like a lot just to customize an item with dropdown. This whole class exists just because we need an
495
+ // onDidChange listener on the submenu, which is apparently not needed in other cases.
496
+ class ChatSubmitDropdownActionItem extends DropdownWithPrimaryActionViewItem {
488
497
constructor (
489
- context : unknown ,
490
- action : IAction ,
491
- options : IActionViewItemOptions ,
492
- @IKeybindingService keybindingService : IKeybindingService ,
498
+ action : MenuItemAction ,
499
+ dropdownAction : IAction ,
500
+ @ IMenuService menuService : IMenuService ,
501
+ @IContextMenuService contextMenuService : IContextMenuService ,
493
502
@IChatAgentService chatAgentService : IChatAgentService ,
503
+ @IContextKeyService contextKeyService : IContextKeyService ,
504
+ @IKeybindingService keybindingService : IKeybindingService ,
505
+ @INotificationService notificationService : INotificationService ,
506
+ @IThemeService themeService : IThemeService ,
507
+ @IAccessibilityService accessibilityService : IAccessibilityService
494
508
) {
495
- super ( context , action , options ) ;
496
-
497
- const primaryKeybinding = keybindingService . lookupKeybinding ( ChatSubmitEditorAction . ID ) ?. getLabel ( ) ;
498
- let tooltip = action . label ;
499
- if ( primaryKeybinding ) {
500
- tooltip += ` (${ primaryKeybinding } )` ;
501
- }
502
-
503
- const secondaryAgent = chatAgentService . getSecondaryAgent ( ) ;
504
- if ( secondaryAgent ) {
505
- const secondaryKeybinding = keybindingService . lookupKeybinding ( ChatSubmitSecondaryAgentEditorAction . ID ) ?. getLabel ( ) ;
506
- if ( secondaryKeybinding ) {
507
- tooltip += `\n${ chatAgentLeader } ${ secondaryAgent . name } (${ secondaryKeybinding } )` ;
509
+ super (
510
+ action ,
511
+ dropdownAction ,
512
+ [ ] ,
513
+ '' ,
514
+ contextMenuService ,
515
+ {
516
+ getKeyBinding : ( action : IAction ) => keybindingService . lookupKeybinding ( action . id , contextKeyService )
517
+ } ,
518
+ keybindingService ,
519
+ notificationService ,
520
+ contextKeyService ,
521
+ themeService ,
522
+ accessibilityService ) ;
523
+ const menu = menuService . createMenu ( MenuId . ChatExecuteSecondary , contextKeyService ) ;
524
+ const setActions = ( ) => {
525
+ const secondary : IAction [ ] = [ ] ;
526
+ createAndFillInActionBarActions ( menu , { shouldForwardArgs : true } , secondary ) ;
527
+ const secondaryAgent = chatAgentService . getSecondaryAgent ( ) ;
528
+ if ( secondaryAgent ) {
529
+ secondary . forEach ( a => {
530
+ if ( a . id === ChatSubmitSecondaryAgentEditorAction . ID ) {
531
+ a . label = localize ( 'chat.submitToSecondaryAgent' , "Send to @{0}" , secondaryAgent . name ) ;
532
+ }
533
+
534
+ return a ;
535
+ } ) ;
508
536
}
509
- }
510
-
511
- this . _tooltip = tooltip ;
512
- }
513
537
514
- protected override getTooltip ( ) : string | undefined {
515
- return this . _tooltip ;
538
+ this . update ( dropdownAction , secondary ) ;
539
+ } ;
540
+ setActions ( ) ;
541
+ this . _register ( menu . onDidChange ( ( ) => setActions ( ) ) ) ;
516
542
}
517
543
}
518
-
519
- function getLastPosition ( model : ITextModel ) : IPosition {
520
- return { lineNumber : model . getLineCount ( ) , column : model . getLineLength ( model . getLineCount ( ) ) + 1 } ;
521
- }
0 commit comments