From 9db39fb358a9adb009f1d391a6b97953c613c7a4 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Wed, 4 Mar 2026 11:30:37 -0500 Subject: [PATCH] fix: remove queue message button and clear localStorage draft on submit (#22615) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes two bugs in the agents chat input: 1. **Remove queue message button next to stop button** — The send button (which showed a ListPlusIcon during streaming) is now hidden when streaming and not editing a queued message. Messages are still queued via Enter key; only the visual button is removed. The stop button remains. 2. **Clear localStorage draft on submit** — The `agents.empty-input` localStorage key is now cleared synchronously in `handleSend` before the async `onCreateChat` call. Previously, the draft was only cleared inside the async `handleCreateChat` after `mutateAsync` resolved, allowing Lexical editor change events to re-persist the draft during the async gap. --- site/src/pages/AgentsPage/AgentChatInput.tsx | 43 ++++++++------------ site/src/pages/AgentsPage/AgentsPage.tsx | 4 ++ 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/site/src/pages/AgentsPage/AgentChatInput.tsx b/site/src/pages/AgentsPage/AgentChatInput.tsx index 3c1aae3ad8..1ea786c582 100644 --- a/site/src/pages/AgentsPage/AgentChatInput.tsx +++ b/site/src/pages/AgentsPage/AgentChatInput.tsx @@ -13,13 +13,7 @@ import { TooltipContent, TooltipTrigger, } from "components/Tooltip/Tooltip"; -import { - ArrowUpIcon, - ListPlusIcon, - Loader2Icon, - Square, - XIcon, -} from "lucide-react"; +import { ArrowUpIcon, Loader2Icon, Square, XIcon } from "lucide-react"; import { memo, type ReactNode, useCallback, useRef, useState } from "react"; import { cn } from "utils/cn"; import { formatProviderLabel } from "./modelOptions"; @@ -317,8 +311,7 @@ export const AgentChatInput = memo( } }; - const sendButtonLabel = - isStreaming && editingQueuedMessageID === null ? "Queue message" : "Send"; + const sendButtonLabel = editingQueuedMessageID !== null ? "Save" : "Send"; const content = (
@@ -430,22 +423,22 @@ export const AgentChatInput = memo( Stop )} - + {!(isStreaming && editingQueuedMessageID === null) && ( + + )}
{inputStatusText && ( diff --git a/site/src/pages/AgentsPage/AgentsPage.tsx b/site/src/pages/AgentsPage/AgentsPage.tsx index 9b8955e790..409bc561d4 100644 --- a/site/src/pages/AgentsPage/AgentsPage.tsx +++ b/site/src/pages/AgentsPage/AgentsPage.tsx @@ -814,6 +814,10 @@ export const AgentsEmptyState: FC = ({ const handleSend = useCallback( (message: string) => { + // Clear the draft synchronously before the async + // onCreateChat call so that editor change events + // firing during the async gap cannot re-persist it. + localStorage.removeItem(emptyInputStorageKey); void onCreateChat({ message, workspaceId: selectedWorkspaceIdRef.current ?? undefined,