@@ -2765,6 +2765,7 @@ export class AgentService extends Disposable implements IAgentService {
27652765 this . _createProviderSession ( provider , config , deferWorktreeCreation ) ,
27662766 ] ) ;
27672767 const session = created . session ;
2768+ const isIdleProvisional = created . provisional === true && ! config ?. importConversation ;
27682769 this . _logService . trace ( `[AgentService] createSession: initialization complete` ) ;
27692770 const creationReference = readSessionCreationReference ( config ?. _meta ) ;
27702771 if ( creationReference && ! isEphemeral ) {
@@ -2783,7 +2784,9 @@ export class AgentService extends Disposable implements IAgentService {
27832784 ( ) => this . _sessionRegistry . tombstone ( session ) ,
27842785 `tombstoning ephemeral session ${ session . toString ( ) } ` ,
27852786 ) ;
2786- this . _invalidateSessionList ( ) ;
2787+ if ( ! isIdleProvisional ) {
2788+ this . _invalidateSessionList ( ) ;
2789+ }
27872790 } catch ( err ) {
27882791 await this . _rollbackProviderSession ( provider , session ) ;
27892792 throw err ;
@@ -2795,7 +2798,9 @@ export class AgentService extends Disposable implements IAgentService {
27952798 ( ) => this . _sessionRegistry . register ( session , { provider : provider . id , startTime : registeredAt , modifiedTime : registeredAt , source : 'explicit' } , { checkTombstone : false } ) ,
27962799 `registration for ${ session . toString ( ) } ` ,
27972800 ) ;
2798- this . _invalidateSessionList ( ) ;
2801+ if ( ! isIdleProvisional ) {
2802+ this . _invalidateSessionList ( ) ;
2803+ }
27992804 } catch ( err ) {
28002805 await this . _rollbackProviderSession ( provider , session ) ;
28012806 throw err ;
@@ -2835,7 +2840,7 @@ export class AgentService extends Disposable implements IAgentService {
28352840 // updates while resolving that snapshot; without a state entry those
28362841 // actions are rejected as targeting an unknown session and custom agents
28372842 // can disappear from the picker permanently.
2838- const provisionalState = created . provisional && ! config ?. importConversation
2843+ const provisionalState = isIdleProvisional
28392844 ? ( ( ) => {
28402845 const summary = this . _buildInitialSummary ( provider , session , config , created , '' ) ;
28412846 const state = this . _stateManager . createSession ( summary , { emitNotification : false } ) ;
@@ -3931,6 +3936,7 @@ export class AgentService extends Disposable implements IAgentService {
39313936 const sessionKey = session . toString ( ) ;
39323937 this . _cancelPendingSessionGc ( session ) ;
39333938 const isEphemeral = this . _stateManager . isEphemeralSession ( sessionKey ) ;
3939+ const isIdleProvisional = this . _stateManager . isIdleProvisionalSession ( sessionKey ) ;
39343940 this . _stateManager . invalidateSessionChatResolutions ( session . toString ( ) ) ;
39353941 const sessionChats = this . _stateManager . getSessionState ( session . toString ( ) ) ?. chats ?? [ ] ;
39363942 for ( const chat of sessionChats ) {
@@ -3955,7 +3961,9 @@ export class AgentService extends Disposable implements IAgentService {
39553961 `unregistration for ${ session . toString ( ) } ` ,
39563962 ) ;
39573963 }
3958- this . _invalidateSessionList ( ) ;
3964+ if ( ! isIdleProvisional ) {
3965+ this . _invalidateSessionList ( ) ;
3966+ }
39593967 if ( provider ) {
39603968 this . _providerService . releaseSession ( session . toString ( ) ) ;
39613969 this . _clearDownloadProgressInterest ( session . toString ( ) ) ;
0 commit comments