MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / ProjectPickerScreen

Function ProjectPickerScreen

cli/src/components/project-picker-screen.tsx:59–484  ·  view source on GitHub ↗
({
  onSelectProject,
  initialPath,
})

Source from the content-addressed store, hash-verified

57}
58
59export 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

Callers

nothing calls this directly

Calls 12

useThemeFunction · 0.90
useDirectoryBrowserFunction · 0.90
useSearchableListFunction · 0.90
loadRecentProjectsFunction · 0.90
useTerminalLayoutFunction · 0.90
getLogoBlockColorFunction · 0.90
getLogoAccentColorFunction · 0.90
useSheenAnimationFunction · 0.90
useLogoFunction · 0.90
usePathTabCompletionFunction · 0.90
isPlainEnterKeyFunction · 0.90
formatCwdFunction · 0.90

Tested by

no test coverage detected