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(copilot): stop chat composer height flicker and placeholder flash on empty session (#14250)
AutoGPTf5280e422dac
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsxindex 6a7804c8bc..54b3a0264e 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatContainer/ChatContainer.tsx@@ -175,7 +175,6 @@ export const ChatContainer = ({// across renders — otherwise every consumer of `guardedOnSend` (the actions// provider, ChatInput, EmptySession, handleRetry) re-renders on each pass.const guardedOnSend = isSendLocked ? NO_OP_SEND : onSend;- const inputLayoutId = "copilot-2-chat-input";// Measure the usage-limit overlay so the messages scroll area can pad its// bottom — otherwise the last message would sit permanently behind the@@ -356,7 +355,6 @@ export const ChatContainer = ({</div>) : (<EmptySession- inputLayoutId={inputLayoutId}isCreatingSession={isCreatingSession}onCreateSession={onCreateSession}onSend={guardedOnSend}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/flag-off.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/flag-off.test.tsxindex 560aa85ffa..beeb6d8127 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/flag-off.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/flag-off.test.tsx@@ -24,7 +24,6 @@ vi.mock("@/services/feature-flags/use-get-flag", async (importActual) => {});const baseProps = {- inputLayoutId: "test-layout",isCreatingSession: false,onCreateSession: vi.fn(),onSend: vi.fn(),diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/main.test.tsxindex 5036b68e7c..b99f1aef2c 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/main.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotHome/__tests__/main.test.tsx@@ -27,7 +27,6 @@ vi.mock("@/services/feature-flags/use-get-flag", async (importActual) => {});const baseProps = {- inputLayoutId: "test-layout",isCreatingSession: false,onCreateSession: vi.fn(),onSend: vi.fn(),diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/EmptySession/EmptySession.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/EmptySession/EmptySession.tsxindex 1cf77c9ac9..fde95aa14f 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/EmptySession/EmptySession.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/EmptySession/EmptySession.tsx@@ -7,7 +7,7 @@ import { useAuth } from "@/lib/auth/hooks/useAuth";import { DotDistortionShader } from "@/components/ui/dot-distortion-shader";import { cn } from "@/lib/utils";import { motion } from "framer-motion";-import { useEffect, useState } from "react";+import { useLayoutEffect, useState } from "react";import {getGreetingName,getInputPlaceholder,@@ -29,7 +29,6 @@ import { RecipientChip } from "../ChatInput/components/RecipientChip";import { useRecipientPicker } from "./useRecipientPicker";interface Props {- inputLayoutId: string;isCreatingSession: boolean;onCreateSession: () => void | Promise<string>;onSend: (@@ -46,7 +45,6 @@ interface Props {}export function EmptySession({- inputLayoutId,isCreatingSession,onSend,isUploadingFiles,@@ -81,7 +79,12 @@ export function EmptySession({getInputPlaceholder(),);- useEffect(() => {+ // Layout effect (not a regular effect) so the width-dependent placeholder+ // is swapped in before the browser paints — otherwise the shorter default+ // string flashes on screen first and visibly reflows into the longer one,+ // which is what caused the placeholder to jump between wrapping above the+ // icons and sitting next to them.+ useLayoutEffect(() => {function handleResize() {setInputPlaceholder(getInputPlaceholder(window.innerWidth));}@@ -155,9 +158,7 @@ export function EmptySession({the greeting page instead of sitting under a bare hero. */}{!intro.isAwaitingGreeting && (<div className={cn("mb-6", intro.isVisible && "max-w-[48rem]")}>- <motion.div- layoutId={inputLayoutId}- transition={{ type: "spring", bounce: 0.2, duration: 0.65 }}+ <divclassName={cn(isBrainDumpEnabled? "overflow-hidden rounded-xlarge border text-left transition-colors duration-300 ease-out"@@ -204,7 +205,7 @@ export function EmptySession({) : undefined}/>- </motion.div>+ </div></div>)}