@@ -2111,8 +2111,12 @@ class CopilotTokenTracker implements vscode.Disposable {
21112111 const foundPaths : string [ ] = [ ] ;
21122112 for ( let i = 0 ; i < allVSCodePaths . length ; i ++ ) {
21132113 const codeUserPath = allVSCodePaths [ i ] ;
2114- if ( fs . existsSync ( codeUserPath ) ) {
2115- foundPaths . push ( codeUserPath ) ;
2114+ try {
2115+ if ( fs . existsSync ( codeUserPath ) ) {
2116+ foundPaths . push ( codeUserPath ) ;
2117+ }
2118+ } catch ( checkError ) {
2119+ this . warn ( `Could not check path ${ codeUserPath } : ${ checkError } ` ) ;
21162120 }
21172121 // Update progress
21182122 if ( ( i + 1 ) % 5 === 0 || i === allVSCodePaths . length - 1 ) {
@@ -2130,53 +2134,89 @@ class CopilotTokenTracker implements vscode.Disposable {
21302134
21312135 // Workspace storage sessions
21322136 const workspaceStoragePath = path . join ( codeUserPath , 'workspaceStorage' ) ;
2133- if ( fs . existsSync ( workspaceStoragePath ) ) {
2134- const workspaceDirs = fs . readdirSync ( workspaceStoragePath ) ;
2135-
2136- for ( const workspaceDir of workspaceDirs ) {
2137- const chatSessionsPath = path . join ( workspaceStoragePath , workspaceDir , 'chatSessions' ) ;
2138- if ( fs . existsSync ( chatSessionsPath ) ) {
2139- const sessionFiles2 = fs . readdirSync ( chatSessionsPath )
2140- . filter ( file => file . endsWith ( '.json' ) || file . endsWith ( '.jsonl' ) )
2141- . map ( file => path . join ( chatSessionsPath , file ) ) ;
2142- if ( sessionFiles2 . length > 0 ) {
2143- this . log ( `📄 Found ${ sessionFiles2 . length } session files in ${ pathName } /workspaceStorage/${ workspaceDir } ` ) ;
2144- sessionFiles . push ( ...sessionFiles2 ) ;
2137+ try {
2138+ if ( fs . existsSync ( workspaceStoragePath ) ) {
2139+ try {
2140+ const workspaceDirs = fs . readdirSync ( workspaceStoragePath ) ;
2141+
2142+ for ( const workspaceDir of workspaceDirs ) {
2143+ const chatSessionsPath = path . join ( workspaceStoragePath , workspaceDir , 'chatSessions' ) ;
2144+ try {
2145+ if ( fs . existsSync ( chatSessionsPath ) ) {
2146+ try {
2147+ const sessionFiles2 = fs . readdirSync ( chatSessionsPath )
2148+ . filter ( file => file . endsWith ( '.json' ) || file . endsWith ( '.jsonl' ) )
2149+ . map ( file => path . join ( chatSessionsPath , file ) ) ;
2150+ if ( sessionFiles2 . length > 0 ) {
2151+ this . log ( `📄 Found ${ sessionFiles2 . length } session files in ${ pathName } /workspaceStorage/${ workspaceDir } ` ) ;
2152+ sessionFiles . push ( ...sessionFiles2 ) ;
2153+ }
2154+ } catch ( readError ) {
2155+ this . warn ( `Could not read chat sessions in ${ chatSessionsPath } : ${ readError } ` ) ;
2156+ }
2157+ }
2158+ } catch ( checkError ) {
2159+ this . warn ( `Could not check chat sessions path ${ chatSessionsPath } : ${ checkError } ` ) ;
2160+ }
21452161 }
2162+ } catch ( readError ) {
2163+ this . warn ( `Could not read workspace storage in ${ workspaceStoragePath } : ${ readError } ` ) ;
21462164 }
21472165 }
2166+ } catch ( checkError ) {
2167+ this . warn ( `Could not check workspace storage path ${ workspaceStoragePath } : ${ checkError } ` ) ;
21482168 }
21492169
21502170 // Global storage sessions (legacy emptyWindowChatSessions)
21512171 const globalStoragePath = path . join ( codeUserPath , 'globalStorage' , 'emptyWindowChatSessions' ) ;
2152- if ( fs . existsSync ( globalStoragePath ) ) {
2153- const globalSessionFiles = fs . readdirSync ( globalStoragePath )
2154- . filter ( file => file . endsWith ( '.json' ) || file . endsWith ( '.jsonl' ) )
2155- . map ( file => path . join ( globalStoragePath , file ) ) ;
2156- if ( globalSessionFiles . length > 0 ) {
2157- this . log ( `📄 Found ${ globalSessionFiles . length } session files in ${ pathName } /globalStorage/emptyWindowChatSessions` ) ;
2158- sessionFiles . push ( ...globalSessionFiles ) ;
2172+ try {
2173+ if ( fs . existsSync ( globalStoragePath ) ) {
2174+ try {
2175+ const globalSessionFiles = fs . readdirSync ( globalStoragePath )
2176+ . filter ( file => file . endsWith ( '.json' ) || file . endsWith ( '.jsonl' ) )
2177+ . map ( file => path . join ( globalStoragePath , file ) ) ;
2178+ if ( globalSessionFiles . length > 0 ) {
2179+ this . log ( `📄 Found ${ globalSessionFiles . length } session files in ${ pathName } /globalStorage/emptyWindowChatSessions` ) ;
2180+ sessionFiles . push ( ...globalSessionFiles ) ;
2181+ }
2182+ } catch ( readError ) {
2183+ this . warn ( `Could not read global storage in ${ globalStoragePath } : ${ readError } ` ) ;
2184+ }
21592185 }
2186+ } catch ( checkError ) {
2187+ this . warn ( `Could not check global storage path ${ globalStoragePath } : ${ checkError } ` ) ;
21602188 }
21612189
21622190 // GitHub Copilot Chat extension global storage
21632191 const copilotChatGlobalPath = path . join ( codeUserPath , 'globalStorage' , 'github.copilot-chat' ) ;
2164- if ( fs . existsSync ( copilotChatGlobalPath ) ) {
2165- this . log ( `📄 Scanning ${ pathName } /globalStorage/github.copilot-chat` ) ;
2166- this . scanDirectoryForSessionFiles ( copilotChatGlobalPath , sessionFiles ) ;
2192+ try {
2193+ if ( fs . existsSync ( copilotChatGlobalPath ) ) {
2194+ this . log ( `📄 Scanning ${ pathName } /globalStorage/github.copilot-chat` ) ;
2195+ this . scanDirectoryForSessionFiles ( copilotChatGlobalPath , sessionFiles ) ;
2196+ }
2197+ } catch ( checkError ) {
2198+ this . warn ( `Could not check Copilot Chat global storage path ${ copilotChatGlobalPath } : ${ checkError } ` ) ;
21672199 }
21682200 }
21692201
21702202 // Check for Copilot CLI session-state directory (new location for agent mode sessions)
21712203 const copilotCliSessionPath = path . join ( os . homedir ( ) , '.copilot' , 'session-state' ) ;
2172- if ( fs . existsSync ( copilotCliSessionPath ) ) {
2173- const cliSessionFiles = fs . readdirSync ( copilotCliSessionPath )
2174- . filter ( file => file . endsWith ( '.json' ) || file . endsWith ( '.jsonl' ) )
2175- . map ( file => path . join ( copilotCliSessionPath , file ) ) ;
2176- if ( cliSessionFiles . length > 0 ) {
2177- this . log ( `📄 Found ${ cliSessionFiles . length } session files in Copilot CLI directory` ) ;
2178- sessionFiles . push ( ...cliSessionFiles ) ;
2204+ try {
2205+ if ( fs . existsSync ( copilotCliSessionPath ) ) {
2206+ try {
2207+ const cliSessionFiles = fs . readdirSync ( copilotCliSessionPath )
2208+ . filter ( file => file . endsWith ( '.json' ) || file . endsWith ( '.jsonl' ) )
2209+ . map ( file => path . join ( copilotCliSessionPath , file ) ) ;
2210+ if ( cliSessionFiles . length > 0 ) {
2211+ this . log ( `📄 Found ${ cliSessionFiles . length } session files in Copilot CLI directory` ) ;
2212+ sessionFiles . push ( ...cliSessionFiles ) ;
2213+ }
2214+ } catch ( readError ) {
2215+ this . warn ( `Could not read Copilot CLI session path in ${ copilotCliSessionPath } : ${ readError } ` ) ;
2216+ }
21792217 }
2218+ } catch ( checkError ) {
2219+ this . warn ( `Could not check Copilot CLI session path ${ copilotCliSessionPath } : ${ checkError } ` ) ;
21802220 }
21812221
21822222 // Log summary
0 commit comments