@@ -15,10 +15,10 @@ import { KeybindingWeight } from '../../../../../platform/keybinding/common/keyb
15
15
import { ActiveEditorContext } from '../../../../common/contextkeys.js' ;
16
16
import { IViewsService } from '../../../../services/views/common/viewsService.js' ;
17
17
import { isChatViewTitleActionContext } from '../../common/chatActions.js' ;
18
- import { ChatAgentLocation } from '../../common/chatAgents.js' ;
19
- import { ChatContextKeys } from '../../common/chatContextKeys.js' ;
18
+ import { ChatContextKeyExprs , ChatContextKeys } from '../../common/chatContextKeys.js' ;
20
19
import { hasAppliedChatEditsContextKey , hasUndecidedChatEditingResourceContextKey , IChatEditingSession , WorkingSetEntryState } from '../../common/chatEditingService.js' ;
21
- import { ChatMode } from '../../common/constants.js' ;
20
+ import { IChatService } from '../../common/chatService.js' ;
21
+ import { ChatAgentLocation , ChatMode } from '../../common/constants.js' ;
22
22
import { ChatViewId , EditsViewId , IChatWidget , IChatWidgetService } from '../chat.js' ;
23
23
import { EditingSessionAction } from '../chatEditing/chatEditingActions.js' ;
24
24
import { ctxIsGlobalEditingSession } from '../chatEditing/chatEditingEditorContextKeys.js' ;
@@ -95,7 +95,9 @@ export function registerNewChatActions() {
95
95
} ,
96
96
{
97
97
id : MenuId . ViewTitle ,
98
- when : ContextKeyExpr . equals ( 'view' , ChatViewId ) ,
98
+ when : ContextKeyExpr . and (
99
+ ChatContextKeys . location . isEqualTo ( ChatAgentLocation . Panel ) ,
100
+ ChatContextKeys . inUnifiedChat . negate ( ) ) ,
99
101
group : 'navigation' ,
100
102
order : - 1
101
103
} ]
@@ -137,7 +139,7 @@ export function registerNewChatActions() {
137
139
} ,
138
140
{
139
141
id : MenuId . ViewTitle ,
140
- when : ContextKeyExpr . equals ( 'view' , EditsViewId ) ,
142
+ when : ChatContextKeyExprs . inEditsOrUnified ,
141
143
group : 'navigation' ,
142
144
order : - 1
143
145
} ] ,
@@ -147,7 +149,7 @@ export function registerNewChatActions() {
147
149
mac : {
148
150
primary : KeyMod . WinCtrl | KeyCode . KeyL
149
151
} ,
150
- when : ContextKeyExpr . and ( ChatContextKeys . inChatSession , ChatContextKeys . location . isEqualTo ( ChatAgentLocation . EditingSession ) )
152
+ when : ContextKeyExpr . and ( ChatContextKeys . inChatSession , ChatContextKeyExprs . inEditingMode )
151
153
}
152
154
} ) ;
153
155
}
@@ -199,6 +201,7 @@ export function registerNewChatActions() {
199
201
const widgetService = accessor . get ( IChatWidgetService ) ;
200
202
const dialogService = accessor . get ( IDialogService ) ;
201
203
const viewsService = accessor . get ( IViewsService ) ;
204
+ const chatService = accessor . get ( IChatService ) ;
202
205
203
206
if ( ! ( await this . _handleCurrentEditingSession ( editingSession , dialogService ) ) ) {
204
207
return ;
@@ -212,8 +215,9 @@ export function registerNewChatActions() {
212
215
widget = widgetService . getWidgetBySessionId ( context . sessionId ) ;
213
216
} else {
214
217
// Is running from f1 or keybinding
215
- const chatView = await viewsService . openView ( EditsViewId ) as ChatViewPane ;
216
- widget = chatView . widget ;
218
+ const view = chatService . unifiedViewEnabled ? ChatViewId : EditsViewId ;
219
+ const chatView = await viewsService . openView < ChatViewPane > ( view ) ;
220
+ widget = chatView ?. widget ;
217
221
}
218
222
219
223
announceChatCleared ( accessibilitySignalService ) ;
@@ -256,7 +260,7 @@ export function registerNewChatActions() {
256
260
f1 : false ,
257
261
menu : [ {
258
262
id : MenuId . ChatEditingWidgetToolbar ,
259
- when : ContextKeyExpr . and ( hasUndecidedChatEditingResourceContextKey . negate ( ) , hasAppliedChatEditsContextKey , ChatContextKeys . editingParticipantRegistered , ChatContextKeys . location . isEqualTo ( ChatAgentLocation . EditingSession ) ) ,
263
+ when : ContextKeyExpr . and ( hasUndecidedChatEditingResourceContextKey . negate ( ) , hasAppliedChatEditsContextKey , ChatContextKeys . editingParticipantRegistered , ChatContextKeyExprs . inEditsOrUnified ) ,
260
264
group : 'navigation' ,
261
265
order : 0
262
266
} ]
@@ -348,12 +352,16 @@ export function registerNewChatActions() {
348
352
precondition : ChatContextKeys . Setup . hidden . toNegated ( ) ,
349
353
menu : [ {
350
354
id : MenuId . ViewTitle ,
351
- when : ContextKeyExpr . and ( ContextKeyExpr . equals ( 'view' , ChatViewId ) , ChatContextKeys . editingParticipantRegistered ,
355
+ when : ContextKeyExpr . and (
356
+ ContextKeyExpr . equals ( 'view' , ChatViewId ) ,
357
+ ChatContextKeys . editingParticipantRegistered ,
352
358
ContextKeyExpr . equals ( `view.${ EditsViewId } .visible` , false ) ,
353
359
ContextKeyExpr . or (
354
360
ContextKeyExpr . and ( ContextKeyExpr . equals ( `workbench.panel.chat.defaultViewContainerLocation` , true ) , ContextKeyExpr . equals ( `workbench.panel.chatEditing.defaultViewContainerLocation` , false ) ) ,
355
361
ContextKeyExpr . and ( ContextKeyExpr . equals ( `workbench.panel.chat.defaultViewContainerLocation` , false ) , ContextKeyExpr . equals ( `workbench.panel.chatEditing.defaultViewContainerLocation` , true ) ) ,
356
- ) ) ,
362
+ ) ,
363
+ ChatContextKeys . inUnifiedChat . negate ( )
364
+ ) ,
357
365
group : 'navigation' ,
358
366
order : 1
359
367
} , {
@@ -380,17 +388,18 @@ export function registerNewChatActions() {
380
388
async run ( accessor : ServicesAccessor , opts ?: string | IChatViewOpenOptions ) {
381
389
opts = typeof opts === 'string' ? { query : opts } : opts ;
382
390
const viewsService = accessor . get ( IViewsService ) ;
383
- const chatView = await viewsService . openView ( EditsViewId ) as ChatViewPane ;
391
+ const chatView = await viewsService . openView < ChatViewPane > ( EditsViewId )
392
+ ?? await viewsService . openView < ChatViewPane > ( ChatViewId ) ;
384
393
385
394
if ( opts ?. query ) {
386
395
if ( opts . isPartialQuery ) {
387
- chatView . widget . setInput ( opts . query ) ;
396
+ chatView ? .widget . setInput ( opts . query ) ;
388
397
} else {
389
- chatView . widget . acceptInput ( opts . query ) ;
398
+ chatView ? .widget . acceptInput ( opts . query ) ;
390
399
}
391
400
}
392
401
393
- chatView . widget . focusInput ( ) ;
402
+ chatView ? .widget . focusInput ( ) ;
394
403
}
395
404
} ) ;
396
405
}
0 commit comments