perf: prevent HomeScreen rerenders during agent streaming
- Add top-level agentLastActivity Map to store (prevents cascade rerenders) - Remove lastActivityAt updates from agent_stream handler (only status changes update timestamps) - useAggregatedAgents now uses agent.lastActivityAt directly - Remove investigation logging from previous debug session The root cause was that every stream event updated agent.lastActivityAt, causing useAggregatedAgents to recalculate, which caused HomeScreen to rerender even when not visible. Now timestamps only update on meaningful events (agent status changes), not individual stream tokens. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -62,14 +62,6 @@ export function AgentStreamView({
|
||||
streamItems,
|
||||
pendingPermissions,
|
||||
}: AgentStreamViewProps) {
|
||||
// INVESTIGATION: Log rerenders
|
||||
const renderCountRef = useRef(0);
|
||||
renderCountRef.current++;
|
||||
console.log(`[INVESTIGATION] AgentStreamView render #${renderCountRef.current}`, {
|
||||
agentId,
|
||||
streamItemsLength: streamItems.length,
|
||||
pendingPermissionsSize: pendingPermissions.size,
|
||||
});
|
||||
const flatListRef = useRef<FlatList<StreamItem>>(null);
|
||||
const insets = useSafeAreaInsets();
|
||||
const [isNearBottom, setIsNearBottom] = useState(true);
|
||||
|
||||
Reference in New Issue
Block a user