Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
💬 fix: Clear Queued Attachments and Simplify Steer Controls (#16969)
Marco Beretta19b9e2e035d3
diff --git a/client/src/components/Chat/Input/EscalateNowButton.tsx b/client/src/components/Chat/Input/EscalateNowButton.tsxindex e677d30470..2cec54d664 100644--- a/client/src/components/Chat/Input/EscalateNowButton.tsx+++ b/client/src/components/Chat/Input/EscalateNowButton.tsx@@ -1,7 +1,7 @@import { useEffect, useId, useSyncExternalStore } from 'react';import { ArrowUp } from 'lucide-react';import * as Ariakit from '@ariakit/react';-import { IconButton } from '@librechat/client';+import { Button, IconButton } from '@librechat/client';import { useShortcutAriaKey, useShortcutDisplay } from '~/hooks/useKeyboardShortcuts';import { getChatPane, getFocusedChatPane } from '~/utils/pane';import { useLocalize } from '~/hooks';@@ -144,6 +144,23 @@ export default function EscalateNowButton({return () => clearActiveTarget(targetId);}, [disabled, targetId]);+ const actionProps = {+ 'aria-keyshortcuts': isActive ? ariaKey : undefined,+ 'data-escalate-steer': surface,+ 'data-escalate-steer-active': isActive ? 'true' : undefined,+ 'data-testid': surface === 'queued' ? 'queued-interrupt-now' : 'steer-escalate-now',+ disabled,+ onPointerEnter: (event: React.PointerEvent<HTMLButtonElement>) => {+ if (!disabled) {+ updateActiveTarget('hover', targetId, true, event.currentTarget);+ }+ },+ onPointerLeave: () => updateActiveTarget('hover', targetId, false),+ onFocus: () => !disabled && updateActiveTarget('focus', targetId, true),+ onBlur: () => updateActiveTarget('focus', targetId, false),+ onClick,+ };+return (<Ariakit.TooltipProvider placement="top" timeout={300}>{/* The disabled IconButton already renders at half opacity; 70% of that@@ -151,26 +168,26 @@ export default function EscalateNowButton({<span className={cn('transition-opacity', disabled && 'opacity-70')}><Ariakit.TooltipAnchorrender={- <IconButton- label={accessibleLabel}- size={size}- shape={shape}- variant="primary"- aria-keyshortcuts={isActive ? ariaKey : undefined}- data-escalate-steer={surface}- data-escalate-steer-active={isActive ? 'true' : undefined}- data-testid={surface === 'queued' ? 'queued-interrupt-now' : 'steer-escalate-now'}- disabled={disabled}- onPointerEnter={(event) =>- !disabled && updateActiveTarget('hover', targetId, true, event.currentTarget)- }- onPointerLeave={() => updateActiveTarget('hover', targetId, false)}- onFocus={() => !disabled && updateActiveTarget('focus', targetId, true)}- onBlur={() => updateActiveTarget('focus', targetId, false)}- onClick={onClick}- >- <ArrowUp className="h-3.5 w-3.5" strokeWidth={2.4} aria-hidden="true" />- </IconButton>+ surface === 'bubble' ? (+ <Button+ type="button"+ variant="message-action"+ aria-label={accessibleLabel}+ {...actionProps}+ >+ <ArrowUp className="h-[19px] w-[19px]" aria-hidden="true" />+ </Button>+ ) : (+ <IconButton+ label={accessibleLabel}+ size={size}+ shape={shape}+ variant="primary"+ {...actionProps}+ >+ <ArrowUp className="h-3.5 w-3.5" strokeWidth={2.4} aria-hidden="true" />+ </IconButton>+ )}/></span>diff --git a/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsx b/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsxindex 94fbbb9dad..acd2dcb856 100644--- a/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/PendingSteers.tsx@@ -1,6 +1,7 @@import { memo, useMemo, useRef, useState } from 'react';-import { TextQuote } from 'lucide-react';+import { Clock, TextQuote, X } from 'lucide-react';import { useQueryClient } from '@tanstack/react-query';+import { Button, TooltipAnchor } from '@librechat/client';import { QueryKeys, type TMessage } from 'librechat-data-provider';import type { SteerReceiptState } from '~/components/Chat/Steering/Receipt';import useSteerCancel, { useSteerMoveToQueue, useSteerRehome } from '~/hooks/Chat/useSteerCancel';@@ -209,7 +210,7 @@ function PendingSteers({ conversationId, index = 0, fullWidth = false }: Pending)}</div>) : (- <div className="text-text-secondary -mt-2 mb-2 flex flex-wrap items-center justify-end gap-2 text-xs">+ <div className="text-text-secondary -mt-2 mb-2 flex flex-wrap items-center justify-end gap-0.5 text-xs">{/* Only a `pending` steer can be armed: `sending` has no server idyet, and one already interrupting has nothing left to escalate. */}{steer.status === 'pending' && steer.preempt !== true && (@@ -229,33 +230,43 @@ function PendingSteers({ conversationId, index = 0, fullWidth = false }: Pending/>)}{steer.status === 'pending' && (- <>- <button- type="button"- disabled={movingId != null}- onClick={() => void queueSteer(steer)}- className={ACTION_CLASS}- >- {localize('com_ui_convert_to_queue')}- </button>- </>+ <TooltipAnchor+ description={localize('com_ui_convert_to_queue')}+ render={+ <Button+ type="button"+ variant="message-action"+ aria-label={localize('com_ui_convert_to_queue')}+ disabled={movingId != null}+ onClick={() => void queueSteer(steer)}+ >+ <Clock className="h-[19px] w-[19px]" aria-hidden="true" />+ </Button>+ }+ />)}{(steer.status === 'pending' || steer.status === 'sending') && (- <button- type="button"- ref={(node) => {- if (node == null) {- cancelButtonRefs.current.delete(steer.steerId);- return;- }- cancelButtonRefs.current.set(steer.steerId, node);- }}- disabled={movingId != null}- onClick={() => void cancelPendingSteer(steer)}- className={ACTION_CLASS}- >- {localize('com_ui_cancel')}- </button>+ <TooltipAnchor+ description={localize('com_ui_cancel')}+ render={+ <Button+ type="button"+ variant="message-action"+ aria-label={localize('com_ui_cancel')}+ ref={(node) => {+ if (node == null) {+ cancelButtonRefs.current.delete(steer.steerId);+ return;+ }+ cancelButtonRefs.current.set(steer.steerId, node);+ }}+ disabled={movingId != null}+ onClick={() => void cancelPendingSteer(steer)}+ >+ <X className="h-[19px] w-[19px]" aria-hidden="true" />+ </Button>+ }+ />)}</div>)}diff --git a/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsx b/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsxindex 0109213308..fb5523d298 100644--- a/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsx+++ b/client/src/components/Chat/Messages/Content/Parts/__tests__/PendingSteers.test.tsx@@ -153,6 +153,24 @@ describe('PendingSteers', () => {}});+ it('renders queue as an icon-only message action', () => {+ renderPending([pending({ status: 'pending' })]);++ expect(screen.getByRole('button', { name: 'com_ui_convert_to_queue' }).textContent).toBe('');+ });++ it('renders cancel as an icon-only message action', () => {+ renderPending([pending({ status: 'pending' })]);++ expect(screen.getByRole('button', { name: 'com_ui_cancel' }).textContent).toBe('');+ });++ it('uses the message-action treatment for interrupting a pending steer', () => {+ renderPending([pending({ status: 'pending' })]);++ expect(screen.getByTestId('steer-escalate-now')).toHaveClass('text-text-secondary-alt');+ });+it('keeps delivered controls available and aligned with the bubble', () => {renderPending([pending({ status: 'pending' })]);@@ -242,7 +260,7 @@ describe('PendingSteers', () => {const steer = pending({ status: 'pending', steerId: 's-ack' });renderPending([steer]);- fireEvent.click(screen.getByText('com_ui_convert_to_queue'));+ fireEvent.click(screen.getByRole('button', { name: 'com_ui_convert_to_queue' }));await waitFor(() => expect(mockMoveToQueue).toHaveBeenCalledWith(steer));});@@ -251,7 +269,7 @@ describe('PendingSteers', () => {mockMoveToQueue.mockResolvedValue('applied');renderPending([pending({ status: 'pending' })]);- fireEvent.click(screen.getByText('com_ui_convert_to_queue'));+ fireEvent.click(screen.getByRole('button', { name: 'com_ui_convert_to_queue' }));await waitFor(() =>expect(mockShowToast).toHaveBeenCalledWith({diff --git a/client/src/components/Chat/Steering/__tests__/Receipt.spec.tsx b/client/src/components/Chat/Steering/__tests__/Receipt.spec.tsxnew file mode 100644index 0000000000..4fa647be5e--- /dev/null+++ b/client/src/components/Chat/Steering/__tests__/Receipt.spec.tsx@@ -0,0 +1,35 @@+import React from 'react';+import { render, screen } from '@testing-library/react';+import Receipt from '../Receipt';++jest.mock('~/hooks', () => ({+ useLocalize: () => (key: string) => {+ const english: Record<string, string> = jest.requireActual('~/locales/en/translation.json');+ return english[key] ?? key;+ },+}));++jest.mock('@librechat/client', () => ({+ ESide: { Top: 'top' },+ InfoHoverCard: ({ text, children }: { text: string; children: React.ReactNode }) => (+ <span aria-label={text}>{children}</span>+ ),+}));++describe('Steer receipt copy', () => {+ it('describes accepted guidance as waiting to apply', () => {+ render(<Receipt state="delivered" />);++ expect(screen.getByTestId('steer-receipt')).toHaveTextContent('Waiting to apply');+ });++ it('explains that accepted guidance has not reached the agent yet', () => {+ render(<Receipt state="delivered" />);++ expect(+ screen.getByLabelText(+ 'Waiting to apply. Your message was accepted and will reach the agent at a safe insertion point after the current tool or reasoning step.',+ ),+ ).toBeInTheDocument();+ });+});diff --git a/client/src/hooks/Chat/__tests__/useSteering.spec.tsx b/client/src/hooks/Chat/__tests__/useSteering.spec.tsxindex 325a122a73..20d159ec3a 100644--- a/client/src/hooks/Chat/__tests__/useSteering.spec.tsx+++ b/client/src/hooks/Chat/__tests__/useSteering.spec.tsx@@ -3842,7 +3842,7 @@ describe('useSteering', () => {type: 'image/png',});- function setupComposer() {+ function setupComposer(initialFiles = new Map<string, ExtendedFile>()) {const sendNow = jest.fn();const stopGenerating = jest.fn();const observed: { files: Map<string, ExtendedFile> } = { files: new Map() };@@ -3852,7 +3852,7 @@ describe('useSteering', () => {/** Real composer state, so `useUpdateFiles` and `useSteering` write* through the same setter they share in `ChatForm`. */const Composer = () => {- const [files, setFiles] = React.useState<Map<string, ExtendedFile>>(new Map());+ const [files, setFiles] = React.useState(initialFiles);observed.files = files;updates = useUpdateFiles(setFiles);steering = useSteering({@@ -3882,6 +3882,59 @@ describe('useSteering', () => {};}+ const uploadedFile = {+ ...extended('file-uploaded', 1),+ temp_file_id: 'upload-key',+ };++ it('clears a queued attachment stored under its temporary upload key', () => {+ const { observed, getSteering } = setupComposer(new Map([['upload-key', uploadedFile]]));++ act(() => {+ getSteering().queueFromComposer('use the uploaded image');+ });++ expect(observed.files.size).toBe(0);+ });++ it('does not attach a previously queued upload to the next queued message', () => {+ const { getSteering } = setupComposer(new Map([['upload-key', uploadedFile]]));++ act(() => {+ getSteering().queueFromComposer('use the uploaded image');+ });+ act(() => {+ getSteering().queueFromComposer('next message without attachments');+ });++ expect(getDefaultStore().get(queuedMessagesByConvoId(CONVO_ID))[1].files).toBeUndefined();+ });++ it('ignores a late callback using the queued attachment temporary upload id', () => {+ const { observed, getUpdates, getSteering } = setupComposer(+ new Map([['upload-key', uploadedFile]]),+ );++ act(() => {+ getSteering().queueFromComposer('use the uploaded image');+ });+ act(() => getUpdates().replaceFile(extended('upload-key', 1)));++ expect(observed.files.size).toBe(0);+ });++ it('keeps the server file reference on the queued message', () => {+ const { getSteering } = setupComposer(new Map([['upload-key', uploadedFile]]));++ act(() => {+ getSteering().queueFromComposer('use the uploaded image');+ });++ expect(getDefaultStore().get(queuedMessagesByConvoId(CONVO_ID))[0].files).toEqual([+ expect.objectContaining({ file_id: 'file-uploaded' }),+ ]);+ });+it('ignores a late callback for an attachment the steer already took', () => {const { observed, getUpdates, getSteering } = setupComposer();diff --git a/client/src/hooks/Chat/useSteering.ts b/client/src/hooks/Chat/useSteering.tsindex 17280eb9b7..87a906963c 100644--- a/client/src/hooks/Chat/useSteering.ts+++ b/client/src/hooks/Chat/useSteering.ts@@ -1301,7 +1301,12 @@ export default function useSteering({return undefined;}const staged = Array.from(files.values());- const takenIds = staged.map((file) => file.file_id);+ // Completed uploads keep their temporary map key after receiving a server id.+ const takenIds = Array.from(files.entries()).flatMap(([key, file]) => [+ key,+ file.file_id,+ ...(file.temp_file_id ? [file.temp_file_id] : []),+ ]);const taken = staged.map((file) => ({file_id: file.file_id,filepath: file.filepath,diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.jsonindex 7989c33bb8..031fa4641c 100644--- a/client/src/locales/en/translation.json+++ b/client/src/locales/en/translation.json@@ -3097,8 +3097,8 @@"com_ui_steer_cancel": "Cancel steering message","com_ui_steer_recovery_held": "Recovery paused","com_ui_steer_cancel_failed": "Could not cancel the steering message — it may still reach the agent",- "com_ui_steer_delivered": "Delivered",- "com_ui_steer_delivered_info": "Delivered. Waiting for a safe insertion point after the current tool or reasoning step.",+ "com_ui_steer_delivered": "Waiting to apply",+ "com_ui_steer_delivered_info": "Waiting to apply. Your message was accepted and will reach the agent at a safe insertion point after the current tool or reasoning step.","com_ui_steer_delivery_unconfirmed": "Delivery unconfirmed","com_ui_steer_delivery_uncertain": "Delivery status is unknown; this steering message may still reach the agent","com_ui_steer_failed": "Steering failed",