From 43e81598223ecdfe68f06d0c95fbe0140eecbba0 Mon Sep 17 00:00:00 2001 From: majdyz Date: Wed, 15 Apr 2026 17:59:53 +0700 Subject: [PATCH] =?UTF-8?q?fix(copilot):=20simplify=20toggle=20visibility?= =?UTF-8?q?=20=E2=80=94=20hide=20mode/model=20on=20session,=20always=20sho?= =?UTF-8?q?w=20dry-run;=20icon-only=20for=20inactive=20model=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ChatInput/ChatInput.tsx | 32 ++++++++----------- .../ChatInput/components/ModeToggleButton.tsx | 25 +++++---------- .../components/ModelToggleButton.tsx | 31 ++++++------------ .../__tests__/ModelToggleButton.test.tsx | 31 ++---------------- 4 files changed, 33 insertions(+), 86 deletions(-) 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.tsx index 1a00f8def6..c4c116b3cd 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 @@ -218,25 +218,19 @@ export function ChatInput({ onFilesSelected={handleFilesSelected} disabled={isBusy} /> - {showModeToggle && - !isStreaming && - (!hasSession || copilotChatMode === "extended_thinking") && ( - - )} - {showModeToggle && - !isStreaming && - (!hasSession || copilotLlmModel === "advanced") && ( - - )} - {showDryRunToggle && (!hasSession || isDryRun) && ( + {showModeToggle && !isStreaming && !hasSession && ( + + )} + {showModeToggle && !isStreaming && !hasSession && ( + + )} + {showDryRunToggle && ( void; - readOnly?: boolean; } -export function ModeToggleButton({ mode, onToggle, readOnly = false }: Props) { +export function ModeToggleButton({ mode, onToggle }: Props) { const isExtended = mode === "extended_thinking"; return ( ); } diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ModelToggleButton.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ModelToggleButton.test.tsx index 1f3931f7bb..a17e702f1a 100644 --- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ModelToggleButton.test.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ModelToggleButton.test.tsx @@ -5,9 +5,10 @@ import { ModelToggleButton } from "../ModelToggleButton"; afterEach(cleanup); describe("ModelToggleButton", () => { - it("shows Standard label when model is standard", () => { + it("shows no text label when model is standard", () => { render(); - expect(screen.getByText("Standard")).toBeTruthy(); + expect(screen.queryByText("Standard")).toBeNull(); + expect(screen.queryByText("Advanced")).toBeNull(); }); it("shows Advanced label when model is advanced", () => { @@ -33,30 +34,4 @@ describe("ModelToggleButton", () => { const btn = screen.getByLabelText("Switch to Standard model"); expect(btn.getAttribute("aria-pressed")).toBe("true"); }); - - it("is disabled when readOnly", () => { - render(); - expect(screen.getByRole("button").hasAttribute("disabled")).toBe(true); - }); - - it("does not call onToggle when readOnly", () => { - const onToggle = vi.fn(); - render(); - fireEvent.click(screen.getByRole("button")); - expect(onToggle).not.toHaveBeenCalled(); - }); - - it("shows session-locked title when readOnly and advanced", () => { - render(); - expect( - screen.getByTitle("Advanced model active for this session"), - ).toBeDefined(); - }); - - it("shows session-locked title when readOnly and standard", () => { - render(); - expect( - screen.getByTitle("Standard model active for this session"), - ).toBeDefined(); - }); });