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): wrap panel in CopilotChatActionsProvider to prevent crash
Zamil Majdy9498daca31c9
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsxindex 7515c8328a..0a85de3009 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx@@ -13,6 +13,7 @@ import {import { KeyboardEvent, useEffect, useRef } from "react";import { ToolUIPart } from "ai";import { MessagePartRenderer } from "@/app/(platform)/copilot/components/ChatMessagesContainer/components/MessagePartRenderer";+import { CopilotChatActionsProvider } from "@/app/(platform)/copilot/components/CopilotChatActionsProvider/CopilotChatActionsProvider";import type { CustomNode } from "../FlowEditor/nodes/CustomNode/CustomNode";import {GraphAction,@@ -53,6 +54,7 @@ export function BuilderChatPanel({inputValue,setInputValue,handleSend,+ sendRawMessage,handleKeyDown,isStreaming,canSend,@@ -80,43 +82,45 @@ export function BuilderChatPanel({)}>{isOpen && (- <div- ref={panelRef}- role="complementary"- aria-label="Builder chat panel"- className="pointer-events-auto flex h-[70vh] w-96 max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-2xl"- >- <PanelHeader- onClose={handleToggle}- undoCount={undoStack.length}- onUndo={handleUndoLastAction}- />+ <CopilotChatActionsProvider onSend={sendRawMessage}>+ <div+ ref={panelRef}+ role="complementary"+ aria-label="Builder chat panel"+ className="pointer-events-auto flex h-[70vh] w-96 max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-2xl"+ >+ <PanelHeader+ onClose={handleToggle}+ undoCount={undoStack.length}+ onUndo={handleUndoLastAction}+ />- <MessageList- messages={messages}- isCreatingSession={isCreatingSession}- sessionError={sessionError}- streamError={error}- nodes={nodes}- parsedActions={parsedActions}- appliedActionKeys={appliedActionKeys}- onApplyAction={handleApplyAction}- onRetry={retrySession}- messagesEndRef={messagesEndRef}- isStreaming={isStreaming}- />+ <MessageList+ messages={messages}+ isCreatingSession={isCreatingSession}+ sessionError={sessionError}+ streamError={error}+ nodes={nodes}+ parsedActions={parsedActions}+ appliedActionKeys={appliedActionKeys}+ onApplyAction={handleApplyAction}+ onRetry={retrySession}+ messagesEndRef={messagesEndRef}+ isStreaming={isStreaming}+ />- <PanelInput- value={inputValue}- onChange={setInputValue}- onKeyDown={handleKeyDown}- onSend={handleSend}- onStop={stop}- isStreaming={isStreaming}- isDisabled={!canSend}- textareaRef={textareaRef}- />- </div>+ <PanelInput+ value={inputValue}+ onChange={setInputValue}+ onKeyDown={handleKeyDown}+ onSend={handleSend}+ onStop={stop}+ isStreaming={isStreaming}+ isDisabled={!canSend}+ textareaRef={textareaRef}+ />+ </div>+ </CopilotChatActionsProvider>)}<buttondiff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsxindex ccd0590806..b838588a95 100644--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsx@@ -49,6 +49,7 @@ function makeMockHook(inputValue: "",setInputValue: vi.fn(),handleSend: vi.fn(),+ sendRawMessage: vi.fn(),handleKeyDown: vi.fn(),isStreaming: false,canSend: false,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 23e61b9c2d..b013fd42a5 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@@ -564,6 +564,14 @@ export function useBuilderChatPanel({setUndoStack((prev) => prev.slice(0, -1));}+ // Sends an arbitrary text message directly, bypassing the input field.+ // Used by CopilotChatActionsProvider so tool components (e.g. EditAgentTool)+ // can programmatically send "try again" prompts without touching the textarea.+ function sendRawMessage(text: string) {+ if (!text || !canSend) return;+ sendMessage({ text });+ }+return {isOpen,handleToggle,@@ -584,6 +592,7 @@ export function useBuilderChatPanel({inputValue,setInputValue,handleSend,+ sendRawMessage,handleKeyDown,isStreaming,canSend,