diff --git a/apps/ui/src/components/dialogs/file-browser-dialog.tsx b/apps/ui/src/components/dialogs/file-browser-dialog.tsx index dc9c1c2e..9dae11bb 100644 --- a/apps/ui/src/components/dialogs/file-browser-dialog.tsx +++ b/apps/ui/src/components/dialogs/file-browser-dialog.tsx @@ -1,15 +1,5 @@ -import { useState, useEffect, useRef, useCallback } from 'react'; -import { - FolderOpen, - Folder, - ChevronRight, - Home, - ArrowLeft, - HardDrive, - CornerDownLeft, - Clock, - X, -} from 'lucide-react'; +import { useState, useEffect, useCallback } from 'react'; +import { FolderOpen, Folder, ChevronRight, HardDrive, Clock, X } from 'lucide-react'; import { Dialog, DialogContent, @@ -19,7 +9,7 @@ import { DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; -import { Input } from '@/components/ui/input'; +import { PathInput } from '@/components/ui/path-input'; import { getJSON, setJSON } from '@/lib/storage'; import { getDefaultWorkspaceDirectory, saveLastProjectDirectory } from '@/lib/workspace-config'; @@ -78,7 +68,6 @@ export function FileBrowserDialog({ initialPath, }: FileBrowserDialogProps) { const [currentPath, setCurrentPath] = useState(''); - const [pathInput, setPathInput] = useState(''); const [parentPath, setParentPath] = useState(null); const [directories, setDirectories] = useState([]); const [drives, setDrives] = useState([]); @@ -86,7 +75,6 @@ export function FileBrowserDialog({ const [error, setError] = useState(''); const [warning, setWarning] = useState(''); const [recentFolders, setRecentFolders] = useState([]); - const pathInputRef = useRef(null); // Load recent folders when dialog opens useEffect(() => { @@ -120,7 +108,6 @@ export function FileBrowserDialog({ if (result.success) { setCurrentPath(result.currentPath); - setPathInput(result.currentPath); setParentPath(result.parentPath); setDirectories(result.directories); setDrives(result.drives || []); @@ -142,11 +129,10 @@ export function FileBrowserDialog({ [browseDirectory] ); - // Reset current path when dialog closes + // Reset state when dialog closes useEffect(() => { if (!open) { setCurrentPath(''); - setPathInput(''); setParentPath(null); setDirectories([]); setError(''); @@ -172,9 +158,6 @@ export function FileBrowserDialog({ const pathToUse = initialPath || defaultDir; if (pathToUse) { - // Pre-fill the path input immediately - setPathInput(pathToUse); - // Then browse to that directory browseDirectory(pathToUse); } else { // No default directory, browse home directory @@ -183,7 +166,6 @@ export function FileBrowserDialog({ } catch { // If config fetch fails, try initialPath or fall back to home directory if (initialPath) { - setPathInput(initialPath); browseDirectory(initialPath); } else { browseDirectory(); @@ -199,34 +181,21 @@ export function FileBrowserDialog({ browseDirectory(dir.path); }; - const handleGoToParent = () => { - if (parentPath) { - browseDirectory(parentPath); - } - }; - - const handleGoHome = () => { + const handleGoHome = useCallback(() => { browseDirectory(); - }; + }, [browseDirectory]); + + const handleNavigate = useCallback( + (path: string) => { + browseDirectory(path); + }, + [browseDirectory] + ); const handleSelectDrive = (drivePath: string) => { browseDirectory(drivePath); }; - const handleGoToPath = () => { - const trimmedPath = pathInput.trim(); - if (trimmedPath) { - browseDirectory(trimmedPath); - } - }; - - const handlePathInputKeyDown = (e: React.KeyboardEvent) => { - if (e.key === 'Enter') { - e.preventDefault(); - handleGoToPath(); - } - }; - const handleSelect = useCallback(() => { if (currentPath) { addRecentFolder(currentPath); @@ -275,31 +244,15 @@ export function FileBrowserDialog({
- {/* Direct path input */} -
- setPathInput(e.target.value)} - onKeyDown={handlePathInputKeyDown} - className="flex-1 font-mono text-xs h-8" - data-testid="path-input" - disabled={loading} - /> - -
+ {/* Path navigation */} + {/* Recent folders */} {recentFolders.length > 0 && ( @@ -352,35 +305,8 @@ export function FileBrowserDialog({
)} - {/* Current path breadcrumb */} -
- - {parentPath && ( - - )} -
- {currentPath || 'Loading...'} -
-
- {/* Directory list */} -
+
{loading && (
Loading directories...
@@ -423,8 +349,8 @@ export function FileBrowserDialog({
- Paste a full path above, or click on folders to navigate. Press Enter or click Go to - jump to a path. + Paste a full path above, or click on folders to navigate. Press Enter or click → to jump + to a path.
diff --git a/apps/ui/src/components/ui/breadcrumb.tsx b/apps/ui/src/components/ui/breadcrumb.tsx new file mode 100644 index 00000000..f8f23e56 --- /dev/null +++ b/apps/ui/src/components/ui/breadcrumb.tsx @@ -0,0 +1,102 @@ +import * as React from 'react'; +import { Slot } from '@radix-ui/react-slot'; +import { ChevronRight, MoreHorizontal } from 'lucide-react'; + +import { cn } from '@/lib/utils'; + +function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) { + return