Memoize agent object in AgentPanelBody to prevent WebStreamViewport re-renders on keystroke

This commit is contained in:
Mohamed Boudra
2026-04-12 12:18:51 +07:00
parent 0d340959d7
commit cde10485d4
+13 -10
View File
@@ -483,16 +483,19 @@ function AgentPanelBody({
isPendingCreateForPanel && (!authoritativeStatus || isAuthoritativeBootstrapping); isPendingCreateForPanel && (!authoritativeStatus || isAuthoritativeBootstrapping);
const canFinalizePendingCreate = Boolean(authoritativeStatus) && !isAuthoritativeBootstrapping; const canFinalizePendingCreate = Boolean(authoritativeStatus) && !isAuthoritativeBootstrapping;
const agent: AgentScreenAgent | null = const agent = useMemo<AgentScreenAgent | null>(
agentState.serverId && agentState.id && agentState.status && agentState.cwd () =>
? { agentState.serverId && agentState.id && agentState.status && agentState.cwd
serverId: agentState.serverId, ? {
id: agentState.id, serverId: agentState.serverId,
status: agentState.status, id: agentState.id,
cwd: agentState.cwd, status: agentState.status,
projectPlacement, cwd: agentState.cwd,
} projectPlacement,
: null; }
: null,
[agentState.serverId, agentState.id, agentState.status, agentState.cwd, projectPlacement],
);
const placeholderAgent: AgentScreenAgent | null = useMemo(() => { const placeholderAgent: AgentScreenAgent | null = useMemo(() => {
if (!shouldUseOptimisticStream || !agentId) { if (!shouldUseOptimisticStream || !agentId) {