@@ -10,7 +10,7 @@ import { BugIndicatingError, ErrorNoTelemetry } from '../../../../base/common/er
1010import { Emitter , Event } from '../../../../base/common/event.js' ;
1111import { MarkdownString } from '../../../../base/common/htmlContent.js' ;
1212import { Iterable } from '../../../../base/common/iterator.js' ;
13- import { Disposable , DisposableMap , DisposableStore , IDisposable , MutableDisposable } from '../../../../base/common/lifecycle.js' ;
13+ import { Disposable , DisposableResourceMap , DisposableStore , IDisposable , MutableDisposable } from '../../../../base/common/lifecycle.js' ;
1414import { revive } from '../../../../base/common/marshalling.js' ;
1515import { Schemas } from '../../../../base/common/network.js' ;
1616import { autorun , derived , IObservable } from '../../../../base/common/observable.js' ;
@@ -72,38 +72,6 @@ class CancellableRequest implements IDisposable {
7272 }
7373}
7474
75-
76-
77- class DisposableResourceMap < T extends IDisposable > extends Disposable {
78-
79- private readonly _map = this . _register ( new DisposableMap < string , T > ( ) ) ;
80-
81- get ( sessionResource : URI ) {
82- return this . _map . get ( this . toKey ( sessionResource ) ) ;
83- }
84-
85- set ( sessionResource : URI , value : T ) {
86- this . _map . set ( this . toKey ( sessionResource ) , value ) ;
87- }
88-
89- has ( sessionResource : URI ) {
90- return this . _map . has ( this . toKey ( sessionResource ) ) ;
91- }
92-
93- deleteAndLeak ( sessionResource : URI ) {
94- return this . _map . deleteAndLeak ( this . toKey ( sessionResource ) ) ;
95- }
96-
97- deleteAndDispose ( sessionResource : URI ) {
98- this . _map . deleteAndDispose ( this . toKey ( sessionResource ) ) ;
99- }
100-
101- private toKey ( uri : URI ) : string {
102- return uri . toString ( ) ;
103- }
104- }
105-
106-
10775export class ChatService extends Disposable implements IChatService {
10876 declare _serviceBrand : undefined ;
10977
@@ -396,7 +364,7 @@ export class ChatService extends Disposable implements IChatService {
396364 async getHistorySessionItems ( ) : Promise < IChatDetail [ ] > {
397365 const index = await this . _chatSessionStore . getIndex ( ) ;
398366 return Object . values ( index )
399- . filter ( entry => ! this . _sessionModels . has ( LocalChatSessionUri . forSession ( entry . sessionId ) ) && this . shouldBeInHistory ( entry ) && ! entry . isEmpty )
367+ . filter ( entry => ! this . _sessionModels . has ( LocalChatSessionUri . forSession ( entry . sessionId ) ) && entry . initialLocation === ChatAgentLocation . Chat && ! entry . isEmpty )
400368 . map ( ( entry ) : IChatDetail => {
401369 const sessionResource = LocalChatSessionUri . forSession ( entry . sessionId ) ;
402370 return ( {
@@ -407,11 +375,8 @@ export class ChatService extends Disposable implements IChatService {
407375 } ) ;
408376 }
409377
410- private shouldBeInHistory ( entry : Partial < ChatModel > ) {
411- if ( entry . sessionResource ) {
412- return ! entry . isImported && LocalChatSessionUri . parseLocalSessionId ( entry . sessionResource ) && entry . initialLocation === ChatAgentLocation . Chat ;
413- }
414- return ! entry . isImported && entry . initialLocation === ChatAgentLocation . Chat ;
378+ private shouldBeInHistory ( entry : ChatModel ) : boolean {
379+ return ! entry . isImported && ! ! LocalChatSessionUri . parseLocalSessionId ( entry . sessionResource ) && entry . initialLocation === ChatAgentLocation . Chat ;
415380 }
416381
417382 async removeHistoryEntry ( sessionResource : URI ) : Promise < void > {
@@ -422,14 +387,13 @@ export class ChatService extends Disposable implements IChatService {
422387 await this . _chatSessionStore . clearAllSessions ( ) ;
423388 }
424389
425- startSession ( location : ChatAgentLocation , token : CancellationToken , options ?: IChatSessionStartOptions ) : IChatModelReference {
390+ startSession ( location : ChatAgentLocation , options ?: IChatSessionStartOptions ) : IChatModelReference {
426391 this . trace ( 'startSession' ) ;
427392 const sessionId = generateUuid ( ) ;
428393 const sessionResource = LocalChatSessionUri . forSession ( sessionId ) ;
429394 return this . _sessionModels . acquireOrCreate ( {
430395 initialData : undefined ,
431396 location,
432- token,
433397 sessionResource,
434398 sessionId,
435399 canUseTools : options ?. canUseTools ?? true ,
@@ -438,17 +402,17 @@ export class ChatService extends Disposable implements IChatService {
438402 }
439403
440404 private _startSession ( props : IStartSessionProps ) : ChatModel {
441- const { initialData, location, token , sessionResource, sessionId, canUseTools, transferEditingSession, disableBackgroundKeepAlive } = props ;
405+ const { initialData, location, sessionResource, sessionId, canUseTools, transferEditingSession, disableBackgroundKeepAlive } = props ;
442406 const model = this . instantiationService . createInstance ( ChatModel , initialData , { initialLocation : location , canUseTools, resource : sessionResource , sessionId, disableBackgroundKeepAlive } ) ;
443407 if ( location === ChatAgentLocation . Chat ) {
444408 model . startEditingSession ( true , transferEditingSession ) ;
445409 }
446410
447- this . initializeSession ( model , token ) ;
411+ this . initializeSession ( model ) ;
448412 return model ;
449413 }
450414
451- private initializeSession ( model : ChatModel , token : CancellationToken ) : void {
415+ private initializeSession ( model : ChatModel ) : void {
452416 this . trace ( 'initializeSession' , `Initialize session ${ model . sessionResource } ` ) ;
453417
454418 // Activate the default extension provided agent but do not wait
@@ -516,7 +480,6 @@ export class ChatService extends Disposable implements IChatService {
516480 const sessionRef = this . _sessionModels . acquireOrCreate ( {
517481 initialData : sessionData ,
518482 location : sessionData . initialLocation ?? ChatAgentLocation . Chat ,
519- token : CancellationToken . None ,
520483 sessionResource,
521484 sessionId,
522485 canUseTools : true ,
@@ -583,7 +546,6 @@ export class ChatService extends Disposable implements IChatService {
583546 return this . _sessionModels . acquireOrCreate ( {
584547 initialData : data ,
585548 location : data . initialLocation ?? ChatAgentLocation . Chat ,
586- token : CancellationToken . None ,
587549 sessionResource,
588550 sessionId,
589551 canUseTools : true ,
@@ -609,7 +571,6 @@ export class ChatService extends Disposable implements IChatService {
609571 const modelRef = this . _sessionModels . acquireOrCreate ( {
610572 initialData : undefined ,
611573 location,
612- token : CancellationToken . None ,
613574 sessionResource : chatSessionResource ,
614575 canUseTools : false ,
615576 transferEditingSession : providedSession . initialEditingSession ,
0 commit comments