diff --git a/packages/app/src/components/agent-list.tsx b/packages/app/src/components/agent-list.tsx index a5e3289f5..489187368 100644 --- a/packages/app/src/components/agent-list.tsx +++ b/packages/app/src/components/agent-list.tsx @@ -1,4 +1,4 @@ -import { View, Text, Pressable, ScrollView, Modal } from "react-native"; +import { View, Text, Pressable, FlatList, Modal, type ListRenderItem } from "react-native"; import { useCallback, useState } from "react"; import { router } from "expo-router"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; @@ -56,79 +56,94 @@ export function AgentList({ agents }: AgentListProps) { setActionAgent(null); }, [actionAgent, deleteAgent]); - return ( - <> - - {agents.map((agent) => { - const statusColor = getAgentStatusColor(agent.status); - const statusLabel = getAgentStatusLabel(agent.status); - const timeAgo = formatTimeAgo(agent.lastActivityAt); - const providerLabel = getAgentProviderDefinition(agent.provider).label; + const renderAgentItem = useCallback>( + ({ item: agent }) => { + const statusColor = getAgentStatusColor(agent.status); + const statusLabel = getAgentStatusLabel(agent.status); + const timeAgo = formatTimeAgo(agent.lastActivityAt); + const providerLabel = getAgentProviderDefinition(agent.provider).label; - return ( - [ - styles.agentItem, - pressed && styles.agentItemPressed, - ]} - onPress={() => handleAgentPress(agent.serverId, agent.id)} - onLongPress={() => handleAgentLongPress(agent)} - > - - + return ( + [ + styles.agentItem, + pressed && styles.agentItemPressed, + ]} + onPress={() => handleAgentPress(agent.serverId, agent.id)} + onLongPress={() => handleAgentLongPress(agent)} + > + + + + {agent.title || "New Agent"} + + - {agent.title || "New Agent"} + {agent.serverLabel} - + + + + + {agent.cwd} + + + + + - {agent.serverLabel} + {providerLabel} + + + + + + + {statusLabel} - - {agent.cwd} + + {timeAgo} - - - - - - {providerLabel} - - - - - - - {statusLabel} - - - - - - {timeAgo} - - - - ); - })} - + + + ); + }, + [handleAgentLongPress, handleAgentPress, theme.colors.muted, theme.colors.mutedForeground] + ); + + const keyExtractor = useCallback( + (agent: AggregatedAgent) => `${agent.serverId}:${agent.id}`, + [] + ); + + return ( + <> + ({ - container: { + list: { flex: 1, + }, + listContent: { paddingHorizontal: theme.spacing[4], paddingTop: theme.spacing[4], + paddingBottom: theme.spacing[4], }, agentItem: { paddingVertical: theme.spacing[4],