({
onSelectProject,
initialPath,
})
| 57 | } |
| 58 | |
| 59 | export const ProjectPickerScreen: React.FC<ProjectPickerScreenProps> = ({ |
| 60 | onSelectProject, |
| 61 | initialPath, |
| 62 | }) => { |
| 63 | const theme = useTheme() |
| 64 | const [sheenPosition, setSheenPosition] = useState(0) |
| 65 | |
| 66 | // Directory browsing state and navigation |
| 67 | const { |
| 68 | currentPath, |
| 69 | setCurrentPath, |
| 70 | directories, |
| 71 | expandPath, |
| 72 | tryNavigateToPath, |
| 73 | navigateToDirectory, |
| 74 | } = useDirectoryBrowser({ initialPath }) |
| 75 | |
| 76 | // Convert directories to SelectableListItem format |
| 77 | const directoryItems: SelectableListItem[] = useMemo( |
| 78 | () => |
| 79 | directories.map((entry) => ({ |
| 80 | id: entry.path, |
| 81 | label: entry.name, |
| 82 | icon: entry.isParent ? '📂' : '📁', |
| 83 | accent: entry.isGitRepo, |
| 84 | })), |
| 85 | [directories], |
| 86 | ) |
| 87 | |
| 88 | // Search filtering and focus management |
| 89 | const { |
| 90 | searchQuery, |
| 91 | setSearchQuery, |
| 92 | focusedIndex, |
| 93 | setFocusedIndex, |
| 94 | filteredItems: filteredDirectoryItems, |
| 95 | handleFocusChange, |
| 96 | } = useSearchableList({ |
| 97 | items: directoryItems, |
| 98 | resetKey: currentPath, |
| 99 | }) |
| 100 | |
| 101 | // Load recent projects, excluding the home directory |
| 102 | const recentProjects = useMemo(() => { |
| 103 | const homeDir = os.homedir() |
| 104 | return loadRecentProjects().filter((project) => project.path !== homeDir) |
| 105 | }, []) |
| 106 | |
| 107 | // Use the terminal layout hook for responsive breakpoints |
| 108 | const { terminalWidth, terminalHeight } = useTerminalLayout() |
| 109 | const contentMaxWidth = Math.min( |
| 110 | terminalWidth - LAYOUT.CONTENT_PADDING, |
| 111 | LAYOUT.MAX_CONTENT_WIDTH, |
| 112 | ) |
| 113 | const contentWidth = Math.min(LAYOUT.PREFERRED_CONTENT_WIDTH, contentMaxWidth) |
| 114 | |
| 115 | // Compact mode: remove padding/margins when space is tight |
| 116 | const isCompactMode = terminalHeight < LAYOUT.COMPACT_MODE_THRESHOLD |
nothing calls this directly
no test coverage detected