Skip to content

Commit da160fe

Browse files
committed
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
1 parent f53fd39 commit da160fe

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

src/services/code-index/orchestrator.ts

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export class CodeIndexOrchestrator {
4545
if (totalInBatch > 0 && this.stateManager.state !== "Indexing") {
4646
this.stateManager.setSystemState("Indexing", "Processing file changes...")
4747
}
48-
this.stateManager.reportFileQueueProgress(
49-
processedInBatch,
50-
totalInBatch,
51-
currentFile ? path.basename(currentFile) : undefined,
52-
)
48+
49+
// Extract package name from file path if possible
50+
let packageName = this.extractPackageName(currentFile)
51+
52+
this.stateManager.reportFileQueueProgress(processedInBatch, totalInBatch, currentFile, packageName)
5353
if (processedInBatch === totalInBatch) {
5454
// Covers (N/N) and (0/0)
5555
if (totalInBatch > 0) {
@@ -291,4 +291,40 @@ export class CodeIndexOrchestrator {
291291
public get state(): IndexingState {
292292
return this.stateManager.state
293293
}
294+
295+
/**
296+
* Extracts package name from a file path
297+
* @param filePath Path to extract package name from
298+
* @returns Package name if identified, otherwise undefined
299+
*/
300+
private extractPackageName(filePath?: string): string | undefined {
301+
if (!filePath) return undefined
302+
303+
// Check if path contains node_modules
304+
const nodeModulesMatch = filePath.match(/node_modules[\\/\\\\](@[^\\/\\\\]+[\\/\\\\][^\\/\\\\]+|[^\\/\\\\]+)/)
305+
if (nodeModulesMatch && nodeModulesMatch[1]) {
306+
return nodeModulesMatch[1]
307+
}
308+
309+
// Check if path contains packages directory structure (monorepo)
310+
const packagesMatch = filePath.match(/packages[\\/\\\\]([^\\/\\\\]+)/)
311+
if (packagesMatch && packagesMatch[1]) {
312+
return packagesMatch[1]
313+
}
314+
315+
// Extract npm package name from package.json if close to the file
316+
try {
317+
const dirPath = path.dirname(filePath)
318+
319+
// Check if it's part of the src/ directory structure
320+
const srcMatch = filePath.match(/src[\\/\\\\]([^\\/\\\\]+)/)
321+
if (srcMatch && srcMatch[1]) {
322+
return srcMatch[1]
323+
}
324+
} catch (error) {
325+
// Ignore errors in package name extraction
326+
}
327+
328+
return undefined
329+
}
294330
}

src/services/code-index/state-manager.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as vscode from "vscode"
2+
import * as path from "path"
23

34
export type IndexingState = "Standby" | "Indexing" | "Indexed" | "Error"
45

@@ -78,7 +79,12 @@ export class CodeIndexStateManager {
7879
}
7980
}
8081

81-
public reportFileQueueProgress(processedFiles: number, totalFiles: number, currentFileBasename?: string): void {
82+
public reportFileQueueProgress(
83+
processedFiles: number,
84+
totalFiles: number,
85+
currentFilePath?: string,
86+
packageName?: string,
87+
): void {
8288
const progressChanged = processedFiles !== this._processedItems || totalFiles !== this._totalItems
8389

8490
if (progressChanged || this._systemStatus !== "Indexing") {
@@ -89,9 +95,16 @@ export class CodeIndexStateManager {
8995

9096
let message: string
9197
if (totalFiles > 0 && processedFiles < totalFiles) {
92-
message = `Processing ${processedFiles} / ${totalFiles} ${this._currentItemUnit}. Current: ${
93-
currentFileBasename || "..."
94-
}`
98+
// Extract file information for display
99+
const fileBasename = currentFilePath ? path.basename(currentFilePath) : "..."
100+
const packageDisplay = packageName ? `${packageName}` : ""
101+
const pathDisplay = currentFilePath ? `${currentFilePath}` : ""
102+
103+
if (packageName) {
104+
message = `Processing ${processedFiles} / ${totalFiles} ${this._currentItemUnit}. Package: ${packageDisplay}, File: ${fileBasename}`
105+
} else {
106+
message = `Processing ${processedFiles} / ${totalFiles} ${this._currentItemUnit}. Path: ${pathDisplay}`
107+
}
95108
} else if (totalFiles > 0 && processedFiles === totalFiles) {
96109
message = `Finished processing ${totalFiles} ${this._currentItemUnit} from queue.`
97110
} else {

0 commit comments

Comments
 (0)