From ed65756d58ecfa7cabd927fbd10e7bb75ce746b0 Mon Sep 17 00:00:00 2001 From: majdyz Date: Sun, 12 Apr 2026 23:22:08 +0000 Subject: [PATCH] fix(frontend): reset isCreatingSession in retrySession and cap parsedActions Add setIsCreatingSession(false) at the start of retrySession so the spinner is cleared when retrying during an in-flight session creation. Add MAX_PARSED_ACTIONS=100 cap to trim the oldest entries from the accumulated action list, preventing unbounded growth in long conversations. --- .../BuilderChatPanel/useBuilderChatPanel.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts index 0ad7f69e3d..66b9c6f6e4 100644 --- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts +++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts @@ -45,6 +45,7 @@ type SendMessageFn = ReturnType["sendMessage"]; * and re-inserting on access, and evicting the oldest entry when over `MAX_SESSION_CACHE`. */ const MAX_SESSION_CACHE = 50; +const MAX_PARSED_ACTIONS = 100; const graphSessionCache = new Map(); function cacheGetSession(flowID: string): string | undefined { @@ -397,6 +398,16 @@ export function useBuilderChatPanel({ } } lastParsedMessageIndexRef.current = messages.length - 1; + // Cap the accumulated actions so the list doesn't grow unboundedly in + // very long conversations. When over the limit, trim the oldest entries. + if (cache.actions.length > MAX_PARSED_ACTIONS) { + const removed = cache.actions.splice( + 0, + cache.actions.length - MAX_PARSED_ACTIONS, + ); + for (const r of removed) cache.seen.delete(getActionKey(r)); + appendedAny = true; + } if (appendedAny) { // Fresh array reference so consumers re-render with the new actions. setParsedActions([...cache.actions]); @@ -492,6 +503,7 @@ export function useBuilderChatPanel({ // Also evicts the stale cached session so a fresh one is created. // All per-session UI state is reset so the new session starts clean. function retrySession() { + setIsCreatingSession(false); if (flowID) graphSessionCache.delete(flowID); setSessionId(null); setSessionError(false);