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
feat: Simplify Queue Row Actions And Steer Controls
Marco Beretta35db010412f9
diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsxindex 2f4c310fcf..edb89ab903 100644--- a/client/src/components/Chat/Input/ChatForm.tsx+++ b/client/src/components/Chat/Input/ChatForm.tsx@@ -1,4 +1,5 @@import { memo, useRef, useMemo, useEffect, useState, useCallback } from 'react';+import { useNavigate } from 'react-router-dom';import { useWatch } from 'react-hook-form';import { useRecoilState, useRecoilValue } from 'recoil';import { composerSurfaceClasses, composerSurfaceShadow, TextareaAutosize } from '@librechat/client';@@ -54,7 +55,6 @@ import useAskAnswerMode from '~/hooks/Input/useAskAnswerMode';import AskUserQuestionPopover from './AskUserQuestionPopover';import useComposerItems from '~/hooks/Input/useComposerItems';import useAttachTarget from '~/hooks/Input/useAttachTarget';-import InterruptSteerButton from './InterruptSteerButton';import Hints, { composerHintId } from './Composer/Hints';import PastedTextDialog from './Files/PastedTextDialog';import DuringRunSendButton from './DuringRunSendButton';@@ -377,6 +377,13 @@ const ChatForm = memo(function ChatForm({}),[submitMessage],);+ const navigate = useNavigate();+ /** A queued message becomes the first message of a fresh chat through the same+ * `prompt` + `submit` query contract that deep links already use. */+ const startQueuedInNewChat = useCallback(+ (text: string) => navigate(`/c/new?${new URLSearchParams({ prompt: text, submit: 'true' })}`),+ [navigate],+ );const { restoreReclaimedSteer, canRestoreToComposer } = useComposerRestore({index,conversationId,@@ -596,15 +603,6 @@ const ChatForm = memo(function ChatForm({if (sendOwnsSlot) {return (<>- {steering.canControlGeneration && (- <InterruptSteerButton- steering={steering}- isNewConversation={isNewConversation}- getText={() => methods.getValues('text')}- onConsumed={consumeComposer}- disabled={filesLoading}- />- )}<DuringRunSendButtonref={submitButtonRef}control={methods.control}@@ -681,9 +679,9 @@ const ChatForm = memo(function ChatForm({cn('md:py-3.5 m-0 w-full resize-none py-[13px] placeholder:text-text-tertiary bg-transparent [&:has(textarea:focus)]:shadow-[0_2px_6px_rgba(0,0,0,.05)]',isCollapsed ? 'max-h-[52px]' : 'max-h-[45vh] md:max-h-[55vh]',- isMoreThanThreeRows ? 'pl-5' : 'px-5',+ 'px-5',),- [isCollapsed, isMoreThanThreeRows],+ [isCollapsed],);/* From `sm` up the band leaves room under itself for the disclaimer, which only@@ -759,6 +757,7 @@ const ChatForm = memo(function ChatForm({conversationId={conversationId}onRestoreToComposer={restoreReclaimedSteer}canRestoreToComposer={canRestoreToComposer}+ onStartNewChat={startQueuedInNewChat}/>)}{(project || codeWorkspace.visible) && (@@ -923,10 +922,7 @@ const ChatForm = memo(function ChatForm({bolted on. Once words arrive the transcript takes over. */<Waveformactive={dictation.active}- className={cn(- 'pointer-events-none absolute inset-y-2',- isMoreThanThreeRows ? 'right-2 left-5' : 'inset-x-5',- )}+ className={cn('pointer-events-none absolute inset-x-5 inset-y-2')}/>)}{/* Sits over the fade scrim in the corner of the inputdiff --git a/client/src/components/Chat/Input/Composer/Queue.tsx b/client/src/components/Chat/Input/Composer/Queue.tsxindex cc4f16183c..9d1383bca4 100644--- a/client/src/components/Chat/Input/Composer/Queue.tsx+++ b/client/src/components/Chat/Input/Composer/Queue.tsx@@ -3,14 +3,29 @@ import { useAtomValue } from 'jotai';import { useRecoilValue } from 'recoil';import { createPortal } from 'react-dom';import { useDrag, useDrop } from 'react-dnd';-import { X, Pencil, TextQuote, TriangleAlert, GripVertical, Clock } from 'lucide-react';+import * as Ariakit from '@ariakit/react';+import { AnimatePresence, motion, useReducedMotion } from 'framer-motion';+import {+ Clock,+ Trash2,+ Pencil,+ Ellipsis,+ TextQuote,+ CirclePlay,+ CirclePause,+ GripVertical,+ TriangleAlert,+ MessageSquarePlus,+} from 'lucide-react';import {Button,IconButton,TooltipAnchor,+ DropdownPopup,useMediaQuery,useToastContext,} from '@librechat/client';+import type { MenuItemProps } from '@librechat/client';import type { RestoreToComposer } from '~/Providers/ComposerRestoreContext';import type { SteeringControls } from '~/hooks/Chat/useSteering';import type { QueuedMessage } from '~/hooks/Chat/queue';@@ -25,6 +40,13 @@ import store from '~/store';const DRAG_TYPE = 'queued-message';+/** One timing for a row entering or leaving the rail, so a message that sends reads as+ * the rail closing up behind it rather than a row vanishing. */+const ROW_TRANSITION = {+ height: { duration: 0.26, ease: [0.4, 0, 0.2, 1] },+ opacity: { duration: 0.16, ease: 'easeOut' },+} as const;+interface DragItem {id: string;index: number;@@ -40,6 +62,8 @@ interface QueueProps {onRestoreToComposer: RestoreToComposer;/** Whether the composer would take this conversation's words right now. */canRestoreToComposer: (conversationId: string) => boolean;+ /** Owned by the composer host: opens a fresh chat that starts with these words. */+ onStartNewChat: (text: string) => void;}interface QueueRowProps {@@ -60,6 +84,7 @@ interface QueueRowProps {reorderHintId: string;onRestoreToComposer: RestoreToComposer;canRestoreToComposer: (conversationId: string) => boolean;+ onStartNewChat: (text: string) => void;/** The server has revealed this row as the next user turn; only removal remains meaningful. */revealed?: boolean;/** The matching user turn owns this row's actions when its bubble is visible. */@@ -103,6 +128,7 @@ function QueueRow({reorderHintId,onRestoreToComposer,canRestoreToComposer,+ onStartNewChat,onAnnounce,revealed = false,portalElement,@@ -369,6 +395,7 @@ function QueueRow({drop(rowRef);drag(gripRef);+ const reduceMotion = useReducedMotion();const fileCount = message.files?.length ?? 0;const quoteCount = message.quotes?.length ?? 0;@@ -394,32 +421,134 @@ function QueueRow({* short enough that appearing and vanishing again just reads as a flicker. */const showEscalate = !isRecovered && (steering.pausedOnApproval || steering.duringRunActive);+ /** The user's own hold keeps a row out of the run-end drain; a hold placed by a+ * rejected steer belongs to its failure surface and is not released from here. */+ const held = message.needsExplicitSend === true;+ const heldByUser = message.heldByUser === true;+ const hasExtras = fileCount > 0 || quoteCount > 0 || (message.manualSkills?.length ?? 0) > 0;+ const toggleHold = useCallback(() => {+ steering.toggleQueuedHold(message.id, !heldByUser);+ /* Releasing after the run already ended would otherwise sit until some+ later generation finishes: nothing is left to wake the drain. */+ if (heldByUser) {+ steering.rewakeDrain(conversationId);+ }+ }, [steering, message.id, heldByUser, conversationId]);+ const startInNewChat = useCallback(+ () =>+ handOff(async () => {+ if (!(await steering.discardQueued(message))) {+ return false;+ }+ steering.removeQueued(message.id);+ onStartNewChat(message.text);+ return true;+ }),+ [handOff, steering, message, onStartNewChat],+ );++ const menuId = useId();+ const [menuOpen, setMenuOpen] = useState(false);+ const menuItems: MenuItemProps[] = [+ {+ id: `${menuId}-edit`,+ label: localize('com_ui_edit_message'),+ icon: <Pencil className="h-4 w-4" aria-hidden="true" />,+ disabled: actionPending || !serverActionable || hasQueuedIntent(message.id),+ onClick: () => void editToComposer(),+ },+ {+ id: `${menuId}-new-chat`,+ label: localize('com_ui_queue_start_new_chat'),+ icon: <MessageSquarePlus className="h-4 w-4" aria-hidden="true" />,+ show: portalElement == null,+ disabled:+ actionPending ||+ !serverActionable ||+ isRecovered ||+ hasExtras ||+ hasQueuedIntent(message.id),+ onClick: () => void startInNewChat(),+ },+ {+ id: `${menuId}-hold`,+ label: localize(heldByUser ? 'com_ui_queue_enable' : 'com_ui_queue_disable'),+ icon: heldByUser ? (+ <CirclePlay className="h-4 w-4" aria-hidden="true" />+ ) : (+ <CirclePause className="h-4 w-4" aria-hidden="true" />+ ),+ show: portalElement == null,+ disabled: actionPending || message.server != null || (held && !heldByUser),+ onClick: toggleHold,+ },+ ];+ const optionsMenu = (+ <DropdownPopup+ portal+ focusLoop+ unmountOnHide+ menuId={menuId}+ isOpen={menuOpen}+ setIsOpen={setMenuOpen}+ items={menuItems}+ className="z-50"+ trigger={+ <Ariakit.MenuButton+ render={+ <IconButton+ label={localize('com_ui_more_options')}+ size="lg"+ shape="control"+ data-testid="queued-message-options"+ disabled={actionPending}+ />+ }+ >+ <Ellipsis className="text-text-secondary h-4 w-4" aria-hidden="true" />+ </Ariakit.MenuButton>+ }+ />+ );+ const removeDisabled =+ portalElement != null+ ? actionPending ||+ hasQueuedIntent(message.id) ||+ (!serverActionable && !(message.server?.id != null && message.server.status === 'claimed'))+ : actionPending ||+ (!serverActionable &&+ !isUnconfirmed &&+ !(message.server?.id != null && message.server.status === 'claimed' && revealed));+ const removeButton = (+ <IconButton+ label={localize(+ isUnconfirmed && portalElement == null+ ? 'com_ui_dismiss_unconfirmed_delivery'+ : 'com_ui_remove_queued',+ )}+ size="lg"+ shape="control"+ disabled={removeDisabled}+ onClick={+ isUnconfirmed && portalElement == null+ ? () => steering.removeQueued(message.id)+ : removeToComposer+ }+ className="group"+ data-testid="queued-message-remove"+ >+ <Trash2+ className="text-text-secondary group-hover:text-text-destructive h-4 w-4 transition-colors"+ aria-hidden="true"+ />+ </IconButton>+ );+if (portalElement != null) {return createPortal(<span className="flex items-center gap-1">- {serverActionable && (- <IconButton- label={localize('com_ui_edit_message')}- size="xs"- disabled={actionPending || hasQueuedIntent(message.id)}- onClick={editToComposer}- >- <Pencil className="h-4 w-4" aria-hidden="true" />- </IconButton>- )}- <IconButton- label={localize('com_ui_remove_queued')}- size="xs"- disabled={- actionPending ||- hasQueuedIntent(message.id) ||- (!serverActionable &&- !(message.server?.id != null && message.server.status === 'claimed'))- }- onClick={removeToComposer}- >- <X className="h-4 w-4" aria-hidden="true" />- </IconButton>+ {removeButton}+ {serverActionable && optionsMenu}</span>,portalElement,message.id,@@ -427,158 +556,143 @@ function QueueRow({}return (- <div+ <motion.divref={rowRef}role="listitem"data-testid="queued-message-row"- className={cn(- 'border-border-light flex items-center gap-2 border-b px-3 py-1.5 text-sm last:border-b-0',- isDragging && 'opacity-40',- )}+ layout="position"+ initial={reduceMotion ? false : { height: 0, opacity: 0 }}+ animate={{ height: 'auto', opacity: isDragging ? 0.4 : 1 }}+ exit={reduceMotion ? { opacity: 0 } : { height: 0, opacity: 0 }}+ transition={reduceMotion ? { duration: 0 } : ROW_TRANSITION}+ className="border-border-light overflow-hidden border-b text-sm last:border-b-0">- <IconButton- ref={gripRef}- label={localize('com_ui_queue_reorder', {- 0: String(index + 1),- 1: String(total),- })}- size="xs"- data-testid="queued-message-grip"- /* Kept even when there is nowhere to move to, rather than swapped for+ <div className="flex min-h-14 items-center gap-2 px-3 py-2">+ <IconButton+ ref={gripRef}+ label={localize('com_ui_queue_reorder', {+ 0: String(index + 1),+ 1: String(total),+ })}+ size="xs"+ data-testid="queued-message-grip"+ /* Kept even when there is nowhere to move to, rather than swapped foran icon: a queue that drains to one message would otherwise unmountthe handle a keyboard user was holding, dropping focus to the top ofthe page. */- aria-disabled={!reorderable}- /* A handle announces what it is but not how to work it, and the keys+ aria-disabled={!reorderable}+ /* A handle announces what it is but not how to work it, and the keysare the only way through it without a pointer. */- aria-describedby={reorderable ? reorderHintId : undefined}- onKeyDown={(event) => {- if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') {- return;- }- /* Both keys scroll the rail's container otherwise, which would+ aria-describedby={reorderable ? reorderHintId : undefined}+ onKeyDown={(event) => {+ if (event.key !== 'ArrowUp' && event.key !== 'ArrowDown') {+ return;+ }+ /* Both keys scroll the rail's container otherwise, which wouldchase the row the press just moved. */- event.preventDefault();- move(event.key === 'ArrowUp' ? -1 : 1);- }}- className={cn(- 'group',- reorderable ? 'cursor-grab active:cursor-grabbing' : 'cursor-default',- canDrag && reorderable && 'touch-none',- )}- >- <GripVertical+ event.preventDefault();+ move(event.key === 'ArrowUp' ? -1 : 1);+ }}className={cn(- 'text-text-secondary group-hover:text-text-primary h-4 w-4 transition-colors',- !reorderable && 'opacity-40',+ 'group',+ reorderable ? 'cursor-grab active:cursor-grabbing' : 'cursor-default',+ canDrag && reorderable && 'touch-none',)}- aria-hidden="true"+ >+ <GripVertical+ className={cn(+ 'text-text-secondary group-hover:text-text-primary h-4 w-4 transition-colors',+ !reorderable && 'opacity-40',+ )}+ aria-hidden="true"+ />+ </IconButton>+ <QueuedIcon+ warning={isRejected || isUnconfirmed || isIndeterminate}+ hint={steering.duringRunActive ? localize('com_ui_steer_queued_info') : undefined}/>- </IconButton>- <QueuedIcon- warning={isRejected || isUnconfirmed || isIndeterminate}- hint={steering.duringRunActive ? localize('com_ui_steer_queued_info') : undefined}- />- <span className="text-text-primary min-w-0 flex-1 truncate" title={message.text}>- {message.text}- </span>- {quoteCount > 0 && (- <span className="text-text-secondary flex shrink-0 items-center gap-0.5 text-xs">- <TextQuote className="h-3.5 w-3.5" aria-hidden="true" />- <span aria-hidden="true">{quoteCount}</span>- <span className="sr-only">- {localize('com_ui_queued_quote_count', { 0: String(quoteCount) })}- </span>+ <span className="text-text-primary min-w-0 flex-1 truncate" title={message.text}>+ {message.text}</span>- )}- {fileCount > 0 && (- <span- className="text-text-secondary shrink-0 text-xs"- title={localize('com_ui_queued_attachment_count', { 0: String(fileCount) })}- >- <span className="sr-only">- {localize('com_ui_queued_attachment_count', { 0: String(fileCount) })}- </span>- <span aria-hidden="true">- {localize(fileCount === 1 ? 'com_ui_attachment_count_one' : 'com_ui_attachment_count', {- count: fileCount,- })}+ {quoteCount > 0 && (+ <span className="text-text-secondary flex shrink-0 items-center gap-0.5 text-xs">+ <TextQuote className="h-3.5 w-3.5" aria-hidden="true" />+ <span aria-hidden="true">{quoteCount}</span>+ <span className="sr-only">+ {localize('com_ui_queued_quote_count', { 0: String(quoteCount) })}+ </span></span>- </span>- )}- {(isRejected || isUnconfirmed || isIndeterminate) && (- <span className="text-status-warning shrink-0 text-xs">{localize(statusLabel)}</span>- )}- {revealed && (- <span className="text-text-secondary shrink-0 text-xs">- {localize('com_ui_queued_turn_starting')}- </span>- )}- {!revealed && (- <>- <Button- variant="ghost"- size="sm"- disabled={sendDisabled}- aria-disabled={sendDisabled}- title={- !steering.canSendQueuedNow || reasoningRequiresNewGeneration- ? localize('com_ui_send_now_paused')- : undefined- }- onClick={() => steering.sendQueuedNow(message)}- className="h-auto shrink-0 disabled:pointer-events-auto disabled:cursor-not-allowed"+ )}+ {fileCount > 0 && (+ <span+ className="text-text-secondary shrink-0 text-xs"+ title={localize('com_ui_queued_attachment_count', { 0: String(fileCount) })}>- <span className="text-text-primary">{localize('com_ui_send_now')}</span>- </Button>- {showEscalate && (- <EscalateNowButton- surface="queued"- messageText={message.text}- disabled={- !steering.canSteer ||- interruptPending ||- actionPending ||- reasoningRequiresNewGeneration ||- !serverActionable+ <span className="sr-only">+ {localize('com_ui_queued_attachment_count', { 0: String(fileCount) })}+ </span>+ <span aria-hidden="true">+ {localize(+ fileCount === 1 ? 'com_ui_attachment_count_one' : 'com_ui_attachment_count',+ {+ count: fileCount,+ },+ )}+ </span>+ </span>+ )}+ {(isRejected || isUnconfirmed || isIndeterminate) && (+ <span className="text-status-warning shrink-0 text-xs">{localize(statusLabel)}</span>+ )}+ {heldByUser && !revealed && (+ <span className="text-text-secondary shrink-0 text-xs">+ {localize('com_ui_queue_held')}+ </span>+ )}+ {revealed && (+ <span className="text-text-secondary shrink-0 text-xs">+ {localize('com_ui_queued_turn_starting')}+ </span>+ )}+ {!revealed && (+ <>+ <Button+ variant="outline"+ shape="theme"+ disabled={sendDisabled}+ aria-disabled={sendDisabled}+ title={+ !steering.canSendQueuedNow || reasoningRequiresNewGeneration+ ? localize('com_ui_send_now_paused')+ : undefined}- onClick={() => steering.sendQueuedNow(message, { preempt: true })}- />- )}- <IconButton- label={localize('com_ui_edit_message')}- size="xs"- disabled={actionPending || !serverActionable}- onClick={editToComposer}- className="group"- >- <Pencil- className="text-text-secondary group-hover:text-text-primary h-4 w-4 transition-colors"- aria-hidden="true"- />- </IconButton>- </>- )}- <IconButton- label={localize(- isUnconfirmed ? 'com_ui_dismiss_unconfirmed_delivery' : 'com_ui_remove_queued',+ onClick={() => steering.sendQueuedNow(message)}+ className="shrink-0 disabled:pointer-events-auto disabled:cursor-not-allowed"+ >+ <span className="text-text-primary">{localize('com_ui_send_now')}</span>+ </Button>+ {showEscalate && (+ <EscalateNowButton+ surface="queued"+ size="lg"+ shape="control"+ messageText={message.text}+ disabled={+ !steering.canSteer ||+ interruptPending ||+ actionPending ||+ reasoningRequiresNewGeneration ||+ !serverActionable+ }+ onClick={() => steering.sendQueuedNow(message, { preempt: true })}+ />+ )}+ </>)}- size="xs"- disabled={- actionPending ||- (!serverActionable &&- !isUnconfirmed &&- !(message.server?.id != null && message.server.status === 'claimed' && revealed))- }- onClick={isUnconfirmed ? () => steering.removeQueued(message.id) : removeToComposer}- className="group"- >- <X- className="text-text-secondary group-hover:text-text-primary h-4 w-4 transition-colors"- aria-hidden="true"- />- </IconButton>- </div>+ {removeButton}+ {!revealed && optionsMenu}+ </div>+ </motion.div>);}@@ -607,6 +721,7 @@ function Queue({conversationId,onRestoreToComposer,canRestoreToComposer,+ onStartNewChat,}: QueueProps) {const localize = useLocalize();/* A revealed server turn is already shown in the live thread. Keep its@@ -654,9 +769,8 @@ function Queue({? queued.findIndex((message) => message.clientRequestId === target.clientRequestId): -1;- if (queued.length === 0) {- return null;- }+ const reduceMotion = useReducedMotion();+ const showRail = queued.length > (portaledIndex >= 0 ? 1 : 0);const renderRow = (message: QueuedMessage, index: number, portalElement?: HTMLSpanElement) => (<QueueRow@@ -672,6 +786,7 @@ function Queue({reorderHintId={reorderHintId}onRestoreToComposer={onRestoreToComposer}canRestoreToComposer={canRestoreToComposer}+ onStartNewChat={onStartNewChat}revealed={revealed != null &&message.clientRequestId != null &&@@ -684,28 +799,45 @@ function Queue({return (<>- {queued.length > (portaledIndex >= 0 ? 1 : 0) && (- <div className="border-border-light bg-surface-secondary mx-3 overflow-hidden rounded-t-2xl border border-b-0">- <div- role="list"- aria-label={localize('com_ui_queued_messages')}- data-testid="composer-queue"- className="flex flex-col"+ <AnimatePresence initial={false}>+ {showRail && (+ /* Inset by the composer's corner radius (`mx-6`, 1.5rem) so the rail's sides land+ on the straight part of the composer's top edge instead of running down into+ its curved corners, and overlapping that edge by its 1px border so the two+ surfaces meet in one clean joint. */+ <motion.div+ key="queue-rail"+ initial={reduceMotion ? false : { height: 0, opacity: 0 }}+ animate={{ height: 'auto', opacity: 1 }}+ exit={reduceMotion ? { opacity: 0 } : { height: 0, opacity: 0 }}+ transition={reduceMotion ? { duration: 0 } : ROW_TRANSITION}+ className="mx-6 -mb-px overflow-hidden">- {queued.map((message, index) =>- index === portaledIndex ? null : renderRow(message, index),- )}- </div>- {queued.length > 1 && (- <span id={reorderHintId} className="sr-only">- {localize('com_ui_queue_reorder_hint')}- </span>- )}- <span role="status" aria-live="polite" className="sr-only">- {announcement}- </span>- </div>- )}+ <div className="border-border-light bg-surface-secondary rounded-t-2xl border border-b-0">+ <div+ role="list"+ aria-label={localize('com_ui_queued_messages')}+ data-testid="composer-queue"+ className="flex flex-col"+ >+ <AnimatePresence initial={false}>+ {queued.map((message, index) =>+ index === portaledIndex ? null : renderRow(message, index),+ )}+ </AnimatePresence>+ </div>+ {queued.length > 1 && (+ <span id={reorderHintId} className="sr-only">+ {localize('com_ui_queue_reorder_hint')}+ </span>+ )}+ <span role="status" aria-live="polite" className="sr-only">+ {announcement}+ </span>+ </div>+ </motion.div>+ )}+ </AnimatePresence>{portaledIndex >= 0 &&target != null &&renderRow(queued[portaledIndex], portaledIndex, target.element)}diff --git a/client/src/components/Chat/Input/Composer/__tests__/Queue.spec.tsx b/client/src/components/Chat/Input/Composer/__tests__/Queue.spec.tsxindex b363a17070..b5d5ca4e1e 100644--- a/client/src/components/Chat/Input/Composer/__tests__/Queue.spec.tsx+++ b/client/src/components/Chat/Input/Composer/__tests__/Queue.spec.tsx@@ -4,7 +4,7 @@ import { DndProvider } from 'react-dnd';import { getDefaultStore, useSetAtom } from 'jotai';import { HTML5Backend } from 'react-dnd-html5-backend';import { ReasoningEffort } from 'librechat-data-provider';-import { act, render, screen, within, fireEvent } from '@testing-library/react';+import { act, render, screen, within, waitFor, fireEvent } from '@testing-library/react';import type { SteeringControls } from '~/hooks/Chat/useSteering';import type { QueuedMessage } from '~/hooks/Chat/queue';import {@@ -28,6 +28,7 @@ jest.mock('~/hooks', () => ({const mockShowToast = jest.fn();jest.mock('@librechat/client', () => {const ReactActual = jest.requireActual('react') as typeof React;+ const AriakitActual = jest.requireActual('@ariakit/react') as typeof import('@ariakit/react');const IconButton = ReactActual.forwardRef(({@@ -48,6 +49,41 @@ jest.mock('@librechat/client', () => {Button: ({ children, ...props }: { children?: React.ReactNode } & Record<string, unknown>) =>ReactActual.createElement('button', { type: 'button', ...props }, children),IconButton,+ /* The real menu portals its items in on open; flattening them keeps every row's+ actions queryable by label without driving the popup in each test. */+ DropdownPopup: ({+ trigger,+ items,+ }: {+ trigger: React.ReactNode;+ items: Array<{+ id?: string;+ label?: string;+ show?: boolean;+ disabled?: boolean;+ onClick?: () => void;+ }>;+ }) =>+ ReactActual.createElement(+ AriakitActual.MenuProvider,+ null,+ trigger,+ items+ .filter((item) => item.show !== false)+ .map((item) =>+ ReactActual.createElement(+ 'button',+ {+ key: item.id,+ type: 'button',+ 'aria-label': item.label,+ disabled: item.disabled,+ onClick: item.onClick,+ },+ item.label,+ ),+ ),+ ),TooltipAnchor: ({children,render,@@ -136,6 +172,7 @@ function renderQueue(onEditToComposer?: jest.Mock;onRestoreToComposer?: jest.Mock;canRestoreToComposer?: jest.Mock;+ onStartNewChat?: jest.Mock;portalRequestId?: string;} = {},) {@@ -153,6 +190,7 @@ function renderQueue(handlers.onRestoreToComposer ?? handlers.onEditToComposer ?? jest.fn()}canRestoreToComposer={handlers.canRestoreToComposer ?? jest.fn().mockReturnValue(true)}+ onStartNewChat={handlers.onStartNewChat ?? jest.fn()}/>{handlers.portalRequestId != null && (<PendingTurnTarget requestId={handlers.portalRequestId} />@@ -173,7 +211,7 @@ describe('Queue', () => {expect(container).toBeEmptyDOMElement();});- it('renders a row per queued message with every action visible, none behind a menu', () => {+ it('renders a row per queued message with send now, remove and one options menu', () => {renderQueue([queued({ id: 'q1' }), queued({ id: 'q2' })]);const rows = screen.getAllByTestId('queued-message-row');expect(rows).toHaveLength(2);@@ -181,9 +219,51 @@ describe('Queue', () => {const firstRow = within(rows[0]);expect(firstRow.getByRole('button', { name: 'com_ui_send_now' })).toBeInTheDocument();expect(firstRow.getByTestId('queued-interrupt-now')).toBeInTheDocument();- expect(firstRow.getByLabelText('com_ui_edit_message')).toBeInTheDocument();expect(firstRow.getByLabelText('com_ui_remove_queued')).toBeInTheDocument();- expect(firstRow.queryByLabelText('com_ui_more_options')).not.toBeInTheDocument();+ expect(firstRow.getByLabelText('com_ui_more_options')).toBeInTheDocument();+ expect(firstRow.getByLabelText('com_ui_edit_message')).toBeInTheDocument();+ expect(firstRow.getByLabelText('com_ui_queue_start_new_chat')).toBeInTheDocument();+ expect(firstRow.getByLabelText('com_ui_queue_disable')).toBeInTheDocument();+ });++ it('starts a queued message in a new chat and drops it from the queue', async () => {+ const onStartNewChat = jest.fn();+ renderQueue([queued({ id: 'q1', text: 'carry me over' })], steering, { onStartNewChat });+ await act(async () => {+ fireEvent.click(screen.getByLabelText('com_ui_queue_start_new_chat'));+ });+ expect(mockDiscardQueued).toHaveBeenCalled();+ expect(mockRemoveQueued).toHaveBeenCalledWith('q1');+ expect(onStartNewChat).toHaveBeenCalledWith('carry me over');+ });++ it('keeps a message with attachments out of "Start in a new chat"', () => {+ renderQueue([queued({ id: 'q1', files: [{ file_id: 'f1' }] as never })]);+ expect(screen.getByLabelText('com_ui_queue_start_new_chat')).toBeDisabled();+ });++ it('holds a row out of the drain and releases it from the same menu item', () => {+ const toggle = jest.fn();+ renderQueue([queued({ id: 'q1' })], steeringWith({ toggleQueuedHold: toggle }));+ fireEvent.click(screen.getByLabelText('com_ui_queue_disable'));+ expect(toggle).toHaveBeenCalledWith('q1', true);+ });++ it('offers to re-enable a row the user disabled, and wakes the drain when released', () => {+ const toggle = jest.fn();+ renderQueue(+ [queued({ id: 'q1', needsExplicitSend: true, heldByUser: true })],+ steeringWith({ toggleQueuedHold: toggle }),+ );+ expect(screen.getByText('com_ui_queue_held')).toBeInTheDocument();+ fireEvent.click(screen.getByLabelText('com_ui_queue_enable'));+ expect(toggle).toHaveBeenCalledWith('q1', false);+ expect(mockRewakeDrain).toHaveBeenCalledWith(CONVO_ID);+ });++ it('does not let the user release a hold that a rejected steer placed', () => {+ renderQueue([queued({ id: 'q1', needsExplicitSend: true })]);+ expect(screen.getByLabelText('com_ui_queue_disable')).toBeDisabled();});it('sends the row that was clicked, not the first one', () => {@@ -639,6 +719,7 @@ describe('Queue', () => {conversationId="left-convo"onRestoreToComposer={jest.fn()}canRestoreToComposer={() => true}+ onStartNewChat={jest.fn()}/></RecoilRoot><RecoilRoot>@@ -647,6 +728,7 @@ describe('Queue', () => {conversationId="right-convo"onRestoreToComposer={jest.fn()}canRestoreToComposer={() => true}+ onStartNewChat={jest.fn()}/></RecoilRoot></DndProvider>,@@ -693,6 +775,7 @@ describe('Queue', () => {conversationId={CONVO_ID}onRestoreToComposer={jest.fn()}canRestoreToComposer={() => true}+ onStartNewChat={jest.fn()}/></DndProvider></RecoilRoot>,@@ -862,7 +945,7 @@ describe('Queue', () => {}});- it('moves a claimed turn’s sole remove action into the pending user turn', () => {+ it('moves a claimed turn’s sole remove action into the pending user turn', async () => {const jotaiStore = getDefaultStore();jotaiStore.set(revealedQueuedTurnFamily(CONVO_ID), {clientRequestId: 'req-1',@@ -887,6 +970,8 @@ describe('Queue', () => {expect(turn.getByLabelText('com_ui_remove_queued')).toBeEnabled();expect(turn.queryByRole('button', { name: 'com_ui_send_now' })).not.toBeInTheDocument();expect(turn.queryByLabelText('com_ui_edit_message')).not.toBeInTheDocument();+ /* The row that moved into the turn plays its exit before it leaves the rail. */+ await waitFor(() => expect(screen.getAllByTestId('queued-message-row')).toHaveLength(1));const row = screen.getByTestId('queued-message-row');expect(row).toHaveTextContent('another queued message');expect(row).not.toHaveTextContent('follow up on this');diff --git a/client/src/components/Chat/Input/EscalateNowButton.tsx b/client/src/components/Chat/Input/EscalateNowButton.tsxindex 985b4626a5..09dd899994 100644--- a/client/src/components/Chat/Input/EscalateNowButton.tsx+++ b/client/src/components/Chat/Input/EscalateNowButton.tsx@@ -95,6 +95,9 @@ interface EscalateNowButtonProps {surface: 'bubble' | 'queued';disabled: boolean;messageText: string;+ /** The queued rail uses the taller control height; the thread bubble keeps the compact one. */+ size?: 'xs' | 'md' | 'lg';+ shape?: 'round' | 'square' | 'control';onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;}@@ -109,6 +112,8 @@ export default function EscalateNowButton({surface,disabled,messageText,+ size = 'xs',+ shape,onClick,}: EscalateNowButtonProps) {const localize = useLocalize();@@ -148,7 +153,8 @@ export default function EscalateNowButton({render={<IconButtonlabel={accessibleLabel}- size="xs"+ size={size}+ shape={shape}variant="primary"aria-keyshortcuts={isActive ? ariaKey : undefined}data-escalate-steer={surface}diff --git a/client/src/components/Chat/Input/InterruptSteerButton.tsx b/client/src/components/Chat/Input/InterruptSteerButton.tsxdeleted file mode 100644index e6d55f8bb4..0000000000--- a/client/src/components/Chat/Input/InterruptSteerButton.tsx+++ /dev/null@@ -1,80 +0,0 @@-import React from 'react';-import { ZapOff } from 'lucide-react';-import * as Ariakit from '@ariakit/react';-import type { SteeringControls } from '~/hooks/Chat/useSteering';-import { useLocalize } from '~/hooks';-import { cn } from '~/utils';--type InterruptSteerButtonProps = {- steering: SteeringControls;- isNewConversation: boolean;- getText: () => string;- onConsumed: () => void;- /** External hold (e.g. uploads in flight), mirroring the send button. */- disabled?: boolean;-};--/**- * Always-visible composer control for earlier steering. Before a conversation- * exists, steering cannot reach the run, so this control instead stops the- * response and sends a new turn. Its label must reflect that fallback.- *- * `type="button"`: the composer footer sits inside the chat form, and only- * `DuringRunSendButton` may receive Enter's synthetic submit.- */-const InterruptSteerButton = React.memo((props: InterruptSteerButtonProps) => {- const localize = useLocalize();- const { steering } = props;- const label = localize(- props.isNewConversation ? 'com_ui_steer_first_turn_stop' : 'com_ui_interrupt_steer_button',- );- /** Pre-empts the server's 409: a paused run cannot accept a steer. */- const disabled =- props.disabled === true || steering.pausedOnApproval || !steering.canControlGeneration;-- const onClick = () => {- const text = props.getText().trim();- if (text.length === 0) {- return;- }- if (steering.interruptSteer(text) !== false) {- props.onConsumed();- }- };-- return (- <Ariakit.TooltipProvider placement="top" timeout={300}>- <Ariakit.TooltipAnchor- render={- <button- type="button"- aria-label={label}- data-testid="interrupt-steer-button"- disabled={disabled}- onClick={onClick}- className={cn(- 'border-border-light size-theme-control rounded-theme-control-round flex items-center justify-center border',- 'text-text-secondary duration-theme-normal transition-colors',- 'hover:bg-surface-composer-hover hover:text-text-primary',- 'focus-visible:ring-border-xheavy focus-visible:ring-2 focus-visible:outline-hidden',- 'disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent',- )}- >- <ZapOff className="size-4" aria-hidden="true" />- </button>- }- />- <Ariakit.Tooltip className="bg-surface-tertiary text-text-primary z-50 rounded-lg px-2 py-1 text-xs shadow-lg">- {localize(- props.isNewConversation- ? 'com_ui_steer_first_turn_stop_info'- : 'com_ui_interrupt_steer_desc',- )}- </Ariakit.Tooltip>- </Ariakit.TooltipProvider>- );-});--InterruptSteerButton.displayName = 'InterruptSteerButton';--export default InterruptSteerButton;diff --git a/client/src/components/Chat/Input/__tests__/InterruptSteerButton.test.tsx b/client/src/components/Chat/Input/__tests__/InterruptSteerButton.test.tsxdeleted file mode 100644index b0576b143a..0000000000--- a/client/src/components/Chat/Input/__tests__/InterruptSteerButton.test.tsx+++ /dev/null@@ -1,68 +0,0 @@-import React from 'react';-import { render, screen, fireEvent } from '@testing-library/react';-import type { SteeringControls } from '~/hooks/Chat/useSteering';-import InterruptSteerButton from '../InterruptSteerButton';-import en from '~/locales/en/translation.json';--jest.mock('~/hooks', () => ({- useLocalize: () => (key: string) => key,-}));--jest.mock('@ariakit/react', () => ({- TooltipProvider: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,- TooltipAnchor: ({ render }: { render: React.ReactElement }) => render,- Tooltip: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,-}));--const interruptSteer = jest.fn(() => true);-const onConsumed = jest.fn();-const steering = {- pausedOnApproval: false,- canControlGeneration: true,- interruptSteer,-} as unknown as SteeringControls;--beforeEach(() => {- jest.clearAllMocks();-});--test('the first response advertises the actual stop-and-send fallback', () => {- render(- <InterruptSteerButton- steering={steering}- isNewConversation- getText={() => 'please change course'}- onConsumed={onConsumed}- />,- );-- expect(screen.getByRole('button', { name: 'com_ui_steer_first_turn_stop' })).toBeEnabled();- expect(screen.getByText('com_ui_steer_first_turn_stop_info')).toBeInTheDocument();- fireEvent.click(screen.getByRole('button', { name: 'com_ui_steer_first_turn_stop' }));- expect(interruptSteer).toHaveBeenCalledWith('please change course');- expect(onConsumed).toHaveBeenCalledTimes(1);-});--test('an established conversation advertises earlier steering instead', () => {- render(- <InterruptSteerButton- steering={steering}- isNewConversation={false}- getText={() => 'please change course'}- onConsumed={onConsumed}- />,- );-- expect(screen.getByRole('button', { name: 'com_ui_interrupt_steer_button' })).toBeEnabled();- expect(screen.getByText('com_ui_interrupt_steer_desc')).toBeInTheDocument();- expect(screen.queryByText('com_ui_steer_first_turn_stop_info')).not.toBeInTheDocument();-});--test('English copy distinguishes requested steering, running tools, and reasoning restarts', () => {- expect(en.com_ui_steer_in_flight_preempt).toBe('Steer sooner requested');- expect(en.com_ui_steer_interrupting_info).toMatch(/may pause a text reply/);- expect(en.com_ui_steer_interrupting_info).toMatch(/restart an attempt.*only reasoning/);- expect(en.com_ui_steer_interrupting_info).toMatch(/Running tools finish first/);- expect(en.com_ui_steer_first_turn_stop_info).toMatch(/new turn/);- expect(en.com_nav_info_during_run_action).toContain(en.com_ui_steer_interrupts_default);-});diff --git a/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts b/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.tsindex adfbe92efe..ab247bb3d3 100644--- a/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts+++ b/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts@@ -12,7 +12,6 @@ const themedControls = [/** The submit slot's faces share one recipe, which owns the coarse-pointer* tap-target floor as well as the geometry. */['DuringRunSendButton.tsx', ['composerSubmitClasses()']],- ['InterruptSteerButton.tsx', ['size-theme-control', 'rounded-theme-control-round']],['TokenUsage/index.tsx', ['size-theme-control', 'rounded-theme-control-round']],['Files/AttachFile.tsx', ['size-theme-control', 'rounded-theme-control-round']],['CodeApprovalMenu.tsx', ['composerControlClasses()', 'md:px-theme-control-x']],diff --git a/client/src/hooks/Chat/queue.ts b/client/src/hooks/Chat/queue.tsindex e4f5308d8a..bde2bf6468 100644--- a/client/src/hooks/Chat/queue.ts+++ b/client/src/hooks/Chat/queue.ts@@ -84,6 +84,8 @@ export type QueuedMessage = {* the failure surface offers Retry and "Send as new", and auto-sending here* would start a turn the user never asked for with text that was refused. */needsExplicitSend?: boolean;+ /** Set when the user chose "Disable Queue" on this row, so only that choice can undo the hold. */+ heldByUser?: boolean;/** Stable identity for server enqueue/retry. Recovered steer rows also use* it to dismiss their parked source; a later recovery attempt gets a fresh* identity. */diff --git a/client/src/hooks/Chat/useSteering.ts b/client/src/hooks/Chat/useSteering.tsindex b3643ecdb8..303ac699f1 100644--- a/client/src/hooks/Chat/useSteering.ts+++ b/client/src/hooks/Chat/useSteering.ts@@ -1439,6 +1439,23 @@ export default function useSteering({[updateQueuedMessage],);+ /** The user's own hold on a local row: out of the run-end drain until released.+ * A hold that came from a rejected steer is not the user's to release. */+ const toggleQueuedHold = useCallback(+ (id: string, held: boolean) =>+ updateQueuedMessage(id, (item) => {+ if (held) {+ return { ...item, needsExplicitSend: true, heldByUser: true };+ }+ if (item.heldByUser !== true) {+ return item;+ }+ const { needsExplicitSend: _held, heldByUser: _byUser, ...rest } = item;+ return rest;+ }),+ [updateQueuedMessage],+ );+const downgradeServerQueuedTurn = useCallback((id: string): boolean => {const queue = jotaiStore.get(queuedMessagesByConvoId(queueKey));@@ -2615,6 +2632,7 @@ export default function useSteering({enqueue,removeQueued,holdQueued,+ toggleQueuedHold,discardQueued,dismissRecovery,rewakeDrain,@@ -2648,6 +2666,7 @@ export default function useSteering({enqueue,removeQueued,holdQueued,+ toggleQueuedHold,discardQueued,dismissRecovery,rewakeDrain,diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.jsonindex 28e0929954..6e2cd03a4d 100644--- a/client/src/locales/en/translation.json+++ b/client/src/locales/en/translation.json@@ -1821,8 +1821,6 @@"com_ui_instructions": "Instructions","com_ui_interrupt_send": "Interrupt & send","com_ui_interrupt_steer": "Steer sooner",- "com_ui_interrupt_steer_button": "Steer this response sooner",- "com_ui_interrupt_steer_desc": "Tries to steer at the next safe point. Running tools finish first.","com_ui_interrupt_steer_now": "Steer sooner","com_ui_invalid_json": "Invalid JSON","com_ui_invocation_auto": "Auto",@@ -2292,13 +2290,17 @@"com_ui_answer_questions_above": "Answer the questions above","com_ui_question_unanswered": "No answer was given","com_ui_queue": "Queue",+ "com_ui_queue_disable": "Disable Queue",+ "com_ui_queue_enable": "Enable Queue","com_ui_queue_edit_blocked": "Clear the message box in this chat, or finish answering the question, to edit this message.",+ "com_ui_queue_held": "Will not send automatically","com_ui_queue_moved": "Moved to {{0}} of {{1}}","com_ui_queue_reorder_blocked": "Queued turns already acknowledged by the server cannot be reordered.","com_ui_queue_remove_blocked": "Clear the message box in this chat to take this message back.","com_ui_queue_reorder": "Reorder message, {{0}} of {{1}}","com_ui_queue_reorder_hint": "Use the up and down arrow keys to move this message in the queue.","com_ui_queue_send": "Queue message for after the response",+ "com_ui_queue_start_new_chat": "Start in a new chat","com_ui_queued_attachment_count": "{{0}} attachments queued with this message","com_ui_queued_messages": "Queued messages","com_ui_queued_quote_count": "{{0}} quoted excerpts included with this message",@@ -2825,7 +2827,6 @@"com_ui_steer_failed": "Steering failed","com_ui_steer_failed_inline": "Couldn't add to this reply","com_ui_steer_first_turn_stop": "Stop & send (first response)",- "com_ui_steer_first_turn_stop_info": "Steering isn't available yet. Stops this response and sends your message as a new turn.","com_ui_steer_in_flight": "Steering","com_ui_steer_in_flight_preempt": "Steer sooner requested","com_ui_steer_interrupting_info": "Earlier steering requested. The agent may pause a text reply at a safe point or restart an attempt that has produced only reasoning. Running tools finish first. If it cannot pause, your message waits for the next tool step or an end-of-response opportunity.",diff --git a/e2e/specs/mock/scenarios/composer-redesign.spec.ts b/e2e/specs/mock/scenarios/composer-redesign.spec.tsindex d95f11c06e..712b15e278 100644--- a/e2e/specs/mock/scenarios/composer-redesign.spec.ts+++ b/e2e/specs/mock/scenarios/composer-redesign.spec.ts@@ -246,7 +246,8 @@ test.describe('composer redesign contracts', () => {await expect(queuedRow).toBeVisible();/** Editing the queued row while that draft is still typed would merge the* two the same way, so Edit refuses and says what to do instead. */- await queuedRow.getByRole('button', { name: 'Edit message' }).click();+ await queuedRow.getByRole('button', { name: 'More options' }).click();+ await page.getByRole('menuitem', { name: 'Edit message' }).click();await expect(page.getByLabel('Notifications (F8)').getByText(/Clear the message box in this chat/),).toBeVisible();diff --git a/e2e/specs/mock/steering.spec.ts b/e2e/specs/mock/steering.spec.tsindex f689846fa3..0e4b80bbcf 100644--- a/e2e/specs/mock/steering.spec.ts+++ b/e2e/specs/mock/steering.spec.ts@@ -615,7 +615,8 @@ test.describe('mid-run steering and queuing', () => {await expect(row).toBeVisible({ timeout: 15000 });await expect(row.getByRole('button', { name: 'Remove message', exact: true })).toBeVisible();- const edit = row.getByRole('button', { name: 'Edit message', exact: true });+ await row.getByRole('button', { name: 'More options' }).click();+ const edit = page.getByRole('menuitem', { name: 'Edit message', exact: true });await expect(edit).toBeVisible();await edit.click();diff --git a/packages/client/src/components/IconButton.spec.tsx b/packages/client/src/components/IconButton.spec.tsxindex 9a2fbfd7d2..cb4c14f0b0 100644--- a/packages/client/src/components/IconButton.spec.tsx+++ b/packages/client/src/components/IconButton.spec.tsx@@ -33,6 +33,18 @@ describe('IconButton', () => {);});+ it('offers the theme control corner between square and round', () => {+ render(+ <IconButton label="Soft" size="lg" shape="control">+ soft+ </IconButton>,+ );++ const button = screen.getByRole('button', { name: 'Soft' });+ expect(button).toHaveClass('size-10', 'rounded-theme-control');+ expect(button).not.toHaveClass('rounded-full');+ });+it('keeps submit glyphs contrasted against the theme fill', () => {render(<IconButton label="Stop" variant="submit" size="theme" shape="theme">diff --git a/packages/client/src/components/IconButton.tsx b/packages/client/src/components/IconButton.tsxindex 9100bb132a..562821622d 100644--- a/packages/client/src/components/IconButton.tsx+++ b/packages/client/src/components/IconButton.tsx@@ -16,7 +16,7 @@ type IconButtonVariantProps = {| 'submit'| null;size?: 'xs' | 'sm' | 'md' | 'lg' | 'theme' | null;- shape?: 'round' | 'square' | 'theme' | null;+ shape?: 'round' | 'square' | 'control' | 'theme' | null;};const iconButtonVariants: (props?: IconButtonVariantProps & ClassProp) => string = cva(@@ -54,6 +54,8 @@ const iconButtonVariants: (props?: IconButtonVariantProps & ClassProp) => stringshape: {round: 'rounded-full',square: 'rounded-lg',+ /** The theme's control corner: softer than `square`, short of the full circle of `round`. */+ control: 'rounded-theme-control',theme: 'rounded-theme-control-round',},},