@@ -278,13 +278,21 @@ export class CopilotCLIChatSessionItemProvider extends Disposable implements vsc
278278 }
279279}
280280
281- export class CopilotCLIChatSessionContentProvider implements vscode . ChatSessionContentProvider {
281+ export class CopilotCLIChatSessionContentProvider extends Disposable implements vscode . ChatSessionContentProvider {
282+ private readonly _onDidChangeChatSessionOptions = this . _register ( new Emitter < vscode . ChatSessionOptionChangeEvent > ( ) ) ;
283+ readonly onDidChangeChatSessionOptions = this . _onDidChangeChatSessionOptions . event ;
282284 constructor (
283285 private readonly worktreeManager : CopilotCLIWorktreeManager ,
284286 @ICopilotCLIModels private readonly copilotCLIModels : ICopilotCLIModels ,
285287 @ICopilotCLIAgents private readonly copilotCLIAgents : ICopilotCLIAgents ,
286288 @ICopilotCLISessionService private readonly sessionService : ICopilotCLISessionService ,
287- ) { }
289+ ) {
290+ super ( ) ;
291+ }
292+
293+ public notifySessionOptionsChange ( resource : vscode . Uri , updates : ReadonlyArray < { optionId : string ; value : string } > ) : void {
294+ this . _onDidChangeChatSessionOptions . fire ( { resource, updates } ) ;
295+ }
288296
289297 async provideChatSessionContent ( resource : Uri , token : vscode . CancellationToken ) : Promise < vscode . ChatSession > {
290298 const copilotcliSessionId = SessionIdForCLI . parse ( resource ) ;
@@ -413,6 +421,7 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
413421 private CLI_CANCEL = vscode . l10n . t ( 'Cancel' ) ;
414422
415423 constructor (
424+ private readonly contentProvider : CopilotCLIChatSessionContentProvider ,
416425 private readonly promptResolver : CopilotCLIPromptResolver ,
417426 private readonly sessionItemProvider : CopilotCLIChatSessionItemProvider ,
418427 private readonly cloudSessionProvider : CopilotCloudSessionsProvider | undefined ,
@@ -475,6 +484,21 @@ export class CopilotCLIChatSessionParticipant extends Disposable {
475484 this . getModelId ( id , request , token ) ,
476485 this . getAgent ( id , request , token ) ,
477486 ] ) ;
487+ if ( isUntitled && ( modelId || agent ) ) {
488+ const promptFile = request ? await this . getPromptInfoFromRequest ( request , token ) : undefined ;
489+ if ( promptFile ) {
490+ const changes : { optionId : string ; value : string } [ ] = [ ] ;
491+ if ( agent ) {
492+ changes . push ( { optionId : AGENTS_OPTION_ID , value : agent . name } ) ;
493+ }
494+ if ( modelId ) {
495+ changes . push ( { optionId : MODELS_OPTION_ID , value : modelId } ) ;
496+ }
497+ if ( changes . length > 0 ) {
498+ this . contentProvider . notifySessionOptionsChange ( resource , changes ) ;
499+ }
500+ }
501+ }
478502 const session = await this . getOrCreateSession ( request , chatSessionContext , modelId , agent , stream , disposables , token ) ;
479503 if ( ! session || token . isCancellationRequested ) {
480504 return { } ;
0 commit comments