@@ -166,8 +166,8 @@ export class CopilotAgent extends Disposable implements IAgent {
166166 const projectByContext = new Map < string , Promise < IAgentSessionProjectInfo | undefined > > ( ) ;
167167 const result : IAgentSessionMetadata [ ] = await Promise . all ( sessions . map ( async s => {
168168 const session = AgentSession . uri ( this . id , s . sessionId ) ;
169- const metadata = await this . _readSessionMetadata ( session ) ;
170- let { project, resolved } = await this . _readSessionProject ( session ) ;
169+ const metadata = await this . _readStoredSessionMetadata ( session ) ;
170+ let { project, resolved } = metadata ;
171171 if ( ! resolved ) {
172172 project = await this . _resolveSessionProject ( s . context , projectLimiter , projectByContext ) ;
173173 this . _storeSessionProjectResolution ( session , project ) ;
@@ -179,7 +179,7 @@ export class CopilotAgent extends Disposable implements IAgent {
179179 ...( project ? { project } : { } ) ,
180180 summary : s . summary ,
181181 model : metadata . model ,
182- workingDirectory : typeof s . context ?. cwd === 'string' ? URI . file ( s . context . cwd ) : undefined ,
182+ workingDirectory : typeof s . context ?. cwd === 'string' ? URI . file ( s . context . cwd ) : metadata . workingDirectory ,
183183 } ;
184184 } ) ) ;
185185 this . _logService . info ( `[Copilot] Found ${ result . length } sessions` ) ;
@@ -566,19 +566,21 @@ export class CopilotAgent extends Disposable implements IAgent {
566566 }
567567 }
568568
569- private async _readSessionProject ( session : URI ) : Promise < { project ?: IAgentSessionProjectInfo ; resolved : boolean } > {
569+ private async _readStoredSessionMetadata ( session : URI ) : Promise < { model ?: string ; workingDirectory ?: URI ; project ?: IAgentSessionProjectInfo ; resolved : boolean } > {
570570 const ref = await this . _sessionDataService . tryOpenDatabase ( session ) ;
571571 if ( ! ref ) {
572572 return { resolved : false } ;
573573 }
574574 try {
575- const [ resolved , uri , displayName ] = await Promise . all ( [
575+ const [ model , cwd , resolved , uri , displayName ] = await Promise . all ( [
576+ ref . object . getMetadata ( CopilotAgent . _META_MODEL ) ,
577+ ref . object . getMetadata ( CopilotAgent . _META_CWD ) ,
576578 ref . object . getMetadata ( CopilotAgent . _META_PROJECT_RESOLVED ) ,
577579 ref . object . getMetadata ( CopilotAgent . _META_PROJECT_URI ) ,
578580 ref . object . getMetadata ( CopilotAgent . _META_PROJECT_DISPLAY_NAME ) ,
579581 ] ) ;
580582 const project = uri && displayName ? { uri : URI . parse ( uri ) , displayName } : undefined ;
581- return { project, resolved : resolved === 'true' || project !== undefined } ;
583+ return { model , workingDirectory : cwd ? URI . parse ( cwd ) : undefined , project, resolved : resolved === 'true' || project !== undefined } ;
582584 } finally {
583585 ref . dispose ( ) ;
584586 }
0 commit comments