feat: show package names and file paths during indexing

- Enhanced state-manager.ts to accept full file path and package name parameters
- Added package name extraction logic to orchestrator.ts
- Updated status messages to display package names and file paths during indexing
- Improved user visibility into what is being indexed in multi-package workspaces

Fixes #6907
This commit is contained in:
Roo Code 2025-08-10 16:50:00 +00:00
parent f53fd39014
commit da160fed99
2 changed files with 58 additions and 9 deletions

View file

@ -45,11 +45,11 @@ export class CodeIndexOrchestrator {
if (totalInBatch > 0 && this.stateManager.state !== "Indexing") {
this.stateManager.setSystemState("Indexing", "Processing file changes...")
}
this.stateManager.reportFileQueueProgress(
processedInBatch,
totalInBatch,
currentFile ? path.basename(currentFile) : undefined,
)
// Extract package name from file path if possible
let packageName = this.extractPackageName(currentFile)
this.stateManager.reportFileQueueProgress(processedInBatch, totalInBatch, currentFile, packageName)
if (processedInBatch === totalInBatch) {
// Covers (N/N) and (0/0)
if (totalInBatch > 0) {
@ -291,4 +291,40 @@ export class CodeIndexOrchestrator {
public get state(): IndexingState {
return this.stateManager.state
}
/**
* Extracts package name from a file path
* @param filePath Path to extract package name from
* @returns Package name if identified, otherwise undefined
*/
private extractPackageName(filePath?: string): string | undefined {
if (!filePath) return undefined
// Check if path contains node_modules
const nodeModulesMatch = filePath.match(/node_modules[\\/\\\\](@[^\\/\\\\]+[\\/\\\\][^\\/\\\\]+|[^\\/\\\\]+)/)
if (nodeModulesMatch && nodeModulesMatch[1]) {
return nodeModulesMatch[1]
}
// Check if path contains packages directory structure (monorepo)
const packagesMatch = filePath.match(/packages[\\/\\\\]([^\\/\\\\]+)/)
if (packagesMatch && packagesMatch[1]) {
return packagesMatch[1]
}
// Extract npm package name from package.json if close to the file
try {
const dirPath = path.dirname(filePath)
// Check if it's part of the src/ directory structure
const srcMatch = filePath.match(/src[\\/\\\\]([^\\/\\\\]+)/)
if (srcMatch && srcMatch[1]) {
return srcMatch[1]
}
} catch (error) {
// Ignore errors in package name extraction
}
return undefined
}
}

View file

@ -1,4 +1,5 @@
import * as vscode from "vscode"
import * as path from "path"
export type IndexingState = "Standby" | "Indexing" | "Indexed" | "Error"
@ -78,7 +79,12 @@ export class CodeIndexStateManager {
}
}
public reportFileQueueProgress(processedFiles: number, totalFiles: number, currentFileBasename?: string): void {
public reportFileQueueProgress(
processedFiles: number,
totalFiles: number,
currentFilePath?: string,
packageName?: string,
): void {
const progressChanged = processedFiles !== this._processedItems || totalFiles !== this._totalItems
if (progressChanged || this._systemStatus !== "Indexing") {
@ -89,9 +95,16 @@ export class CodeIndexStateManager {
let message: string
if (totalFiles > 0 && processedFiles < totalFiles) {
message = `Processing ${processedFiles} / ${totalFiles} ${this._currentItemUnit}. Current: ${
currentFileBasename || "..."
}`
// Extract file information for display
const fileBasename = currentFilePath ? path.basename(currentFilePath) : "..."
const packageDisplay = packageName ? `${packageName}` : ""
const pathDisplay = currentFilePath ? `${currentFilePath}` : ""
if (packageName) {
message = `Processing ${processedFiles} / ${totalFiles} ${this._currentItemUnit}. Package: ${packageDisplay}, File: ${fileBasename}`
} else {
message = `Processing ${processedFiles} / ${totalFiles} ${this._currentItemUnit}. Path: ${pathDisplay}`
}
} else if (totalFiles > 0 && processedFiles === totalFiles) {
message = `Finished processing ${totalFiles} ${this._currentItemUnit} from queue.`
} else {