Skip to content

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

🧰 style: Hover-Revealed Tool Output Copy, Full Output, and a Virtualized My Files Table (#16640)

Marco Beretta448ab4a41154
diff --git a/client/src/components/Chat/Input/Files/Table/DataTable.tsx b/client/src/components/Chat/Input/Files/Table/DataTable.tsx
index 797ee3ec76..c2e8a8c2b6 100644
--- a/client/src/components/Chat/Input/Files/Table/DataTable.tsx
+++ b/client/src/components/Chat/Input/Files/Table/DataTable.tsx
@@ -1,13 +1,13 @@
-import { useState } from 'react';
+import { useRef, useState, useEffect, useCallback } from 'react';
import { useSetRecoilState } from 'recoil';
import { FileContext } from 'librechat-data-provider';
+import { useVirtualizer } from '@tanstack/react-virtual';
import {
flexRender,
useReactTable,
getCoreRowModel,
getSortedRowModel,
getFilteredRowModel,
- getPaginationRowModel,
} from '@tanstack/react-table';
import {
Table,
@@ -40,6 +40,8 @@ interface DataTableProps<TData, TValue> {
data: TData[];
}
+const ESTIMATED_ROW_HEIGHT = 52;
+
const contextMap: Record<string, TranslationKeys> = {
[FileContext.filename]: 'com_ui_name',
[FileContext.updatedAt]: 'com_ui_date',
@@ -66,6 +68,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
const isSmallScreen = useMediaQuery('(max-width: 768px)');
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
+ const scrollRef = useRef<HTMLDivElement>(null);
const table = useReactTable({
data,
@@ -81,7 +84,6 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
onColumnFiltersChange: setColumnFilters,
getFilteredRowModel: getFilteredRowModel(),
onColumnVisibilityChange: setColumnVisibility,
- getPaginationRowModel: getPaginationRowModel(),
onRowSelectionChange: setRowSelection,
state: {
sorting,
@@ -91,6 +93,31 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
},
});
+ const { rows } = table.getRowModel();
+ const estimateSize = useCallback(() => ESTIMATED_ROW_HEIGHT, []);
+ const getItemKey = useCallback((index: number) => rows[index]?.id ?? index, [rows]);
+ const rowVirtualizer = useVirtualizer({
+ count: rows.length,
+ getScrollElement: () => scrollRef.current,
+ estimateSize,
+ getItemKey,
+ overscan: 8,
+ });
+
+ useEffect(() => {
+ if (scrollRef.current) {
+ scrollRef.current.scrollTop = 0;
+ }
+ }, [sorting, columnFilters]);
+
+ const virtualRows = rowVirtualizer.getVirtualItems();
+ const paddingTop = virtualRows[0]?.start ?? 0;
+ const paddingBottom =
+ virtualRows.length > 0
+ ? rowVirtualizer.getTotalSize() - (virtualRows[virtualRows.length - 1]?.end ?? 0)
+ : 0;
+ const visibleColumnCount = table.getVisibleLeafColumns().length;
+
return (
<div className="flex h-full flex-col gap-4">
<div className="flex flex-wrap items-center gap-2 py-2 sm:gap-4 sm:py-4">
@@ -130,11 +157,20 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
/>
</div>
</div>
- <div className="relative grid h-full max-h-[calc(100vh-20rem)] min-h-[calc(100vh-20rem)] w-full flex-1 overflow-hidden overflow-x-auto overflow-y-auto rounded-md">
- <Table className="w-full min-w-[300px] border-separate border-spacing-0">
+ <div
+ ref={scrollRef}
+ className="relative grid h-full max-h-[calc(100vh-20rem)] min-h-[calc(100vh-20rem)] w-full flex-1 overflow-hidden overflow-x-auto overflow-y-auto rounded-md"
+ >
+ {/* Unwrapped: this div is the scroller the virtualizer observes, so the table
+ must not add its own scrolling wrapper inside it. */}
+ <Table
+ unwrapped
+ aria-rowcount={rows.length > 0 ? rows.length + 1 : undefined}
+ className="w-full min-w-[300px] border-separate border-spacing-0"
+ >
<TableHeader sticky>
{table.getHeaderGroups().map((headerGroup) => (
- <TableRow key={headerGroup.id}>
+ <TableRow key={headerGroup.id} aria-rowindex={1}>
{headerGroup.headers.map((header, _index) => {
const size = header.getSize();
const style: Style = {
@@ -158,31 +194,55 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
))}
</TableHeader>
<TableBody className="w-full">
- {table.getRowModel().rows.length ? (
- table.getRowModel().rows.map((row) => (
- <TableRow key={row.id} data-state={row.getIsSelected() && 'selected'}>
- {row.getVisibleCells().map((cell, _index) => {
- const size = cell.column.getSize();
- const style: Style = {
- width: size === Number.MAX_SAFE_INTEGER ? 'auto' : size,
- };
+ {rows.length ? (
+ <>
+ {paddingTop > 0 && (
+ <tr aria-hidden="true">
+ <td colSpan={visibleColumnCount} style={{ height: paddingTop }} />
+ </tr>
+ )}
+ {virtualRows.map((virtualRow) => {
+ const row = rows[virtualRow.index];
+ if (!row) {
+ return null;
+ }
+ return (
+ <TableRow
+ key={virtualRow.key}
+ ref={rowVirtualizer.measureElement}
+ data-index={virtualRow.index}
+ aria-rowindex={virtualRow.index + 2}
+ data-state={row.getIsSelected() && 'selected'}
+ >
+ {row.getVisibleCells().map((cell) => {
+ const size = cell.column.getSize();
+ const style: Style = {
+ width: size === Number.MAX_SAFE_INTEGER ? 'auto' : size,
+ };
- return (
- <TableCell
- key={cell.id}
- size="compact"
- className={cn(
- 'align-start px-2 text-xs sm:px-4 sm:text-sm [tr[data-disabled=true]_&]:opacity-50',
- cell.column.id === 'select' ? 'overflow-visible' : 'overflow-x-auto',
- )}
- style={style}
- >
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
- </TableCell>
- );
- })}
- </TableRow>
- ))
+ return (
+ <TableCell
+ key={cell.id}
+ size="compact"
+ className={cn(
+ 'align-start px-2 text-xs sm:px-4 sm:text-sm [tr[data-disabled=true]_&]:opacity-50',
+ cell.column.id === 'select' ? 'overflow-visible' : 'overflow-x-auto',
+ )}
+ style={style}
+ >
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ </TableCell>
+ );
+ })}
+ </TableRow>
+ );
+ })}
+ {paddingBottom > 0 && (
+ <tr aria-hidden="true">
+ <td colSpan={visibleColumnCount} style={{ height: paddingBottom }} />
+ </tr>
+ )}
+ </>
) : (
<TableRow>
<TableCell colSpan={columns.length} className="h-24 text-center">
@@ -208,30 +268,6 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
}`}
</span>
</div>
- <div className="text-text-primary flex items-center space-x-1 pr-2 text-xs font-bold sm:text-sm">
- <span className="hidden sm:inline">{localize('com_ui_page')}</span>
- <span>{table.getState().pagination.pageIndex + 1}</span>
- <span>/</span>
- <span>{Math.max(table.getPageCount(), 1)}</span>
- </div>
- <Button
- className="select-none"
- variant="outline"
- size="sm"
- onClick={() => table.previousPage()}
- disabled={!table.getCanPreviousPage()}
- >
- {localize('com_ui_prev')}
- </Button>
- <Button
- className="select-none"
- variant="outline"
- size="sm"
- onClick={() => table.nextPage()}
- disabled={!table.getCanNextPage()}
- >
- {localize('com_ui_next')}
- </Button>
</div>
</div>
);
diff --git a/client/src/components/Chat/Input/TokenUsage/CompactAction.tsx b/client/src/components/Chat/Input/TokenUsage/CompactAction.tsx
index df07a5b215..47a7be2a62 100644
--- a/client/src/components/Chat/Input/TokenUsage/CompactAction.tsx
+++ b/client/src/components/Chat/Input/TokenUsage/CompactAction.tsx
@@ -20,7 +20,7 @@ function CompactAction({ compact, canCompact, isCompacting }: CompactActionProps
const description = localize('com_ui_context_compact_info');
return (
- <>
+ <div>
<TooltipAnchor
side="bottom"
description={description}
@@ -50,7 +50,7 @@ function CompactAction({ compact, canCompact, isCompacting }: CompactActionProps
<span id={descriptionId} className="sr-only">
{description}
</span>
- </>
+ </div>
);
}
diff --git a/client/src/components/Chat/Messages/Content/Parts/BashCall.tsx b/client/src/components/Chat/Messages/Content/Parts/BashCall.tsx
index 69d0e721cc..860d97480a 100644
--- a/client/src/components/Chat/Messages/Content/Parts/BashCall.tsx
+++ b/client/src/components/Chat/Messages/Content/Parts/BashCall.tsx
@@ -7,6 +7,7 @@ import parseJsonField, { areToolCallArgsComplete } from './parseJsonField';
import { useMessagePartsHost } from '~/Providers/MessagePartsHostContext';
import CopyButton from '~/components/Messages/Content/CopyButton';
import LangIcon from '~/components/Messages/Content/LangIcon';
+import { PANE_COPY_REVEAL, TOOL_ROW_CLASSES } from '../rows';
import { toolPanelSpacingClassName } from '../disclosure';
import useToolCallState from './useToolCallState';
import useLazyHighlight from './useLazyHighlight';
@@ -16,7 +17,6 @@ import { ERROR_PATTERNS } from './ExecuteCode';
import { AttachmentGroup } from './Attachment';
import { parseCommandOutput } from './command';
import { useToolCallIntent } from './intent';
-import { TOOL_ROW_CLASSES } from '../rows';
import PtcToolTrace from './PtcToolTrace';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
@@ -215,12 +215,12 @@ export default function BashCall({
// (`DiffView`, the user-turn code bars) instead of a palette shade a theme
// cannot reach: the previous dark-only gray-950 fill was Tailwind's blue-black,
// outside this palette entirely.
- <div className="bg-surface-code relative">
+ <div className="bg-surface-code group/copy relative">
<CopyButton
iconOnly
isCopied={isCopied}
onClick={handleCopy}
- className="absolute top-1 right-1.5"
+ className={cn('bg-surface-code absolute top-1 right-1.5 z-[1]', PANE_COPY_REVEAL)}
label={localize('com_ui_copy_code')}
/>
<div
@@ -228,7 +228,7 @@ export default function BashCall({
onScroll={onCommandPaneScroll}
className="max-h-[300px] overflow-auto"
>
- <pre className="px-3 py-2.5 pr-10 font-mono text-xs break-words whitespace-pre-wrap">
+ <pre className="px-3 py-2.5 font-mono text-xs break-words whitespace-pre-wrap">
<span className="text-text-tertiary select-none" aria-hidden="true">
{'$ '}
</span>
diff --git a/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx b/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx
index 6ea6cac939..f8f6635d04 100644
--- a/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx
+++ b/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx
@@ -517,16 +517,10 @@ describe('BashCall output pane', () => {
const numbered = (count: number) =>
Array.from({ length: count }, (_, i) => `line ${i + 1}`).join('\n');
- it('collapses long output to its tail and expands to the full text', () => {
+ it('shows long output in full with no show more toggle', () => {
finished(numbered(40));
- const pre = screen.getByText(/line 40/);
- const shown = () => (pre.textContent ?? '').split('\n');
- expect(shown()).toEqual(numbered(40).split('\n').slice(-15));
-
- fireEvent.click(screen.getByRole('button', { name: 'Show more' }));
- expect(shown()).toHaveLength(40);
- expect(shown()[0]).toBe('line 1');
- expect(screen.getByRole('button', { name: 'Show less' })).toBeInTheDocument();
+ expect(screen.getByText(/line 40/).textContent).toBe(numbered(40));
+ expect(screen.queryByRole('button', { name: 'Show more' })).not.toBeInTheDocument();
});
it('keeps leading whitespace and blank lines verbatim', () => {
diff --git a/client/src/components/Chat/Messages/Content/ProgressText.tsx b/client/src/components/Chat/Messages/Content/ProgressText.tsx
index 8f605a06b8..4e35713fe0 100644
--- a/client/src/components/Chat/Messages/Content/ProgressText.tsx
+++ b/client/src/components/Chat/Messages/Content/ProgressText.tsx
@@ -202,13 +202,8 @@ export default function ProgressText({
<Wrapper popover={popover} failed={phase === 'failed'} rootRef={rootRef}>
<Button
type="button"
- variant="ghost"
- className={cn(
- 'group/disclosure inline-flex h-auto w-full items-center justify-start gap-2 rounded-none p-0 hover:bg-transparent hover:text-inherit disabled:opacity-100',
- hasInput
- ? 'focus-visible:ring-border-heavy focus-visible:ring-offset-0'
- : 'pointer-events-none',
- )}
+ variant="disclosure"
+ className="group/disclosure"
disabled={!hasInput}
tabIndex={hasInput ? 0 : -1}
onClick={hasInput ? onClick : undefined}
diff --git a/client/src/components/Chat/Messages/Content/ToolOutput/OutputRenderer.tsx b/client/src/components/Chat/Messages/Content/ToolOutput/OutputRenderer.tsx
index 6d9a006796..bd7df54659 100644
--- a/client/src/components/Chat/Messages/Content/ToolOutput/OutputRenderer.tsx
+++ b/client/src/components/Chat/Messages/Content/ToolOutput/OutputRenderer.tsx
@@ -1,8 +1,10 @@
-import { useState, useMemo, useCallback } from 'react';
+import { useRef, useState, useMemo, useCallback, useLayoutEffect } from 'react';
import copy from 'copy-to-clipboard';
import { Button } from '@librechat/client';
import { hasToolCallErrorPrefix, stripToolCallErrorPrefix } from 'librechat-data-provider';
+import type { UIEvent } from 'react';
import CopyButton from '~/components/Messages/Content/CopyButton';
+import { PANE_COPY_REVEAL } from '../rows';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
@@ -100,47 +102,17 @@ function extractText(raw: string, verbatim = false): ExtractedText {
return { text: trimmed, rawError: '', error: false, isJson: false };
}
-const TRUNCATE_LINES = 20;
-const VISIBLE_LINES = 15;
-
export interface OutputSegment {
text: string;
className?: string;
}
-/** The last `count` lines of `segments`, keeping each line's own styling. */
-function tailSegments(segments: OutputSegment[], count: number): OutputSegment[] {
- const tail: OutputSegment[] = [];
- /** Matches the line count: a final newline ends the last line rather than starting one. */
- const last = segments.findLast((segment) => segment.text !== '');
- let newlines = last?.text.endsWith('\n') === true ? -1 : 0;
- for (let i = segments.length - 1; i >= 0; i--) {
- const { text, className } = segments[i];
- let cut = text.length;
- while (cut > 0) {
- const at = text.lastIndexOf('\n', cut - 1);
- if (at < 0) {
- break;
- }
- newlines++;
- if (newlines >= count) {
- tail.unshift({ text: text.slice(at + 1), className });
- return tail;
- }
- cut = at;
- }
- tail.unshift({ text, className });
- }
- return tail;
-}
-
interface OutputRendererProps {
text: string;
copyText?: string;
/** Forces error styling when the caller detected a failure the text itself does not mark. */
error?: boolean;
- /** `terminal` renders command output: monospace, verbatim (no JSON reformatting), and the
- * collapsed view keeps the LAST lines, where failures and stack traces land. */
+ /** `terminal` renders command output: monospace and verbatim (no JSON reformatting). */
variant?: 'default' | 'terminal';
/** Terminal output split into styled runs whose texts join to `text` (for example stdout,
* stderr and an exit trailer). Rendered in place of the plain text. */
@@ -159,9 +131,25 @@ export default function OutputRenderer({
const extracted = useMemo(() => extractText(text, terminal), [text, terminal]);
const { text: displayText, rawError, isJson } = extracted;
const error = extracted.error || forceError;
- const [isExpanded, setIsExpanded] = useState(false);
const [showErrorDetails, setShowErrorDetails] = useState(false);
const [isCopied, setIsCopied] = useState(false);
+ const outputRef = useRef<HTMLPreElement>(null);
+ /** Whether the reader is at the bottom of the box; scrolling up stops the follow. */
+ const followRef = useRef(true);
+
+ /* Terminal output opens on its last lines, where failures, stack traces and the
+ exit trailer land, and keeps following new output until the reader scrolls up. */
+ useLayoutEffect(() => {
+ const node = outputRef.current;
+ if (terminal && node != null && followRef.current) {
+ node.scrollTop = node.scrollHeight;
+ }
+ }, [terminal, displayText, segments]);
+
+ const handleOutputScroll = useCallback((event: UIEvent<HTMLPreElement>) => {
+ const node = event.currentTarget;
+ followRef.current = node.scrollHeight - node.scrollTop - node.clientHeight <= 8;
+ }, []);
const handleCopy = useCallback(() => {
setIsCopied(true);
@@ -173,28 +161,22 @@ export default function OutputRenderer({
return null;
}
- /** A final newline ends the last line; it does not start an empty one. */
- const body = displayText.endsWith('\n') ? displayText.slice(0, -1) : displayText;
- const lines = body.split('\n');
- const needsTruncation = lines.length > TRUNCATE_LINES;
- const collapsedLines = terminal ? lines.slice(-VISIBLE_LINES) : lines.slice(0, VISIBLE_LINES);
- const visibleText = needsTruncation && !isExpanded ? collapsedLines.join('\n') : displayText;
const structured = !isJson && (terminal || isStructuredText(displayText));
const styled = terminal && segments != null && !error;
- const visibleSegments =
- styled && needsTruncation && !isExpanded ? tailSegments(segments, VISIBLE_LINES) : segments;
return (
<div>
- <div className="relative pr-10">
+ <div className="group/copy relative">
{isJson ? (
<pre className="max-h-[300px] overflow-auto rounded text-xs">
<code className="hljs language-json !break-words !whitespace-pre-wrap">
- {visibleText}
+ {displayText}
</code>
</pre>
) : (
<pre
+ ref={outputRef}
+ onScroll={terminal ? handleOutputScroll : undefined}
className={cn(
'max-h-[300px] overflow-auto text-xs break-words whitespace-pre-wrap',
error && 'text-status-error font-mono',
@@ -204,35 +186,24 @@ export default function OutputRenderer({
)}
>
{styled
- ? visibleSegments?.map((segment, i) =>
+ ? segments?.map((segment, i) =>
segment.text === '' ? null : (
<span key={i} className={segment.className}>
{segment.text}
</span>
),
)
- : visibleText}
+ : displayText}
</pre>
)}
- <div className="absolute top-1/2 right-0 -translate-y-1/2">
- <CopyButton
- isCopied={isCopied}
- onClick={handleCopy}
- iconOnly
- label={localize('com_ui_copy')}
- />
- </div>
+ <CopyButton
+ isCopied={isCopied}
+ onClick={handleCopy}
+ iconOnly
+ label={localize('com_ui_copy')}
+ className={cn('bg-presentation absolute right-0 bottom-0 z-[1]', PANE_COPY_REVEAL)}
+ />
</div>
- {needsTruncation && (
- <Button
- variant="link"
- size="sm"
- className="text-text-secondary focus-visible:ring-border-heavy mt-1 h-auto p-0 text-xs underline focus-visible:ring-2"
- onClick={() => setIsExpanded((prev) => !prev)}
- >
- {isExpanded ? localize('com_ui_show_less') : localize('com_ui_show_more')}
- </Button>
- )}
{error && rawError && rawError !== displayText && (
<Button
variant="link"
diff --git a/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx b/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx
index d20ec6e670..25e92d044a 100644
--- a/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx
+++ b/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx
@@ -77,7 +77,7 @@ export default function StackedToolIcons({
}
return (
- <div className="flex items-center" aria-hidden="true">
+ <div className="isolate flex items-center" aria-hidden="true">
{visibleIcons.map((icon, index) => (
<div
key={icon.key}
diff --git a/client/src/components/Chat/Messages/Content/ToolOutput/__tests__/OutputRenderer.test.tsx b/client/src/components/Chat/Messages/Content/ToolOutput/__tests__/OutputRenderer.test.tsx
index 2cb2d9f50b..cccc760926 100644
--- a/client/src/components/Chat/Messages/Content/ToolOutput/__tests__/OutputRenderer.test.tsx
+++ b/client/src/components/Chat/Messages/Content/ToolOutput/__tests__/OutputRenderer.test.tsx
@@ -11,18 +11,20 @@ jest.mock('~/hooks', () => ({
jest.mock('~/components/Messages/Content/CopyButton', () => ({
__esModule: true,
- default: ({ onClick }: { onClick: () => void }) => (
- <button type="button" data-testid="copy-output" onClick={onClick} />
+ default: ({ onClick, className }: { onClick: () => void; className?: string }) => (
+ <button type="button" data-testid="copy-output" className={className} onClick={onClick} />
),
}));
describe('OutputRenderer', () => {
- it('vertically centers the copy control beside the output', () => {
+ it('lays the copy control over the bottom right of the output without reserving width', () => {
render(<OutputRenderer text={'First line\nSecond line'} />);
- const copyPositioner = screen.getByTestId('copy-output').parentElement;
- expect(copyPositioner).toHaveClass('absolute', 'right-0', 'top-1/2', '-translate-y-1/2');
- expect(copyPositioner?.parentElement).toHaveClass('relative', 'pr-10');
+ const copyButton = screen.getByTestId('copy-output');
+ expect(copyButton).toHaveClass('absolute', 'right-0', 'bottom-0');
+ expect(copyButton).toHaveClass('[@media(hover:hover)]:group-hover/copy:opacity-100');
+ expect(copyButton.parentElement).toHaveClass('group/copy', 'relative');
+ expect(copyButton.parentElement).not.toHaveClass('pr-10');
});
it('copies original bytes when a code result has been formatted for display', () => {
@@ -32,37 +34,72 @@ describe('OutputRenderer', () => {
expect(copy).toHaveBeenCalledWith(raw, { format: 'text/plain' });
});
- it('keeps the head by default and the tail for terminal output when collapsed', () => {
+ it('renders long output in full with no show more toggle', () => {
const text = Array.from({ length: 30 }, (_, i) => `line ${i + 1}`).join('\n');
const { unmount } = render(<OutputRenderer text={text} />);
- expect(screen.getByText(/line 1/).textContent?.split('\n')[0]).toBe('line 1');
+ expect(screen.getByText(/line 1/).textContent?.split('\n')).toHaveLength(30);
+ expect(screen.queryByText('com_ui_show_more')).not.toBeInTheDocument();
unmount();
render(<OutputRenderer text={text} variant="terminal" />);
- const shown = screen.getByText(/line 30/).textContent?.split('\n') ?? [];
- expect(shown[0]).toBe('line 16');
- expect(shown).toHaveLength(15);
+ const pre = screen.getByText(/line 30/);
+ expect(pre.textContent).toBe(text);
+ expect(pre).toHaveClass('max-h-[300px]', 'overflow-auto');
+ expect(screen.queryByText('com_ui_show_more')).not.toBeInTheDocument();
});
- it('keeps whitespace-only terminal output', () => {
- const { container } = render(<OutputRenderer text={'\n\n'} variant="terminal" />);
- expect(container.querySelector('pre')?.textContent).toBe('\n\n');
+ it('opens terminal output on its last lines and default output on its first', () => {
+ const text = Array.from({ length: 30 }, (_, i) => `line ${i + 1}`).join('\n');
+ const scrollHeight = jest
+ .spyOn(HTMLElement.prototype, 'scrollHeight', 'get')
+ .mockReturnValue(900);
+ try {
+ const { unmount } = render(<OutputRenderer text={text} variant="terminal" />);
+ expect(screen.getByText(/line 30/).scrollTop).toBe(900);
+ unmount();
+
+ render(<OutputRenderer text={text} />);
+ expect(screen.getByText(/line 30/).scrollTop).toBe(0);
+ } finally {
+ scrollHeight.mockRestore();
+ }
});
- it('does not count a final newline as a line when collapsing terminal output', () => {
- const numbered = (n: number) =>
- Array.from({ length: n }, (_, i) => `line ${i + 1}`).join('\n') + '\n';
- const { unmount } = render(<OutputRenderer text={numbered(20)} variant="terminal" />);
- expect(screen.queryByText('com_ui_show_more')).not.toBeInTheDocument();
- unmount();
+ it('stops following streamed terminal output once the reader scrolls up', () => {
+ const lines = (count: number) =>
+ Array.from({ length: count }, (_, i) => `line ${i + 1}`).join('\n');
+ const scrollHeight = jest
+ .spyOn(HTMLElement.prototype, 'scrollHeight', 'get')
+ .mockReturnValue(900);
+ const clientHeight = jest
+ .spyOn(HTMLElement.prototype, 'clientHeight', 'get')
+ .mockReturnValue(300);
+ try {
+ const { rerender } = render(<OutputRenderer text={lines(30)} variant="terminal" />);
+ const pre = screen.getByText(/line 30/);
+ expect(pre.scrollTop).toBe(900);
- render(<OutputRenderer text={numbered(30)} variant="terminal" />);
- const shown = screen.getByText(/line 30/).textContent?.split('\n') ?? [];
- expect(shown).toHaveLength(15);
- expect(shown[0]).toBe('line 16');
+ pre.scrollTop = 100;
+ fireEvent.scroll(pre);
+ rerender(<OutputRenderer text={lines(40)} variant="terminal" />);
+ expect(pre.scrollTop).toBe(100);
+
+ pre.scrollTop = 600;
+ fireEvent.scroll(pre);
+ rerender(<OutputRenderer text={lines(50)} variant="terminal" />);
+ expect(pre.scrollTop).toBe(900);
+ } finally {
+ scrollHeight.mockRestore();
+ clientHeight.mockRestore();
+ }
+ });
+
+ it('keeps whitespace-only terminal output', () => {
+ const { container } = render(<OutputRenderer text={'\n\n'} variant="terminal" />);
+ expect(container.querySelector('pre')?.textContent).toBe('\n\n');
});
- it('keeps segment styling when collapsing terminal output to its tail', () => {
+ it('keeps segment styling across the full terminal output', () => {
const out = Array.from({ length: 25 }, (_, i) => `out ${i + 1}`).join('\n') + '\n';
const err = 'stderr:\nboom\n';
const trailer = '[exit code: 1]';
@@ -79,20 +116,12 @@ describe('OutputRenderer', () => {
);
const pre = screen.getByText(/out 25/).closest('pre') as HTMLElement;
const shown = (pre.textContent ?? '').split('\n');
- expect(shown).toHaveLength(15);
- expect(shown[0]).toBe('out 14');
+ expect(shown[0]).toBe('out 1');
+ expect(pre.textContent).toBe(out + err + trailer);
expect(screen.getByText(/boom/)).toHaveClass('text-status-error');
expect(screen.getByText('[exit code: 1]')).toHaveClass('text-text-tertiary');
});
- it('shows as many styled lines as plain lines when output ends in a newline', () => {
- const out = Array.from({ length: 30 }, (_, i) => `row ${i + 1}`).join('\n') + '\n';
- render(<OutputRenderer text={out} variant="terminal" segments={[{ text: out }]} />);
- const shown = (screen.getByText(/row 30/).closest('pre')?.textContent ?? '').split('\n');
- expect(shown.filter(Boolean)).toHaveLength(15);
- expect(shown[0]).toBe('row 16');
- });
-
it('does not treat text between bracketed prefixes as a tool-call error', () => {
expect(isError('Error: [agent] unexpected [search] tool call failed: unavailable')).toBe(false);
});
diff --git a/client/src/components/Chat/Messages/Content/rows.ts b/client/src/components/Chat/Messages/Content/rows.ts
index ae9acb48b1..4d81d084ba 100644
--- a/client/src/components/Chat/Messages/Content/rows.ts
+++ b/client/src/components/Chat/Messages/Content/rows.ts
@@ -29,3 +29,11 @@ export const ROW_GLYPH_SLOT = 'flex h-5 min-w-6 shrink-0 items-center justify-ce
* in that inset, out of flow, so the height animation is untouched.
*/
export const FOLD_RAIL_CLASSES = 'relative pl-6';
+
+/**
+ * A copy action laid over its pane (`group/copy`) instead of beside it, so it
+ * takes no width from the content. Hidden until the pane is hovered or the
+ * action holds keyboard focus; touch input, which cannot hover, always sees it.
+ */
+export const PANE_COPY_REVEAL =
+ '[@media(hover:hover)]:opacity-0 [@media(hover:hover)]:focus-visible:opacity-100 [@media(hover:hover)]:group-hover/copy:opacity-100';
diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json
index db1c9239db..21df8f11e4 100644
--- a/client/src/locales/en/translation.json
+++ b/client/src/locales/en/translation.json
@@ -2110,7 +2110,6 @@
"com_ui_optional": "(optional)",
"com_ui_options": "options",
"com_ui_output": "Output",
- "com_ui_page": "Page",
"com_ui_parameters": "Parameters",
"com_ui_params_changed_count": "{{count}} changed settings",
"com_ui_params_changed_count_one": "{{count}} changed setting",
diff --git a/e2e/specs/mock/scenarios/my-files-virtual.spec.ts b/e2e/specs/mock/scenarios/my-files-virtual.spec.ts
new file mode 100644
index 0000000000..df960b5a27
--- /dev/null
+++ b/e2e/specs/mock/scenarios/my-files-virtual.spec.ts
@@ -0,0 +1,83 @@
+import { expect, test } from '@playwright/test';
+import { FileSources } from 'librechat-data-provider';
+import type { TFile } from 'librechat-data-provider';
+import type { Page } from '@playwright/test';
+
+/**
+ * The My Files table renders only the rows near its scroll position. With a list
+ * far longer than the dialog, scrolling has to keep mounting rows down to the
+ * last file, and each mounted row has to report its place in the whole list.
+ * The account menu sits behind the mobile drawer on a phone-width viewport, so
+ * this scenario uses a desktop viewport.
+ */
+test.describe.configure({ timeout: 120_000 });
+test.use({ viewport: { width: 1280, height: 800 } });
+
+const FILE_COUNT = 200;
+
+const files: TFile[] = Array.from({ length: FILE_COUNT }, (_, index) => ({
+ file_id: `virtual-file-${index}`,
+ filename: `Virtual fixture ${String(index).padStart(3, '0')}.txt`,
+ filepath: `/files/virtual-file-${index}.txt`,
+ user: 'virtual-files-user',
+ bytes: 100,
+ object: 'file',
+ source: FileSources.local,
+ type: 'text/plain',
+ usage: 0,
+ embedded: false,
+ createdAt: '2026-09-01T00:00:00.000Z',
+ updatedAt: '2026-09-01T00:00:00.000Z',
+}));
+
+async function openMyFiles(page: Page) {
+ await page.route('**/api/files', (route) => route.fulfill({ json: files }));
+ await page.goto('/c/new', { timeout: 15000 });
+ await page.getByTestId('nav-user').click();
+ await page.getByRole('menu').getByRole('menuitem', { name: 'My Files', exact: true }).click();
+ const dialog = page.getByRole('dialog', { name: 'My Files', exact: true });
+ await expect(dialog).toBeVisible({ timeout: 15000 });
+ const table = dialog.getByRole('table');
+ await expect(table.locator('tbody tr[aria-rowindex="2"]')).toBeVisible();
+ return { dialog, table };
+}
+
+/** Wheels over the table until the last row is mounted, as a user scrolling down would. */
+async function scrollToLastRow(page: Page, table: ReturnType<Page['getByRole']>) {
+ const lastRow = table.locator(`tbody tr[aria-rowindex="${FILE_COUNT + 1}"]`);
+ await table.hover();
+ for (let attempt = 0; attempt < 80 && (await lastRow.count()) === 0; attempt++) {
+ await page.mouse.wheel(0, 1200);
+ }
+ return lastRow;
+}
+
+test.describe('my files virtual table', () => {
+ test('scrolling the files table reaches the last file @scenario:my-files-scroll-reaches-last-file', async ({
+ page,
+ }) => {
+ const { table } = await openMyFiles(page);
+ const mounted = await table.locator('tbody tr[aria-rowindex]').count();
+ expect(mounted).toBeLessThan(FILE_COUNT);
+
+ const lastRow = await scrollToLastRow(page, table);
+ await expect(lastRow).toBeInViewport();
+ await expect(lastRow).toContainText('Virtual fixture');
+ });
+
+ test('a mounted file row reports its position in the whole list @scenario:my-files-rows-report-position', async ({
+ page,
+ }) => {
+ const { table } = await openMyFiles(page);
+ await expect(table).toHaveAttribute('aria-rowcount', String(FILE_COUNT + 1));
+ await expect(table.locator('thead tr')).toHaveAttribute('aria-rowindex', '1');
+
+ const lastRow = await scrollToLastRow(page, table);
+ await expect(lastRow).toBeInViewport();
+ /* The spacer rows that stand in for unmounted files stay out of the tree. */
+ const spacers = table.locator('tbody tr:not([aria-rowindex])');
+ for (const spacer of await spacers.all()) {
+ await expect(spacer).toHaveAttribute('aria-hidden', 'true');
+ }
+ });
+});
diff --git a/e2e/specs/mock/scenarios/tool-output-polish.spec.ts b/e2e/specs/mock/scenarios/tool-output-polish.spec.ts
new file mode 100644
index 0000000000..bd088a006e
--- /dev/null
+++ b/e2e/specs/mock/scenarios/tool-output-polish.spec.ts
@@ -0,0 +1,177 @@
+import { expect, test } from '@playwright/test';
+import type { Locator, Page, Route } from '@playwright/test';
+import { messagesView } from '../helpers';
+
+/**
+ * Tool output cards: the copy button overlays the output and reveals on hover or keyboard focus,
+ * the full output sits in the fixed max-height scroll box, and the row header shows no pressed fill.
+ */
+
+const NO_PARENT = '00000000-0000-0000-0000-000000000000';
+const unique = (prefix: string) => `${prefix}-${Date.now()}-${Math.floor(Math.random() * 1e6)}`;
+const escapeRe = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+const LINE_COUNT = 60;
+const lineLabel = (n: number) => `line-${String(n).padStart(3, '0')}`;
+
+async function seedToolConversation(page: Page): Promise<void> {
+ const conversationId = unique('e2e-tool-output');
+ const now = new Date(0).toISOString();
+ const output = Array.from({ length: LINE_COUNT }, (_, i) => lineLabel(i + 1)).join('\n');
+ const message = {
+ messageId: `${conversationId}-msg`,
+ conversationId,
+ parentMessageId: NO_PARENT,
+ isCreatedByUser: false,
+ sender: 'Assistant',
+ endpoint: 'Mock Provider A',
+ model: 'mock-model-a',
+ text: '',
+ content: [
+ {
+ type: 'tool_call',
+ tool_call: {
+ id: `${conversationId}-tool`,
+ name: 'lookup_records',
+ args: JSON.stringify({ query: 'numbered lines' }),
+ output,
+ progress: 1,
+ },
+ },
+ ],
+ createdAt: now,
+ updatedAt: now,
+ };
+ const conversation = {
+ conversationId,
+ title: 'Tool output polish',
+ endpoint: 'Mock Provider A',
+ endpointType: 'custom',
+ model: 'mock-model-a',
+ createdAt: now,
+ updatedAt: now,
+ };
+ const convoIdRe = escapeRe(conversationId);
+ await page.route(new RegExp(`/api/convos/${convoIdRe}(?:\\?.*)?$`), (route: Route) =>
+ route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify(conversation),
+ }),
+ );
+ await page.route(new RegExp(`/api/messages/${convoIdRe}(?:\\?.*)?$`), (route: Route) =>
+ route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify([message]),
+ }),
+ );
+ await page.goto(`/c/${conversationId}`, { timeout: 30000 });
+}
+
+/** The tool row header: the disclosure button inside the `tool-call` row (ProgressText.tsx). */
+const rowHeader = (page: Page): Locator =>
+ messagesView(page).getByTestId('tool-call').getByRole('button').first();
+
+/** Seeds the conversation and makes sure the row is expanded, whatever the auto-expand preference. */
+async function openToolRow(page: Page): Promise<{ header: Locator; output: Locator }> {
+ await seedToolConversation(page);
+ const header = rowHeader(page);
+ await expect(header).toBeVisible({ timeout: 15000 });
+ if ((await header.getAttribute('aria-expanded')) !== 'true') {
+ await header.click();
+ }
+ await expect(header).toHaveAttribute('aria-expanded', 'true');
+ const output = messagesView(page)
+ .locator('pre', { hasText: lineLabel(1) })
+ .first();
+ await expect(output).toBeVisible({ timeout: 15000 });
+ return { header, output };
+}
+
+const opacityOf = (locator: Locator) =>
+ locator.evaluate((el) => Number.parseFloat(getComputedStyle(el).opacity));
+
+test.describe('tool output polish', () => {
+ test.afterEach(async ({ page }) => {
+ await page.unrouteAll();
+ });
+
+ test('copy reveals on hover or focus @scenario:tool-output-copy-reveals-on-hover-or-focus', async ({
+ page,
+ }) => {
+ test.setTimeout(60000);
+ const { header, output } = await openToolRow(page);
+ const copy = messagesView(page)
+ .getByTestId('tool-call')
+ .locator('xpath=following-sibling::*')
+ .getByRole('button', { name: 'Copy', exact: true });
+ await expect(copy).toHaveCount(1);
+ const canHover = await page.evaluate(() => matchMedia('(hover: hover)').matches);
+
+ if (!canHover) {
+ await expect.poll(() => opacityOf(copy)).toBe(1);
+ await copy.focus();
+ await expect.poll(() => opacityOf(copy)).toBe(1);
+ return;
+ }
+
+ await page.mouse.move(1, 1);
+ await expect.poll(() => opacityOf(copy)).toBe(0);
+
+ await output.hover();
+ await expect.poll(() => opacityOf(copy)).toBe(1);
+
+ await page.mouse.move(1, 1);
+ await expect.poll(() => opacityOf(copy)).toBe(0);
+
+ /* Tabbing on from the row header reaches the copy button (the scrollable output box can
+ take a stop first); focus-visible reveals it. */
+ await header.focus();
+ for (let presses = 0; presses < 5; presses++) {
+ await page.keyboard.press('Tab');
+ if (await copy.evaluate((el) => el === document.activeElement)) {
+ break;
+ }
+ }
+ await expect(copy).toBeFocused();
+ await expect.poll(() => opacityOf(copy)).toBe(1);
+ });
+
+ test('output renders in full inside the scroll box @scenario:tool-output-shows-full-output', async ({
+ page,
+ }) => {
+ test.setTimeout(60000);
+ const { output } = await openToolRow(page);
+ await expect(output).toContainText(lineLabel(1));
+ await expect(output).toContainText(lineLabel(LINE_COUNT));
+ await expect(messagesView(page).getByRole('button', { name: 'Show more' })).toHaveCount(0);
+ const { scrollHeight, clientHeight } = await output.evaluate((el) => ({
+ scrollHeight: el.scrollHeight,
+ clientHeight: el.clientHeight,
+ }));
+ expect(scrollHeight).toBeGreaterThan(clientHeight);
+ });
+
+ test('pressing the row header shows no fill @scenario:tool-row-header-has-no-pressed-fill', async ({
+ page,
+ }) => {
+ test.setTimeout(60000);
+ const { header } = await openToolRow(page);
+ const background = () => header.evaluate((el) => getComputedStyle(el).backgroundColor);
+ await page.mouse.move(1, 1);
+ const resting = await background();
+
+ const box = await header.boundingBox();
+ expect(box).not.toBeNull();
+ if (box == null) {
+ return;
+ }
+ await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
+ await page.mouse.down();
+ try {
+ await expect.poll(background).toBe(resting);
+ } finally {
+ await page.mouse.up();
+ }
+ });
+});
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index 072fbfc2d3..8bb8ca3c90 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -626,9 +626,6 @@
"client/src/components/Chat/Messages/Content/ProgressText.tsx": {
"shadcn/no-inline-styles": {
"count": 2
- },
- "shadcn/no-restyle": {
- "count": 8
}
},
"client/src/components/Chat/Messages/Content/RetrievalCall.tsx": {
@@ -674,7 +671,7 @@
},
"client/src/components/Chat/Messages/Content/ToolOutput/OutputRenderer.tsx": {
"shadcn/no-restyle": {
- "count": 12
+ "count": 6
}
},
"client/src/components/Chat/Messages/Content/ToolOutput/ToolIcon.tsx": {
diff --git a/packages/client/src/components/Button.spec.tsx b/packages/client/src/components/Button.spec.tsx
index 7ac2abef9a..617f27a5c2 100644
--- a/packages/client/src/components/Button.spec.tsx
+++ b/packages/client/src/components/Button.spec.tsx
@@ -245,6 +245,19 @@ describe('Button', () => {
expect(header).not.toMatch(/(^|\s)hover:bg-/);
});
+ /** A tool call's fold header reads as its own label: holding the pointer
+ * down on it must not flash the ghost pressed fill. */
+ it('gives a disclosure header no hover or pressed fill and no default size', () => {
+ const header = cn(buttonVariants({ variant: 'disclosure' }));
+
+ expect(header).toContain('h-auto');
+ expect(header).toContain('p-0');
+ expect(header).toContain('rounded-none');
+ expect(header).not.toContain('h-theme-button');
+ expect(header).not.toMatch(/(^|\s)hover:bg-/);
+ expect(header).not.toMatch(/(^|\s)(hover:)?active:bg-/);
+ });
+
it('still takes a size when a caller asks for one', () => {
expect(cn(buttonVariants({ variant: 'section-header', size: 'sm' }))).toContain(
'h-theme-button-sm',
diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsx
index dbe0532718..9e67358801 100644
--- a/packages/client/src/components/Button.tsx
+++ b/packages/client/src/components/Button.tsx
@@ -26,6 +26,7 @@ type ButtonVariantOptions =
| 'header-action'
| 'inline-edit'
| 'card'
+ | 'disclosure'
| null
| undefined;
size?:
@@ -148,6 +149,14 @@ const buttonVariantRecipe = cva(
* around it owns the surface; it adds the hover fill and an inset ring,
* and left-aligns its content, which the caller lays out.
*/
+ /**
+ * The header row that folds a tool call's details open: it reads as the
+ * line of text it labels, so it takes no fill under the pointer or while
+ * pressed, and a header with nothing to open keeps full opacity. Its ring
+ * is inset because the row sits flush against the panel it opens.
+ */
+ disclosure:
+ 'w-full justify-start focus-visible:ring-border-heavy focus-visible:ring-offset-0 disabled:opacity-100',
card: 'justify-start whitespace-normal rounded-2xl text-left font-normal hover:bg-surface-hover focus-visible:ring-inset focus-visible:ring-offset-0',
},
size: {
@@ -201,6 +210,12 @@ const buttonVariantRecipe = cva(
size: 'default',
class: 'h-auto px-1 py-2',
},
+ /* Sized and shaped by the row it heads, like `section-header`. */
+ {
+ variant: 'disclosure',
+ size: 'default',
+ class: 'h-auto rounded-none p-0',
+ },
/* Sized by the text it stands for, like `section-header`, so the default
* size recipe must not pad it away from the content it lines up with. */
{