@@ -180,7 +180,7 @@ export class ChatService extends Disposable implements IChatService {
180180 private saveState ( ) : void {
181181 const liveChats = Array . from ( this . _sessionModels . values ( ) )
182182 . filter ( session =>
183- this . shouldSaveToHistory ( session . sessionId ) && ( session . initialLocation === ChatAgentLocation . Panel || session . initialLocation === ChatAgentLocation . Editor ) ) ;
183+ ! session . inputType && ( session . initialLocation === ChatAgentLocation . Panel || session . initialLocation === ChatAgentLocation . Editor ) ) ;
184184
185185 if ( this . useFileStorage ) {
186186 this . _chatSessionStore . storeSessions ( liveChats ) ;
@@ -415,7 +415,7 @@ export class ChatService extends Disposable implements IChatService {
415415 async getHistory ( ) : Promise < IChatDetail [ ] > {
416416 if ( this . useFileStorage ) {
417417 const liveSessionItems = Array . from ( this . _sessionModels . values ( ) )
418- . filter ( session => ! session . isImported )
418+ . filter ( session => ! session . isImported && ! session . inputType )
419419 . map ( session => {
420420 const title = session . title || localize ( 'newChat' , "New Chat" ) ;
421421 return {
@@ -489,13 +489,13 @@ export class ChatService extends Disposable implements IChatService {
489489 this . saveState ( ) ;
490490 }
491491
492- startSession ( location : ChatAgentLocation , token : CancellationToken , isGlobalEditingSession : boolean = true ) : ChatModel {
492+ startSession ( location : ChatAgentLocation , token : CancellationToken , isGlobalEditingSession : boolean = true , inputType ?: string ) : ChatModel {
493493 this . trace ( 'startSession' ) ;
494- return this . _startSession ( undefined , location , isGlobalEditingSession , token ) ;
494+ return this . _startSession ( undefined , location , isGlobalEditingSession , token , inputType ) ;
495495 }
496496
497- private _startSession ( someSessionHistory : IExportableChatData | ISerializableChatData | undefined , location : ChatAgentLocation , isGlobalEditingSession : boolean , token : CancellationToken ) : ChatModel {
498- const model = this . instantiationService . createInstance ( ChatModel , someSessionHistory , location ) ;
497+ private _startSession ( someSessionHistory : IExportableChatData | ISerializableChatData | undefined , location : ChatAgentLocation , isGlobalEditingSession : boolean , token : CancellationToken , inputType ?: string ) : ChatModel {
498+ const model = this . instantiationService . createInstance ( ChatModel , someSessionHistory , { initialLocation : location , inputType } ) ;
499499 if ( location === ChatAgentLocation . Panel ) {
500500 model . startEditingSession ( isGlobalEditingSession ) ;
501501 }
@@ -632,7 +632,7 @@ export class ChatService extends Disposable implements IChatService {
632632 const chatSessionType = parsed . chatSessionType ;
633633 const content = await this . chatSessionService . provideChatSessionContent ( chatSessionType , parsed . sessionId , CancellationToken . None ) ;
634634
635- const model = this . _startSession ( undefined , location , true , CancellationToken . None ) ;
635+ const model = this . _startSession ( undefined , location , true , CancellationToken . None , chatSessionType ) ;
636636 if ( ! this . _contentProviderSessionModels . has ( chatSessionType ) ) {
637637 this . _contentProviderSessionModels . set ( chatSessionType , new Map ( ) ) ;
638638 }
@@ -1238,14 +1238,13 @@ export class ChatService extends Disposable implements IChatService {
12381238 }
12391239
12401240 async clearSession ( sessionId : string ) : Promise < void > {
1241- const shouldSaveToHistory = this . shouldSaveToHistory ( sessionId ) ;
1242- this . trace ( 'clearSession' , `sessionId: ${ sessionId } , save to history: ${ shouldSaveToHistory } ` ) ;
1241+ this . trace ( 'clearSession' , `sessionId: ${ sessionId } ` ) ;
12431242 const model = this . _sessionModels . get ( sessionId ) ;
12441243 if ( ! model ) {
12451244 throw new Error ( `Unknown session: ${ sessionId } ` ) ;
12461245 }
1247-
1248- if ( shouldSaveToHistory && ( model . initialLocation === ChatAgentLocation . Panel || model . initialLocation === ChatAgentLocation . Editor ) ) {
1246+ this . trace ( `Model input type: ${ model . inputType } ` ) ;
1247+ if ( ! model . inputType && ( model . initialLocation === ChatAgentLocation . Panel || model . initialLocation === ChatAgentLocation . Editor ) ) {
12491248 if ( this . useFileStorage ) {
12501249 // Always preserve sessions that have custom titles, even if empty
12511250 if ( model . getRequests ( ) . length === 0 && ! model . customTitle ) {
@@ -1310,22 +1309,4 @@ export class ChatService extends Disposable implements IChatService {
13101309 logChatIndex ( ) : void {
13111310 this . _chatSessionStore . logIndex ( ) ;
13121311 }
1313-
1314- private shouldSaveToHistory ( sessionId : string ) : boolean {
1315- // We shouldn't save contributed sessions from content providers
1316- for ( const [ _ , sessions ] of this . _contentProviderSessionModels ) {
1317- let session : { readonly model : IChatModel ; readonly disposables : DisposableStore } | undefined ;
1318- for ( const entry of sessions . values ( ) ) {
1319- if ( entry . model . sessionId === sessionId ) {
1320- session = entry ;
1321- break ;
1322- }
1323- }
1324- if ( session ) {
1325- return false ;
1326- }
1327- }
1328-
1329- return true ;
1330- }
13311312}
0 commit comments