@@ -127,6 +127,7 @@ export class CodeIndexOrchestrator {
127127 let cumulativeBlocksIndexed = 0
128128 let cumulativeBlocksFoundSoFar = 0
129129 let batchErrors : Error [ ] = [ ]
130+ let scanStartTime = Date . now ( )
130131
131132 const handleFileParsed = ( fileBlockCount : number ) => {
132133 cumulativeBlocksFoundSoFar += fileBlockCount
@@ -138,6 +139,13 @@ export class CodeIndexOrchestrator {
138139 this . stateManager . reportBlockIndexingProgress ( cumulativeBlocksIndexed , cumulativeBlocksFoundSoFar )
139140 }
140141
142+ // Report initial scanning progress
143+ this . stateManager . setSystemState ( "Indexing" , "Discovering files to scan..." )
144+
145+ const handleProgressUpdate = ( message : string ) => {
146+ this . stateManager . setSystemState ( "Indexing" , message )
147+ }
148+
141149 const result = await this . scanner . scanDirectory (
142150 this . workspacePath ,
143151 ( batchError : Error ) => {
@@ -149,13 +157,32 @@ export class CodeIndexOrchestrator {
149157 } ,
150158 handleBlocksIndexed ,
151159 handleFileParsed ,
160+ handleProgressUpdate ,
152161 )
153162
154163 if ( ! result ) {
155164 throw new Error ( "Scan failed, is scanner initialized?" )
156165 }
157166
158167 const { stats } = result
168+ const scanDuration = Date . now ( ) - scanStartTime
169+
170+ // Validate that actual scanning work was performed
171+ const totalFilesProcessed = stats . processed + stats . skipped
172+ const hasActualWork = totalFilesProcessed > 0
173+
174+ // If no files were found to process, this might indicate a configuration issue
175+ if ( ! hasActualWork ) {
176+ this . stateManager . setSystemState ( "Indexed" , "No supported files found in workspace. Index is empty." )
177+ await this . _startWatcher ( )
178+ return
179+ }
180+
181+ // Report scanning completion with meaningful progress
182+ this . stateManager . setSystemState (
183+ "Indexing" ,
184+ `Scanned ${ totalFilesProcessed } files (${ stats . processed } processed, ${ stats . skipped } cached). Processing code blocks...` ,
185+ )
159186
160187 // Check if any blocks were actually indexed successfully
161188 // If no blocks were indexed but blocks were found, it means all batches failed
@@ -172,7 +199,10 @@ export class CodeIndexOrchestrator {
172199 }
173200
174201 // Check for partial failures - if a significant portion of blocks failed
175- const failureRate = ( cumulativeBlocksFoundSoFar - cumulativeBlocksIndexed ) / cumulativeBlocksFoundSoFar
202+ const failureRate =
203+ cumulativeBlocksFoundSoFar > 0
204+ ? ( cumulativeBlocksFoundSoFar - cumulativeBlocksIndexed ) / cumulativeBlocksFoundSoFar
205+ : 0
176206 if ( batchErrors . length > 0 && failureRate > 0.1 ) {
177207 // More than 10% of blocks failed to index
178208 const firstError = batchErrors [ 0 ]
@@ -196,9 +226,22 @@ export class CodeIndexOrchestrator {
196226 )
197227 }
198228
229+ // Provide meaningful completion message based on what was actually done
230+ let completionMessage : string
231+ if ( stats . processed === 0 && stats . skipped > 0 ) {
232+ // All files were cached - no actual processing needed
233+ completionMessage = `Index up-to-date. All ${ stats . skipped } files were already cached (no changes detected).`
234+ } else if ( cumulativeBlocksIndexed > 0 ) {
235+ // Some blocks were actually indexed
236+ completionMessage = `Indexing complete. Processed ${ stats . processed } files and indexed ${ cumulativeBlocksIndexed } code blocks in ${ Math . round ( scanDuration / 1000 ) } s.`
237+ } else {
238+ // No blocks found to index
239+ completionMessage = `Scan complete. No code blocks found in ${ totalFilesProcessed } files.`
240+ }
241+
199242 await this . _startWatcher ( )
200243
201- this . stateManager . setSystemState ( "Indexed" , "File watcher started." )
244+ this . stateManager . setSystemState ( "Indexed" , completionMessage )
202245 } catch ( error : any ) {
203246 console . error ( "[CodeIndexOrchestrator] Error during indexing:" , error )
204247 TelemetryService . instance . captureEvent ( TelemetryEventName . CODE_INDEX_ERROR , {
0 commit comments