@@ -8,6 +8,9 @@ import { KeyCode, KeyMod } from '../../../../../base/common/keyCodes.js';
8
8
import { localize2 } from '../../../../../nls.js' ;
9
9
import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js' ;
10
10
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js' ;
11
+ import { IChatWidgetService } from '../../../chat/browser/chat.js' ;
12
+ import { ChatAgentLocation } from '../../../chat/common/chatAgents.js' ;
13
+ import { IChatService } from '../../../chat/common/chatService.js' ;
11
14
import { AbstractInlineChatAction } from '../../../inlineChat/browser/inlineChatActions.js' ;
12
15
import { isDetachedTerminalInstance } from '../../../terminal/browser/terminal.js' ;
13
16
import { registerActiveXtermAction } from '../../../terminal/browser/terminalActions.js' ;
@@ -209,6 +212,48 @@ registerActiveXtermAction({
209
212
}
210
213
} ) ;
211
214
215
+ registerActiveXtermAction ( {
216
+ id : TerminalChatCommandId . RerunRequest ,
217
+ title : localize2 ( 'chat.rerun.label' , "Rerun Request" ) ,
218
+ f1 : false ,
219
+ icon : Codicon . refresh ,
220
+ category : AbstractInlineChatAction . category ,
221
+ precondition : ContextKeyExpr . and (
222
+ ContextKeyExpr . or ( TerminalContextKeys . processSupported , TerminalContextKeys . terminalHasBeenCreated ) ,
223
+ TerminalChatContextKeys . requestActive . negate ( ) ,
224
+ ) ,
225
+ keybinding : {
226
+ weight : KeybindingWeight . WorkbenchContrib ,
227
+ primary : KeyMod . CtrlCmd | KeyCode . KeyR
228
+ } ,
229
+ menu : {
230
+ id : MENU_TERMINAL_CHAT_WIDGET_STATUS ,
231
+ group : '0_main' ,
232
+ order : 5 ,
233
+ when : ContextKeyExpr . and ( TerminalChatContextKeys . inputHasText . toNegated ( ) , TerminalChatContextKeys . requestActive . negate ( ) )
234
+ } ,
235
+ run : async ( _xterm , _accessor , activeInstance ) => {
236
+ const chatService = _accessor . get ( IChatService ) ;
237
+ const chatWidgetService = _accessor . get ( IChatWidgetService ) ;
238
+ const contr = TerminalChatController . activeChatController ;
239
+ const model = contr ?. terminalChatWidget ?. inlineChatWidget . chatWidget . viewModel ?. model ;
240
+ if ( ! model ) {
241
+ return ;
242
+ }
243
+
244
+ const lastRequest = model . getRequests ( ) . at ( - 1 ) ;
245
+ if ( lastRequest ) {
246
+ const widget = chatWidgetService . getWidgetBySessionId ( model . sessionId ) ;
247
+ await chatService . resendRequest ( lastRequest , {
248
+ noCommandDetection : false ,
249
+ attempt : lastRequest . attempt + 1 ,
250
+ location : ChatAgentLocation . Terminal ,
251
+ userSelectedModelId : widget ?. input . currentLanguageModel
252
+ } ) ;
253
+ }
254
+ }
255
+ } ) ;
256
+
212
257
registerActiveXtermAction ( {
213
258
id : TerminalChatCommandId . ViewInChat ,
214
259
title : localize2 ( 'viewInChat' , 'View in Chat' ) ,
0 commit comments