diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx
index bab48e241c..6991216399 100644
--- a/client/src/components/Chat/Input/ChatForm.tsx
+++ b/client/src/components/Chat/Input/ChatForm.tsx
@@ -554,6 +554,9 @@ const ChatForm = memo(function ChatForm({
speechToText: SpeechToText,
index,
});
+ /** The waveform stands in for the placeholder until words arrive, and is
+ * then the only thing drawn on that line. */
+ const listening = dictation.active && (textValue?.trim() ?? '') === '';
const uploadingCount = useMemo(() => {
let count = 0;
for (const file of files.values()) {
@@ -843,7 +846,11 @@ const ChatForm = memo(function ChatForm({
{endpoint && (
- {dictation.active && (textValue?.trim() ?? '') === '' && (
+ {listening && (
/* Stands in for the placeholder: same inset, same line, so
it reads as the input listening rather than as a widget
bolted on. Once words arrive the transcript takes over. */
diff --git a/client/src/components/Chat/Input/Composer/Bar.tsx b/client/src/components/Chat/Input/Composer/Bar.tsx
index 51e8cac378..badf9a6ae7 100644
--- a/client/src/components/Chat/Input/Composer/Bar.tsx
+++ b/client/src/components/Chat/Input/Composer/Bar.tsx
@@ -1,7 +1,7 @@
import React, { memo, useMemo, useState, useCallback } from 'react';
import * as Ariakit from '@ariakit/react';
import { Mic, Plus, Check, Square, ChevronDown } from 'lucide-react';
-import { MCPIcon, IconButton, TooltipAnchor, SendIcon } from '@librechat/client';
+import { IconButton, TooltipAnchor, SendIcon } from '@librechat/client';
import type { TConversation, EModelEndpoint, EndpointFileConfig } from 'librechat-data-provider';
import type { PaletteEntry, PaletteMode } from '~/hooks/Input/usePaletteEntries';
import type { Dictation } from '~/hooks/Input/useDictation';
@@ -24,14 +24,6 @@ const EMPTY_ENTRIES: PaletteEntry[] = [];
/** Matches the rows' `gap-1.5`, which the split arithmetic has to account for. */
const CHIP_GAP = 6;
-/**
- * Key of the aggregate MCP menu chip. Server rows are keyed `mcp:${serverName}`
- * (`usePaletteEntries`), so this cannot live in that namespace: a server named
- * `pinned` would produce the same key, and the bar would render two entries
- * with one React key and one packing-width slot.
- */
-export const PINNED_MCP_KEY = 'aggregate:mcp';
-
/**
* Whether every chip fits on the button row beside the `+` and the controls.
*
@@ -78,35 +70,8 @@ export function chipMenuModes(modes?: PaletteMode[]) {
}
/** Projects palette state into the persistent quick controls in one pass. */
-export function projectBarEntries(
- entries: PaletteEntry[],
- pinnedMcpEntry?: PaletteEntry,
-): PaletteEntry[] {
- const projected: PaletteEntry[] = [];
- const mcpModes: PaletteMode[] = [];
-
- for (const entry of entries) {
- if (entry.section === 'skill') {
- continue;
- }
- if (entry.section === 'mcp') {
- mcpModes.push({
- id: entry.itemId,
- label: entry.label,
- active: entry.active,
- onSelect: entry.onSelect,
- });
- }
- if (entry.active || entry.pinned) {
- projected.push(entry);
- }
- }
-
- if (pinnedMcpEntry != null && mcpModes.length > 0) {
- projected.push({ ...pinnedMcpEntry, modes: mcpModes });
- }
-
- return projected;
+export function projectBarEntries(entries: PaletteEntry[]): PaletteEntry[] {
+ return entries.filter((entry) => entry.section !== 'skill' && (entry.active || entry.pinned));
}
interface RoundButtonProps {
@@ -160,10 +125,9 @@ function RoundButton({
*/
interface ChipModesProps {
modes: PaletteMode[];
- menuLabel?: string;
}
-export function ChipModes({ modes, menuLabel }: ChipModesProps) {
+export function ChipModes({ modes }: ChipModesProps) {
const localize = useLocalize();
const [open, setOpen] = useState(false);
const active = modes.find((mode) => mode.active);
@@ -174,7 +138,7 @@ export function ChipModes({ modes, menuLabel }: ChipModesProps) {
aria-label={
active != null
? localize('com_ui_mode_value', { 0: active.label })
- : (menuLabel ?? localize('com_ui_mode'))
+ : localize('com_ui_mode')
}
onClick={(e) => e.stopPropagation()}
className="text-text-secondary hover:bg-surface-tertiary hover:text-text-primary focus-visible:ring-border-xheavy -mr-0.5 flex shrink-0 items-center gap-0.5 rounded px-1 text-xs transition-colors focus-visible:ring-2 focus-visible:outline-hidden"
@@ -305,33 +269,10 @@ function Bar({
gate lives in one place rather than being re-applied to its result here. */
const entries = allEntries;
- const manager = context?.mcpServerManager;
- const pinnedMcpEntry = useMemo(() => {
- if (manager?.isPinned !== true) {
- return undefined;
- }
- const { placeholderText, setIsPinned } = manager;
- return {
- key: PINNED_MCP_KEY,
- itemType: 'mcp',
- itemId: 'mcp',
- label: placeholderText || localize('com_ui_mcp_servers'),
- icon: ,
- section: 'mcp',
- active: true,
- pinned: true,
- onSelect: () => setIsPinned(false),
- };
- }, [manager, localize]);
-
/* Catalog skills are excluded: a picked skill is staged context for the next
turn, so it belongs in the tray above the textarea with files and quotes.
- Built-in tool pins remain visible while off. The legacy aggregate MCP pin
- remains one server menu alongside any selected server chips. */
- const barEntries = useMemo(
- () => projectBarEntries(entries, pinnedMcpEntry),
- [entries, pinnedMcpEntry],
- );
+ Built-in tool pins remain visible while off. */
+ const barEntries = useMemo(() => projectBarEntries(entries), [entries]);
/* Catalog order puts long skill and MCP names mid-row, stranding the rest of
that row; packing widest-first fills the rows instead. */
const { ordered: packedEntries, rootRef, widths } = useChipPacking(barEntries);
@@ -382,12 +323,8 @@ function Bar({
const renderChip = (entry: PaletteEntry) => {
const pinnedInactive = entry.pinned && !entry.active;
- const isPinnedMcp = entry.key === PINNED_MCP_KEY;
const menuModes = chipMenuModes(entry.modes);
- const modeMenu =
- menuModes.length > 0 ? (
-
- ) : null;
+ const modeMenu = menuModes.length > 0 ? : null;
const activate = pinnedInactive ? (
;
+
+/** The agent builder's Skills dialog views, in the same order and wording. */
+const VIEWS: Array<{ value: View; labelKey: TranslationKeys }> = [
+ { value: 'marketplace', labelKey: 'com_ui_all_proper' },
+ { value: 'mine', labelKey: 'com_ui_tools_view_made_by_you' },
+ { value: 'favorites', labelKey: 'com_ui_tools_view_favorites' },
+];
+
+const TITLE: Record = {
+ skill: 'com_ui_skills',
+ mcp: 'com_ui_mcp_servers',
+ files: 'com_ui_composer_files',
+};
+
+const SEARCH: Record = {
+ skill: 'com_ui_composer_search_skills',
+ mcp: 'com_ui_composer_search_mcp',
+ files: 'com_ui_composer_search_files',
+};
+
+const FILTER: Record = {
+ skill: 'com_ui_skills_filter',
+ mcp: 'com_ui_composer_mcp_filter',
+ files: 'com_ui_composer_files_filter',
+};
+
+/** The palette row as the agent builder's card expects it. Rows without a
+ * catalog record (a skill staged by name before the catalog loaded) have no
+ * card to show and are left to the chip in the bar. */
+function toItem(entry: PaletteEntry): AgentItem | null {
+ if (entry.section === 'skill') {
+ if (entry.skill == null) {
+ return null;
+ }
+ return {
+ kind: 'skill',
+ id: entry.itemId,
+ name: entry.label,
+ description: entry.description ?? '',
+ iconKey: 'skill',
+ skill: entry.skill,
+ ownedByUser: entry.ownedByUser,
+ };
+ }
+ if (entry.section === 'mcp') {
+ return {
+ kind: 'mcp',
+ id: entry.itemId,
+ name: entry.label,
+ description: entry.description ?? '',
+ iconKey: 'mcp',
+ ownedByUser: entry.ownedByUser,
+ toolCount: 0,
+ server: {
+ serverName: entry.itemId,
+ tools: [],
+ isConfigured: true,
+ isConnected: true,
+ metadata: { name: entry.label, pluginKey: entry.itemId, icon: entry.iconUrl },
+ },
+ };
+ }
+ return null;
+}
+
+const matches = (query: string, ...fields: Array) =>
+ query === '' || fields.some((field) => field?.toLowerCase().includes(query) === true);
+
+function EntryGrid({
+ section,
+ entries,
+ query,
+ view,
+}: {
+ section: 'skill' | 'mcp';
+ entries: PaletteEntry[];
+ query: string;
+ view: View;
+}) {
+ const localize = useLocalize();
+ const { favoriteKeys, toggle } = useToolFavorites();
+
+ const { items, selectedIds, byKey } = useMemo(() => {
+ const nextItems: AgentItem[] = [];
+ const selected = new Set();
+ const keyed = new Map();
+ for (const entry of entries) {
+ if (entry.section !== section || !matches(query, entry.label, entry.description)) {
+ continue;
+ }
+ const item = toItem(entry);
+ if (item == null || !matchesView(item, view, { favoritedIds: favoriteKeys })) {
+ continue;
+ }
+ const key = itemKey(item);
+ nextItems.push(item);
+ keyed.set(key, entry);
+ if (entry.active) {
+ selected.add(key);
+ }
+ }
+ return { items: nextItems, selectedIds: selected, byKey: keyed };
+ }, [entries, section, query, view, favoriteKeys]);
+
+ return (
+ byKey.get(itemKey(item))?.onSelect()}
+ view={view}
+ statusFor={(item) => byKey.get(itemKey(item))?.status}
+ favoriteKeys={favoriteKeys}
+ onToggleFavorite={toggle}
+ emptyKey={view === 'marketplace' || query !== '' ? 'com_ui_composer_no_results' : undefined}
+ ariaLabel={localize(TITLE[section])}
+ />
+ );
+}
+
+interface CatalogProps {
+ section: CatalogSection | null;
+ onClose: () => void;
+ entries: PaletteEntry[];
+ onAttach: (file: TFile) => void;
+ /** Where focus returns on close: the palette that opened this is gone. */
+ returnFocusRef: React.RefObject;
+}
+
+/**
+ * Everything behind a palette section's "Show all": the palette keeps a short
+ * list per section, and this is where the rest of it lives. Skills and MCP
+ * servers reuse the agent builder's card grid, toggled through the same
+ * handlers as the palette rows so the two cannot disagree.
+ */
+export default function Catalog({
+ section,
+ onClose,
+ entries,
+ onAttach,
+ returnFocusRef,
+}: CatalogProps) {
+ const localize = useLocalize();
+ const [search, setSearch] = useState('');
+ const [view, setView] = useState('marketplace');
+ const [fileView, setFileView] = useState('all');
+ const [shown, setShown] = useState(section);
+ if (section !== shown) {
+ setShown(section);
+ if (section != null) {
+ setSearch('');
+ setView('marketplace');
+ setFileView('all');
+ }
+ }
+ const current = section ?? shown;
+ const viewOptions = useMemo(
+ () =>
+ (current === 'files' ? FILE_VIEWS : VIEWS).map((option) => ({
+ value: option.value,
+ label: localize(option.labelKey),
+ })),
+ [current, localize],
+ );
+ const query = search.trim().toLowerCase();
+
+ /* Focus goes back to the message field only after a mouse or keyboard close:
+ after a tap it would summon the on-screen keyboard the user just left, the
+ same rule the palette applies to its own close. */
+ const focusTargetRef = useRef(null);
+ useEffect(() => {
+ if (section == null) {
+ return;
+ }
+ const aim = (touch: boolean) => {
+ focusTargetRef.current = touch ? null : returnFocusRef.current;
+ };
+ aim(window.matchMedia('(pointer: coarse)').matches);
+ const onPointer = (event: PointerEvent) => aim(event.pointerType !== 'mouse');
+ const onKey = () => aim(false);
+ window.addEventListener('pointerdown', onPointer, true);
+ window.addEventListener('keydown', onKey, true);
+ return () => {
+ window.removeEventListener('pointerdown', onPointer, true);
+ window.removeEventListener('keydown', onKey, true);
+ };
+ }, [section, returnFocusRef]);
+
+ return (
+ {
+ if (!open) {
+ onClose();
+ }
+ }}
+ >
+ {current != null && (
+
+
+ {localize(TITLE[current])}
+
+ {localize(SEARCH[current])}
+
+ {/* Reaches into the dialog's right padding so the scrollbar sits at the
+ edge, and pads the content back so the cards keep their inset. The
+ controls ride inside it as a sticky header, so they share the cards'
+ exact width whether the scrollbar takes space or overlays; the small
+ left inset keeps the search field's focus ring from being clipped. */}
+
+
+
+ current === 'files' ? setFileView(value as FileView) : setView(value as View)
+ }
+ aria-labelledby="composer-catalog-view-label"
+ />
+
+ {current === 'files' ? (
+
+ ) : (
+
+ )}
+
+
+
+ )}
+
+ );
+}
diff --git a/client/src/components/Chat/Input/Composer/Effort.tsx b/client/src/components/Chat/Input/Composer/Effort.tsx
index ca65d275ec..396cd2b9e7 100644
--- a/client/src/components/Chat/Input/Composer/Effort.tsx
+++ b/client/src/components/Chat/Input/Composer/Effort.tsx
@@ -12,6 +12,7 @@ import type { SettingDefinition, TConversation, TReasoningOverride } from 'libre
import type { CSSProperties } from 'react';
import type { LocalizeFunction } from '~/common';
import type { TranslationKeys } from '~/hooks';
+import useReducedMotion from '~/hooks/Generic/useReducedMotion';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
@@ -28,6 +29,16 @@ const TRACK_H = 24;
* row is sized to the largest it can get and the rail is banded inside it. */
const THUMB = 28;
const THUMB_ACTIVE = 32;
+/** How far, in px, the held thumb can lean toward the pointer before the
+ * gesture commits to the next stop. The lean approaches this and never
+ * reaches it, so pulling harder only ever tightens. */
+const MAX_LEAN = 10;
+/** How quickly the lean stiffens; the constant iOS uses for rubber banding. */
+const LEAN_STIFFNESS = 0.55;
+/** Stretch along the pull and the matching squash across it, at full lean. */
+const LEAN_STRETCH = 0.16;
+const LEAN_SQUASH = 0.08;
+
/** Which way each arrow key moves along the track. */
const ARROW_STEP: Record = {
ArrowLeft: -1,
@@ -41,6 +52,27 @@ const ARROW_STEP: Record = {
* rendering it directly is what leaks `com_ui_medium` into the UI. Shared with
* the trigger button, which is the only place the level is named.
*/
+/**
+ * Where a value sits on the effort scale, for telling whether a change went up
+ * or down. The separate mode ranks below every level.
+ */
+export function effortRank(setting: SettingDefinition, value: string | undefined): number {
+ if (value == null || UNGRADED_VALUES.has(value)) {
+ return -1;
+ }
+ return (setting.options ?? [])
+ .map(String)
+ .filter((option) => !UNGRADED_VALUES.has(option))
+ .indexOf(value);
+}
+
+/** Rubber-band resistance: tracks the pointer closely at first and stiffens
+ * toward `MAX_LEAN`, the curve iOS uses at the end of a scroll view. */
+export function leanFor(distance: number): number {
+ const magnitude = MAX_LEAN * (1 - 1 / ((Math.abs(distance) * LEAN_STIFFNESS) / MAX_LEAN + 1));
+ return Math.sign(distance) * magnitude;
+}
+
export function resolveEffortLabel(
setting: SettingDefinition,
value: string,
@@ -87,6 +119,7 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
/** One per stop, so an arrow key can move focus along with the selection. */
const stopRefs = useRef<(HTMLButtonElement | null)[]>([]);
const [dragging, setDragging] = useState(false);
+ const reducedMotion = useReducedMotion();
const { levels, ungradedValue } = useMemo(() => {
const options = (setting.options ?? []).map(String);
@@ -195,7 +228,21 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
return;
}
const ratio = (clientX - rect.left - THUMB / 2) / usable;
- pendingRef.current = Math.round(Math.min(1, Math.max(0, ratio)) * (levels.length - 1));
+ const index = Math.round(Math.min(1, Math.max(0, ratio)) * (levels.length - 1));
+ pendingRef.current = index;
+ /* The thumb leans toward the pointer from the stop it is on, stretching
+ along the pull, and only moves stops once the pointer crosses halfway.
+ Written straight to the track as custom properties: the thumb follows
+ the pointer at frame rate without re-rendering anything. */
+ if (!reducedMotion) {
+ const stopX =
+ rect.left + THUMB / 2 + (levels.length === 1 ? 1 : index / (levels.length - 1)) * usable;
+ const lean = leanFor(clientX - stopX);
+ const strength = Math.abs(lean) / MAX_LEAN;
+ track.style.setProperty('--effort-lean', `${lean.toFixed(2)}px`);
+ track.style.setProperty('--effort-stretch', (1 + LEAN_STRETCH * strength).toFixed(3));
+ track.style.setProperty('--effort-squash', (1 - LEAN_SQUASH * strength).toFixed(3));
+ }
if (frameRef.current != null) {
return;
}
@@ -208,9 +255,17 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
}
});
},
- [levels, select],
+ [levels, select, reducedMotion],
);
+ /** Lets go of the lean; the thumb springs back onto its stop. */
+ const settle = useCallback(() => {
+ const track = trackRef.current;
+ track?.style.removeProperty('--effort-lean');
+ track?.style.removeProperty('--effort-stretch');
+ track?.style.removeProperty('--effort-squash');
+ }, []);
+
useEffect(
() => () => {
if (frameRef.current != null) {
@@ -245,16 +300,12 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
thumb lifting rather than as a misaligned track. */
const centerOf = (index: number) =>
`calc(${THUMB / 2}px + ${ratioOf(index)} * (100% - ${THUMB}px))`;
- /* Ends half a rail-height PAST the thumb's centre, which puts the fill's own
- rounded cap concentric with the thumb. The cap's radius (TRACK_H / 2) is
- smaller than the thumb's, so the thumb geometrically contains it at every
- position, including the first stop where the fill disappears entirely
- beneath it.
- That containment holds mid-animation too, because the offset is constant:
- collapsing to zero at the first stop instead left the fill briefly wider
- than the thumb could cover, which flashed green on the way down. */
+ /* Ends at the thumb's centre, so the thumb covers the fill's end even while
+ it leans toward the pointer (up to MAX_LEAN, well inside its radius), and
+ the fill disappears entirely beneath it at the first stop. The two glide
+ on the same curve, so that holds mid-animation as well. */
const fillWidth = (index: number) =>
- `calc(${THUMB / 2 + TRACK_H / 2}px + ${ratioOf(index)} * (100% - ${THUMB}px))`;
+ `calc(${THUMB / 2}px + ${ratioOf(index)} * (100% - ${THUMB}px))`;
/* `descriptionCode` is what says whether this is a translation key or the
literal text an admin wrote. Translating it either way sent literal text
@@ -305,10 +356,12 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
}
draggingRef.current = false;
setDragging(false);
+ settle();
}}
onPointerCancel={() => {
draggingRef.current = false;
setDragging(false);
+ settle();
}}
className={cn(
'relative w-full touch-none transition-opacity duration-200 select-none',
@@ -345,15 +398,15 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
@@ -391,17 +444,19 @@ function Effort({ setting, conversation, value, onChange }: EffortProps) {
+ data-dragging={dragging || undefined}
+ className="composer-effort-thumb block h-full w-full"
+ >
+
+
{levels.map((value, index) => {
diff --git a/client/src/components/Chat/Input/Composer/Files.tsx b/client/src/components/Chat/Input/Composer/Files.tsx
new file mode 100644
index 0000000000..6dde9fbccd
--- /dev/null
+++ b/client/src/components/Chat/Input/Composer/Files.tsx
@@ -0,0 +1,322 @@
+import { memo, useRef, useMemo, useState, useEffect } from 'react';
+import { Eye, Search } from 'lucide-react';
+import { apiBaseUrl } from 'librechat-data-provider';
+import { Button, IconButton, Spinner, useToastContext } from '@librechat/client';
+import type { TFile } from 'librechat-data-provider';
+import type { TranslationKeys } from '~/hooks';
+import FilePreviewDialog, {
+ formatBytes,
+ getDisplayType,
+} from '~/components/Chat/Messages/Content/FilePreviewDialog';
+import { getPreviewKind } from '~/components/Chat/Messages/Content/preview';
+import { getFileType, toAbsoluteFilePath, triggerDownload } from '~/utils';
+import DialogImage from '~/components/Chat/Messages/Content/DialogImage';
+import FilePreview from '~/components/Chat/Input/Files/FilePreview';
+import { useGetFiles, useFilePreviewBlob } from '~/data-provider';
+import { useLocalize, useAuthContext } from '~/hooks';
+
+export type FileView = 'all' | 'images' | 'documents';
+
+export const FILE_VIEWS: Array<{ value: FileView; labelKey: TranslationKeys }> = [
+ { value: 'all', labelKey: 'com_ui_all_proper' },
+ { value: 'images', labelKey: 'com_ui_composer_files_images' },
+ { value: 'documents', labelKey: 'com_ui_composer_files_documents' },
+];
+
+const isImage = (file: TFile) => file.type?.startsWith('image/') === true;
+
+/** Images, audio and video are media; everything else is a document. */
+const isDocument = (file: TFile) =>
+ !isImage(file) &&
+ file.type?.startsWith('audio/') !== true &&
+ file.type?.startsWith('video/') !== true;
+
+/** What a card's preview button opens, if anything: images in the message
+ * image viewer, PDFs in the message file preview. */
+function previewOf(file: TFile): 'image' | 'pdf' | null {
+ if (isImage(file)) {
+ return 'image';
+ }
+ return getPreviewKind(file.filename ?? '', file.type ?? undefined, file.source) === 'pdf'
+ ? 'pdf'
+ : null;
+}
+
+function formatDate(file: TFile): string {
+ const raw = file.updatedAt ?? file.createdAt;
+ if (raw == null) {
+ return '';
+ }
+ return new Date(raw).toLocaleDateString(undefined, {
+ day: 'numeric',
+ month: 'short',
+ year: 'numeric',
+ });
+}
+
+/** The image itself for images, so the card is recognisable at a glance; the
+ * file-type tile otherwise, or when the image cannot be loaded. */
+function Thumbnail({ file }: { file: TFile }) {
+ const [failed, setFailed] = useState(false);
+ if (isImage(file) && !failed && file.filepath) {
+ return (
+
+ setFailed(true)}
+ className="h-full w-full object-cover"
+ />
+
+ );
+ }
+ return (
+
+
+
+ );
+}
+
+interface FileCardProps {
+ file: TFile;
+ onAttach: (file: TFile) => void;
+ onPreview: (file: TFile, trigger: HTMLButtonElement) => void;
+}
+
+/** Laid out like the skill and MCP cards: the card is the attach action, and
+ * the corner holds the one secondary action, previewing, where they keep the
+ * favourite star. */
+const FileCard = memo(function FileCard({ file, onAttach, onPreview }: FileCardProps) {
+ const localize = useLocalize();
+ const name = file.filename ?? '';
+ const details = [
+ getDisplayType(localize, file.type ?? undefined, name),
+ formatBytes(file.bytes ?? 0),
+ ];
+ const canPreview = previewOf(file) != null;
+
+ return (
+
+ );
+});
+
+/** What the grid shows in place of cards: still loading, the list failed to
+ * load, or nothing matches the search and view. */
+function EmptyState({
+ loading,
+ failed,
+ onRetry,
+}: {
+ loading: boolean;
+ failed: boolean;
+ onRetry: () => void;
+}) {
+ const localize = useLocalize();
+ if (loading) {
+ return (
+
+
+ {localize('com_ui_loading')}
+
+ );
+ }
+ if (failed) {
+ return (
+
+
+ {localize('com_ui_error_connection')}
+
+ {/* The files query does not refetch on mount, focus or reconnect, so
+ reopening the dialog would not recover without this. */}
+
+
+ );
+ }
+ return (
+
+
+
{localize('com_ui_composer_no_results')}
+
+ );
+}
+
+interface FileGridProps {
+ query: string;
+ view: FileView;
+ onAttach: (file: TFile) => void;
+}
+
+/** The user's files as cards, filtered by name and kind, with a preview for
+ * anything the message viewers can show. */
+export default function FileGrid({ query, view, onAttach }: FileGridProps) {
+ const localize = useLocalize();
+ const { data: files = [], isLoading, isError, refetch } = useGetFiles();
+ const [previewing, setPreviewing] = useState(null);
+ /** The Preview button that opened the viewer, where focus returns on close. */
+ const previewTriggerRef = useRef(null);
+ const openPreview = (file: TFile, trigger: HTMLButtonElement) => {
+ previewTriggerRef.current = trigger;
+ setPreviewing(file);
+ };
+
+ const visible = useMemo(
+ () =>
+ files.filter((file) => {
+ if (query !== '' && file.filename?.toLowerCase().includes(query) !== true) {
+ return false;
+ }
+ if (view === 'images') {
+ return isImage(file);
+ }
+ if (view === 'documents') {
+ return isDocument(file);
+ }
+ return true;
+ }),
+ [files, query, view],
+ );
+
+ const previewKind = previewing != null ? previewOf(previewing) : null;
+
+ /* The image is fetched through the backend by id, as the PDF preview is,
+ rather than from its stored link: a signed storage link can expire between
+ the list refreshing it and the preview opening. The link is the fallback. */
+ const { user } = useAuthContext();
+ const { refetch: fetchPreview } = useFilePreviewBlob(user?.id, previewing?.file_id);
+ const { showToast } = useToastContext();
+ /* Read through a ref: `showToast` is a new function each render, and the
+ preview effect must not refetch because of it. */
+ const previewFailedRef = useRef<(file: TFile) => void>(() => undefined);
+ previewFailedRef.current = (file: TFile) => {
+ showToast({
+ message: localize('com_ui_composer_preview_failed', { 0: file.filename ?? '' }),
+ status: 'error',
+ });
+ setPreviewing(null);
+ };
+ const [imageUrl, setImageUrl] = useState();
+ useEffect(() => {
+ if (previewKind !== 'image' || previewing == null) {
+ return;
+ }
+ let objectUrl: string | undefined;
+ let cancelled = false;
+ void fetchPreview().then(({ data }) => {
+ if (cancelled) {
+ return;
+ }
+ if (data != null) {
+ objectUrl = URL.createObjectURL(data);
+ setImageUrl(objectUrl);
+ return;
+ }
+ /* Nothing to show: stay on the grid and say so, rather than open an
+ empty viewer or let the click appear to do nothing. */
+ const fail = () => previewFailedRef.current(previewing);
+ if (!previewing.filepath) {
+ fail();
+ return;
+ }
+ /* A stored link can be expired: open only once it actually loads. */
+ const fallback = toAbsoluteFilePath(previewing.filepath, apiBaseUrl());
+ const probe = new Image();
+ probe.onload = () => !cancelled && setImageUrl(fallback);
+ probe.onerror = () => !cancelled && fail();
+ probe.src = fallback;
+ });
+ return () => {
+ cancelled = true;
+ if (objectUrl != null) {
+ URL.revokeObjectURL(objectUrl);
+ }
+ setImageUrl(undefined);
+ };
+ }, [previewKind, previewing, fetchPreview]);
+
+ const closePreview = (open: boolean) => {
+ if (!open) {
+ setPreviewing(null);
+ }
+ };
+
+ return (
+ <>
+ {visible.length === 0 ? (
+ void refetch()}
+ />
+ ) : (
+
+ {visible.map((file) => (
+
+
+
+ ))}
+
+ )}
+ {
+ if (imageUrl != null) {
+ triggerDownload(imageUrl, previewing?.filename ?? 'image');
+ }
+ }}
+ />
+
+ >
+ );
+}
diff --git a/client/src/components/Chat/Input/Composer/Palette.tsx b/client/src/components/Chat/Input/Composer/Palette.tsx
index 991fccd035..e326d134fd 100644
--- a/client/src/components/Chat/Input/Composer/Palette.tsx
+++ b/client/src/components/Chat/Input/Composer/Palette.tsx
@@ -11,7 +11,7 @@ import { useSetAtom } from 'jotai';
import * as Ariakit from '@ariakit/react';
import { AutoSizer, List } from 'react-virtualized';
import { Star, Plus, Search, ChevronDown } from 'lucide-react';
-import { FileUpload, IconButton, TooltipAnchor } from '@librechat/client';
+import { Button, FileUpload, IconButton, TooltipAnchor, useMediaQuery } from '@librechat/client';
import type {
TFile,
TConversation,
@@ -21,6 +21,7 @@ import type {
import type { PaletteEntry, PaletteSection } from '~/hooks/Input/usePaletteEntries';
import type { AttachEntry } from '~/hooks/Input/useAttachItems';
import type { ExtendedFile, FileSetter } from '~/common';
+import type { CatalogSection } from './Catalog';
import type { TranslationKeys } from '~/hooks';
import FilePreview from '~/components/Chat/Input/Files/FilePreview';
import { SharePointPickerDialog } from '~/components/SharePoint';
@@ -35,8 +36,14 @@ import { isMacPlatform } from '~/utils/shortcuts';
import { useBadgeRowContext } from '~/Providers';
import { composerLiftFamily } from './state';
import { useLocalize } from '~/hooks';
+import Catalog from './Catalog';
const HEADER_HEIGHT = 26;
+/** A header carrying its section's "Show all" button, which is taller than the
+ * label alone. */
+const HEADER_ACTION_HEIGHT = 32;
+/** Rows a capped section shows before the rest move behind "Show all". */
+const SECTION_LIMIT = 5;
const ROW_HEIGHT = 34;
const ROW_HEIGHT_DESC = 46;
/* Kept short enough that the popup clears the space below the composer, so it
@@ -92,13 +99,13 @@ const SECTION_LABEL: Record = {
};
type PaletteRow =
- | { type: 'header'; key: string; label: string }
+ | { type: 'header'; key: string; label: string; showAll?: CatalogSection }
| { type: 'attach'; key: string; entry: AttachEntry }
| { type: 'more'; key: string; label: string }
| { type: 'file'; key: string; file: TFile }
| { type: 'entry'; key: string; entry: PaletteEntry; isFavorite: boolean };
-const isSelectable = (row: PaletteRow) => row.type !== 'header';
+const isSelectable = (row: PaletteRow) => row.type !== 'header' || row.showAll != null;
/** Ranks a match so exact prefixes float above incidental description hits. */
function scoreEntry(label: string, description: string | undefined, query: string): number {
@@ -130,7 +137,7 @@ function formatFileDate(file: TFile): string {
function rowHeight(row: PaletteRow): number {
if (row.type === 'header') {
- return HEADER_HEIGHT;
+ return row.showAll != null ? HEADER_ACTION_HEIGHT : HEADER_HEIGHT;
}
if (row.type === 'entry' && row.entry.description != null && row.entry.description !== '') {
return ROW_HEIGHT_DESC;
@@ -211,14 +218,14 @@ function Palette({
with the controlled form, hide-on-interact-outside fired on mousedown and
the disclosure's own click re-opened it, so clicking `+` while the palette
was up reopened it instead of closing it. */
- const popover = Ariakit.usePopoverStore({ placement: 'bottom-start' });
+ /* Above the composer on a phone, where the composer sits at the bottom of the
+ screen; the lift below exists only to make room for the downward popup. */
+ const opensUp = useMediaQuery('(max-width: 767px)');
+ const popover = Ariakit.usePopoverStore({ placement: opensUp ? 'top-start' : 'bottom-start' });
const open = popover.useState('open');
const context = useBadgeRowContext();
const mcpManager = context?.mcpServerManager;
const configDialogOpen = mcpManager?.getConfigDialogProps()?.isOpen === true;
- useMCPRefresh({
- enabled: (open || configDialogOpen) && (mcpManager?.availableMCPServers.length ?? 0) > 0,
- });
useEffect(() => {
if (open) {
onOpened?.();
@@ -230,6 +237,20 @@ function Palette({
to a tool once will do it again, and re-expanding every time is the cost of
hiding it. */
const [showAllAttach, setShowAllAttach] = useState(false);
+ /** The section whose "Show all" dialog is open, if any. */
+ const [catalog, setCatalog] = useState(null);
+ /** Set while the palette closes to hand over to a dialog, so its close does
+ * not pull focus back into the composer from under the dialog. */
+ const openingCatalogRef = useRef(false);
+ /** Where focus lands when a "Show all" dialog closes. */
+ const catalogReturnRef = useRef(null);
+ /* The MCP catalog shows the same live statuses as the palette rows, so it
+ keeps the refresh running after the palette hands over to it. */
+ useMCPRefresh({
+ enabled:
+ (open || configDialogOpen || catalog === 'mcp') &&
+ (mcpManager?.availableMCPServers.length ?? 0) > 0,
+ });
/* Closing runs in two beats, so the rows below never slide up through a hole
where the folded destinations used to be: they fade where they stand, and
only once they are gone does the list close over them. */
@@ -326,7 +347,7 @@ function Palette({
useEffect(() => () => applyLift(0), [applyLift]);
const baselineRef = useRef(null);
const updateLift = useCallback(() => {
- if (!mounted) {
+ if (!mounted || opensUp) {
baselineRef.current = null;
applyLift(0);
return;
@@ -347,7 +368,7 @@ function Palette({
viewport != null ? viewport.offsetTop + viewport.height : window.innerHeight;
applyLift(Math.max(0, Math.ceil(needed - (viewportBottom - baselineRef.current))));
follow();
- }, [mounted, popupHeight, applyLift, anchorRef, follow]);
+ }, [mounted, opensUp, popupHeight, applyLift, anchorRef, follow]);
useLayoutEffect(updateLift, [updateLift]);
@@ -482,12 +503,17 @@ function Palette({
if (list.length === 0) {
return;
}
+ /* Tools are a short fixed set; skills and servers run to hundreds, so
+ the palette keeps a handful and the dialog holds the rest. */
+ const capped = section !== 'tool';
next.push({
type: 'header',
key: `h:${section}`,
label: localize(SECTION_LABEL[section]),
+ showAll: capped ? section : undefined,
});
- for (const entry of list) {
+ const shown = capped ? list.slice(0, SECTION_LIMIT) : list;
+ for (const entry of shown) {
next.push({ type: 'entry', key: entry.key, entry, isFavorite: false });
}
};
@@ -497,8 +523,13 @@ function Palette({
pushSection('mcp');
if (canAttach && recent.files.length > 0) {
- next.push({ type: 'header', key: 'h:files', label: localize('com_ui_composer_files') });
- for (const file of recent.files) {
+ next.push({
+ type: 'header',
+ key: 'h:files',
+ label: localize('com_ui_composer_files'),
+ showAll: 'files',
+ });
+ for (const file of recent.files.slice(0, SECTION_LIMIT)) {
next.push({ type: 'file', key: `file:${file.file_id}`, file });
}
}
@@ -631,7 +662,12 @@ function Palette({
return () => window.clearTimeout(timer);
}, [collapsing]);
- const firstSelectable = useMemo(() => rows.findIndex(isSelectable), [rows]);
+ /* A section's "Show all" is reachable by the arrows, but never the resting
+ highlight: Enter straight after opening should pick a row, not a dialog. */
+ const firstSelectable = useMemo(() => {
+ const firstRow = rows.findIndex((row) => row.type !== 'header');
+ return firstRow === -1 ? rows.findIndex(isSelectable) : firstRow;
+ }, [rows]);
/** Where the active row sits now, falling back to the first row that can be
* chosen once the query has filtered the old one away. */
@@ -654,12 +690,17 @@ function Palette({
/* Cleared on unmount rather than on close: the popup stays up through its
leave animation, so clearing on close emptied the field and repopulated the
- list in full view of the user. */
+ list in full view of the user.
+ The highlight goes with it. It follows the pointer as well as the arrows,
+ so keeping it made the next opening light up whatever row or "Show all"
+ the pointer last crossed, wherever the pointer now is. */
const [wasMounted, setWasMounted] = useState(false);
if (mounted !== wasMounted) {
setWasMounted(mounted);
if (!mounted) {
setSearch('');
+ setActiveKey('');
+ setScrollToActive(false);
}
}
@@ -684,7 +725,18 @@ function Palette({
const activate = useCallback(
(index: number) => {
const row = rows[index];
- if (!row || row.type === 'header') {
+ if (!row) {
+ return;
+ }
+ if (row.type === 'header') {
+ if (row.showAll == null) {
+ return;
+ }
+ openingCatalogRef.current = true;
+ catalogReturnRef.current =
+ anchorRef.current?.querySelector('[data-testid="text-input"]') ?? null;
+ popover.hide();
+ setCatalog(row.showAll);
return;
}
if (row.type === 'attach') {
@@ -715,7 +767,7 @@ function Palette({
a file picker, dismisses it. */
row.entry.onSelect();
},
- [rows, popover, recent, showAllAttach],
+ [rows, popover, recent, showAllAttach, anchorRef],
);
/**
@@ -815,6 +867,32 @@ function Palette({
>
{row.label}
+ )}
);
}
@@ -941,6 +1019,7 @@ function Palette({
const departing = row.type === 'attach' && row.entry.primary !== true && collapsing;
const { label, icon } = row.entry;
const description = isEntry ? row.entry.description : undefined;
+ const status = isEntry ? row.entry.status : undefined;
const checked = isEntry ? row.entry.active : false;
const favorited = isEntry && row.isFavorite;
const canFavorite = isEntry && row.entry.favoritable !== false;
@@ -989,11 +1068,24 @@ function Palette({
}
className="flex h-full min-w-0 flex-1 cursor-pointer items-center gap-2.5 rounded-lg px-2 text-left"
>
-
+
{icon}
+ {status != null && (
+ /* Sits on the icon's corner like the MCP menu's server items;
+ the ring takes the popup's surface so the dot reads as cut
+ out of the glyph. */
+
+ )}
{label}
+ {/* The dot is color only, so the status is still said aloud. */}
+ {status != null && {status.label}}
{description != null && description !== '' && (
{description}
@@ -1010,6 +1102,7 @@ function Palette({
{
@@ -1053,6 +1146,7 @@ function Palette({
{
@@ -1065,7 +1159,7 @@ function Palette({
className={cn(
'h-4 w-4',
favorited
- ? 'text-accent-primary group-hover:text-accent-primary-hover'
+ ? 'text-series-4 group-hover:text-series-4'
: 'text-text-secondary group-hover:text-text-primary',
)}
fill={favorited ? 'currentColor' : 'none'}
@@ -1098,8 +1192,9 @@ function Palette({
return (
<>
- {/* Opens downward like the thinking popup; Ariakit flips it above on
- its own once the composer sits too low for it to fit below. */}
+ {/* Opens downward like the thinking popup on wider screens, and above
+ on a phone; Ariakit flips a downward one above on its own once the
+ composer sits too low for it to fit below. */}
{/* The disclosure is the outer component and the tooltip is what it
renders through, not the other way round: passing a
@@ -1180,8 +1275,10 @@ function Palette({
onClose={() => {
window.requestAnimationFrame(() => {
/* Reopened within the frame: that session owns the input and
- the field must not take focus from it. */
- if (popover.getState().open) {
+ the field must not take focus from it. Handed over to a
+ "Show all" dialog: the dialog owns focus now. */
+ if (popover.getState().open || openingCatalogRef.current) {
+ openingCatalogRef.current = false;
return;
}
const touch =
@@ -1318,6 +1415,16 @@ function Palette({
downloadProgress={attach.downloadProgress}
maxSelectionCount={attach.maxSelectionCount}
/>
+ setCatalog(null)}
+ entries={entries}
+ returnFocusRef={catalogReturnRef}
+ onAttach={(file) => {
+ setCatalog(null);
+ recent.attach(file);
+ }}
+ />
>
);
}
diff --git a/client/src/components/Chat/Input/Composer/Thinking.tsx b/client/src/components/Chat/Input/Composer/Thinking.tsx
index b98fbe2f0e..f5347220d7 100644
--- a/client/src/components/Chat/Input/Composer/Thinking.tsx
+++ b/client/src/components/Chat/Input/Composer/Thinking.tsx
@@ -1,10 +1,10 @@
import { memo, useRef, useMemo, useState, useLayoutEffect } from 'react';
import * as Ariakit from '@ariakit/react';
import { ChevronDown } from 'lucide-react';
-import { TooltipAnchor } from '@librechat/client';
+import { TooltipAnchor, useMediaQuery } from '@librechat/client';
import type { SettingDefinition, TConversation, TReasoningOverride } from 'librechat-data-provider';
import { ReasoningControl, useComposerReasoning } from '../Reasoning';
-import Effort, { resolveEffortLabel } from './Effort';
+import Effort, { effortRank, resolveEffortLabel } from './Effort';
import { useGetStartupConfig } from '~/data-provider';
import { useChatContext } from '~/Providers';
import { cn, getModelSpec } from '~/utils';
@@ -32,7 +32,10 @@ function ThinkingControl({
with the controlled form, hide-on-interact-outside fired on mousedown and
the disclosure's own click re-opened it, so a second click never closed the
popup. */
- const popover = Ariakit.usePopoverStore({ placement: 'bottom' });
+ /* Above the composer on a phone, where the composer sits at the bottom of the
+ screen and a popup below it would open off the edge or under the keyboard. */
+ const isMobile = useMediaQuery('(max-width: 767px)');
+ const popover = Ariakit.usePopoverStore({ placement: isMobile ? 'top' : 'bottom' });
const open = popover.useState('open');
const disclosureRef = useRef(null);
const ghostsRef = useRef(null);
@@ -53,6 +56,29 @@ function ThinkingControl({
? localize('com_ui_auto')
: resolveEffortLabel(setting, currentValue, localize);
+ /* The word on the button moves with the level: up for a higher one, down for
+ a lower one, the outgoing word staying behind as a blurred ghost until it
+ has cleared. `turn` restarts the animation for each change. */
+ const rank = effortRank(setting, currentValue);
+ const [label, setLabel] = useState({
+ text: display,
+ rank,
+ previous: null as string | null,
+ up: true,
+ turn: 0,
+ });
+ if (label.text !== display) {
+ setLabel({
+ text: display,
+ rank,
+ previous: label.text,
+ up: rank >= label.rank,
+ turn: label.turn + 1,
+ });
+ }
+ const clearPrevious = (turn: number) =>
+ setLabel((state) => (state.turn === turn ? { ...state, previous: null } : state));
+
/* Every label this button can show, in the active language. All of them get
measured rather than picking by character count: the longest string is not
the widest one in a proportional font, and even less so across languages. */
@@ -83,8 +109,8 @@ function ThinkingControl({
}
}, [open, display, optionLabels]);
- /* Opens downward; Ariakit flips it above on its own once the composer sits
- low enough in the viewport that there is no room below. */
+ /* Opens downward on wider screens; Ariakit flips it above on its own once
+ the composer sits low enough in the viewport that there is no room below. */
return (
{/* Named on hover like the mic and send buttons: closed, the trigger shows
@@ -115,8 +141,9 @@ function ThinkingControl({
{/* Closed, the button hugs its label so it takes no more room in the bar
than it needs. Open, it widens to the longest label and the text
centres, so changing levels while the popup is up never shifts the
- row. The label itself swaps plainly: a keyed crossfade dipped it to
- transparent mid-change, which read as a flicker rather than polish. */}
+ row. A level change never dips the label to transparent (a plain
+ keyed crossfade did, and read as a flicker): the new word arrives
+ while the old one is still leaving, so one is always legible. */}
{display}
+
+ {label.previous != null && (
+ clearPrevious(label.turn)}
+ className={cn(
+ 'col-start-1 row-start-1',
+ label.up ? 'composer-label-out-up' : 'composer-label-out-down',
+ )}
+ >
+ {label.previous}
+
+ )}
+ 0 && (label.up ? 'composer-label-in-up' : 'composer-label-in-down'),
+ )}
+ >
+ {display}
+
+
{/* Turns to point at the popup, which is the only cue that the button
and the panel below it are one control. */}
@@ -164,6 +214,21 @@ function ThinkingControl({
click immediately re-opened it. Excluding the trigger leaves a single
clean toggle. */
hideOnInteractOutside={(event) => !disclosureRef.current?.contains(event.target as Node)}
+ /* On a phone the button sits inside the composer, so opening above the
+ button alone would cover the message field. It rises from the
+ composer's top edge instead, still centred over its button. */
+ getAnchorRect={
+ isMobile
+ ? (anchor) => {
+ const button = anchor?.getBoundingClientRect();
+ const composer = anchor?.closest('form')?.getBoundingClientRect();
+ if (button == null || composer == null) {
+ return null;
+ }
+ return { x: button.x, y: composer.y, width: button.width, height: 0 };
+ }
+ : undefined
+ }
aria-label={localize('com_ui_composer_thinking_value', { 0: display })}
/* `border-light` resolves to the same value as `surface-tertiary`, so
the edge was invisible against the popup's own background. */
diff --git a/client/src/components/Chat/Input/Composer/Waveform.tsx b/client/src/components/Chat/Input/Composer/Waveform.tsx
index ca20f732e0..7c117c60f3 100644
--- a/client/src/components/Chat/Input/Composer/Waveform.tsx
+++ b/client/src/components/Chat/Input/Composer/Waveform.tsx
@@ -1,9 +1,19 @@
-import { memo } from 'react';
+import { memo, useRef, useEffect } from 'react';
+import useReducedMotion from '~/hooks/Generic/useReducedMotion';
+import useElementSize from '~/hooks/Generic/useElementSize';
import useAudioLevels from '~/hooks/Input/useAudioLevels';
import { cn } from '~/utils';
-/** Bars never collapse to nothing, so silence still reads as a live line. */
-const MIN_BAR = 0.1;
+/** One loudness sample per this many ms; each becomes a bar. */
+const SAMPLE_MS = 55;
+const BAR_WIDTH = 3;
+/** One bar and the gap after it, in px. */
+const BAR_PITCH = 5;
+/** Silence still reads as a live line rather than as nothing. */
+const MIN_BAR_PX = 3;
+/** A frame this late (a backgrounded tab) restarts the clock instead of
+ * replaying every missed sample at once. */
+const MAX_CATCH_UP_MS = 500;
interface WaveformProps {
/** Whether the microphone is running; the levels are sampled from here. */
@@ -12,27 +22,79 @@ interface WaveformProps {
}
/**
- * Live microphone trace. Spreads a fixed bar count across whatever width it is
- * given, so it fills its container rather than overflowing and being clipped.
+ * Live microphone trace. Drawn on a canvas from an animation-frame loop, so
+ * the bars glide left continuously between samples instead of stepping once
+ * per sample, and nothing re-renders while it runs: the whole trace lives in
+ * this effect. Newest on the right, as many bars as the width holds. Reduced
+ * motion keeps the step.
*
- * Samples the microphone itself rather than being handed the levels: at ~18
- * samples a second, holding them any higher up re-rendered the whole composer,
- * and every tool and skill row with it, to move these bars.
+ * The bar color is the element's own `text-text-primary`, read from the
+ * canvas every frame, so it follows the theme like any other text.
*/
function Waveform({ active, className }: WaveformProps) {
- const levels = useAudioLevels(active);
+ const read = useAudioLevels(active);
+ const reducedMotion = useReducedMotion();
+ const canvasRef = useRef(null);
+ const { ref, width, height } = useElementSize();
+
+ useEffect(() => {
+ const canvas = canvasRef.current;
+ const context = canvas?.getContext('2d');
+ if (!active || canvas == null || context == null || width === 0 || height === 0) {
+ return;
+ }
+ const ratio = window.devicePixelRatio || 1;
+ canvas.width = Math.round(width * ratio);
+ canvas.height = Math.round(height * ratio);
+ context.setTransform(ratio, 0, 0, ratio, 0, 0);
+ /* Live: read per frame so a theme switch mid-dictation recolors the bars. */
+ const style = getComputedStyle(canvas);
+
+ const capacity = Math.ceil(width / BAR_PITCH) + 2;
+ const levels: number[] = new Array(capacity).fill(0);
+ let sampledAt = performance.now();
+ let frame = 0;
+
+ const draw = (now: number) => {
+ if (now - sampledAt > MAX_CATCH_UP_MS) {
+ sampledAt = now;
+ }
+ while (now - sampledAt >= SAMPLE_MS) {
+ sampledAt += SAMPLE_MS;
+ levels.push(read() ?? 0);
+ levels.shift();
+ }
+ /* How far the newest bar has slid in since it was sampled. */
+ const progress = reducedMotion ? 1 : (now - sampledAt) / SAMPLE_MS;
+
+ context.clearRect(0, 0, width, height);
+ context.fillStyle = style.color;
+ context.beginPath();
+ for (let age = 0; age < capacity; age++) {
+ const x = width - BAR_WIDTH - (age - 1 + progress) * BAR_PITCH;
+ if (x > width) {
+ continue;
+ }
+ if (x < -BAR_WIDTH) {
+ break;
+ }
+ const barHeight = Math.max(MIN_BAR_PX, levels[capacity - 1 - age] * height);
+ context.roundRect(x, (height - barHeight) / 2, BAR_WIDTH, barHeight, BAR_WIDTH / 2);
+ }
+ context.fill();
+ frame = requestAnimationFrame(draw);
+ };
+ frame = requestAnimationFrame(draw);
+
+ return () => {
+ cancelAnimationFrame(frame);
+ context.clearRect(0, 0, width, height);
+ };
+ }, [active, width, height, read, reducedMotion]);
+
return (
-
- {levels.map((level, index) => (
-
- ))}
+
+
);
}
diff --git a/client/src/components/Chat/Input/Composer/__tests__/Bar.spec.ts b/client/src/components/Chat/Input/Composer/__tests__/Bar.spec.ts
index 728e5fc2ff..5aefeacba9 100644
--- a/client/src/components/Chat/Input/Composer/__tests__/Bar.spec.ts
+++ b/client/src/components/Chat/Input/Composer/__tests__/Bar.spec.ts
@@ -1,11 +1,5 @@
import type { PaletteEntry } from '~/hooks/Input/usePaletteEntries';
-import {
- PINNED_MCP_KEY,
- chipMenuModes,
- chipsFitInline,
- formatElapsed,
- projectBarEntries,
-} from '../Bar';
+import { chipMenuModes, chipsFitInline, formatElapsed, projectBarEntries } from '../Bar';
/** Pure decisions behind the bar's tool projection, layout and elapsed time. */
@@ -32,66 +26,6 @@ describe('projectBarEntries', () => {
expect(projectBarEntries([active, pinned, inactive, skill])).toEqual([active, pinned]);
});
-
- it('keeps a pinned MCP menu alongside selected server chips', () => {
- const github = entry('mcp:github', {
- itemType: 'mcp',
- itemId: 'github',
- section: 'mcp',
- });
- const pinnedMcp = entry(PINNED_MCP_KEY, {
- itemType: 'mcp',
- itemId: 'mcp',
- section: 'mcp',
- active: true,
- pinned: true,
- });
-
- const projected = projectBarEntries([github], pinnedMcp);
- expect(projected).toHaveLength(1);
- expect(projected[0]).toEqual(
- expect.objectContaining({
- key: PINNED_MCP_KEY,
- modes: [expect.objectContaining({ id: 'github', label: 'mcp:github', active: false })],
- }),
- );
-
- const selected = { ...github, active: true };
- const selectedProjection = projectBarEntries([selected], pinnedMcp);
- expect(selectedProjection).toHaveLength(2);
- expect(selectedProjection[0]).toBe(selected);
- expect(selectedProjection[1]).toEqual(
- expect.objectContaining({
- key: PINNED_MCP_KEY,
- modes: [expect.objectContaining({ id: 'github', active: true })],
- }),
- );
- });
-
- /* Chip keys are React keys and packing-width slots: two entries sharing one
- would let a chip or its menu be measured as the other. A server may be
- named anything, including the word the aggregate pin used to key on. */
- it('keeps the aggregate MCP chip distinct from a server named pinned', () => {
- const server = entry('mcp:pinned', {
- itemType: 'mcp',
- itemId: 'pinned',
- section: 'mcp',
- active: true,
- });
- const aggregate = entry(PINNED_MCP_KEY, {
- itemType: 'mcp',
- itemId: 'mcp',
- section: 'mcp',
- active: true,
- pinned: true,
- });
-
- const projected = projectBarEntries([server], aggregate);
- const keys = projected.map((projectedEntry) => projectedEntry.key);
-
- expect(keys).toEqual(['mcp:pinned', PINNED_MCP_KEY]);
- expect(new Set(keys).size).toBe(keys.length);
- });
});
describe('chipMenuModes', () => {
diff --git a/client/src/components/Chat/Input/Composer/__tests__/Files.spec.tsx b/client/src/components/Chat/Input/Composer/__tests__/Files.spec.tsx
new file mode 100644
index 0000000000..5d4e794f7e
--- /dev/null
+++ b/client/src/components/Chat/Input/Composer/__tests__/Files.spec.tsx
@@ -0,0 +1,159 @@
+import React from 'react';
+import { RecoilRoot } from 'recoil';
+import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
+import type { TFile } from 'librechat-data-provider';
+import FileGrid from '../Files';
+
+const file = (over: Partial & Pick): TFile =>
+ ({
+ bytes: 2048,
+ type: 'text/plain',
+ filepath: `/uploads/${over.filename}`,
+ source: 'local',
+ createdAt: '2026-09-27T10:00:00.000Z',
+ ...over,
+ }) as TFile;
+
+let mockFiles: TFile[] | undefined = [];
+let mockQueryState = { isLoading: false, isError: false };
+const mockRefetch = jest.fn();
+const mockFetchPreview = jest.fn();
+
+jest.mock('~/data-provider', () => ({
+ useGetFiles: () => ({ data: mockFiles, refetch: mockRefetch, ...mockQueryState }),
+ useFilePreviewBlob: () => ({ refetch: mockFetchPreview }),
+ useFilePreview: () => ({ refetch: jest.fn() }),
+ useFileDownload: () => ({ refetch: jest.fn() }),
+ useSharedFileDownload: () => ({ refetch: jest.fn() }),
+}));
+
+const mockShowToast = jest.fn();
+jest.mock('@librechat/client', () => ({
+ ...jest.requireActual('@librechat/client'),
+ useToastContext: () => ({ showToast: mockShowToast }),
+}));
+
+jest.mock('~/hooks', () => ({
+ useLocalize: () => (key: string, options?: Record) =>
+ options ? `${key}:${options['0']}` : key,
+ useAuthContext: () => ({ user: { id: 'user-1' } }),
+}));
+
+const renderGrid = (props: Partial> = {}) => {
+ const onAttach = jest.fn();
+ render(
+
+
+ ,
+ );
+ return { onAttach };
+};
+
+describe('FileGrid', () => {
+ beforeEach(() => {
+ mockFetchPreview.mockReset().mockResolvedValue({ data: undefined });
+ mockQueryState = { isLoading: false, isError: false };
+ mockFiles = [
+ file({ file_id: 'img', filename: 'photo.png', type: 'image/png' }),
+ file({ file_id: 'pdf', filename: 'report.pdf', type: 'application/pdf' }),
+ file({ file_id: 'txt', filename: 'notes.txt' }),
+ ];
+ });
+
+ it('shows every file as a card with its kind and size', () => {
+ renderGrid();
+ const cards = within(screen.getByRole('list')).getAllByRole('listitem');
+ expect(cards).toHaveLength(3);
+ expect(cards[1]).toHaveTextContent('report.pdf');
+ expect(cards[1]).toHaveTextContent('PDF · 2.0 KB');
+ });
+
+ it('offers a preview for images and PDFs only', () => {
+ renderGrid();
+ expect(
+ screen.getByRole('button', { name: 'com_ui_composer_preview_file:photo.png' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'com_ui_composer_preview_file:report.pdf' }),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByRole('button', { name: 'com_ui_composer_preview_file:notes.txt' }),
+ ).not.toBeInTheDocument();
+ });
+
+ it('filters by kind and by name', () => {
+ renderGrid({ view: 'images' });
+ expect(within(screen.getByRole('list')).getAllByRole('listitem')).toHaveLength(1);
+ });
+
+ it('keeps audio and video out of the documents view', () => {
+ mockFiles = [
+ ...(mockFiles ?? []),
+ file({ file_id: 'mp3', filename: 'memo.mp3', type: 'audio/mpeg' }),
+ file({ file_id: 'mp4', filename: 'clip.mp4', type: 'video/mp4' }),
+ ];
+ renderGrid({ view: 'documents' });
+ const list = within(screen.getByRole('list'));
+ expect(list.getAllByRole('listitem')).toHaveLength(2);
+ expect(list.queryByText('memo.mp3')).not.toBeInTheDocument();
+ expect(list.queryByText('clip.mp4')).not.toBeInTheDocument();
+ });
+
+ it('matches a search against the file name', () => {
+ renderGrid({ query: 'repo' });
+ const cards = within(screen.getByRole('list')).getAllByRole('listitem');
+ expect(cards).toHaveLength(1);
+ expect(cards[0]).toHaveTextContent('report.pdf');
+ });
+
+ it('says so when nothing matches', () => {
+ renderGrid({ query: 'nothing-here' });
+ expect(screen.getByRole('status')).toHaveTextContent('com_ui_composer_no_results');
+ });
+
+ it('shows loading rather than no matches while the files are fetched', () => {
+ mockFiles = undefined;
+ mockQueryState = { isLoading: true, isError: false };
+ renderGrid();
+ expect(screen.getByRole('status')).toHaveTextContent('com_ui_loading');
+ expect(screen.queryByText('com_ui_composer_no_results')).not.toBeInTheDocument();
+ });
+
+ it('reports a failed fetch rather than an empty list', () => {
+ mockFiles = undefined;
+ mockQueryState = { isLoading: false, isError: true };
+ renderGrid();
+ expect(screen.getByRole('alert')).toHaveTextContent('com_ui_error_connection');
+ fireEvent.click(screen.getByRole('button', { name: 'com_ui_retry' }));
+ expect(mockRefetch).toHaveBeenCalledTimes(1);
+ });
+
+ it('stays on the grid when an image has nothing to preview', async () => {
+ mockFiles = [file({ file_id: 'bare', filename: 'bare.png', type: 'image/png', filepath: '' })];
+ renderGrid();
+ fireEvent.click(screen.getByRole('button', { name: 'com_ui_composer_preview_file:bare.png' }));
+ await waitFor(() => expect(mockFetchPreview).toHaveBeenCalledTimes(1));
+ await waitFor(() =>
+ expect(mockShowToast).toHaveBeenCalledWith(
+ expect.objectContaining({
+ message: 'com_ui_composer_preview_failed:bare.png',
+ status: 'error',
+ }),
+ ),
+ );
+ await waitFor(() =>
+ expect(
+ screen.getByRole('button', { name: 'com_ui_composer_preview_file:bare.png' }),
+ ).toBeInTheDocument(),
+ );
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
+ });
+
+ it('attaches a file when its card is chosen, not when it is previewed', () => {
+ const { onAttach } = renderGrid();
+ fireEvent.click(screen.getByRole('button', { name: 'com_ui_composer_preview_file:photo.png' }));
+ expect(onAttach).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByText('notes.txt'));
+ expect(onAttach).toHaveBeenCalledWith(expect.objectContaining({ file_id: 'txt' }));
+ });
+});
diff --git a/client/src/components/Chat/Input/Composer/__tests__/Palette.spec.tsx b/client/src/components/Chat/Input/Composer/__tests__/Palette.spec.tsx
index f429cb35fc..5f01f401e4 100644
--- a/client/src/components/Chat/Input/Composer/__tests__/Palette.spec.tsx
+++ b/client/src/components/Chat/Input/Composer/__tests__/Palette.spec.tsx
@@ -83,6 +83,8 @@ jest.mock('~/Providers', () => ({
jest.mock('~/hooks', () => ({
useLocalize: () => (key: string, options?: Record) =>
options ? `${key}:${options['0'] ?? options.count}` : key,
+ useAuthContext: () => ({ user: { id: 'user-1' } }),
+ useToolFavorites: () => ({ favoriteKeys: new Set(), toggle: jest.fn() }),
}));
let mockFavoriteKeys: string[] = [];
@@ -185,7 +187,9 @@ const rows = () =>
/** Just the section headers, which is what carries the order. */
const headers = () =>
Array.from(
- document.querySelectorAll('[id^="composer-palette-list"] [data-row-key^="h:"]'),
+ document.querySelectorAll(
+ '[id^="composer-palette-list"] [data-row-key^="h:"] [role="columnheader"]',
+ ),
).map((row) => row.textContent?.trim() ?? '');
/** Row identities in list order, which is what the model actually decides. */
@@ -312,6 +316,105 @@ describe('Palette', () => {
);
});
+ describe('show all', () => {
+ const many = (section: 'skill' | 'mcp', count: number) =>
+ Array.from({ length: count }, (_, i) =>
+ entry({ key: `${section}:item${i}`, itemId: `item${i}`, label: `item${i}`, section }),
+ );
+
+ it('caps skills, servers and files at five rows each', () => {
+ mockRecentFiles = Array.from({ length: 7 }, (_, i) => ({
+ file_id: `f${i}`,
+ filename: `file${i}.pdf`,
+ type: 'application/pdf',
+ }));
+ /* Rendered one section at a time: the list is virtualized, so rows past
+ its height are not in the DOM to count. */
+ const { unmount } = renderPalette({ entries: [...many('skill', 8), ...many('mcp', 8)] });
+ const listed = keys();
+ expect(listed.filter((key) => key.startsWith('skill:'))).toHaveLength(5);
+ expect(listed.filter((key) => key.startsWith('mcp:'))).toHaveLength(5);
+ unmount();
+ renderPalette({ entries: [] });
+ expect(keys().filter((key) => key.startsWith('file:'))).toHaveLength(5);
+ });
+
+ it('keeps the resting highlight on a row, not on a header action', () => {
+ renderPalette({ canAttach: false, entries: many('mcp', 2) });
+ expect(screen.getByTestId('composer-palette-search')).toHaveAttribute(
+ 'aria-activedescendant',
+ expect.stringContaining(
+ Array.from('mcp:item0', (c) => c.charCodeAt(0).toString(16).padStart(4, '0')).join(''),
+ ),
+ );
+ });
+
+ it('opens the section dialog, whose cards toggle the same entries', async () => {
+ const servers = many('mcp', 7);
+ renderPalette({ entries: servers });
+ fireEvent.click(
+ screen.getByRole('button', { name: 'com_ui_composer_show_all_label:com_ui_composer_mcp' }),
+ );
+ const dialog = await screen.findByRole('dialog');
+ expect(dialog).toHaveTextContent('com_ui_mcp_servers');
+ fireEvent.click(screen.getByRole('button', { name: /item6/ }));
+ expect(servers[6].onSelect).toHaveBeenCalledTimes(1);
+ });
+
+ it('shows each server status on its row and on its card', async () => {
+ const servers = [
+ entry({
+ key: 'mcp:up',
+ itemId: 'up',
+ label: 'Up server',
+ section: 'mcp',
+ status: { label: 'Connected', tone: 'bg-status-success' },
+ }),
+ entry({
+ key: 'mcp:auth',
+ itemId: 'auth',
+ label: 'Auth server',
+ section: 'mcp',
+ status: { label: 'Needs Auth', tone: 'bg-status-warning' },
+ }),
+ ];
+ renderPalette({ entries: servers });
+ expect(rows()).toEqual(
+ expect.arrayContaining([
+ expect.stringContaining('Up serverConnected'),
+ expect.stringContaining('Auth serverNeeds Auth'),
+ ]),
+ );
+ fireEvent.click(
+ screen.getByRole('button', { name: 'com_ui_composer_show_all_label:com_ui_composer_mcp' }),
+ );
+ const dialog = await screen.findByRole('dialog');
+ const cards = Array.from(dialog.querySelectorAll('li')).map((card) => card.textContent);
+ expect(cards).toEqual([
+ expect.stringContaining('Connected'),
+ expect.stringContaining('Needs Auth'),
+ ]);
+ });
+
+ it('narrows the dialog to servers the user made', async () => {
+ const servers = many('mcp', 7).map((server, i) => ({ ...server, ownedByUser: i < 2 }));
+ renderPalette({ entries: servers });
+ fireEvent.click(
+ screen.getByRole('button', { name: 'com_ui_composer_show_all_label:com_ui_composer_mcp' }),
+ );
+ const dialog = await screen.findByRole('dialog');
+ const cards = () =>
+ Array.from(dialog.querySelectorAll('li > div > button[aria-pressed]')).map(
+ (card) => card.textContent?.match(/item\d/)?.[0],
+ );
+ expect(cards()).toHaveLength(7);
+ fireEvent.click(screen.getByText('com_ui_tools_view_made_by_you'));
+ expect(cards()).toEqual(['item0', 'item1']);
+ fireEvent.click(screen.getByText('com_ui_tools_view_favorites'));
+ expect(cards()).toEqual([]);
+ });
+ });
+
describe('section order', () => {
it('reads attach, tools, skills, servers, files', () => {
mockRecentFiles = [{ file_id: 'f1', filename: 'notes.pdf', type: 'application/pdf' }];
@@ -592,6 +695,26 @@ describe('Palette', () => {
);
});
+ /* The highlight follows the pointer too, so a kept one lit up whatever the
+ pointer last crossed (a star's row, "Show all") on the next opening. */
+ it('starts each opening fresh rather than where the last one was left', async () => {
+ renderPalette();
+ const input = screen.getByTestId('composer-palette-search');
+ const first = input.getAttribute('aria-activedescendant');
+ const webRow = document.querySelector('[data-row-key="web_search"]');
+ fireEvent.mouseEnter(webRow as Element);
+ expect(input.getAttribute('aria-activedescendant')).not.toBe(first);
+
+ fireEvent.keyDown(input, { key: 'Escape' });
+ await waitFor(() =>
+ expect(screen.queryByTestId('composer-palette-search')).not.toBeInTheDocument(),
+ );
+ fireEvent.click(screen.getByTestId('composer-palette-button'));
+
+ const reopened = await screen.findByTestId('composer-palette-search');
+ expect(reopened.getAttribute('aria-activedescendant')).toBe(first);
+ });
+
/* An id that names nothing is the failure mode here: screen readers lose
the active option entirely and announce nothing in its place. */
it('always points at a row that is in the document', () => {
diff --git a/client/src/components/Chat/Input/Composer/__tests__/Thinking.spec.tsx b/client/src/components/Chat/Input/Composer/__tests__/Thinking.spec.tsx
index 795d1a380f..133550c46e 100644
--- a/client/src/components/Chat/Input/Composer/__tests__/Thinking.spec.tsx
+++ b/client/src/components/Chat/Input/Composer/__tests__/Thinking.spec.tsx
@@ -3,6 +3,7 @@ import { ReasoningEffort } from 'librechat-data-provider';
import { fireEvent, render, screen } from '@testing-library/react';
import type { SettingDefinition, TConversation, TReasoningOverride } from 'librechat-data-provider';
import type * as ReasoningModule from '../../Reasoning';
+import { effortRank, leanFor } from '../Effort';
import Thinking from '../Thinking';
const mockSetValue = jest.fn();
@@ -127,6 +128,42 @@ describe('Thinking', () => {
expect(mockSetValue).toHaveBeenLastCalledWith({ key: 'thinkingBudget', value: 4224 });
});
+ it('moves the label up for a higher level and down for a lower one', () => {
+ const { rerenderConversation } = renderInComposer();
+ const button = screen.getByTestId('composer-thinking-button');
+ expect(button.querySelector('[class*="composer-label-"]')).toBeNull();
+
+ mockPendingOverride = { key: 'reasoning_effort', value: ReasoningEffort.high };
+ rerenderConversation();
+ expect(button.querySelector('.composer-label-in-up')).toHaveTextContent('High');
+ expect(button.querySelector('.composer-label-out-up')).toHaveTextContent('Low');
+
+ mockPendingOverride = { key: 'reasoning_effort', value: ReasoningEffort.unset };
+ rerenderConversation();
+ expect(button).toHaveTextContent('Auto');
+ expect(button.querySelector('.composer-label-in-down')).toHaveTextContent('Auto');
+ expect(button.querySelector('.composer-label-out-down')).toHaveTextContent('High');
+ });
+
+ it('ranks the separate mode below every level', () => {
+ expect(effortRank(mockSetting, 'auto')).toBe(-1);
+ expect(effortRank(mockSetting, undefined)).toBe(-1);
+ expect(effortRank(mockSetting, 'low')).toBe(0);
+ expect(effortRank(mockSetting, 'high')).toBe(1);
+ });
+
+ it('leans toward the pointer with growing resistance, never past its limit', () => {
+ expect(leanFor(0)).toBe(0);
+ const small = leanFor(5);
+ const larger = leanFor(40);
+ expect(small).toBeGreaterThan(0);
+ expect(larger).toBeGreaterThan(small);
+ /* Resistance: the second 35px buys less than the first 5px did per px. */
+ expect((larger - small) / 35).toBeLessThan(small / 5);
+ expect(leanFor(10_000)).toBeLessThan(10);
+ expect(leanFor(-40)).toBeCloseTo(-larger);
+ });
+
it('shows staged one-shot effort without mutating the conversation', () => {
mockPendingOverride = { key: 'reasoning_effort', value: ReasoningEffort.high };
renderInComposer();
diff --git a/client/src/components/Chat/Messages/Content/DialogImage.tsx b/client/src/components/Chat/Messages/Content/DialogImage.tsx
index da58a359e8..2a9c69abf6 100644
--- a/client/src/components/Chat/Messages/Content/DialogImage.tsx
+++ b/client/src/components/Chat/Messages/Content/DialogImage.tsx
@@ -24,6 +24,8 @@ export default function DialogImage({
downloadImage,
args,
triggerRef,
+ showDetails = true,
+ title,
}: {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
@@ -36,6 +38,10 @@ export default function DialogImage({
[key: string]: unknown;
};
triggerRef?: React.RefObject;
+ /** Off for an uploaded file, which has no generation details to show. */
+ showDetails?: boolean;
+ /** Names the dialog and the image for assistive tech, e.g. the file name. */
+ title?: string;
}) {
const localize = useLocalize();
const [isPromptOpen, setIsPromptOpen] = useState(false);
@@ -254,11 +260,11 @@ export default function DialogImage({
{
e.preventDefault();
closeButtonRef.current?.focus();
@@ -270,6 +276,9 @@ export default function DialogImage({
onPointerDownOutside={(e) => e.preventDefault()}
onClick={handleBackgroundClick}
>
+ {title != null && (
+ {title}
+ )}
{/* Close button - top left */}