AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend/builder): reset hasSentSeedMessageRef in retrySession so seed is sent to new session
Zamil Majdy98f3e0958095
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.tsindex 9c121bc241..398c82ae91 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.ts+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/useBuilderChatPanel.test.ts@@ -856,6 +856,35 @@ describe("useBuilderChatPanel – retrySession", () => {expect(result.current.sessionError).toBe(false);expect(result.current.sessionId).toBe("sess-retry");});++ it("re-sends seed message to new session after retry (hasSentSeedMessageRef is reset)", async () => {+ // First session succeeds and seed is sent+ mockPostV2CreateSession.mockResolvedValueOnce({+ status: 200,+ data: { id: "sess-first" },+ });+ const { result } = renderHook(() =>+ useBuilderChatPanel({ isGraphLoaded: true }),+ );+ await openAndFlush(() => result.current.handleToggle());+ expect(result.current.sessionId).toBe("sess-first");+ expect(mockSendMessage).toHaveBeenCalledOnce();++ // Force a retry: evict cache and set error state manually, then retry+ mockSendMessage.mockClear();+ mockPostV2CreateSession.mockResolvedValueOnce({+ status: 200,+ data: { id: "sess-retry-seed" },+ });+ await act(async () => {+ result.current.retrySession();+ await new Promise<void>((resolve) => setTimeout(resolve, 0));+ });++ // New session obtained; seed message must be sent again to the new session+ expect(result.current.sessionId).toBe("sess-retry-seed");+ expect(mockSendMessage).toHaveBeenCalledOnce();+ });});describe("useBuilderChatPanel – handleSend", () => {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.tsindex b013fd42a5..38f2395676 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@@ -343,11 +343,15 @@ export function useBuilderChatPanel({// Resets session error state so the session-creation effect re-runs on// the next render without toggling the panel closed and back open.// Also evicts the stale cached session so a fresh one is created.+ // hasSentSeedMessageRef is reset so the seed message is re-sent to the+ // new session (it may have been set to true by a previous successful session+ // that was later invalidated without a flowID change).function retrySession() {if (flowID) graphSessionCache.delete(flowID);setSessionId(null);setSessionError(false);isCreatingSessionRef.current = false;+ hasSentSeedMessageRef.current = false;}function handleSend() {