Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,30 @@ describe("FileWatcher", () => {
expect(processedFiles).not.toContain(".hidden/src/components/Button.tsx")
expect(processedFiles).not.toContain("src/components/.hidden/Button.tsx")
})

it("should process files when workspace is under hidden parent directory", async () => {
// Create file watcher with workspace under hidden parent directory
const watcherUnderHidden = new FileWatcher(
"/Users/test/.config/project",
mockContext,
mockCacheManager,
mockEmbedder,
mockVectorStore,
mockIgnoreInstance,
)

await watcherUnderHidden.initialize()

// Simulate file creation in workspace under hidden parent
await mockOnDidCreate({ fsPath: "/Users/test/.config/project/src/file.ts" })

// Wait for batch processing
await new Promise((resolve) => setTimeout(resolve, 600))

// File should be processed, not filtered out
// The key assertion is that upsertPoints was called, meaning the file wasn't filtered
expect(mockVectorStore.upsertPoints).toHaveBeenCalled()
})
})

describe("dispose", () => {
Expand Down
26 changes: 26 additions & 0 deletions src/services/code-index/processors/__tests__/scanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,32 @@ describe("DirectoryScanner", () => {
expect(mockCodeParser.parseFile).toHaveBeenCalledTimes(2)
})

it("should process files when workspace is under hidden parent directory", async () => {
const { listFiles } = await import("../../../glob/list-files")
// Simulate workspace at /Users/test/.root-project
vi.mocked(listFiles).mockResolvedValue([["src/file1.js"], false])

const mockBlocks: any[] = [
{
file_path: "src/file1.js",
content: "test content",
start_line: 1,
end_line: 5,
identifier: "test",
type: "function",
fileHash: "hash",
segmentHash: "segment-hash",
},
]
;(mockCodeParser.parseFile as any).mockResolvedValue(mockBlocks)

const result = await scanner.scanDirectory("/Users/test/.root-project")

// File should be processed, not filtered out
expect(result.stats.processed).toBe(1)
expect(mockCodeParser.parseFile).toHaveBeenCalledWith("src/file1.js", expect.any(Object))
})

it("should process markdown files alongside code files", async () => {
// Create scanner without embedder to test the non-embedding path
const scannerNoEmbeddings = new DirectoryScanner(
Expand Down
7 changes: 5 additions & 2 deletions src/services/code-index/processors/file-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,12 @@ export class FileWatcher implements IFileWatcher {
*/
async processFile(filePath: string): Promise<FileProcessingResult> {
try {
// Calculate relative path for ignore checks
const relativeFilePath = generateRelativeFilePath(filePath, this.workspacePath)

// Check if file is in an ignored directory
if (isPathInIgnoredDirectory(filePath)) {
// Use relative path to avoid filtering out workspaces under hidden parent directories
if (isPathInIgnoredDirectory(relativeFilePath)) {
return {
path: filePath,
status: "skipped" as const,
Expand All @@ -518,7 +522,6 @@ export class FileWatcher implements IFileWatcher {
}

// Check if file should be ignored
const relativeFilePath = generateRelativeFilePath(filePath, this.workspacePath)
if (
!this.ignoreController.validateAccess(filePath) ||
(this.ignoreInstance && this.ignoreInstance.ignores(relativeFilePath))
Expand Down
3 changes: 2 additions & 1 deletion src/services/code-index/processors/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export class DirectoryScanner implements IDirectoryScanner {
const relativeFilePath = generateRelativeFilePath(filePath, scanWorkspace)

// Check if file is in an ignored directory using the shared helper
if (isPathInIgnoredDirectory(filePath)) {
// Use relative path to avoid filtering out workspaces under hidden parent directories
if (isPathInIgnoredDirectory(relativeFilePath)) {
return false
}

Expand Down
Loading