Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
40 changes: 3 additions & 37 deletions src/hooks/useFileNavigation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function TestComponent({
onFilesLoaded?: (files: ClaudeFileInfo[]) => void;
}) {
const { files, selectedFile, isLoading, error } = useFileNavigation(
{ recursive: false },
{},
scanner,
);

Expand Down Expand Up @@ -80,20 +80,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: fixture.getPath('test-project'),
recursive: false,
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: fixture.getPath('test-project'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('test-project'),
recursive: false,
}),
};

Expand Down Expand Up @@ -175,20 +172,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: fixture.getPath('accessible'),
recursive: false,
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: fixture.getPath('accessible'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('accessible'),
recursive: false,
}),
};

Expand Down Expand Up @@ -224,20 +218,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: f.getPath('empty-project'),
recursive: false,
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: f.getPath('empty-project'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: f.getPath('empty-project'),
recursive: false,
}),
};

Expand Down Expand Up @@ -274,20 +265,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: fixture.getPath('my-app'),
recursive: false,
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: fixture.getPath('my-app'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('my-app'),
recursive: false,
}),
};

Expand Down Expand Up @@ -329,14 +317,12 @@ if (import.meta.vitest) {
const localFiles = await scanClaudeFiles({
...options,
path: fixture.getPath('project'),
recursive: false,
});

// Scan global files
const globalFiles = await scanClaudeFiles({
...options,
path: fixture.getPath('.claude'),
recursive: false,
});

// Combine results
Expand All @@ -346,14 +332,12 @@ if (import.meta.vitest) {
scanSlashCommands({
...options,
path: fixture.getPath('project'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('project'),
recursive: false,
}),
};

Expand Down Expand Up @@ -388,20 +372,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: fixture.getPath('slash-project'),
recursive: false,
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: fixture.getPath('slash-project'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('slash-project'),
recursive: false,
}),
};

Expand Down Expand Up @@ -435,20 +416,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: fixture.getPath('mixed-project'),
recursive: false,
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: fixture.getPath('mixed-project'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('mixed-project'),
recursive: false,
}),
};

Expand Down Expand Up @@ -480,20 +458,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: fixture.getPath('update-test'),
recursive: false,
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: fixture.getPath('update-test'),
recursive: false,
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('update-test'),
recursive: false,
}),
};

Expand Down Expand Up @@ -536,20 +511,17 @@ if (import.meta.vitest) {
scanClaudeFiles({
...options,
path: fixture.getPath('nested-project'),
recursive: true, // This test specifically tests recursive scanning
}),
scanSlashCommands: (options) =>
scanSlashCommands({
...options,
path: fixture.getPath('nested-project'),
recursive: true, // This test specifically tests recursive scanning
}),
scanSubAgents: async () => [], // No subagents in test
scanSettingsJson: (options) =>
scanSettingsJson({
...options,
path: fixture.getPath('nested-project'),
recursive: true, // This test specifically tests recursive scanning
}),
};

Expand Down Expand Up @@ -628,10 +600,7 @@ if (import.meta.vitest) {

// Create a test component that captures fileGroups
function TestEmptyGroupsComponent({ scanner }: { scanner: FileScanner }) {
const { fileGroups, isLoading, error } = useFileNavigation(
{ recursive: false },
scanner,
);
const { fileGroups, isLoading, error } = useFileNavigation({}, scanner);

React.useEffect(() => {
if (!isLoading) {
Expand Down Expand Up @@ -857,10 +826,7 @@ if (import.meta.vitest) {

// Create a test component that captures fileGroups
function TestGroupOrderComponent({ scanner }: { scanner: FileScanner }) {
const { fileGroups, isLoading, error } = useFileNavigation(
{ recursive: false },
scanner,
);
const { fileGroups, isLoading, error } = useFileNavigation({}, scanner);

React.useEffect(() => {
if (!isLoading) {
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useFileNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export function useFileNavigation(
const [error, setError] = useState<string | undefined>();

// Destructure object dependencies
const { path, recursive = true } = options;
const { path } = options;

useEffect(() => {
// Execute file scan
const scanOptions = { recursive, path };
const scanOptions = { path };
Promise.all([
scanner.scanClaudeFiles(scanOptions),
scanner.scanSlashCommands(scanOptions),
Expand Down Expand Up @@ -166,7 +166,7 @@ export function useFileNavigation(
setError(err.message || 'Failed to scan files');
setIsLoading(false);
});
}, [path, recursive, scanner]);
}, [path, scanner]);

const selectFile = useCallback((file: NavigationFile): void => {
setSelectedFile(file);
Expand Down
3 changes: 1 addition & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export type SubAgentInfo = {

// Scan options
export type ScanOptions = {
readonly path?: string | undefined;
readonly recursive?: boolean | undefined;
readonly path?: string | undefined; // default: HOME directory
readonly type?: ClaudeFileType | undefined;
readonly includeHidden?: boolean | undefined;
};
Expand Down
Loading
Loading