@@ -7,6 +7,7 @@ import { $, getWindow } from '../../../../base/browser/dom.js';
77import { CancellationToken } from '../../../../base/common/cancellation.js' ;
88import { DisposableStore } from '../../../../base/common/lifecycle.js' ;
99import { MarshalledId } from '../../../../base/common/marshallingIds.js' ;
10+ import { Schemas } from '../../../../base/common/network.js' ;
1011import { URI } from '../../../../base/common/uri.js' ;
1112import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js' ;
1213import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js' ;
@@ -31,7 +32,9 @@ import { ChatContextKeys } from '../common/chatContextKeys.js';
3132import { IChatModel } from '../common/chatModel.js' ;
3233import { CHAT_PROVIDER_ID } from '../common/chatParticipantContribTypes.js' ;
3334import { IChatService } from '../common/chatService.js' ;
35+ import { IChatSessionsService , IChatSessionsExtensionPoint } from '../common/chatSessionsService.js' ;
3436import { ChatAgentLocation , ChatModeKind } from '../common/constants.js' ;
37+ import { ChatSessionUri } from '../common/chatUri.js' ;
3538import { ChatWidget , IChatViewState } from './chatWidget.js' ;
3639import { ChatViewWelcomeController , IViewWelcomeDelegate } from './viewsWelcome/chatViewWelcomeController.js' ;
3740
@@ -69,6 +72,7 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate {
6972 @IChatAgentService private readonly chatAgentService : IChatAgentService ,
7073 @ILogService private readonly logService : ILogService ,
7174 @ILayoutService private readonly layoutService : ILayoutService ,
75+ @IChatSessionsService private readonly chatSessionsService : IChatSessionsService ,
7276 ) {
7377 super ( options , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService , hoverService ) ;
7478
@@ -249,6 +253,19 @@ export class ChatViewPane extends ViewPane implements IViewWelcomeDelegate {
249253 await this . chatService . clearSession ( this . widget . viewModel . sessionId ) ;
250254 }
251255
256+ // Handle locking for contributed chat sessions
257+ if ( URI . isUri ( sessionId ) && sessionId . scheme === Schemas . vscodeChatSession ) {
258+ const parsed = ChatSessionUri . parse ( sessionId ) ;
259+ if ( parsed ?. chatSessionType ) {
260+ await this . chatSessionsService . canResolveContentProvider ( parsed . chatSessionType ) ;
261+ const contributions = this . chatSessionsService . getAllChatSessionContributions ( ) ;
262+ const contribution = contributions . find ( ( c : IChatSessionsExtensionPoint ) => c . type === parsed . chatSessionType ) ;
263+ if ( contribution ) {
264+ this . widget . lockToCodingAgent ( contribution . name , contribution . displayName , contribution . type ) ;
265+ }
266+ }
267+ }
268+
252269 const newModel = await ( URI . isUri ( sessionId ) ? this . chatService . loadSessionForResource ( sessionId , ChatAgentLocation . Panel , CancellationToken . None ) : this . chatService . getOrRestoreSession ( sessionId ) ) ;
253270 await this . updateModel ( newModel , viewState ) ;
254271 }
0 commit comments