MCPcopy
hub / github.com/CodebuffAI/codebuff / AgentChecklist

Function AgentChecklist

cli/src/components/agent-checklist.tsx:126–350  ·  view source on GitHub ↗
({
  allAgents,
  filteredAgents,
  selectedIds,
  searchQuery,
  focusedIndex,
  onToggleAgent,
  onFocusChange,
  agentDefinitions,
  maxHeight = 8,
})

Source from the content-addressed store, hash-verified

124}
125
126export const AgentChecklist: React.FC<AgentChecklistProps> = ({
127 allAgents,
128 filteredAgents,
129 selectedIds,
130 searchQuery,
131 focusedIndex,
132 onToggleAgent,
133 onFocusChange,
134 agentDefinitions,
135 maxHeight = 8,
136}) => {
137 const theme = useTheme()
138 const scrollRef = useRef<ScrollBoxRenderable | null>(null)
139 const [hoveredIndex, setHoveredIndex] = useState<number | null>(null)
140 const [expandedAgentIds, setExpandedAgentIds] = useState<Set<string>>(new Set())
141 const [hoveredSubagentLink, setHoveredSubagentLink] = useState<string | null>(null)
142
143 // Precompute local agent IDs for dependency calculations
144 const localAgentIds = useMemo(() => new Set(allAgents.map((a) => a.id)), [allAgents])
145
146 // Calculate dependency count for each agent
147 const dependencyCounts = useMemo(() => {
148 const counts = new Map<string, number>()
149 for (const agent of allAgents) {
150 const count = countDependencies(agent.id, agentDefinitions, localAgentIds, new Set())
151 counts.set(agent.id, count)
152 }
153 return counts
154 }, [allAgents, agentDefinitions, localAgentIds])
155
156 // Toggle expansion of an agent's dependencies
157 const toggleExpanded = (agentId: string) => {
158 setExpandedAgentIds((prev) => {
159 const next = new Set(prev)
160 if (next.has(agentId)) {
161 next.delete(agentId)
162 } else {
163 next.add(agentId)
164 }
165 return next
166 })
167 }
168
169 // Scroll focused item into view when focus changes via keyboard
170 useEffect(() => {
171 const scrollbox = scrollRef.current
172 if (!scrollbox || filteredAgents.length === 0) return
173
174 // Calculate approximate position of focused item (1 line per item)
175 const itemHeight = 1
176 const focusedTop = focusedIndex * itemHeight
177 const focusedBottom = focusedTop + itemHeight
178
179 const viewportHeight = scrollbox.viewport.height
180 const currentScroll = scrollbox.scrollTop
181
182 // Scroll up if focused item is above viewport
183 if (focusedTop < currentScroll) {

Callers

nothing calls this directly

Calls 7

useThemeFunction · 0.90
pluralizeFunction · 0.90
countDependenciesFunction · 0.85
buildDepTreeFunction · 0.85
setMethod · 0.80
toggleExpandedFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected