@@ -13,10 +13,11 @@ import { Emitter } from '../../../../../../base/common/event.js';
1313import { Disposable , MutableDisposable } from '../../../../../../base/common/lifecycle.js' ;
1414import { localize , localize2 } from '../../../../../../nls.js' ;
1515import { getFlatContextMenuActions } from '../../../../../../platform/actions/browser/menuEntryActionViewItem.js' ;
16+ import { MenuWorkbenchToolBar } from '../../../../../../platform/actions/browser/toolbar.js' ;
1617import { Action2 , IMenuService , MenuId , registerAction2 } from '../../../../../../platform/actions/common/actions.js' ;
1718import { IContextKey , IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.js' ;
1819import { IContextMenuService } from '../../../../../../platform/contextview/browser/contextView.js' ;
19- import { ServicesAccessor } from '../../../../../../platform/instantiation/common/instantiation.js' ;
20+ import { IInstantiationService , ServicesAccessor } from '../../../../../../platform/instantiation/common/instantiation.js' ;
2021import { IMarkdownRenderer } from '../../../../../../platform/markdown/browser/markdownRenderer.js' ;
2122import { ChatContextKeys } from '../../../common/actions/chatContextKeys.js' ;
2223import { IChatTip , IChatTipService } from '../../chatTipService.js' ;
@@ -30,6 +31,7 @@ export class ChatTipContentPart extends Disposable {
3031 public readonly onDidHide = this . _onDidHide . event ;
3132
3233 private readonly _renderedContent = this . _register ( new MutableDisposable ( ) ) ;
34+ private readonly _toolbar = this . _register ( new MutableDisposable < MenuWorkbenchToolBar > ( ) ) ;
3335
3436 private readonly _inChatTipContextKey : IContextKey < boolean > ;
3537
@@ -41,6 +43,7 @@ export class ChatTipContentPart extends Disposable {
4143 @IContextMenuService private readonly _contextMenuService : IContextMenuService ,
4244 @IMenuService private readonly _menuService : IMenuService ,
4345 @IContextKeyService private readonly _contextKeyService : IContextKeyService ,
46+ @IInstantiationService private readonly _instantiationService : IInstantiationService ,
4447 ) {
4548 super ( ) ;
4649
@@ -66,6 +69,14 @@ export class ChatTipContentPart extends Disposable {
6669 }
6770 } ) ) ;
6871
72+ this . _register ( this . _chatTipService . onDidNavigateTip ( tip => {
73+ this . _renderTip ( tip ) ;
74+ } ) ) ;
75+
76+ this . _register ( this . _chatTipService . onDidHideTip ( ( ) => {
77+ this . _onDidHide . fire ( ) ;
78+ } ) ) ;
79+
6980 this . _register ( this . _chatTipService . onDidDisableTips ( ( ) => {
7081 this . _onDidHide . fire ( ) ;
7182 } ) ) ;
@@ -93,10 +104,22 @@ export class ChatTipContentPart extends Disposable {
93104
94105 private _renderTip ( tip : IChatTip ) : void {
95106 dom . clearNode ( this . domNode ) ;
107+ this . _toolbar . clear ( ) ;
108+
96109 this . domNode . appendChild ( renderIcon ( Codicon . lightbulb ) ) ;
97110 const markdownContent = this . _renderer . render ( tip . content ) ;
98111 this . _renderedContent . value = markdownContent ;
99112 this . domNode . appendChild ( markdownContent . element ) ;
113+
114+ // Toolbar with previous, next, and dismiss actions via MenuWorkbenchToolBar
115+ const toolbarContainer = $ ( '.chat-tip-toolbar' ) ;
116+ this . _toolbar . value = this . _instantiationService . createInstance ( MenuWorkbenchToolBar , toolbarContainer , MenuId . ChatTipToolbar , {
117+ menuOptions : {
118+ shouldForwardArgs : true ,
119+ } ,
120+ } ) ;
121+ this . domNode . appendChild ( toolbarContainer ) ;
122+
100123 const textContent = markdownContent . element . textContent ?? localize ( 'chatTip' , "Chat tip" ) ;
101124 const hasLink = / \[ .* ?\] \( .* ?\) / . test ( tip . content . value ) ;
102125 const ariaLabel = hasLink
@@ -107,6 +130,94 @@ export class ChatTipContentPart extends Disposable {
107130 }
108131}
109132
133+ //#region Tip toolbar actions
134+
135+ registerAction2 ( class PreviousTipAction extends Action2 {
136+ constructor ( ) {
137+ super ( {
138+ id : 'workbench.action.chat.previousTip' ,
139+ title : localize2 ( 'chatTip.previous' , "Previous Tip" ) ,
140+ icon : Codicon . chevronLeft ,
141+ f1 : false ,
142+ menu : [ {
143+ id : MenuId . ChatTipToolbar ,
144+ group : 'navigation' ,
145+ order : 1 ,
146+ } ]
147+ } ) ;
148+ }
149+
150+ override async run ( accessor : ServicesAccessor ) : Promise < void > {
151+ const chatTipService = accessor . get ( IChatTipService ) ;
152+ const contextKeyService = accessor . get ( IContextKeyService ) ;
153+ chatTipService . navigateToPreviousTip ( contextKeyService ) ;
154+ }
155+ } ) ;
156+
157+ registerAction2 ( class NextTipAction extends Action2 {
158+ constructor ( ) {
159+ super ( {
160+ id : 'workbench.action.chat.nextTip' ,
161+ title : localize2 ( 'chatTip.next' , "Next Tip" ) ,
162+ icon : Codicon . chevronRight ,
163+ f1 : false ,
164+ menu : [ {
165+ id : MenuId . ChatTipToolbar ,
166+ group : 'navigation' ,
167+ order : 2 ,
168+ } ]
169+ } ) ;
170+ }
171+
172+ override async run ( accessor : ServicesAccessor ) : Promise < void > {
173+ const chatTipService = accessor . get ( IChatTipService ) ;
174+ const contextKeyService = accessor . get ( IContextKeyService ) ;
175+ chatTipService . navigateToNextTip ( contextKeyService ) ;
176+ }
177+ } ) ;
178+
179+ registerAction2 ( class DismissTipToolbarAction extends Action2 {
180+ constructor ( ) {
181+ super ( {
182+ id : 'workbench.action.chat.dismissTipToolbar' ,
183+ title : localize2 ( 'chatTip.dismissButton' , "Dismiss Tip" ) ,
184+ icon : Codicon . check ,
185+ f1 : false ,
186+ menu : [ {
187+ id : MenuId . ChatTipToolbar ,
188+ group : 'navigation' ,
189+ order : 3 ,
190+ } ]
191+ } ) ;
192+ }
193+
194+ override async run ( accessor : ServicesAccessor ) : Promise < void > {
195+ accessor . get ( IChatTipService ) . dismissTip ( ) ;
196+ }
197+ } ) ;
198+
199+ registerAction2 ( class CloseTipToolbarAction extends Action2 {
200+ constructor ( ) {
201+ super ( {
202+ id : 'workbench.action.chat.closeTip' ,
203+ title : localize2 ( 'chatTip.close' , "Close Tips" ) ,
204+ icon : Codicon . close ,
205+ f1 : false ,
206+ menu : [ {
207+ id : MenuId . ChatTipToolbar ,
208+ group : 'navigation' ,
209+ order : 4 ,
210+ } ]
211+ } ) ;
212+ }
213+
214+ override async run ( accessor : ServicesAccessor ) : Promise < void > {
215+ accessor . get ( IChatTipService ) . hideTip ( ) ;
216+ }
217+ } ) ;
218+
219+ //#endregion
220+
110221//#region Tip context menu actions
111222
112223registerAction2 ( class DismissTipAction extends Action2 {
0 commit comments