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);
|
||||
|
||||
@@ -262,8 +262,6 @@ function AgentFlowModal({
|
||||
}, [serverId, daemonEntries]);
|
||||
const [selectedServerId, setSelectedServerId] = useState<string | null>(initialServerId);
|
||||
|
||||
// [INVESTIGATION] Using useSessionStore directly with granular selectors
|
||||
// Get the complete session state for the selected server
|
||||
const sessionState = useSessionStore((state) =>
|
||||
selectedServerId ? state.sessions[selectedServerId] : undefined
|
||||
);
|
||||
@@ -2155,9 +2153,6 @@ function AgentFlowModal({
|
||||
value={initialPrompt}
|
||||
isLoading={isLoading}
|
||||
onChange={(text) => {
|
||||
console.log('[INVESTIGATION] CreateModal onChange called', {
|
||||
textLength: text.length,
|
||||
});
|
||||
setInitialPrompt(text);
|
||||
setErrorMessage("");
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user