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): hide seed message from visible chat messages
Zamil Majdy8c228afb15c7
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 b03d26894d..7515c8328a 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@@ -16,6 +16,7 @@ import { MessagePartRenderer } from "@/app/(platform)/copilot/components/ChatMesimport type { CustomNode } from "../FlowEditor/nodes/CustomNode/CustomNode";import {GraphAction,+ SEED_PROMPT_PREFIX,extractTextFromParts,getActionKey,getNodeDisplayName,@@ -199,12 +200,16 @@ function MessageList({messagesEndRef,isStreaming,}: MessageListProps) {- const visibleMessages = messages.filter(- (msg) =>- Boolean(extractTextFromParts(msg.parts)) ||+ const visibleMessages = messages.filter((msg) => {+ const text = extractTextFromParts(msg.parts);+ if (msg.role === "user" && text.startsWith(SEED_PROMPT_PREFIX))+ return false;+ return (+ Boolean(text) ||(msg.role === "assistant" &&- msg.parts?.some((p) => p.type === "dynamic-tool")),- );+ msg.parts?.some((p) => p.type === "dynamic-tool"))+ );+ });const lastVisibleRole = visibleMessages.at(-1)?.role;const showTypingIndicator =isStreaming && (!lastVisibleRole || lastVisibleRole === "user");diff --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 5730a9ef2f..ccd0590806 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@@ -13,6 +13,7 @@ import {getNodeDisplayName,buildSeedPrompt,extractTextFromParts,+ SEED_PROMPT_PREFIX,} from "../helpers";import type { CustomNode } from "../../FlowEditor/nodes/CustomNode/CustomNode";import type { CustomEdge } from "../../FlowEditor/edges/CustomEdge";@@ -341,6 +342,34 @@ describe("BuilderChatPanel", () => {expect(screen.queryByLabelText("Undo last applied change")).toBeNull();});+ it("hides the seed message from the chat UI", () => {+ mockUseBuilderChatPanel.mockReturnValue(+ makeMockHook({+ isOpen: true,+ messages: [+ {+ id: "seed",+ role: "user",+ parts: [+ {+ type: "text",+ text: `${SEED_PROMPT_PREFIX} Here is the current graph...`,+ },+ ],+ },+ {+ id: "reply",+ role: "assistant",+ parts: [{ type: "text", text: "I see you have an empty graph." }],+ },+ ] as ReturnType<typeof useBuilderChatPanel>["messages"],+ }),+ );+ render(<BuilderChatPanel />);+ expect(screen.queryByText(SEED_PROMPT_PREFIX, { exact: false })).toBeNull();+ expect(screen.getByText("I see you have an empty graph.")).toBeDefined();+ });+it("passes onGraphEdited and isGraphLoaded to useBuilderChatPanel", () => {const onGraphEdited = vi.fn();render(