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/copilot): stop the composer flickering between its row and stacked layouts (#14270)
Ubbe17c527d9c39e
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsxindex 790fec2bdb..041c6cc458 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/ChatInput.tsx@@ -39,7 +39,11 @@ import { WorkspaceFilePicker } from "./components/WorkspaceFilePicker/WorkspaceFimport { useCopilotUIStore } from "../../store";import { isTokenDevtoolEnabled } from "../../tokenDevtool/gate";import { TokenDevtoolBadge } from "../TokenDevtoolBadge/TokenDevtoolBadge";-import { getFilesFromClipboard } from "./helpers";+import {+ CARD_ICON_BUTTON_CLASS,+ CARD_SEND_BUTTON_CLASS,+ getFilesFromClipboard,+} from "./helpers";import { useChatInput } from "./useChatInput";import { useChatMentions } from "./useChatMentions";import { useOnboardingMicGlow } from "./useOnboardingMicGlow";@@ -74,6 +78,9 @@ interface Props {hideSubmitWhenEmpty?: boolean;/** Recipient picker chip rendered before the mode chips (new-task state). */recipientPicker?: ReactNode;+ /** Card composer: the text always keeps its own row above the controls,+ * instead of sharing a single pill row until it wraps. Empty state only. */+ stacked?: boolean;}export function ChatInput({@@ -92,6 +99,7 @@ export function ChatInput({sessionId = null,hideSubmitWhenEmpty = false,recipientPicker,+ stacked = false,}: Props) {const { isDryRun, setIsDryRun } = useCopilotUIStore();// Still the CHAT_MODE_OPTION flag, which no longer names what it gates: the@@ -275,7 +283,11 @@ export function ChatInput({keeps the controls pinned to the bottom edge as the textarea grows. */}<InputGroupclassName={cn(- "relative z-10 flex-col overflow-hidden !rounded-[1.75rem] border-zinc-200 shadow-[0_1px_2px_rgba(0,0,0,0.04),0_4px_20px_rgba(0,0,0,0.08)] has-[[data-slot=input-group-control]:focus-visible]:border-zinc-300 has-[[data-slot=input-group-control]:focus-visible]:ring-0",+ "relative z-10 flex-col overflow-hidden !rounded-[2rem] border-zinc-200 shadow-[0_1px_2px_rgba(0,0,0,0.04),0_4px_20px_rgba(0,0,0,0.08)] has-[[data-slot=input-group-control]:focus-visible]:border-zinc-300 has-[[data-slot=input-group-control]:focus-visible]:ring-0",+ // Card composer: a hairline ring and a shallow drop instead of the+ // pill's deep shadow, so it reads as a surface the text sits on.+ stacked &&+ "gap-3 !rounded-3xl border-transparent px-3.5 pb-3.5 pt-3 shadow-[0_0_0_0.5px_rgba(0,0,0,0.08),0_1px_2px_rgba(0,0,0,0.05),0_2px_4px_rgba(0,0,0,0.02)] has-[[data-slot=input-group-control]:focus-visible]:border-transparent",isRecording &&"border-red-400 ring-1 ring-red-400 has-[[data-slot=input-group-control]:focus-visible]:border-red-400 has-[[data-slot=input-group-control]:focus-visible]:ring-red-400",)}@@ -284,22 +296,40 @@ export function ChatInput({attachments={attachments}onRemove={handleRemoveAttachment}isUploading={isUploadingFiles}+ stacked={stacked}/>- <div className="flex w-full flex-wrap items-end">+ <div+ className={cn(+ "flex w-full flex-wrap",+ stacked ? "items-center" : "items-end",+ )}+ ><InputGroupAddonalign="inline-start"- className="order-none gap-1 py-1 pl-1.5"+ className={cn(+ "order-none gap-1 py-1 pl-1.5",+ stacked && "gap-1.5 p-0",+ )}><ComposerPlusMenuonFilesSelected={handleFilesSelected}onUseWorkspaceFile={() => setIsPickerOpen(true)}onClearGuidedPrompt={handleClearGuidedPrompt}disabled={isBusy}+ className={+ stacked+ ? cn(+ CARD_ICON_BUTTON_CLASS,+ "[&[aria-expanded=true]_svg]:rotate-45 [&_svg]:transition-transform [&_svg]:duration-200",+ )+ : undefined+ }/>{recipientPicker}{/* Connection and tier are per-message settings, so they remain- changeable between turns in an existing session. */}- {(!hasSession || !isStreaming) && (+ changeable between turns in an existing session. The card+ composer leaves this to the page's top-right control. */}+ {!stacked && (!hasSession || !isStreaming) && (<ConnectionPicker connectionLocked={hasSession} />)}</InputGroupAddon>@@ -308,7 +338,7 @@ export function ChatInput({<divclassName={cn("relative",- isMultiline ? "order-first w-full" : "min-w-0 flex-1",+ stacked || isMultiline ? "order-first w-full" : "min-w-0 flex-1",)}><PromptInputTextarea@@ -322,6 +352,7 @@ export function ChatInput({disabled={isInputDisabled}placeholder={resolvedPlaceholder}onMultilineChange={setIsMultiline}+ className={stacked ? "px-0.5 py-1" : undefined}/>{isRecording && !value && (<div className="pointer-events-none absolute inset-0 flex items-center justify-center">@@ -334,7 +365,10 @@ export function ChatInput({</div><InputGroupAddonalign="inline-end"- className="order-none ml-auto gap-1 py-1 pr-1.5"+ className={cn(+ "order-none ml-auto gap-1 py-1 pr-1.5",+ stacked && "gap-1.5 p-0",+ )}>{showAdvancedComposerControls && !hasSession && (<DryRunToggleButton@@ -352,6 +386,7 @@ export function ChatInput({isStreaming={isStreaming}disabled={disabled || isTranscribing || isStreaming}highlight={isMicGlowing}+ className={stacked ? CARD_ICON_BUTTON_CLASS : undefined}onClick={() => {dismissGlow();toggleRecording();@@ -390,7 +425,10 @@ export function ChatInput({<TooltipContent side="top">Stop</TooltipContent></Tooltip>) : hideSubmitWhenEmpty && !canSend ? null : (- <PromptInputSubmit disabled={!canSend} />+ <PromptInputSubmit+ disabled={!canSend}+ className={stacked ? CARD_SEND_BUTTON_CLASS : undefined}+ />)}</InputGroupAddon></div>diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputComposerRow.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputComposerRow.test.tsxnew file mode 100644index 0000000000..4e9962177b--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/__tests__/ChatInputComposerRow.test.tsx@@ -0,0 +1,374 @@+import {+ act,+ fireEvent,+ render,+ screen,+} from "@/tests/integrations/test-utils";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { ChatInput } from "../ChatInput";++vi.mock("@/app/api/__generated__/endpoints/chat/chat", () => ({+ postV2CancelSessionTask: vi.fn(),+ // A lone platform connection whose tiers resolve to one model: the picker+ // presents nothing, which keeps these tests about the composer itself.+ useGetV2ListChatConnections: () => ({+ data: {+ status: 200,+ data: {+ offers: [+ {+ offer_id: "platform:deployment",+ provider_family: "autogpt",+ display_name: "AutoGPT Platform",+ auth_method: "deployment",+ credential_id: null,+ backed_by_label: "Your AutoGPT plan",+ description: "New chats are backed by your AutoGPT plan.",+ state: "ready",+ selectable: true,+ is_default: true,+ tiers: [+ {+ tier: "standard",+ label: "Balanced",+ selectable: true,+ display_model: "one-model",+ },+ ],+ limitations: [],+ },+ ],+ },+ },+ isLoading: false,+ isPending: false,+ isError: false,+ }),+}));++vi.mock("@/app/(platform)/copilot/store", () => ({+ useCopilotUIStore: () => ({+ copilotChatMode: "extended_thinking",+ setCopilotChatMode: vi.fn(),+ copilotModePinned: false,+ copilotLlmModel: "standard",+ setCopilotLlmModel: vi.fn(),+ copilotLlmAuth: { authProvider: "platform", credentialId: null },+ setCopilotLlmAuth: vi.fn(),+ isDryRun: false,+ setIsDryRun: vi.fn(),+ initialPrompt: null,+ setInitialPrompt: vi.fn(),+ sentMessageCount: 0,+ notifyMessageSent: vi.fn(),+ }),+}));++vi.mock("@/services/feature-flags/use-get-flag", () => ({+ Flag: {+ CHAT_MODE_OPTION: "CHAT_MODE_OPTION",+ CHAT_WORKSPACE_FILES: "CHAT_WORKSPACE_FILES",+ },+ useGetFlag: () => false,+}));++vi.mock("../useVoiceRecording", () => ({+ useVoiceRecording: () => ({+ isRecording: false,+ isTranscribing: false,+ elapsedTime: 0,+ toggleRecording: vi.fn(),+ handleKeyDown: vi.fn(),+ showMicButton: false,+ isInputDisabled: false,+ audioStream: null,+ }),+}));++vi.mock("../components/ComposerPlusMenu", () => ({+ ComposerPlusMenu: () => null,+}));+vi.mock("../components/FileChips", () => ({+ FileChips: () => null,+}));++// jsdom lays nothing out, so the composer's geometry is played here: the box+// shares a row with the addons (the row minus ADDONS_WIDTH) until the host+// stacks it on its own full-width row, and text wraps once it no longer fits+// the content box at CHAR_WIDTH per character.+//+// The box is `box-sizing: border-box` with horizontal padding, so the two ways+// of reading its width disagree and an inline width means the border box:+// getBoundingClientRect and `style.width` speak border box, getComputedStyle+// speaks content box. Modelling that gap is what makes replaying a content-box+// width as an inline one observable here rather than only in a browser.+const ADDONS_WIDTH = 240;+const CHAR_WIDTH = 10;+const LINE_HEIGHT = 24;+const PADDING = 12;+const PADDING_X = 12;+// The hero composer floors the box at 4.5rem, so scrollHeight reports that+// floor for content that would be shorter — until measureContentHeight lifts+// it for the read.+const HERO_MIN_HEIGHT = 72;++const DEFAULT_ROW_WIDTH = 640;+let rowWidth = DEFAULT_ROW_WIDTH;++const resizeCallbacks: ResizeObserverCallback[] = [];++class ResizeObserverStub {+ constructor(callback: ResizeObserverCallback) {+ resizeCallbacks.push(callback);+ }+ observe() {+ return;+ }+ unobserve() {+ return;+ }+ disconnect() {+ return;+ }+}++function singleRowWidth() {+ return rowWidth - ADDONS_WIDTH;+}++function charsPerLine(width: number) {+ return Math.max(1, Math.floor(width / CHAR_WIDTH));+}++function isStacked(textarea: HTMLTextAreaElement) {+ return textarea.parentElement?.classList.contains("w-full") ?? false;+}++function layoutWidth(textarea: HTMLTextAreaElement) {+ return isStacked(textarea) ? rowWidth : singleRowWidth();+}++// An inline `style.width` sets the border box, so it wins over the layout.+function borderBoxWidth(textarea: HTMLTextAreaElement) {+ const inlineWidth = parseFloat(textarea.style.width);+ return Number.isFinite(inlineWidth) ? inlineWidth : layoutWidth(textarea);+}++function contentBoxWidth(borderBox: number) {+ return borderBox - PADDING_X * 2;+}++function contentWidth(textarea: HTMLTextAreaElement) {+ return contentBoxWidth(borderBoxWidth(textarea));+}++function contentHeight(textarea: HTMLTextAreaElement) {+ const content = textarea.value || textarea.placeholder;+ const limit = charsPerLine(contentWidth(textarea));+ const lines = Math.max(1, Math.ceil(content.length / limit));+ const height = lines * LINE_HEIGHT + PADDING * 2;+ return parseFloat(textarea.style.minHeight) === 0+ ? height+ : Math.max(height, HERO_MIN_HEIGHT);+}++function fakeTextareaStyle(textarea: HTMLTextAreaElement) {+ return {+ lineHeight: `${LINE_HEIGHT}px`,+ paddingTop: `${PADDING}px`,+ paddingBottom: `${PADDING}px`,+ width: `${contentWidth(textarea)}px`,+ } as unknown as CSSStyleDeclaration;+}++// The browser reports the new width after the host re-lays out the row;+// here the test delivers that notification. `contentRect` is the content box,+// which is all the component uses it for: noticing that the width changed.+function reportResize(textarea: HTMLTextAreaElement) {+ act(() => {+ const entry = {+ target: textarea,+ contentRect: { width: contentBoxWidth(layoutWidth(textarea)) },+ } as unknown as ResizeObserverEntry;+ resizeCallbacks.forEach((callback) =>+ callback([entry], {} as ResizeObserver),+ );+ });+}++// Every layout the host puts the composer through, not just the one it lands+// on. A wrong measurement that corrects itself on the next frame still settles+// on the right layout, so the settled state alone cannot tell a fix from the+// blink it was meant to remove; the record of what the row passed through can.+function recordLayouts(textarea: HTMLTextAreaElement) {+ const row = textarea.parentElement as HTMLElement;+ const passedThrough: boolean[] = [];+ const observer = new MutationObserver((records) => {+ for (const record of records) {+ passedThrough.push((record.oldValue ?? "").split(" ").includes("w-full"));+ }+ });+ observer.observe(row, {+ attributes: true,+ attributeFilter: ["class"],+ attributeOldValue: true,+ });+ return {+ // The states it left, plus the one it is in now.+ seen: () => [...passedThrough, isStacked(textarea)],+ stop: () => observer.disconnect(),+ };+}++function renderComposer(placeholder: string) {+ render(<ChatInput onSend={vi.fn()} placeholder={placeholder} />);+ return screen.getByLabelText("Chat message input") as HTMLTextAreaElement;+}++// How many characters fit one line of a row of the given border-box width.+function fitsInRow(borderBox: number) {+ return charsPerLine(contentBoxWidth(borderBox));+}++// Text that wraps in the single row but fits the full-width one: the band the+// composer used to shake in.+function wrapsInRowOnly() {+ return "x".repeat(fitsInRow(singleRowWidth()) + 10);+}++beforeEach(() => {+ rowWidth = DEFAULT_ROW_WIDTH;+ vi.stubGlobal("ResizeObserver", ResizeObserverStub);+ Object.defineProperty(HTMLTextAreaElement.prototype, "scrollHeight", {+ configurable: true,+ get(this: HTMLTextAreaElement) {+ return contentHeight(this);+ },+ });+ Object.defineProperty(+ HTMLTextAreaElement.prototype,+ "getBoundingClientRect",+ {+ configurable: true,+ value: function (this: HTMLTextAreaElement) {+ return { width: borderBoxWidth(this) } as unknown as DOMRect;+ },+ },+ );+ const realGetComputedStyle = window.getComputedStyle.bind(window);+ vi.spyOn(window, "getComputedStyle").mockImplementation((element, pseudo) =>+ element instanceof HTMLTextAreaElement+ ? fakeTextareaStyle(element)+ : realGetComputedStyle(element, pseudo),+ );+});++afterEach(() => {+ resizeCallbacks.length = 0;+ Reflect.deleteProperty(HTMLTextAreaElement.prototype, "scrollHeight");+ Reflect.deleteProperty(+ HTMLTextAreaElement.prototype,+ "getBoundingClientRect",+ );+ vi.restoreAllMocks();+ vi.unstubAllGlobals();+});++describe("ChatInput composer row layout", () => {+ it("stays stacked once text wraps in the row, even though it fits the full width", () => {+ const textarea = renderComposer("Ask");+ expect(isStacked(textarea)).toBe(false);++ fireEvent.change(textarea, { target: { value: wrapsInRowOnly() } });+ expect(isStacked(textarea)).toBe(true);++ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);+ });++ it("returns to the single row once the text fits it again", () => {+ const textarea = renderComposer("Ask");+ fireEvent.change(textarea, { target: { value: wrapsInRowOnly() } });+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);++ fireEvent.change(textarea, {+ target: { value: "x".repeat(fitsInRow(singleRowWidth()) - 10) },+ });+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(false);+ });++ it("keeps the empty hero composer stacked when only its placeholder wraps in the row", () => {+ const textarea = renderComposer(+ "p".repeat(fitsInRow(singleRowWidth()) + 10),+ );+ expect(isStacked(textarea)).toBe(true);++ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);+ });++ it("re-measures the single row when the host row grows while stacked", () => {+ const textarea = renderComposer("Ask");+ const value = wrapsInRowOnly();+ fireEvent.change(textarea, { target: { value } });+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);++ // A side panel closes: the same text now fits the wider single row, so the+ // box must judge itself against that row rather than the remembered one.+ rowWidth = DEFAULT_ROW_WIDTH * 2;+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(false);+ expect(fitsInRow(singleRowWidth())).toBeGreaterThan(value.length);+ });++ it("never measures against a single row wider than the row it now has", async () => {+ const textarea = renderComposer("Ask");+ fireEvent.change(textarea, { target: { value: wrapsInRowOnly() } });+ expect(isStacked(textarea)).toBe(true);++ // The window narrows past what the addons themselves take, so subtracting+ // them from the row leaves nothing: the offset can say nothing about this+ // row, and the remembered width now describes one wider than the whole+ // composer.+ const remembered = singleRowWidth();+ rowWidth = ADDONS_WIDTH - 40;+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);++ // Text that would fit the row the box remembers but wraps in the one it+ // actually has. Judged against the stale width the composer unstacks, then+ // wraps in the real row on the very next measurement and stacks again.+ const value = "x".repeat(fitsInRow(rowWidth) + 4);+ expect(value.length).toBeLessThan(fitsInRow(remembered));++ const layouts = recordLayouts(textarea);+ fireEvent.change(textarea, { target: { value } });+ await act(async () => undefined);+ layouts.stop();++ expect(layouts.seen()).toEqual([true]);+ });++ it("measures the single row at its border-box width", () => {+ const textarea = renderComposer("Ask");+ fireEvent.change(textarea, { target: { value: wrapsInRowOnly() } });+ reportResize(textarea);+ expect(isStacked(textarea)).toBe(true);++ // Text that fits the real single row but not one mistaken for its content+ // box: a content-box width handed back as an inline width loses the box's+ // horizontal padding, so the row is judged PADDING_X * 2 too narrow.+ const fits = fitsInRow(singleRowWidth());+ expect(fits).toBeGreaterThan(fitsInRow(contentBoxWidth(singleRowWidth())));++ fireEvent.change(textarea, { target: { value: "x".repeat(fits) } });+ expect(isStacked(textarea)).toBe(false);+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsxindex 161e5926e2..d922da00a7 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsx@@ -24,6 +24,7 @@ interface Props {onUseWorkspaceFile?: () => void;onClearGuidedPrompt?: () => void;disabled?: boolean;+ className?: string;}export function ComposerPlusMenu({@@ -31,6 +32,7 @@ export function ComposerPlusMenu({onUseWorkspaceFile,onClearGuidedPrompt,disabled,+ className,}: Props) {const {fileInputRef,@@ -61,6 +63,7 @@ export function ComposerPlusMenu({disabled={disabled}className={cn("border-transparent bg-transparent text-black shadow-none hover:border-transparent hover:bg-zinc-100 hover:text-black",+ className,disabled && "opacity-40",)}>diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ChoiceRow.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ChoiceRow.tsxindex 3f3c1cc900..764a988390 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ChoiceRow.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ChoiceRow.tsx@@ -2,11 +2,14 @@import { cn } from "@/lib/utils";import Link from "next/link";-import { LockIcon } from "@hugeicons/core-free-icons";+import { LockIcon, Tick02Icon } from "@hugeicons/core-free-icons";import { Icon } from "@/components/atoms/Icon/Icon";+import { InformationTooltip } from "@/components/molecules/InformationTooltip/InformationTooltip";interface Props {+ /** The mark that identifies the row at a glance — a provider logo, a glyph. */+ leading?: React.ReactNode;title: string;subtitle?: string;notes?: string[];@@ -32,6 +35,7 @@ interface Props {}export function ChoiceRow({+ leading,title,subtitle,notes,@@ -50,57 +54,68 @@ export function ChoiceRow({}return (- <button- type="button"- role="radio"- aria-checked={isSelected}- aria-label={label}- data-offer={offerId}- tabIndex={tabIndex}- onClick={onSelect}+ /* The row is a container rather than the radio itself, so the info mark can+ sit on it without sitting *inside* it: a radio's descendants are+ presentational to assistive technology, and an SVG takes no focus either+ way, so a tooltip nested in the radio was unreachable by keyboard. The+ container carries the hover and focus wash so the row still lights up as+ one thing. */+ <divclassName={cn(- "flex w-full items-start gap-2.5 px-3 py-2 text-left transition-colors",- "focus-visible:bg-muted focus-visible:outline-none",- isSelected ? "bg-muted/60" : "hover:bg-muted/40",+ "flex w-full items-center gap-3 px-3 py-2.5 transition-colors",+ "has-[button:focus-visible]:bg-neutral-50 hover:bg-neutral-50",)}>- <span- aria-hidden- className={cn(- "mt-[3px] flex h-3.5 w-3.5 flex-none items-center justify-center rounded-full border",- isSelected ? "border-primary" : "border-muted-foreground/50",- )}+ <button+ type="button"+ role="radio"+ aria-checked={isSelected}+ aria-label={label}+ data-offer={offerId}+ tabIndex={tabIndex}+ onClick={onSelect}+ className="flex min-w-0 flex-1 items-center gap-3 text-left focus-visible:outline-none">- {isSelected && (- <span className="h-1.5 w-1.5 rounded-full bg-primary" aria-hidden />+ {leading && (+ <span aria-hidden className="flex-none">+ {leading}+ </span>)}- </span>- <span className="flex min-w-0 flex-col">- <span className="flex items-center gap-1.5">- <span className="text-[13px] font-semibold text-foreground">- {title}+ <span className="flex min-w-0 flex-1 flex-col">+ <span className="flex items-center gap-1.5">+ <span className="text-sm font-medium text-zinc-900">{title}</span>+ {badge && (+ <span className="rounded-full bg-green-500/10 px-1.5 py-px text-[10px] font-medium text-green-700">+ {badge}+ </span>+ )}</span>- {badge && (- <span className="rounded-full bg-green-500/10 px-1.5 py-px text-[10px] font-medium text-green-700">- {badge}+ {subtitle && (+ <span className="break-words text-sm leading-snug text-zinc-500">+ {subtitle}</span>)}</span>- {subtitle && (- <span className="break-words text-[11px] leading-snug text-muted-foreground">- {subtitle}- </span>+ </button>+ {/* What applies to a route matters once, when you are weighing it.+ Spelled out on the row it competes with the choice itself, so it+ waits behind the info mark. */}+ {notes && notes.length > 0 && (+ <InformationTooltip description={notes.join("\n\n")} iconSize={22} />+ )}+ {/* The tick alone says which one is live: a row that is not chosen needs+ no marker of its own, and an empty circle beside every option is one+ more thing to read past. */}+ <Icon+ icon={Tick02Icon}+ size={16}+ aria-hidden+ className={cn(+ "flex-none text-primary transition-opacity",+ isSelected ? "opacity-100" : "opacity-0",)}- {notes?.map((note) => (- <span- key={note}- className="mt-0.5 text-[11px] leading-snug text-muted-foreground/80"- >- {note}- </span>- ))}- </span>- </button>+ />+ </div>);}@@ -118,37 +133,35 @@ interface LockedProps {*/function LockedRow({ title, subtitle, notes, lock }: LockedProps) {return (- <div className="flex items-start gap-2.5 px-3 py-2">+ <div className="flex items-start gap-2.5 px-3 py-2.5"><Iconicon={LockIcon}size={14}aria-hidden- className="mt-[3px] flex-none text-muted-foreground/70"+ className="mt-[3px] flex-none text-zinc-400"/><span className="flex min-w-0 flex-col">- <span className="text-[13px] font-semibold text-muted-foreground">- {title}- </span>+ <span className="text-sm font-medium text-zinc-500">{title}</span>{subtitle && (- <span className="break-words text-[11px] leading-snug text-muted-foreground/80">+ <span className="break-words text-sm leading-snug text-zinc-400">{subtitle}</span>)}{notes?.map((note) => (<spankey={note}- className="mt-0.5 text-[11px] leading-snug text-muted-foreground/80"+ className="mt-0.5 text-[11px] leading-snug text-zinc-400">{note}</span>))}- <span className="mt-0.5 text-[11px] leading-snug text-muted-foreground/80">+ <span className="mt-0.5 text-[11px] leading-snug text-zinc-400">{lock.reason}</span>{lock.href && (<Linkhref={lock.href}- className="mt-1 w-fit text-[11px] font-medium text-primary underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"+ className="mt-1 w-fit text-[11px] font-medium text-zinc-900 underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-300">See plans</Link>diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectAccountRow.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectAccountRow.tsxnew file mode 100644index 0000000000..f12139fd37--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectAccountRow.tsx@@ -0,0 +1,50 @@+"use client";++import { PlusSignIcon } from "@hugeicons/core-free-icons";++import { Button } from "@/components/atoms/Button/Button";+import { Icon } from "@/components/atoms/Icon/Icon";+import { LoadingSpinner } from "@/components/atoms/LoadingSpinner/LoadingSpinner";+import { IntegrationLogo } from "@/components/molecules/IntegrationLogo/IntegrationLogo";++interface Props {+ onConnect: () => void;+ isConnecting: boolean;+}++/**+ * The way in for a subscription the user has not linked yet.+ *+ * Without it the picker can only list what already exists, so a user who+ * has never connected ChatGPT sees a control about connections that offers+ * no way to make one, and has to discover Settings to act on it.+ */+export function ConnectAccountRow({ onConnect, isConnecting }: Props) {+ return (+ <div className="flex items-center gap-3 px-3 py-2">+ <IntegrationLogo provider="openai" size={20} />+ {/* The row sits under "Add a connection" and beside the connections it+ would join, so what it is for is already said. A sentence of its own+ would only repeat the section above it. */}+ <span className="min-w-0 flex-1 truncate text-sm font-medium text-zinc-900">+ ChatGPT subscription+ </span>+ <Button+ variant="primary"+ size="small"+ aria-label="Connect a ChatGPT subscription"+ // Not the Button's own `loading`: it keeps the children beside its+ // spinner, and drops the props that carry this button's only name.+ disabled={isConnecting}+ onClick={onConnect}+ className="h-8 w-8 min-w-0 flex-none p-0"+ >+ {isConnecting ? (+ <LoadingSpinner size="small" />+ ) : (+ <Icon icon={PlusSignIcon} size={16} aria-hidden />+ )}+ </Button>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsxindex bc04f28492..4499742e76 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsx@@ -5,22 +5,30 @@ import {PopoverContent,PopoverTrigger,} from "@/components/molecules/Popover/Popover";+import type { AIConnectionOffer } from "@/app/api/__generated__/models/aIConnectionOffer";import {AlertCircleIcon,ArrowDown01Icon,- KeyIcon,+ AiBrain01Icon,+ CloudServerIcon,+ FlashIcon,} from "@hugeicons/core-free-icons";import Link from "next/link";+import { Button } from "@/components/atoms/Button/Button";import { Icon } from "@/components/atoms/Icon/Icon";+import { IntegrationLogo } from "@/components/molecules/IntegrationLogo/IntegrationLogo";import { cn } from "@/lib/utils";import { ChoiceRow } from "./ChoiceRow";+import { ConnectAccountRow } from "./ConnectAccountRow";+import { Swap } from "./Swap";import {isLinkedAccount,isSelectable,offerSubtitle,tierLabel,+ tierModel,tierName,tierLock,tierSummary,@@ -41,6 +49,7 @@ interface Props {* exists would take that away.*/connectionLocked?: boolean;+ className?: string;}/**@@ -48,7 +57,10 @@ interface Props {* within it. Both come from the server-owned connection offer, so the client* decides nothing about routing, billing copy, or which models a tier maps to.*/-export function ConnectionPicker({ connectionLocked = false }: Props) {+export function ConnectionPicker({+ connectionLocked = false,+ className,+}: Props) {const {offers,active,@@ -57,6 +69,9 @@ export function ConnectionPicker({ connectionLocked = false }: Props) {setTier,showTiers,hasConnectionChoice,+ connectChatGPT,+ isConnecting,+ canConnectChatGPT,isLoading,isError,} = useConnectionPicker();@@ -67,7 +82,10 @@ export function ConnectionPicker({ connectionLocked = false }: Props) {return (<spanaria-label="AI connections unavailable"- className="ml-2 inline-flex h-9 items-center gap-1.5 rounded-full border border-destructive/20 bg-destructive/10 px-2.5 text-xs font-medium text-destructive"+ className={cn(+ "ml-2 inline-flex h-9 items-center gap-1.5 rounded-full border border-destructive/20 bg-destructive/10 px-2.5 text-xs font-medium text-destructive",+ className,+ )}><Icon icon={AlertCircleIcon} size={14} /><span className="hidden sm:inline">Connections unavailable</span>@@ -80,7 +98,10 @@ export function ConnectionPicker({ connectionLocked = false }: Props) {<Linkhref="/settings/integrations"aria-label="Set up an AI connection"- className="ml-2 inline-flex h-9 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted/80"+ className={cn(+ "ml-2 inline-flex h-9 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted/80",+ className,+ )}><Icon icon={AlertCircleIcon} size={14} /><span className="hidden sm:inline">Set up AI connection</span>@@ -122,110 +143,147 @@ export function ConnectionPicker({ connectionLocked = false }: Props) {: (active?.display_name ?? "Choose connection");// "ChatGPT · your plan". Spending your own subscription rather than the// platform's is the thing worth noticing before sending, so the chip says- // so and carries the accent that goes with it.+ // so.const triggerLabel =runsOnOwnPlan && !showsTier ? `${label} · your plan` : label;+ // One runnable row is nothing to choose between. A locked-only row is+ // different: the explanation and unlock link are the entire reason the chip+ // remains visible.+ const showsConnections =+ (!connectionLocked || onlyOfferIsLocked) &&+ (offers.length > 1 || onlyOfferIsLocked);return (<Popover><PopoverTrigger asChild>- <button+ <Buttontype="button"+ variant="ghost"+ size="small"+ unmask={false}aria-label={showsTier? `Model tier ${label} — change`: `Runs on ${triggerLabel} — change`}className={cn(- "ml-2 inline-flex h-9 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium shadow-sm transition-colors",- runsOnOwnPlan && !showsTier- ? "border-accent/40 bg-accent/5 text-accent hover:bg-accent/10"- : "border-border bg-background text-foreground hover:bg-muted",+ "ml-2 h-9 min-w-0 gap-1.5 px-2.5 py-1 text-sm",+ className,)}>- {/* The key stands for a credential. Against a tier name it would be- labelling reasoning depth as an account, so it is dropped. */}- {!showsTier && <Icon icon={KeyIcon} size={14} />}- <span className="hidden sm:inline">{triggerLabel}</span>+ {/* The tier the next turn runs at, whichever half of the setting+ the label happens to be naming. It swaps on the same beat as the+ label beside it, so the two read as one change. */}+ <Swap swapKey={tier} className="flex-none">+ <Icon+ icon={tier === "advanced" ? AiBrain01Icon : FlashIcon}+ size={16}+ />+ </Swap>+ <span className="hidden sm:inline">+ <Swap>{triggerLabel}</Swap>+ </span><Iconicon={ArrowDown01Icon}- size={12}+ size={14}className="text-muted-foreground"/>- </button>+ </Button></PopoverTrigger><PopoverContent- align="start"- className="w-[26rem] max-w-[calc(100vw-2rem)] border-border bg-popover p-0 text-popover-foreground"+ align="end"+ className="w-[24rem] max-w-[calc(100vw-2rem)] rounded-2xl border-zinc-200 bg-[#F9F9FA] p-3 pt-4 text-zinc-900 shadow-lg">- {/* One runnable row is nothing to choose between. A locked-only row is- different: the explanation and unlock link are the entire reason- the chip remains visible. */}- {(!connectionLocked || onlyOfferIsLocked) &&- (offers.length > 1 || onlyOfferIsLocked) && (- <>- <SectionLabel>Runs on</SectionLabel>- <div- role="radiogroup"- aria-label="Connection this chat runs on"- onKeyDown={(event) => {- const to = nextRovingValue(+ {showsConnections && (+ <>+ <SectionLabel>Runs on</SectionLabel>+ <div+ role="radiogroup"+ aria-label="Connection this chat runs on"+ // The connections read as plain rows on the sheet: a card around+ // them would frame the choice twice, once here and once around+ // the tiers below.+ className="overflow-hidden rounded-xl"+ onKeyDown={(event) => {+ const to = nextRovingValue(+ connectionOptions,+ active?.offer_id ?? "",+ event.key,+ );+ if (to === null) return;+ event.preventDefault();+ const target = offers.find((o) => o.offer_id === to);+ if (target) chooseConnection(target);+ event.currentTarget+ .querySelector<HTMLElement>(`[data-offer="${to}"]`)+ ?.focus();+ }}+ >+ {offers.map((offer) => (+ <ChoiceRow+ key={offer.offer_id}+ offerId={offer.offer_id}+ tabIndex={rovingTabIndex(connectionOptions,+ { value: offer.offer_id },active?.offer_id ?? "",- event.key,- );- if (to === null) return;- event.preventDefault();- const target = offers.find((o) => o.offer_id === to);- if (target) chooseConnection(target);- event.currentTarget- .querySelector<HTMLElement>(`[data-offer="${to}"]`)- ?.focus();- }}- >- {offers.map((offer) => (- <ChoiceRow- key={offer.offer_id}- offerId={offer.offer_id}- tabIndex={rovingTabIndex(- connectionOptions,- { value: offer.offer_id },- active?.offer_id ?? "",- )}- title={offer.display_name}- subtitle={offerSubtitle(offer)}- badge={isLinkedAccount(offer) ? "Connected" : undefined}- notes={[tierSummary(offer), ...offer.limitations].filter(- Boolean,- )}- isSelected={offer.offer_id === active?.offer_id}- onSelect={() => chooseConnection(offer)}- lock={- offer.lock_reason- ? {- reason: offer.lock_reason,- href: offer.unlock_href ?? null,- }- : undefined- }- />- ))}- </div>- </>- )}+ )}+ leading={<OfferMark offer={offer} />}+ title={offer.display_name}+ subtitle={offerSubtitle(offer)}+ badge={isLinkedAccount(offer) ? "Connected" : undefined}+ // A selectable row's models are named by the tier toggle+ // right below it, so repeating them here only crowds the+ // choice. A locked row has no toggle, so it keeps them.+ notes={+ offer.lock_reason+ ? [tierSummary(offer), ...offer.limitations].filter(+ Boolean,+ )+ : offer.limitations+ }+ isSelected={offer.offer_id === active?.offer_id}+ onSelect={() => chooseConnection(offer)}+ lock={+ offer.lock_reason+ ? {+ reason: offer.lock_reason,+ href: offer.unlock_href ?? null,+ }+ : undefined+ }+ />+ ))}+ </div>+ </>+ )}{showTiers && (<><SectionLabel>Model tier</SectionLabel>- <TierToggle- value={tier}- onSelect={setTier}- segments={TIERS.map((candidate) => ({- tier: candidate,- label: tierLabel(active, candidate),- lock: tierLock(active, candidate),- }))}+ <div className="overflow-hidden rounded-xl border border-neutral-200 bg-white">+ <TierToggle+ value={tier}+ onSelect={setTier}+ segments={TIERS.map((candidate) => ({+ tier: candidate,+ label: tierLabel(active, candidate),+ name: tierName(active, candidate),+ model: tierModel(active, candidate),+ lock: tierLock(active, candidate),+ }))}+ />+ </div>+ </>+ )}++ {canConnectChatGPT && (+ <>+ <SectionLabel>Add a connection</SectionLabel>+ <ConnectAccountRow+ onConnect={connectChatGPT}+ isConnecting={isConnecting}/></>)}@@ -234,9 +292,20 @@ export function ConnectionPicker({ connectionLocked = false }: Props) {);}+/**+ * What a connection is, before its name is read: the provider's own logo where+ * there is one, and the machine it runs on where the route is this deployment.+ */+function OfferMark({ offer }: { offer: AIConnectionOffer }) {+ if (offer.auth_method === "deployment") {+ return <Icon icon={CloudServerIcon} size={20} className="text-zinc-500" />;+ }+ return <IntegrationLogo provider={offer.provider_family} size={20} />;+}+function SectionLabel({ children }: { children: React.ReactNode }) {return (- <p className="px-3 pb-1 pt-3 text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground">+ <p className="px-3 pb-1.5 pt-3 text-[11px] font-medium uppercase tracking-[0.06em] text-zinc-500 first:pt-0">{children}</p>);diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/Swap.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/Swap.tsxnew file mode 100644index 0000000000..3611090770--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/Swap.tsx@@ -0,0 +1,37 @@+"use client";++import { cn } from "@/lib/utils";++import { useSwap } from "./useSwap";++interface Props {+ /** What a swap is measured by. Defaults to the text being shown. */+ swapKey?: string;+ children: React.ReactNode;+ className?: string;+}++/**+ * Content that slides and blurs out when it changes, and its replacement in.+ *+ * Switching connection rewrites several things at once — the chip's label and+ * its glyph, and the model under each tier. Swapped in place they read as a+ * glitch; moving them makes the change legible as one thing replacing another.+ */+export function Swap({ swapKey, children, className }: Props) {+ const { shown, phase } = useSwap(swapKey ?? String(children), children);++ return (+ <span+ className={cn(+ "inline-block transition-[transform,filter,opacity] duration-150 ease-in-out motion-reduce:transition-none",+ phase === "exit" && "-translate-y-1 opacity-0 blur-[2px]",+ phase === "enter" &&+ "translate-y-1 opacity-0 blur-[2px] transition-none",+ className,+ )}+ >+ {shown}+ </span>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/TierToggle.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/TierToggle.tsxindex 2d663e4ea6..3bf116b8d7 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/TierToggle.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/TierToggle.tsx@@ -1,6 +1,11 @@"use client";-import { LockIcon } from "@hugeicons/core-free-icons";+import {+ AiBrain01Icon,+ FlashIcon,+ LockIcon,+ Tick02Icon,+} from "@hugeicons/core-free-icons";import Link from "next/link";import { Icon } from "@/components/atoms/Icon/Icon";@@ -8,11 +13,16 @@ import { cn } from "@/lib/utils";import type { CopilotLlmModel } from "../../../../store";import { nextRovingValue, rovingTabIndex } from "./radioKeys";+import { Swap } from "./Swap";interface Segment {tier: CopilotLlmModel;- /** "Balanced · Claude Sonnet 5" — the tier and the model it resolves to. */+ /** "Balanced · Claude Sonnet 5" — the whole choice, for the accessible name. */label: string;+ /** "Balanced" — the tier on its own, for the row's title line. */+ name?: string;+ /** "Claude Sonnet 5" — the model, on the line under the tier. */+ model?: string | null;lock?: { reason: string; href: string | null };}@@ -23,18 +33,18 @@ interface Props {}/**- * The two tiers side by side, as one control rather than a list of choices.+ * The tiers as a stacked list, matching the connection rows above it.*- * A list reads as "here are some options"; a segmented control reads as "it is- * one of these two", which is the shape of the decision — there is no third- * tier, because absorbing that complexity is what having tiers is for.- *- * Each segment names its model inline. That only fits because the model now- * arrives as a display name rather than a routing slug; while a tier read- * "anthropic/claude-sonnet-5" the label had to wrap onto a second line.+ * A segmented control put the two side by side, which halved the width each+ * tier had to name its model in and made the section read as a different kind+ * of control from the one directly above. Stacked, both sections are the same+ * list of rows, and the tick is the only thing saying which one is live.*/+function tierIcon(tier: CopilotLlmModel) {+ return tier === "advanced" ? AiBrain01Icon : FlashIcon;+}+export function TierToggle({ segments, value, onSelect }: Props) {- const locked = segments.filter((segment) => segment.lock);const options = segments.map((segment) => ({value: segment.tier,disabled: Boolean(segment.lock),@@ -53,57 +63,58 @@ export function TierToggle({ segments, value, onSelect }: Props) {}return (- <div className="mb-3 mt-1 flex flex-col gap-1.5 px-3">- <div- role="radiogroup"- aria-label="Model tier"- onKeyDown={handleKeyDown}- className="flex items-stretch gap-1 rounded-full bg-muted/70 p-1"- >- {segments.map((segment) =>- segment.lock ? (- <LockedSegment key={segment.tier} segment={segment} />- ) : (- <button- key={segment.tier}- type="button"- role="radio"- aria-checked={segment.tier === value}- data-tier={segment.tier}- tabIndex={rovingTabIndex(options, { value: segment.tier }, value)}- onClick={() => onSelect(segment.tier)}+ <div+ role="radiogroup"+ aria-label="Model tier"+ onKeyDown={handleKeyDown}+ className="divide-y divide-neutral-200"+ >+ {segments.map((segment) =>+ segment.lock ? (+ <LockedSegment key={segment.tier} segment={segment} />+ ) : (+ <button+ key={segment.tier}+ type="button"+ role="radio"+ aria-checked={segment.tier === value}+ data-tier={segment.tier}+ tabIndex={rovingTabIndex(options, { value: segment.tier }, value)}+ aria-label={segment.label}+ onClick={() => onSelect(segment.tier)}+ className={cn(+ "flex w-full items-center gap-3 px-3 py-2.5 text-left transition-colors",+ "focus-visible:bg-neutral-50 focus-visible:outline-none",+ )}+ >+ <Icon+ icon={tierIcon(segment.tier)}+ size={18}+ aria-hidden+ className="flex-none text-zinc-500"+ />+ <span className="flex min-w-0 flex-1 flex-col">+ <span className="truncate text-sm font-medium text-zinc-900">+ {segment.name ?? segment.label}+ </span>+ {segment.model && (+ <span className="text-sm leading-snug text-zinc-500">+ <Swap className="max-w-full truncate">{segment.model}</Swap>+ </span>+ )}+ </span>+ <Icon+ icon={Tick02Icon}+ size={16}+ aria-hiddenclassName={cn(- "min-w-0 flex-1 truncate rounded-full px-3 py-1.5 text-[11px] font-medium transition-colors",- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",- segment.tier === value- ? "bg-background text-foreground shadow-sm"- : "text-muted-foreground hover:text-foreground",+ "flex-none text-primary transition-opacity",+ segment.tier === value ? "opacity-100" : "opacity-0",)}- >- {segment.label}- </button>- ),- )}- </div>-- {/* A segment has room for the lock but not for why. Saying only "locked"- would leave the user to guess at a barrier they can actually clear. */}- {locked.map((segment) => (- <p- key={segment.tier}- className="px-1 text-[11px] leading-snug text-muted-foreground/80"- >- {segment.lock?.reason}{" "}- {segment.lock?.href && (- <Link- href={segment.lock.href}- className="font-medium text-accent underline-offset-2 hover:underline"- >- See plans- </Link>- )}- </p>- ))}+ />+ </button>+ ),+ )}</div>);}@@ -111,20 +122,56 @@ export function TierToggle({ segments, value, onSelect }: Props) {/*** A tier the plan excludes. It remains a disabled radio so assistive* technology receives a complete account of the radiogroup, while the line- * below has room to explain the barrier.+ * below the name has room to explain the barrier.*/function LockedSegment({ segment }: { segment: Segment }) {return (- <span- role="radio"- aria-checked={false}- aria-disabled="true"- aria-label={`${segment.label} — ${segment.lock?.reason ?? "unavailable"}`}- tabIndex={-1}- className="flex min-w-0 flex-1 items-center justify-center gap-1 rounded-full px-3 py-1.5 text-[11px] font-medium text-muted-foreground/70"- >- <Icon icon={LockIcon} size={11} aria-hidden className="flex-none" />- <span className="truncate">{segment.label}</span>- </span>+ /* The upgrade link is a sibling of the radio, not a child of it: a radio's+ descendants are presentational to assistive technology, so a link nested+ inside one can lose its link semantics and strand the one action the row+ exists to offer. */+ <div className="flex flex-col px-3 py-2.5">+ <span+ role="radio"+ aria-checked={false}+ aria-disabled="true"+ aria-label={`${segment.label} — ${segment.lock?.reason ?? "unavailable"}`}+ tabIndex={-1}+ className="flex items-start gap-2.5"+ >+ <Icon+ icon={LockIcon}+ size={14}+ aria-hidden+ className="mt-[3px] flex-none text-zinc-400"+ />+ <span className="flex min-w-0 flex-col">+ <span className="truncate text-sm font-medium text-zinc-500">+ {segment.name ?? segment.label}+ </span>+ {segment.model && (+ <span className="text-sm leading-snug text-zinc-400">+ <Swap className="max-w-full truncate">{segment.model}</Swap>+ </span>+ )}+ {/* A row has room for the lock but the name has none for why. Saying+ only "locked" would leave the user to guess at a barrier they can+ actually clear. */}+ <span className="text-[11px] leading-snug text-zinc-400">+ {segment.lock?.reason}+ </span>+ </span>+ </span>+ {segment.lock?.href && (+ <Link+ href={segment.lock.href}+ // Indented past the lock glyph so it lines up under the reason it+ // answers, the way it reads when it follows that sentence inline.+ className="ml-6 mt-1 w-fit text-[11px] font-medium text-zinc-900 underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-300"+ >+ See plans+ </Link>+ )}+ </div>);}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/useConnectionPicker.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/useConnectionPicker.tsindex 3e94ac7ef2..ee52178f81 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/useConnectionPicker.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/useConnectionPicker.ts@@ -2,6 +2,7 @@import { useGetV2ListChatConnections } from "@/app/api/__generated__/endpoints/chat/chat";import type { AIConnectionOffer } from "@/app/api/__generated__/models/aIConnectionOffer";+import { useOAuthConnect } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/useOAuthConnect";import { useCopilotUIStore } from "../../../../store";import {@@ -45,6 +46,13 @@ export function useConnectionPicker() {const active = selected ?? fallback;+ const { connect: connectChatGPT, isPending: isConnecting } = useOAuthConnect({+ provider: "codex",+ onSuccess: () => {+ query.refetch();+ },+ });+function chooseConnection(offer: AIConnectionOffer) {if (!isSelectable(offer)) return;const selection = offerToSelection(offer);@@ -62,6 +70,21 @@ export function useConnectionPicker() {// actually run: a locked offer is listed to explain an absence, so it adds// a row to the popover without adding a decision.hasConnectionChoice: choosable.length > 1,+ connectChatGPT,+ isConnecting,+ // A ChatGPT offer of any kind means the server has already had its say:+ // either it is linked, or it is locked behind a plan and connecting is not+ // the next step. Its absence is the one case where linking is what the+ // user is missing, and the picker is where they are asking about it.+ //+ // No offers at all is not that case. The picker has no popover to put the+ // row in then -- it collapses to a link to Settings, which is both where+ // the user has to go to fix a deployment with no routes at all and a way+ // in for every provider rather than this one.+ canConnectChatGPT:+ query.data?.status === 200 &&+ offers.length > 0 &&+ offers.every((offer) => offer.provider_family !== "openai"),isLoading: query.isLoading,// React Query can retain the last successful offers while a background// refetch fails. Keep that usable snapshot visible; the error state isdiff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/useSwap.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/useSwap.tsnew file mode 100644index 0000000000..41e488cde4--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/useSwap.ts@@ -0,0 +1,70 @@+import { useEffect, useRef, useState } from "react";++/** Matches the duration the exit transition is given in {@link Swap}. */+const SWAP_MS = 150;++function prefersReducedMotion(): boolean {+ if (typeof window === "undefined" || !window.matchMedia) return false;+ return window.matchMedia("(prefers-reduced-motion: reduce)").matches;+}++/**+ * Holds content one beat behind its value so a change can be animated.+ *+ * The old content leaves upward and the replacement arrives from below, which+ * reads as the value being swapped rather than the same spot rewriting itself+ * in place. That needs the outgoing content on screen after the new one has+ * arrived, so what is displayed is state rather than the prop.+ *+ * Keyed by a string because the content may be a node, and nodes cannot be+ * compared: the key is what says a swap has happened.+ */+export function useSwap<T>(key: string, value: T) {+ const [shownKey, setShownKey] = useState(key);+ const [shown, setShown] = useState(value);+ const [phase, setPhase] = useState<"idle" | "exit" | "enter">("idle");+ const timer = useRef<ReturnType<typeof setTimeout> | null>(null);++ useEffect(() => {+ if (key === shownKey) {+ // Back to what is already on screen while its own exit was still+ // running: a second click inside SWAP_MS. The timer was cleared on the+ // way in, so nothing is left to bring the content back, and an exit left+ // standing holds it at opacity 0 until some later swap happens to clear+ // it. There is no longer anything to animate, so it simply stays.+ setPhase((current) => (current === "exit" ? "idle" : current));+ return;+ }+ if (prefersReducedMotion()) {+ setShownKey(key);+ setShown(value);+ return;+ }+ setPhase("exit");+ timer.current = setTimeout(() => {+ setShownKey(key);+ setShown(value);+ setPhase("enter");+ }, SWAP_MS);+ return () => {+ if (timer.current) clearTimeout(timer.current);+ };+ }, [key, shownKey, value]);++ useEffect(() => {+ if (phase !== "enter") return;+ // The entry position has to be painted before the transition back to rest+ // is allowed, or the browser collapses both into a single frame and there+ // is nothing to see. Two frames is what guarantees that paint.+ let inner = 0;+ const outer = requestAnimationFrame(() => {+ inner = requestAnimationFrame(() => setPhase("idle"));+ });+ return () => {+ cancelAnimationFrame(outer);+ cancelAnimationFrame(inner);+ };+ }, [phase]);++ return { shown, phase };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/FileChips.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/FileChips.tsxindex d37c8968b5..f41b326bad 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/FileChips.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/FileChips.tsx@@ -8,6 +8,7 @@ import {} from "../../../helpers/workspaceAttachments";import { Cancel01Icon, Loading03Icon } from "@hugeicons/core-free-icons";import { Icon } from "@/components/atoms/Icon/Icon";+import { cn } from "@/lib/utils";function attachmentMimeType(attachment: Attachment): string {return attachment.kind === "local"@@ -27,13 +28,21 @@ interface Props {attachments: Attachment[];onRemove: (index: number) => void;isUploading?: boolean;+ /** Card composer chips: white with a hairline ring, sitting inside the+ * frame's own padding. */+ stacked?: boolean;}// ease-out so chips settle naturally; kept under 300ms (Emil's timing rules).const EASE_OUT = [0.16, 1, 0.3, 1] as const;const DURATION = 0.2;-export function FileChips({ attachments, onRemove, isUploading }: Props) {+export function FileChips({+ attachments,+ onRemove,+ isUploading,+ stacked = false,+}: Props) {const reduceMotion = useReducedMotion();return (@@ -47,9 +56,17 @@ export function FileChips({ attachments, onRemove, isUploading }: Props) {}exit={reduceMotion ? { opacity: 0 } : { opacity: 0, height: 0 }}transition={{ duration: DURATION, ease: EASE_OUT }}- className="w-full overflow-hidden"+ // The pull towards the textarea belongs on the clipping box, not+ // inside it: a negative bottom margin on the row would shrink this+ // wrapper's auto height by the same amount and crop the chips.+ className={cn("w-full overflow-hidden", stacked && "-mb-1.5")}>- <div className="flex w-full flex-wrap gap-2 px-3 pb-2 pt-2">+ <div+ className={cn(+ "flex w-full flex-wrap gap-2 px-3 pb-2 pt-2",+ stacked && "gap-1.5 p-0",+ )}+ ><AnimatePresence initial={false} mode="popLayout">{attachments.map((attachment, index) => {const name = attachmentName(attachment);@@ -85,11 +102,18 @@ export function FileChips({ attachments, onRemove, isUploading }: Props) {}transition={{ duration: DURATION, ease: EASE_OUT }}style={{ willChange: "transform, opacity, filter" }}- className="inline-flex items-center gap-1 rounded-full bg-zinc-100 px-3 py-1 text-sm text-zinc-700"+ className={cn(+ "inline-flex items-center gap-1 rounded-full bg-zinc-100 px-3 py-1 text-sm text-zinc-700",+ stacked &&+ "gap-1.5 border border-zinc-200 bg-white py-[3px] pl-2 pr-1.5 text-xs text-zinc-900 shadow-[0_1px_2px_rgba(0,0,0,0.02)]",+ )}><Iconicon={fileIcon}- className="h-3.5 w-3.5 shrink-0 text-zinc-900"+ className={cn(+ "h-3.5 w-3.5 shrink-0 text-zinc-900",+ stacked && "text-zinc-400",+ )}/><span className="max-w-[160px] truncate">{name}</span>{showSpinner ? (@@ -102,7 +126,10 @@ export function FileChips({ attachments, onRemove, isUploading }: Props) {type="button"aria-label={`Remove ${name}`}onClick={() => onRemove(index)}- className="ml-0.5 rounded-full p-0.5 text-zinc-400 transition-colors hover:bg-zinc-200 hover:text-zinc-600"+ className={cn(+ "ml-0.5 rounded-full p-0.5 text-zinc-400 transition-colors hover:bg-zinc-200 hover:text-zinc-600",+ stacked && "hover:bg-zinc-100 hover:text-zinc-900",+ )}><Icon icon={Cancel01Icon} className="h-3 w-3" /></button>diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecipientChip.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecipientChip.tsxindex 071ae24132..cd7bc012f0 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecipientChip.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecipientChip.tsx@@ -33,7 +33,7 @@ interface Props {}const CHIP_CLASSNAME =- "ml-2 inline-flex h-9 items-center gap-1.5 rounded-full border border-neutral-200 bg-white px-2.5 text-xs font-medium text-zinc-700 shadow-sm";+ "ml-2 inline-flex h-9 items-center gap-1.5 rounded-2xl border border-neutral-200 bg-white pl-1.5 pr-2 text-sm font-medium text-zinc-700 shadow-sm";export function RecipientChip({recipient,@@ -48,7 +48,7 @@ export function RecipientChip({aria-label="Loading recipient"className={CHIP_CLASSNAME}>- <Skeleton className="h-5 w-5 rounded-full" />+ <Skeleton className="h-6 w-6 rounded-full" /><Skeleton className="h-3 w-16" /></div>);@@ -62,12 +62,15 @@ export function RecipientChip({aria-label={`Sending to ${recipient.name} — change recipient`}className={cn(CHIP_CLASSNAME,- "transition-colors hover:bg-neutral-50",+ "group transition-colors hover:bg-neutral-50",)}><RecipientAvatar option={recipient} />{recipient.name}- <Icon icon={ArrowDown01Icon} className="size-3 text-zinc-400" />+ <Icon+ icon={ArrowDown01Icon}+ className="size-3.5 text-zinc-600 transition-transform duration-150 group-data-[state=open]:rotate-180"+ /></button></DropdownMenuTrigger><DropdownMenuContent align="start">@@ -88,11 +91,11 @@ export function RecipientChip({function RecipientAvatar({ option }: { option: RecipientOption }) {return (- <Avatar className="h-5 w-5">+ <Avatar className="h-6 w-6">{option.avatarUrl ? (<AvatarImage src={option.avatarUrl} alt={option.name} />) : null}- <AvatarFallback className="text-[9px]">+ <AvatarFallback className="text-[10px]">{option.name.slice(0, 2)}</AvatarFallback></Avatar>diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecordingButton.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecordingButton.tsxindex c86ec1418a..e596c207a9 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecordingButton.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/RecordingButton.tsx@@ -15,6 +15,7 @@ interface Props {// dump: AutoPilot's intro invites them to record, so the button it// points at has to be findable.highlight?: boolean;+ className?: string;}export function RecordingButton({@@ -24,6 +25,7 @@ export function RecordingButton({disabled,onClick,highlight = false,+ className,}: Props) {return (<Button@@ -35,6 +37,7 @@ export function RecordingButton({onClick={onClick}className={cn("border-transparent bg-transparent text-black shadow-none hover:border-transparent hover:bg-zinc-100 hover:text-black",+ className,disabled && "opacity-40",isRecording && "animate-pulse bg-red-500 text-white hover:bg-red-600",isTranscribing && "bg-zinc-100 text-zinc-400",diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ConnectionPicker.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ConnectionPicker.test.tsxindex 55477fba7c..76d95871a4 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ConnectionPicker.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ConnectionPicker.test.tsx@@ -325,14 +325,25 @@ describe("ConnectionPicker", () => {});it("surfaces a limitation the user can actually hit", async () => {+ // It waits behind the row's info mark rather than spelling itself out+ // beside the choice, but it is still reachable without leaving the popover.mockOffers([offer(), chatgpt()]);render(<ConnectionPicker />);await userEvent.click(await openPicker());+ const rows = await screen.findByRole("radiogroup", {+ name: "Connection this chat runs on",+ });+ await userEvent.hover(within(rows).getByLabelText("More information"));+expect(- await screen.findByText(/builder's chat panel always runs on AutoGPT/),- ).toBeDefined();+ (+ await screen.findAllByText(+ /builder's chat panel always runs on AutoGPT/,+ )+ ).length,+ ).toBeGreaterThan(0);});it("stays out of the way when there is nothing to choose", async () => {@@ -513,16 +524,20 @@ describe("ConnectionPicker", () => {expect(useCopilotUIStore.getState().copilotLlmAuth).toBeNull();});- it("names both models on a connection before you switch to it", async () => {- // Otherwise you have to select a connection to discover what it runs,- // which is the wrong order.+ it("leaves the models to the tier toggle on a selectable connection", async () => {+ // The toggle names them a few pixels below, so repeating them per row only+ // crowds the choice the rows exist to present.mockOffers([offer(), chatgpt()]);render(<ConnectionPicker />);await userEvent.click(await openPicker());+ await screen.findByRole("radio", { name: /AutoGPT Platform/ });expect(- await screen.findByText("Balanced: sonnet-5 · Advanced: opus-5"),+ screen.queryByText("Balanced: sonnet-5 · Advanced: opus-5"),+ ).toBeNull();+ expect(+ screen.getByRole("radio", { name: "Balanced \u00b7 sonnet-5" }),).toBeDefined();});@@ -573,6 +588,87 @@ describe("ConnectionPicker", () => {expect(within(tierGroup).getAllByRole("radio")).toHaveLength(2);});+ it("offers to link ChatGPT when the user has no ChatGPT at all", async () => {+ // Otherwise the one control about connections cannot make one, and the+ // user has to find Settings to act on what they are already looking at.+ mockOffers([offer()]);++ render(<ConnectionPicker />);+ await userEvent.click(await openPicker());++ expect(+ await screen.findByRole("button", {+ name: /Connect a ChatGPT subscription/,+ }),+ ).toBeDefined();+ });++ it("lets a keyboard user read a connection's limitations", async () => {+ // The mark is a real button rather than the icon itself: bound to an SVG+ // the tooltip opened on hover only, so the notes it holds were reachable+ // with a mouse and by no other means.+ mockOffers([offer(), chatgpt()]);++ render(<ConnectionPicker />);+ await userEvent.click(await openPicker());++ const rows = await screen.findByRole("radiogroup", {+ name: "Connection this chat runs on",+ });+ within(rows).getByRole("button", { name: "More information" }).focus();++ expect(+ (+ await screen.findAllByText(+ /builder's chat panel always runs on AutoGPT/,+ )+ ).length,+ ).toBeGreaterThan(0);+ });++ it("sends a user with no connections at all to Settings", async () => {+ // A successful response with nothing in it leaves no popover to hang a+ // connect row on, and no routes at all is a bigger problem than an+ // unlinked ChatGPT, so the way out is the whole control.+ mockOffers([]);++ render(<ConnectionPicker />);++ expect(+ await screen.findByLabelText("Set up an AI connection"),+ ).toBeDefined();+ expect(+ screen.queryByRole("button", { name: /Connect a ChatGPT subscription/ }),+ ).toBeNull();+ });++ it("does not offer to link a ChatGPT the plan does not include", async () => {+ // The locked row already says what the next step is, and it is buying a+ // plan rather than signing in — an invitation to connect would send the+ // user into a flow the server can only refuse.+ mockOffers([offer(), locked()]);++ render(<ConnectionPicker />);+ await userEvent.click(await openPicker());+ await screen.findByText("A Max plan or higher is required to use ChatGPT.");++ expect(+ screen.queryByRole("button", { name: /Connect a ChatGPT subscription/ }),+ ).toBeNull();+ });++ it("does not offer to link a ChatGPT that is already linked", async () => {+ mockOffers([offer(), chatgpt()]);++ render(<ConnectionPicker />);+ await userEvent.click(await openPicker());+ await screen.findByRole("radio", { name: /ChatGPT/ });++ expect(+ screen.queryByRole("button", { name: /Connect a ChatGPT subscription/ }),+ ).toBeNull();+ });+it("reports a failure rather than inventing a connection", async () => {server.use(getGetV2ListChatConnectionsMockHandler401());@@ -643,15 +739,17 @@ describe("ConnectionPicker", () => {expect(screen.getByText("ChatGPT")).toBeDefined();});- it("drops the key icon when the chip names a tier", async () => {- // A key stands for a credential; against "Balanced" it would be labelling- // reasoning depth as an account.+ it("marks the chip with the tier it will run, whatever it is labelled", async () => {+ // The chip names either the connection or the tier depending on what is+ // still open, but the tier applies to the next turn either way, so its+ // glyph is on the chip in both. A key was once here instead, which against+ // "Balanced" labelled reasoning depth as an account.mockOffers([chatgpt({ is_default: true })]);render(<ConnectionPicker />);const trigger = await screen.findByRole("button", { name: /Model tier/ });- // One icon left: the dropdown chevron.- expect(trigger.querySelectorAll("svg")).toHaveLength(1);+ // The tier glyph and the dropdown chevron.+ expect(trigger.querySelectorAll("svg")).toHaveLength(2);});});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/Swap.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/Swap.test.tsxnew file mode 100644index 0000000000..7793853ece--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/Swap.test.tsx@@ -0,0 +1,51 @@+import { act, render, screen } from "@/tests/integrations/test-utils";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import { Swap } from "../ConnectionPicker/Swap";++// Matches SWAP_MS in useSwap.+const SWAP_MS = 150;++function isHidden(element: HTMLElement) {+ return element.className.includes("opacity-0");+}++beforeEach(() => {+ vi.useFakeTimers();+});++afterEach(() => {+ vi.useRealTimers();+});++describe("Swap", () => {+ it("leaves nothing faded out when the value comes back mid-swap", () => {+ // Two clicks inside the exit's 150ms -- advanced, then straight back to+ // standard. The exit is cancelled with its timer, so nothing is left to+ // return the content to rest, and an exit left standing holds it invisible+ // until some later swap happens to clear it.+ const { rerender } = render(<Swap swapKey="standard">Balanced</Swap>);+ const swap = screen.getByText("Balanced");+ expect(isHidden(swap)).toBe(false);++ rerender(<Swap swapKey="advanced">Advanced</Swap>);+ expect(isHidden(swap)).toBe(true);++ rerender(<Swap swapKey="standard">Balanced</Swap>);+ expect(isHidden(swap)).toBe(false);++ // And the cancelled swap does not land late.+ act(() => vi.advanceTimersByTime(SWAP_MS * 2));+ expect(screen.getByText("Balanced")).toBeDefined();+ expect(isHidden(swap)).toBe(false);+ });++ it("still swaps content once the exit has run", () => {+ const { rerender } = render(<Swap swapKey="standard">Balanced</Swap>);++ rerender(<Swap swapKey="advanced">Advanced</Swap>);+ act(() => vi.advanceTimersByTime(SWAP_MS));++ expect(screen.getByText("Advanced")).toBeDefined();+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/TierToggle.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/TierToggle.test.tsxindex fa61b5d561..c6e5c764a6 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/TierToggle.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/TierToggle.test.tsx@@ -7,10 +7,17 @@ it("exposes a locked tier as a disabled member of the radio group", () => {render(<TierTogglesegments={[- { tier: "standard", label: "Balanced · Sonnet" },+ {+ tier: "standard",+ label: "Balanced · Sonnet",+ name: "Balanced",+ model: "Sonnet",+ },{tier: "advanced",label: "Advanced · Opus",+ name: "Advanced",+ model: "Opus",lock: { reason: "Upgrade required", href: "/profile" },},]}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.tsindex 08d69898d9..6fc45e8036 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/helpers.ts@@ -31,3 +31,9 @@ export function formatElapsedTime(ms: number): string {const remainingSeconds = seconds % 60;return `${minutes}:${remainingSeconds.toString().padStart(2, "0")}`;}++export const CARD_ICON_BUTTON_CLASS =+ "size-9 rounded-full border-transparent bg-zinc-950/[0.06] p-0 text-zinc-900 shadow-none transition-[background-color,transform] hover:border-transparent hover:bg-zinc-950/10 hover:text-zinc-900 active:scale-[0.98] aria-expanded:bg-zinc-950/[0.12]";++export const CARD_SEND_BUTTON_CLASS =+ "size-9 rounded-full border-transparent bg-zinc-950 text-white transition-[background-color,transform] hover:border-transparent hover:bg-zinc-800 active:scale-[0.98] disabled:border-transparent disabled:bg-zinc-950/[0.06] disabled:text-zinc-400";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 fde95aa14f..48714afdf2 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@@ -26,6 +26,7 @@ import { GreetingLoader } from "./components/GreetingLoader";import { ExpertKickoffLoader } from "./components/ExpertKickoffLoader/ExpertKickoffLoader";import { CopilotHome } from "../CopilotHome/CopilotHome";import { RecipientChip } from "../ChatInput/components/RecipientChip";+import { ConnectionPicker } from "../ChatInput/components/ConnectionPicker/ConnectionPicker";import { useRecipientPicker } from "./useRecipientPicker";interface Props {@@ -119,6 +120,11 @@ export function EmptySession({isOpen={intro.isWelcomeOpen}onClose={intro.closeWelcome}/>+ {/* Which connection the new chat runs on, kept out of the composer and+ in the page corner, level with the inset header's controls. */}+ <div className="absolute right-3 top-3 z-30 empty:hidden">+ <ConnectionPicker className="ml-0" />+ </div><motion.divclassName={cn("relative z-10 w-full max-w-[52rem] text-center",@@ -161,18 +167,20 @@ export function EmptySession({<divclassName={cn(isBrainDumpEnabled- ? "overflow-hidden rounded-xlarge border text-left transition-colors duration-300 ease-out"+ ? "text-left transition-colors duration-300 ease-out": "w-full px-2",// The greeting's prompt card bleeds 1.25rem past the text// (-mx-5); the composer stretches the same amount so their- // borders line up. The regular hero keeps it centered.+ // borders line up. The regular hero keeps it centered, and+ // drops the card chrome so the composer pill is the only+ // outline on screen.isBrainDumpEnabled &&(intro.isVisible- ? "-mx-5 max-w-[50.5rem]"+ ? "-mx-5 max-w-[50.5rem] overflow-hidden rounded-xlarge border": "mx-auto w-full max-w-[42rem]"),)}style={- isBrainDumpEnabled+ isBrainDumpEnabled && intro.isVisible? {borderColor: "#e4e4e7",boxShadow: "0 2px 8px rgba(0,0,0,0.04)",@@ -182,9 +190,9 @@ export function EmptySession({><ChatInputinputId="chat-input-empty"+ stackedonSend={onSend}disabled={isComposerDisabled}- hideSubmitWhenEmpty={Boolean(isBrainDumpEnabled)}isUploadingFiles={isUploadingFiles}placeholder={inputPlaceholder}className={diff --git a/autogpt_platform/frontend/src/components/ai-elements/prompt-input.tsx b/autogpt_platform/frontend/src/components/ai-elements/prompt-input.tsxindex ba4c8b0544..9c1c35a6da 100644--- a/autogpt_platform/frontend/src/components/ai-elements/prompt-input.tsx+++ b/autogpt_platform/frontend/src/components/ai-elements/prompt-input.tsx@@ -98,10 +98,10 @@ export function PromptInput({export type PromptInputTextareaProps = ComponentProps<typeof InputGroupTextarea> & {- /** Reports whether the content now spans more than one line, so a host can- * switch between single-row and stacked composer layouts. Derived from the- * box's own line-height rather than a shared pixel constant, which cannot- * survive hosts that restyle the textarea. */+ /** Reports whether the content needs more than one line of the host's+ * single-row layout, so the host can switch to a stacked one. Derived from+ * the box's own line-height rather than a shared pixel constant, which+ * cannot survive hosts that restyle the textarea. */onMultilineChange?: (isMultiline: boolean) => void;};@@ -119,6 +119,19 @@ function isWrapped(el: HTMLTextAreaElement, contentHeight: number): boolean {return contentHeight > lineHeight + padding + 1;}+/** scrollHeight of the content alone, leaving the box at height:auto. A host+ * min-height floors scrollHeight (the hero composer sets 4.5rem), so an empty+ * box would report its minimum and read as already wrapped; the floor is+ * lifted for the read and handed back. */+function measureContentHeight(el: HTMLTextAreaElement): number {+ const ownMinHeight = el.style.minHeight;+ el.style.height = "auto";+ el.style.minHeight = "0";+ const contentHeight = el.scrollHeight;+ el.style.minHeight = ownMinHeight;+ return contentHeight;+}+export function PromptInputTextarea({onKeyDown,onChange,@@ -134,18 +147,70 @@ export function PromptInputTextarea({// still reaching the latest callback.const onMultilineChangeRef = useRef(onMultilineChange);onMultilineChangeRef.current = onMultilineChange;+ // Wrapping is judged at the width the box has in the host's single row,+ // remembered from the last time it sat there. Judging it at whatever width+ // the box has right now lets the layout argue with itself: text that wraps+ // in the narrow row but fits the full-width one would flip the host between+ // the two layouts on every frame.+ const isMultilineRef = useRef(false);+ const singleRowWidthRef = useRef<number | null>(null);+ // How much of the row the host's addons take beside the box, learned the+ // first time the box is measured while stacked.+ const addonsWidthRef = useRef<number | null>(null);function autoResize(el: HTMLTextAreaElement) {- el.style.height = "auto";- // A host min-height floors scrollHeight (the hero composer sets 4.5rem),- // so an empty box would report its minimum and read as already wrapped.- // Measure the content with the floor lifted, then hand the box back.- const ownMinHeight = el.style.minHeight;- el.style.minHeight = "0";- const contentHeight = el.scrollHeight;- el.style.minHeight = ownMinHeight;+ const contentHeight = measureContentHeight(el);el.style.height = `${contentHeight}px`;- onMultilineChangeRef.current?.(isWrapped(el, contentHeight));++ // Border-box width, because that is what handing the number back as an+ // inline width means under `box-sizing: border-box`. `getComputedStyle`+ // reports the content box, so replaying it would silently drop the box's+ // horizontal padding and judge wrapping in a row narrower than the real+ // one. A zero width (an unmounted or collapsed row) is no measurement at+ // all: caching it would pin every later check to a row that always wraps.+ const width = el.getBoundingClientRect().width;+ const rememberedWidth = singleRowWidthRef.current;+ let wrapped: boolean;+ if (isMultilineRef.current && rememberedWidth !== null) {+ // The row itself changes while the box is stacked — a panel opening, the+ // window resizing — so the remembered width is only a starting point:+ // once the addon offset is known, the box's current full-row width gives+ // back the single-row width it would have now. Judging against the width+ // it had when it last sat in the row would leave it stacked over text+ // that now fits, or unstack it into a row it no longer fits.+ if (width > 0) {+ let singleRow = rememberedWidth;+ if (addonsWidthRef.current === null) {+ const addonsWidth = width - rememberedWidth;+ if (addonsWidth > 0) addonsWidthRef.current = addonsWidth;+ } else {+ const candidate = width - addonsWidthRef.current;+ if (candidate > 0) singleRow = candidate;+ }+ // The single row sits inside the full row, so it can never be the+ // wider of the two. Once the row has narrowed past what the addons+ // take, neither branch above can say anything, and the remembered+ // width describes a row the composer no longer has -- measuring there+ // would call text that now wraps a fit. The full row is the most the+ // box can know then.+ singleRowWidthRef.current = Math.min(singleRow, width);+ }+ const ownWidth = el.style.width;+ el.style.width = `${singleRowWidthRef.current}px`;+ wrapped = isWrapped(el, measureContentHeight(el));+ el.style.width = ownWidth;+ el.style.height = `${contentHeight}px`;+ } else {+ singleRowWidthRef.current = width > 0 ? width : null;+ // Measured from the row itself, so the offset is re-learned on the next+ // stack rather than carried over from an addon row that has since+ // changed (the connection picker hides while a turn is streaming).+ addonsWidthRef.current = null;+ wrapped = isWrapped(el, contentHeight);+ }+ if (wrapped === isMultilineRef.current) return;+ isMultilineRef.current = wrapped;+ onMultilineChangeRef.current?.(wrapped);}// Resize when value changes externally (e.g. a guided prompt dropped in,diff --git a/autogpt_platform/frontend/src/components/molecules/InformationTooltip/InformationTooltip.tsx b/autogpt_platform/frontend/src/components/molecules/InformationTooltip/InformationTooltip.tsxindex 36184f08c4..ed01d71113 100644--- a/autogpt_platform/frontend/src/components/molecules/InformationTooltip/InformationTooltip.tsx+++ b/autogpt_platform/frontend/src/components/molecules/InformationTooltip/InformationTooltip.tsx@@ -19,10 +19,19 @@ export function InformationTooltip({ description, iconSize = 24 }: Props) {<TooltipProvider delayDuration={400}><Tooltip><TooltipTrigger asChild>- <Info- className="rounded-full p-1 hover:bg-slate-50"- size={iconSize}- />+ {/* A native button, because an SVG cannot take focus: bound straight+ to the icon, the tooltip opened on hover only and a keyboard user+ had no way to read what it holds. Inside a <label> a click would+ be forwarded to the labelled control, which is not what pressing+ an info mark asks for. */}+ <button+ type="button"+ aria-label="More information"+ onClick={(event) => event.preventDefault()}+ className="inline-flex flex-none items-center justify-center rounded-full p-1 text-current hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-300"+ >+ <Info aria-hidden size={iconSize} />+ </button></TooltipTrigger><TooltipContent><ReactMarkdown