🪶 style: Quieter Primitives, Shared Panel Headers, and Flat Management Lists (#16244)

* style: Quieten the shared primitives and the dark borders

The primitives carried the weight the screens then inherited: boxed empty
states, outlined table shells, raised composer pills. Softening them here
means a screen gets the quieter treatment by composing what it already
composes rather than by overriding it.

Dark moves its border roles one step off the page instead of two, so an
edge separates a surface from the one behind it without reading as a seam.
The values live in style.css for the pre-hydration paint and in dark.ts for
the runtime theme, so both change together.

Checkbox gains CheckboxGlyph, the presentational half of the control, for
rows that are already a button and must not nest a second one inside it.

* feat(client): Panel header and scroll fade for the side panels

Every management panel was building its own title row, so the title, the
search field and the create button sat at a different size and spacing in
each one. PanelHeader is that row, and the panels adopt it next.

PanelContent gains a fade at its foot, fed by useScrollFade, which watches
the viewport and its content and reports whether anything sits below the
fold. A list that is exactly as tall as its box shows no fade, and the
gradient is dropped under prefers-reduced-motion.

The sidebar keeps a right edge in every theme now that it shares a surface
with the content beside it, rather than only in high contrast.

* style: Apply the quieter layout to the panels and management pages

The main content now sits on the same surface as the sidebar, so the app
reads as one plane instead of a page floating on a backdrop. With the fill
gone the containers had nothing left to justify them: cards, outlines and
double borders come off the MCP, Skills, Bookmarks, Memory, Prompts and
Scheduled Chats lists, and spacing and weight carry the hierarchy instead.

The management screens adopt PanelHeader, so title, search and create sit
at one size and one rhythm across all of them, and Schedules gains the
search its siblings already had. Secondary row actions appear on hover and
focus rather than resting in the row.

Two rows also stop nesting interactive controls: the skills row splits into
sibling buttons under a focus-within ring, and the memory and prompt toggles
render CheckboxGlyph inside their button rather than a second control.

* fix(client): Keep the schedules quota and skeleton honest under filtering

The footer counted the filtered list while the create limit is enforced
against all schedules, so filtering made a full account look under quota.
The skeleton reserved a switch, a menu and three text rows the flattened
row no longer has, so the panel visibly collapsed on load; it now mirrors
the healthy row. The skill file expander announced "Show files" even
while expanded, so its label is now a neutral toggle.

* fix(client): Restore schedule row actions and settle the panels' design debt

A schedule row's actions sat in the hover-revealing slot other lists use,
but this panel's rows end at the sidebar's resize handle and a slot
collapsed to zero width put the switch's clickable point outside the
panel, under the handle, where no hover could ever reveal it; the slot
now keeps its width and the menu trigger fades in on row hover alone.

The design-rule violations this branch had suppressed are paid instead:
the tables drop restatements the Table primitives own and take a compact
header size, FilterInput gains the dialog surface instead of a
caller-side color, the projects entries move to the section-action
variant, the MCP cancel cross fades via a wrapper the caller owns, and
the panel group's backdrop moves to its host. The counts this branch had
raised come back down with the entries pruned.

* fix(client): Preserve Shared Row Actions and Verify Panel States

* fix(client): Match Schedule Skeleton Action Height

* fix(client): Preserve Panel Overflow and Schedule History Actions

* refactor(client): Derive Row Action Classes From the Reveal Variant

The reveal recipe was spelled out both in the row-action-reveal Button variant
and in rowActionClasses. The helper now starts from the variant and only adds
the open and always-visible states, and the MCP card spec asserts classes the
real recipe renders instead of a mocked string.

* fix(client): Announce Panel Filter Results and Usage Changes

The schedule filter now reports its match count through a polite live
region, as the prompt filter does. The memory usage badge keeps a status
region beside its toggle so a changed usage is announced while focus is
elsewhere, and the search count reads as a floor while more pages remain.

* fix(client): Keep Row Focus Visible and Warn on Balance-Skipped Runs

The row action slot clipped its overflow even while focus was inside it,
cutting off the focused action's ring. It now clips only while collapsed.

Skill rows drew one focus ring around the whole row, so moving between the
open and disclosure buttons changed nothing on screen. Each button now draws
its own ring.

A run skipped for balance keeps its schedule enabled only until the skip
count disables it, so the row now shows it as a warning instead of reading
as healthy.

* test(e2e): Match the always-applied skill row's full button name

* refactor(client): Render MCP Row Actions Through the Button Primitive

The MCP row actions passed a computed class string to TooltipAnchor, which
the design rules cannot check, and the file carried a new static-classes
suppression for it. They now render the shared Button with the row-action
variants, like the bookmark and memory rows, and the suppression is gone.

* fix(client): Paint Field Notches With the Page Surface and Respect IME Escape

The marketplace, skills and prompts pages moved to the primary-alt surface,
but the floating labels on their fields still painted the presentation
surface, leaving a patch across each field's border in both themes. The
labels now paint the surface they sit on. The create-skill name label is a
plain label like the edit form's, since the Label primitive owns its color
and a notch has to paint its own backdrop.

Escape in the sidebar search cleared the query even while an IME was
composing, where Escape only cancels the composition.

* fix(client): Keep the Chat Column Within the Viewport Beside the Sidebar

Moving the surface off ResizablePanelGroup put a new flex item around it
with the default auto minimum width, so a reply with a wide table grew the
chat column past the viewport and cut its right edge off. The host now
allows itself to shrink, as the group did.

Also covers the sidebar search's IME Escape guard with a unit test, since
the search field is not mounted without a search backend.

(cherry picked from commit 7d4a3f00fe)

Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16244
This commit is contained in:
Marco Beretta 2026-09-25 11:46:09 +02:00 • committed by Lia
parent 6e460b7ca7
commit 1dc4e0d278
98 changed files with 2302 additions and 989 deletions

View file

@ -125,7 +125,9 @@ const AgentMarketplace: React.FC<AgentMarketplaceProps> = ({ className = '' }) =
}
return (
<div className={`bg-presentation relative flex w-full grow overflow-hidden ${className}`}>
<div
className={`bg-surface-primary-alt relative flex w-full grow overflow-hidden ${className}`}
>
<SidePanelGroup>
<main
className="flex h-full min-w-0 flex-col overflow-hidden"

View file

@ -72,7 +72,6 @@ const SearchBar: React.FC<SearchBarProps> = ({ value, onSearch, className = '' }
<FilterInput
inputId="agent-search"
label={localize('com_agents_search_aria')}
surface="presentation"
type="text"
ref={inputRef}
value={searchTerm}

View file

@ -195,7 +195,7 @@ function ChatView({ index = 0, project }: { index?: number; project?: TChatProje
page, so normal rendering is unchanged. */}
<div
className={cn(
'w-full bg-presentation [view-transition-name:chat-form]',
'bg-surface-primary-alt w-full [view-transition-name:chat-form]',
!isLandingPage && 'scrollbar-gutter-spacer',
isLandingPage && 'max-w-3xl transition-all duration-200 xl:max-w-4xl',
)}
@ -203,7 +203,7 @@ function ChatView({ index = 0, project }: { index?: number; project?: TChatProje
{isLandingPage && <ConversationStarters />}
{isSubagentThreadReadOnly ? (
<div
className="mx-auto w-full max-w-3xl px-4 py-3 text-center text-sm text-text-secondary xl:max-w-4xl"
className="text-text-secondary mx-auto w-full max-w-3xl px-4 py-3 text-center text-sm xl:max-w-4xl"
role="note"
>
{localize('com_ui_subagent_thread_read_only')}

View file

@ -79,7 +79,7 @@ function Header({
const hiddenBehindNav = navVisible === true && 'max-md:hidden';
return (
<div className="from-presentation via-presentation/70 text-text-primary md:from-presentation/80 md:via-presentation/50 2xl:from-presentation/0 absolute top-0 z-10 flex h-[52px] w-full items-center gap-2 bg-gradient-to-b to-transparent p-2 font-semibold 2xl:via-transparent">
<div className="from-surface-primary-alt via-surface-primary-alt/70 text-text-primary md:from-surface-primary-alt/80 md:via-surface-primary-alt/50 2xl:from-surface-primary-alt/0 absolute top-0 z-10 flex h-[52px] w-full items-center gap-2 bg-gradient-to-b to-transparent p-2 font-semibold 2xl:via-transparent">
<div className="flex shrink-0 items-center md:hidden">
<OpenSidebar testId="header-open-sidebar-button" />
</div>

View file

@ -80,7 +80,7 @@ const ConversationStarters = () => {
key={index}
onClick={() => sendConversationStarter(text)}
style={{ animationDelay: `${index * 75}ms`, animationFillMode: 'backwards' }}
className="border-border-medium bg-surface-secondary text-text-secondary fade-in hover:border-border-heavy hover:bg-surface-tertiary hover:text-text-primary focus-visible:ring-ring-primary flex max-w-[16rem] cursor-pointer items-center justify-center rounded-2xl border px-4 py-2.5 text-center text-sm shadow-xs transition-colors duration-200 focus-visible:ring-2 focus-visible:outline-hidden"
className="bg-surface-secondary text-text-secondary fade-in hover:bg-surface-hover hover:text-text-primary focus-visible:ring-text-primary flex max-w-[16rem] cursor-pointer items-center justify-center rounded-2xl px-4 py-2.5 text-center text-sm transition-colors duration-200 focus-visible:ring-2 focus-visible:outline-hidden"
>
<span className="line-clamp-2 text-balance break-words">{text}</span>
</button>

View file

@ -110,7 +110,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
{isDeleting ? (
<Spinner className="size-3.5 sm:size-4" />
) : (
<TrashIcon className="size-3.5 text-text-destructive sm:size-4" />
<TrashIcon className="text-text-destructive size-3.5 sm:size-4" />
)}
{!isSmallScreen && <span className="ml-2">{localize('com_ui_delete')}</span>}
</Button>
@ -119,6 +119,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
label={localize('com_files_filter')}
value={(table.getColumn('filename')?.getFilterValue() as string | undefined) ?? ''}
onChange={(event) => table.getColumn('filename')?.setFilterValue(event.target.value)}
surface="dialog"
containerClassName="flex-1"
/>
<div className="relative focus-within:z-[100]">
@ -129,11 +130,11 @@ 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 border border-border-light">
<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">
<TableHeader className="sticky top-0 z-50">
<TableHeader sticky>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id} className="border-b border-border-light">
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header, _index) => {
const size = header.getSize();
const style: Style = {
@ -143,7 +144,8 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
return (
<TableHead
key={header.id}
className="whitespace-nowrap bg-surface-secondary px-2 py-2 text-left text-sm font-medium text-text-secondary sm:px-4"
size="sm"
className="px-2 py-2 whitespace-nowrap sm:px-4"
style={{ ...style }}
>
{header.isPlaceholder
@ -158,11 +160,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
<TableBody className="w-full">
{table.getRowModel().rows.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={row.getIsSelected() && 'selected'}
className="border-b border-border-light transition-colors hover:bg-surface-secondary [tr:last-child_&]:border-b-0"
>
<TableRow key={row.id} data-state={row.getIsSelected() && 'selected'}>
{row.getVisibleCells().map((cell, _index) => {
const size = cell.column.getSize();
const style: Style = {
@ -196,7 +194,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
</div>
<div className="flex items-center justify-end gap-2 py-4">
<div className="ml-2 flex-1 truncate text-xs text-text-secondary sm:ml-4 sm:text-sm">
<div className="text-text-secondary ml-2 flex-1 truncate text-xs sm:ml-4 sm:text-sm">
<span className="hidden sm:inline">
{localize('com_files_number_selected', {
0: `${table.getFilteredSelectedRowModel().rows.length}`,
@ -209,7 +207,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
}`}
</span>
</div>
<div className="flex items-center space-x-1 pr-2 text-xs font-bold text-text-primary sm:text-sm">
<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>

View file

@ -1,11 +1,12 @@
import { Link } from 'lucide-react';
import { useRecoilValue } from 'recoil';
import { buttonVariants } from '@librechat/client';
import { QueryKeys } from 'librechat-data-provider';
import { useQueryClient } from '@tanstack/react-query';
import type { TMessage, TConversation } from 'librechat-data-provider';
import type { InfiniteData } from '@tanstack/react-query';
import type { ConversationCursorData } from '~/utils';
import { findConversationInInfinite, setDocumentTitle } from '~/utils';
import { cn, findConversationInInfinite, setDocumentTitle } from '~/utils';
import { useLocalize, useNavigateToConvo } from '~/hooks';
import store from '~/store';
@ -53,15 +54,21 @@ export default function SearchButtons({ message }: { message: TMessage }) {
}
return (
<div className="visible mt-0 flex items-center justify-center gap-1 self-end text-text-secondary lg:justify-start">
<div className="text-text-secondary flex min-w-0 items-center">
{/* The chat this result came from, and the way back to it: the same quiet chip
the rest of the app uses for a secondary action, holding a title that can
be any length. */}
<button
type="button"
className="ml-0 flex cursor-pointer items-center gap-1.5 rounded-md p-1 text-xs hover:text-text-primary hover:underline"
className={cn(
buttonVariants({ variant: 'ghost', size: 'xs' }),
'text-text-secondary hover:text-text-primary max-w-full min-w-0 gap-1.5 font-normal',
)}
onClick={clickHandler}
title={localize('com_ui_go_to_conversation')}
>
<Link className="icon-sm" aria-hidden="true" />
{message.title}
<Link className="size-3.5 shrink-0" aria-hidden="true" />
<span className="truncate">{message.title}</span>
</button>
</div>
);

View file

@ -2,16 +2,17 @@ import { memo, useMemo } from 'react';
import { useRecoilValue } from 'recoil';
import type { TMessage } from 'librechat-data-provider';
import type { TMessageProps, TMessageIcon } from '~/common';
import MessageRow, { getMessageRowWidthClass } from '~/components/Chat/Messages/ui/MessageRow';
import AuthorHeader from '~/components/Chat/Messages/Content/Parts/AuthorHeader';
import MinimalHoverButtons from '~/components/Chat/Messages/MinimalHoverButtons';
import { getHeaderModelName } from '~/components/Chat/Messages/ui/HeaderLabel';
import { getHeaderPrefixForScreenReader, getMessageAriaLabel } from '~/utils';
import SearchContent, { rendersMarkdownLite } from './Content/SearchContent';
import MessageRow from '~/components/Chat/Messages/ui/MessageRow';
import Icon from '~/components/Chat/Messages/MessageIcon';
import { useAuthContext, useLocalize } from '~/hooks';
import SearchButtons from './SearchButtons';
import SubRow from './SubRow';
import { cn } from '~/utils';
import store from '~/store';
function searchFilesEqual(prev?: TMessage['files'], next?: TMessage['files']) {
@ -112,8 +113,13 @@ function SearchMessage({ message }: Pick<TMessageProps, 'message'>) {
}
return (
<div className="w-full bg-transparent text-text-primary">
<div className="m-auto px-4 py-3 sm:px-0">
<div className="text-text-primary w-full bg-transparent">
{/* A hairline where one result ends and the next begins. Results run together
otherwise, and a long answer followed by a short question reads as one
message. Drawn on the column the message occupies, not the window. */}
<div
className={cn('border-border-light mx-auto border-b px-4 py-4', getMessageRowWidthClass())}
>
<MessageRow
id={message.messageId}
icon={<Icon iconData={iconData} />}

View file

@ -141,7 +141,7 @@ export default function Presentation({ children }: { children: React.ReactNode }
const panelElement = artifactsElement ?? subagentElement;
return (
<DragDropWrapper className="relative flex w-full grow overflow-hidden bg-presentation">
<DragDropWrapper className="bg-surface-primary-alt relative flex w-full grow overflow-hidden">
<AppChatSurface>
<ParentSubagentsProvider
conversationId={conversationId ?? ''}

View file

@ -605,7 +605,7 @@ export default function Viewer({
aria-labelledby={headingId}
data-testid="trace-viewer"
onKeyDown={handleKeyDown}
className="bg-presentation text-text-primary absolute inset-0 z-20 flex flex-col"
className="bg-surface-primary-alt text-text-primary absolute inset-0 z-20 flex flex-col"
>
<div className="border-border-light flex h-[52px] shrink-0 items-center gap-2 border-b px-2 md:px-4">
<h2 id={headingId} className="text-base font-semibold">

View file

@ -128,7 +128,7 @@ const ChatsHeader: FC<ChatsHeaderProps> = memo(({ isExpanded, onToggle, trailing
return (
<div
className={cn(
'flex h-8 w-full items-center pr-2',
'flex h-8 w-full items-center pr-1',
highlight && 'bg-surface-active-alt rounded-lg',
)}
>
@ -164,7 +164,7 @@ const DateLabel: FC<{ groupName: string; isFirst?: boolean; isAlphabetical?: boo
isAlphabetical ? 'com_a11y_chats_alpha_section' : 'com_a11y_chats_date_section',
isAlphabetical ? { letter: displayName } : { date: displayName },
)}
className={cn('text-text-secondary pt-1 pl-1', isFirst === true ? 'mt-0' : 'mt-2')}
className={cn('text-text-secondary pt-0.5 pl-1', isFirst === true ? 'mt-0' : 'mt-1.5')}
style={{ fontSize: '0.7rem' }}
>
{displayName}
@ -603,7 +603,7 @@ const Conversations: FC<ConversationsProps> = ({
return (
<div
ref={chatsRegionRef}
className="text-text-primary relative flex flex-1 flex-col pb-2 text-sm"
className="text-text-primary relative flex flex-1 flex-col pt-3 pb-2 text-sm"
>
<div className="px-3">
<ChatsHeader

View file

@ -3,13 +3,7 @@ import * as Ariakit from '@ariakit/react';
import { useQueryClient } from '@tanstack/react-query';
import { useParams, useNavigate } from 'react-router-dom';
import { QueryKeys, PermissionTypes, Permissions } from 'librechat-data-provider';
import {
DropdownPopup,
Spinner,
buttonVariants,
useToastContext,
useMediaQuery,
} from '@librechat/client';
import { DropdownPopup, Spinner, useToastContext, useMediaQuery } from '@librechat/client';
import {
Ellipsis,
Share2,
@ -37,10 +31,10 @@ import {
import { useHasAccess, useLocalize, useNavigateToConvo, useNewConvo } from '~/hooks';
import { useChatContext, useLiveAnnouncer } from '~/Providers';
import { NotificationSeverity } from '~/common';
import { cn, rowActionClasses } from '~/utils';
import ProjectButton from './ProjectButton';
import DeleteButton from './DeleteButton';
import ShareButton from './ShareButton';
import { cn } from '~/utils';
/** The overflow menu and the shift-held quick action show the same archive control in two
* sizes, and must never disagree about which direction it moves the conversation. */
function renderArchiveIcon(isLoading: boolean, isArchived: boolean, className: string) {
@ -436,16 +430,9 @@ function ConvoOptions({
],
);
const buttonClassName = cn(
/** The same shared row action the unpin badge beside it uses, rather than a
* second copy of that recipe. */
buttonVariants({ variant: 'row-action', size: 'icon-xs' }),
'text-text-secondary',
/** Touch has no hover, so a reveal-on-hover trigger is simply invisible there. */
isActiveConvo === true || isPopoverActive || isSmallScreen
? 'opacity-100'
: 'opacity-0 focus:opacity-100 group-focus-within:opacity-100 group-hover:opacity-100 data-[open]:opacity-100',
);
const buttonClassName = rowActionClasses({
visible: isActiveConvo === true || isPopoverActive || isSmallScreen,
});
if (isShiftHeld && isActiveConvo && !isPopoverActive && !showShareDialog && !showDeleteDialog) {
return (

View file

@ -29,6 +29,7 @@ jest.mock('@ariakit/react', () => ({
}));
jest.mock('~/utils', () => ({
cn: (...classes: Array<string | false | null | undefined>) => classes.filter(Boolean).join(' '),
rowActionClasses: () => 'row-action',
}));
jest.mock('librechat-data-provider', () => ({
QueryKeys: { messages: 'messages' },

View file

@ -705,7 +705,7 @@ const PinnedSection = ({
return (
<div
ref={setSectionRef}
className="flex flex-col px-3 text-sm"
className="flex flex-col px-3 pt-3 text-sm"
role="region"
/** The focus handoff after an unpin must act only on rows in this list:
* `ConversationsSection` is also a labelled region and an ancestor of
@ -715,7 +715,7 @@ const PinnedSection = ({
>
<div
className={cn(
'flex h-8 w-full items-center pr-2',
'flex h-8 w-full items-center pr-1',
isPinOver && canPin && 'bg-surface-active-alt rounded-lg',
)}
>

View file

@ -43,7 +43,7 @@ import ProjectCreateDialog from '~/components/Projects/ProjectCreateDialog';
import ProjectDeleteDialog from '~/components/Projects/ProjectDeleteDialog';
import ProjectEditDialog from '~/components/Projects/ProjectEditDialog';
import { useLocalize, useLocalStorage, useNewConvo } from '~/hooks';
import { clearMessagesCache, cn } from '~/utils';
import { clearMessagesCache, cn, rowActionClasses } from '~/utils';
import { Collapse } from '~/components/ui';
import Convo from './Convo';
import store from '~/store';
@ -56,17 +56,6 @@ const iconButtonClassName = cn(
'shrink-0',
);
/** The same control on a project row rather than beside the heading. The row
* itself already fills on hover, so the variant's hover surface would leave
* the button reading as a second, weaker hover on top of it. These take the
* active fill instead — the same one the row's own selected state uses — both
* under the pointer and while the menu they own is open. */
const rowActionClassName = cn(
iconButtonClassName,
'hover:bg-surface-active hover:text-text-primary',
);
const rowActionOpenClassName = 'bg-surface-active text-text-primary';
const noop = () => {};
type ProjectChatsInlineProps = {
@ -282,9 +271,9 @@ const ProjectItem = memo(
<li className="list-none" ref={projectRowRef}>
<div
className={cn(
'group/project-row text-text-primary hover:bg-surface-hover relative flex h-9 items-center rounded-lg text-sm',
'group text-text-primary hover:bg-surface-active-alt relative flex h-9 items-center rounded-lg text-sm',
isActive && 'bg-surface-active-alt hover:bg-surface-active-alt',
!isActive && isMenuOpen && 'bg-surface-hover',
!isActive && isMenuOpen && 'bg-surface-active-alt',
isDropOver && canDrop && 'bg-surface-active-alt ring-border-medium ring-1 ring-inset',
)}
>
@ -307,19 +296,10 @@ const ProjectItem = memo(
<span className="min-w-0 truncate">{project.name}</span>
</button>
<div
className={cn(
/* The 4px between the two controls, and from the row's trailing
edge, that a pinned chat keeps between its unpin badge and its
overflow menu. */
'absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-1',
isMenuOpen
? 'opacity-100'
: [
'[@media(hover:hover)]:opacity-0 [@media(hover:hover)]:transition-opacity',
'group-hover/project-row:opacity-100',
'has-[:focus-visible]:opacity-100',
],
)}
/* The 4px between the two controls, and from the row's trailing edge,
that a pinned chat keeps between its unpin badge and its overflow
menu. Each control reveals itself. */
className="absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-1"
>
<TooltipAnchor
description={localize('com_ui_new_chat_in_project', { name: project.name })}
@ -327,7 +307,7 @@ const ProjectItem = memo(
<a
href={projectChatPath}
aria-label={localize('com_ui_new_chat_in_project', { name: project.name })}
className={rowActionClassName}
className={rowActionClasses({ visible: isMenuOpen })}
onClick={startChat}
>
<NewChatIcon className="h-4 w-4" />
@ -346,7 +326,7 @@ const ProjectItem = memo(
trigger={
<Ariakit.MenuButton
aria-label={localize('com_ui_more_options')}
className={cn(rowActionClassName, isMenuOpen && rowActionOpenClassName)}
className={rowActionClasses({ open: isMenuOpen })}
>
<Ellipsis className="h-4 w-4" aria-hidden="true" />
</Ariakit.MenuButton>
@ -435,11 +415,15 @@ const ProjectsSection = ({ toggleNav, isAuthenticated }: ProjectsSectionProps) =
if (projects.length === 0) {
return (
/* `section-action` owns the quiet-secondary-until-hovered treatment these
* entries share with the section's other controls; only the row shape is
* the caller's. */
<Button
type="button"
variant="ghost"
variant="section-action"
size="sm"
onClick={() => setIsCreateOpen(true)}
className="text-text-secondary hover:bg-surface-hover hover:text-text-primary flex h-9 w-full justify-start gap-2 rounded-lg px-2 text-sm font-normal transition-colors"
className="flex w-full justify-start"
>
<FolderPlus className="h-4 w-4 shrink-0" aria-hidden="true" />
<span className="truncate">{localize('com_ui_new_project')}</span>
@ -462,9 +446,10 @@ const ProjectsSection = ({ toggleNav, isAuthenticated }: ProjectsSectionProps) =
<li className="list-none">
<Button
type="button"
variant="ghost"
variant="section-action"
size="xs"
onClick={openProjects}
className="text-text-secondary hover:bg-surface-hover hover:text-text-primary flex h-8 w-full justify-start rounded-lg px-2 text-xs font-medium transition-colors"
className="flex w-full justify-start"
>
{localize('com_ui_all_projects')}
</Button>
@ -479,8 +464,8 @@ const ProjectsSection = ({ toggleNav, isAuthenticated }: ProjectsSectionProps) =
}
return (
<div className="flex flex-col px-3 text-sm">
<div className="flex h-8 w-full items-center pr-2">
<div className="flex flex-col px-3 pt-3 text-sm">
<div className="flex h-8 w-full items-center pr-1">
<button
type="button"
onClick={() => {

View file

@ -59,17 +59,20 @@ describe('DateLabel', () => {
).toBeInTheDocument();
});
it('applies mt-0 for the first date header', () => {
/** The first heading opens the list and needs no gap above it; every later one
* separates two groups. The size of that gap is a design decision, so what is
* pinned here is that the two cases differ, not the value. */
it('opens the list flush for the first date header', () => {
const { container } = render(<DateLabel groupName="com_ui_date_today" isFirst={true} />);
const heading = container.querySelector('h2');
expect(heading).toHaveClass('mt-0');
expect(heading).not.toHaveClass('mt-2');
expect(heading).not.toHaveClass('mt-1.5');
});
it('applies mt-2 for non-first date headers', () => {
it('separates a later date header from the group above it', () => {
const { container } = render(<DateLabel groupName="com_ui_date_today" isFirst={false} />);
const heading = container.querySelector('h2');
expect(heading).toHaveClass('mt-2');
expect(heading).toHaveClass('mt-1.5');
expect(heading).not.toHaveClass('mt-0');
});
});

View file

@ -733,7 +733,7 @@ export default function InsightsView() {
(insightsFeatureEnabled && (insights.isLoading || isRecoveringAgentFilters))
) {
return (
<div className="bg-presentation h-full w-full p-4">
<div className="bg-surface-primary-alt h-full w-full p-4">
<LoadingState message={localize('com_insights_loading')} />
</div>
);
@ -743,8 +743,8 @@ export default function InsightsView() {
}
return (
<div className="bg-presentation text-text-primary flex h-full w-full min-w-0 flex-col">
<header className="border-border-light bg-presentation z-20 flex min-h-14 w-full shrink-0 flex-col gap-3 border-b px-4 py-3 sm:px-5 md:flex-row md:items-center md:justify-between md:px-6 lg:px-8">
<div className="bg-surface-primary-alt text-text-primary flex h-full w-full min-w-0 flex-col">
<header className="bg-surface-primary-alt z-20 flex min-h-14 w-full shrink-0 flex-col gap-3 px-4 py-3 sm:px-5 md:flex-row md:items-center md:justify-between md:px-6 lg:px-8">
<div className="flex min-w-0 items-center gap-3">
{isSmallScreen && <OpenSidebar />}
<h1 className="text-base font-semibold">{localize('com_insights_title')}</h1>

View file

@ -1,5 +1,5 @@
import React from 'react';
import { PlugZap, SlidersHorizontal, X } from 'lucide-react';
import { KeyRound, PlugZap, X } from 'lucide-react';
import { Button, Spinner, TooltipAnchor } from '@librechat/client';
import type { MCPServerStatus } from 'librechat-data-provider';
import { useLocalize } from '~/hooks';
@ -33,8 +33,8 @@ export interface MCPServerStatusIconProps {
* Renders the appropriate status icon for an MCP server based on its state.
*
* Unified icon system:
* - PlugZap: Connect/Authenticate (for disconnected servers that need connection)
* - SlidersHorizontal: Configure (for connected servers with custom vars)
* - PlugZap: making the connection (for disconnected servers)
* - KeyRound: the credentials the server asks this user for
* - Spinner: Loading state (during connection)
* - X: Cancel (during OAuth flow, shown on hover over spinner)
*/
@ -121,15 +121,15 @@ function CompactStatusDot({ serverStatus, isInitializing }: CompactStatusDotProp
/** `status-info` rather than `-strong`: the strong slot is a neutral grey
* in both standard palettes, so using it turned this blue dot grey. The
* pulse takes the on-status ink so it inverts with the fill. */
<div className="flex size-3.5 items-center justify-center rounded-full border-2 border-surface-secondary bg-status-info">
<div className="size-1.5 animate-pulse rounded-full bg-text-on-status" />
<div className="border-surface-secondary bg-status-info flex size-3.5 items-center justify-center rounded-full border-2">
<div className="bg-text-on-status size-1.5 animate-pulse rounded-full" />
</div>
);
}
if (!serverStatus) {
return (
<div className="size-3 rounded-full border-2 border-surface-secondary bg-status-neutral" />
<div className="border-surface-secondary bg-status-neutral size-3 rounded-full border-2" />
);
}
@ -149,7 +149,7 @@ function CompactStatusDot({ serverStatus, isInitializing }: CompactStatusDotProp
}
return (
<div className={cn('size-3 rounded-full border-2 border-surface-secondary', colorClass)} />
<div className={cn('border-surface-secondary size-3 rounded-full border-2', colorClass)} />
);
}
@ -163,12 +163,12 @@ function LoadingStatusIcon({ serverName, onCancel, canCancel }: InitializingStat
variant="ghost"
size="icon"
onClick={onCancel}
className="group size-6 rounded p-1 hover:bg-status-error-subtle"
className="group hover:bg-status-error-subtle size-6 rounded p-1"
aria-label={localize('com_ui_cancel')}
>
<div className="relative size-4">
<Spinner className="size-4 text-text-primary group-hover:opacity-0" />
<X className="absolute inset-0 size-4 text-text-destructive opacity-0 group-hover:opacity-100" />
<Spinner className="text-text-primary size-4 group-hover:opacity-0" />
<X className="text-text-destructive absolute inset-0 size-4 opacity-0 group-hover:opacity-100" />
</div>
</Button>
}
@ -179,7 +179,7 @@ function LoadingStatusIcon({ serverName, onCancel, canCancel }: InitializingStat
return (
<div className="flex size-6 items-center justify-center rounded p-1">
<Spinner
className="size-4 text-text-primary"
className="text-text-primary size-4"
aria-label={localize('com_nav_mcp_status_connecting', { 0: serverName })}
/>
</div>
@ -190,7 +190,7 @@ function ConnectingSpinner({ serverName }: { serverName: string }) {
return (
<div className="flex size-6 items-center justify-center rounded p-1">
<Spinner
className="size-4 text-text-primary"
className="text-text-primary size-4"
aria-label={localize('com_nav_mcp_status_connecting', { 0: serverName })}
/>
</div>
@ -204,25 +204,25 @@ function ConnectButton({ serverName, onConfigClick }: StatusIconProps) {
variant="ghost"
size="icon"
onClick={onConfigClick}
className="size-6 rounded p-1 hover:bg-surface-secondary"
className="hover:bg-surface-secondary size-6 rounded p-1"
aria-label={localize('com_nav_mcp_connect_server', { 0: serverName })}
>
<PlugZap className="size-4 text-text-secondary" aria-hidden="true" />
<PlugZap className="text-text-secondary size-4" aria-hidden="true" />
</Button>
);
}
/** Configure button - shown for connected servers with custom vars. Uses SlidersHorizontal icon. */
/** Configure button - shown for connected servers with custom vars. Uses KeyRound icon. */
function ConfigureButton({ serverName, onConfigClick }: StatusIconProps) {
return (
<Button
variant="ghost"
size="icon"
onClick={onConfigClick}
className="size-6 rounded p-1 hover:bg-surface-secondary"
className="hover:bg-surface-secondary size-6 rounded p-1"
aria-label={localize('com_nav_mcp_configure_server', { 0: serverName })}
>
<SlidersHorizontal className="size-4 text-text-secondary" aria-hidden="true" />
<KeyRound className="text-text-secondary size-4" aria-hidden="true" />
</Button>
);
}

View file

@ -2,10 +2,11 @@ import React, { forwardRef, useState, useCallback, useMemo, useEffect, useRef }
import debounce from 'lodash/debounce';
import { useRecoilState } from 'recoil';
import { Search, X } from 'lucide-react';
import { buttonVariants } from '@librechat/client';
import { QueryKeys } from 'librechat-data-provider';
import { useQueryClient } from '@tanstack/react-query';
import { useLocation, useNavigate } from 'react-router-dom';
import { useShortcutAriaKey } from '~/hooks/useKeyboardShortcuts';
import { useShortcutAriaKey, useShortcutDisplay } from '~/hooks/useKeyboardShortcuts';
import { useLocalize, useNewConvo } from '~/hooks';
import { cn } from '~/utils';
import store from '~/store';
@ -35,6 +36,7 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: React.Ref<HTMLDivEleme
const inputRef = useRef<HTMLInputElement>(null);
const [showClearIcon, setShowClearIcon] = useState(() => (search.query ?? '').length > 0);
const focusSearchAriaKey = useShortcutAriaKey('focusSearch');
const shortcutDisplay = useShortcutDisplay('focusSearch');
const clearSearch = useCallback(
(pathname?: string) => {
@ -103,6 +105,25 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: React.Ref<HTMLDivEleme
[setSearchState, clearSearch, debouncedSetDebouncedQuery],
);
/** Escape empties the field rather than only leaving it: a stale query keeps the
* results route mounted, so dismissing the search has to dismiss what it found.
* Stopped here so it does not also close the drawer the field sits in. An IME
* composing text owns Escape, which cancels the composition, not the search. */
const handleKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.code === 'Space') {
e.stopPropagation();
return;
}
if (e.key === 'Escape' && text !== '' && !e.nativeEvent.isComposing) {
e.preventDefault();
e.stopPropagation();
clearText(location.pathname);
}
},
[clearText, location.pathname, text],
);
const handleKeyUp = useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => {
const { value } = e.target as HTMLInputElement;
@ -139,22 +160,23 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: React.Ref<HTMLDivEleme
return (
<div
ref={ref}
className="group text-text-primary focus-within:border-ring-primary focus-within:bg-surface-active-alt hover:bg-surface-active-alt relative flex h-9 min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-lg border-2 border-transparent px-3 py-1.5"
/** A field, resting on a fill of its own: the sidebar and the content beside
* it share one surface now, so a transparent box with nothing in it read as
* empty space rather than as somewhere to type.
*
* No edge on focus, by request. What marks the focused field is its caret and
* the chord appearing in the trailing slot. */
className="group bg-surface-secondary text-text-primary flex h-9 min-w-0 flex-1 cursor-text items-center gap-2 rounded-lg pr-1 pl-2.5"
>
<Search
aria-hidden="true"
className="text-text-secondary group-focus-within:text-text-primary group-hover:text-text-primary absolute left-3 h-4 w-4"
/>
<Search aria-hidden="true" className="text-text-secondary size-4 shrink-0" />
<input
type="text"
data-testid="nav-search-input"
ref={inputRef}
className="placeholder-text-secondary placeholder-opacity-100 group-focus-within:placeholder-text-primary group-hover:placeholder-text-primary m-0 mr-0 w-full border-none bg-transparent p-0 pl-7 text-sm leading-tight focus-visible:outline-hidden"
className="placeholder-text-secondary m-0 min-w-0 flex-1 border-none bg-transparent p-0 text-sm leading-tight focus-visible:outline-hidden"
value={text}
onChange={onChange}
onKeyDown={(e) => {
e.code === 'Space' ? e.stopPropagation() : null;
}}
onKeyDown={handleKeyDown}
aria-label={localize('com_nav_search_placeholder')}
aria-keyshortcuts={focusSearchAriaKey}
placeholder={localize('com_nav_search_placeholder')}
@ -164,20 +186,37 @@ const SearchBar = forwardRef((props: SearchBarProps, ref: React.Ref<HTMLDivEleme
autoComplete="off"
dir="auto"
/>
<button
type="button"
aria-label={localize('com_ui_clear_search')}
className={cn(
'absolute right-[7px] flex h-5 w-5 items-center justify-center rounded-full border-none bg-transparent p-0 transition-opacity duration-200',
showClearIcon ? 'opacity-100' : 'opacity-0',
isSmallScreen === true ? 'right-[16px]' : '',
)}
onClick={() => clearText(location.pathname)}
tabIndex={showClearIcon ? 0 : -1}
disabled={!showClearIcon}
>
<X className="h-5 w-5 cursor-pointer" aria-hidden="true" />
</button>
{showClearIcon ? (
<button
type="button"
aria-label={localize('com_ui_clear_search')}
className={cn(
buttonVariants({ variant: 'ghost', size: 'icon-xs' }),
/** One radius step inside the field it sits in, and the same 4px from
* the top, the bottom and the trailing edge, so the field's corner and
* the button's corner are concentric. */
'text-text-secondary hover:text-text-primary shrink-0 rounded-md',
)}
onClick={() => clearText(location.pathname)}
>
<X className="size-4" aria-hidden="true" />
</button>
) : (
/** The chord that reaches this field, shown once the field has focus and not
* in the resting sidebar, where it would be one more thing printed on a
* surface meant to be quiet. It keeps its width either way, so nothing
* shifts as it appears. Absent on touch, where there is no chord to press,
* and while there is a query, where the clear takes the slot. */
shortcutDisplay !== '' &&
isSmallScreen !== true && (
<kbd
aria-hidden="true"
className="bg-surface-tertiary text-text-secondary pointer-events-none shrink-0 rounded-md px-1.5 py-0.5 font-sans text-xs font-medium opacity-0 group-focus-within:opacity-100"
>
{shortcutDisplay}
</kbd>
)
)}
</div>
);
});

View file

@ -29,18 +29,18 @@ export default function Content({ activeTab, query, ctx }: ContentProps) {
return (
<div aria-label={localize('com_ui_settings_results_aria')} aria-live="polite">
{results.length === 0 ? (
<p className="p-2 text-sm text-text-secondary">
<p className="text-text-secondary p-2 text-sm">
{localize('com_ui_settings_no_results')}
</p>
) : (
<div className="divide-y divide-border-light overflow-hidden rounded-xl border border-border-light text-sm text-text-primary">
<div className="text-text-primary overflow-hidden rounded-xl text-sm">
{results.map(({ entry, label }) => {
const Cmp = entry.Component;
const tabMeta = TABS.find((t) => t.id === entry.tab)!;
const sectionMeta = tabMeta.sections.find((s) => s.id === entry.section);
return (
<div key={entry.id} className="px-4 py-3">
<div className="mb-1.5 text-xs text-text-tertiary">
<div className="text-text-tertiary mb-1.5 text-xs">
{localize(tabMeta.labelKey)} ›{' '}
{sectionMeta ? localize(sectionMeta.labelKey) : label}
</div>

View file

@ -13,17 +13,20 @@ export default function Section({ heading, icon, danger, children }: SectionProp
<section className="mb-7">
<h3
className={cn(
'mb-2 flex items-center gap-1.5 px-1 text-xs font-semibold uppercase tracking-wide',
'mb-1 flex items-center gap-1.5 px-1 text-xs font-medium tracking-wide uppercase',
danger ? 'text-text-destructive' : 'text-text-secondary',
)}
>
{icon}
{heading}
</h3>
{/* A section is a group, not a card: spacing and the label above carry the
grouping. The destructive section keeps its edge, where the box is the
warning rather than decoration. */}
<div
className={cn(
'divide-y divide-border-light overflow-hidden rounded-xl border text-sm text-text-primary',
danger ? 'border-status-error-border' : 'border-border-light',
'text-text-primary overflow-hidden rounded-xl text-sm',
danger && 'border-status-error-border border',
)}
>
{children}

View file

@ -44,6 +44,8 @@ jest.mock('~/hooks', () => ({
jest.mock('~/hooks/useKeyboardShortcuts', () => ({
useShortcutAriaKey: () => 'Meta+/',
/** The chord the field prints while it is empty. */
useShortcutDisplay: () => '⌘/',
}));
jest.mock('~/store', () => ({
@ -102,6 +104,34 @@ describe('SearchBar across a breakpoint remount', () => {
});
});
describe('what the field offers while it rests', () => {
/** The chord is painted under the pointer only, which is CSS; what is checked
* here is which of the two the trailing slot holds. */
it('holds the chord until there is something to clear', () => {
render(<SearchBar />);
expect(screen.getByText('⌘/')).toBeInTheDocument();
expect(screen.queryByLabelText('com_ui_clear_search')).not.toBeInTheDocument();
type('mobile nav');
expect(screen.queryByText('⌘/')).not.toBeInTheDocument();
expect(screen.getByLabelText('com_ui_clear_search')).toBeInTheDocument();
});
/** A query left behind keeps the results route mounted, so the key that
* dismisses the search has to dismiss what it found. */
it('empties itself on Escape', () => {
render(<SearchBar />);
type('mobile nav');
fireEvent.keyDown(input(), { key: 'Escape' });
expect(input().value).toBe('');
expect(mockSearchState.query).toBe('');
});
});
describe('what the departing instance owes the search state', () => {
beforeEach(() => jest.useFakeTimers());
afterEach(() => jest.useRealTimers());
@ -194,4 +224,18 @@ describe('SearchBar across a breakpoint remount', () => {
expect(mockSearchState.debouncedQuery).toBe('');
});
});
/** An IME uses Escape to cancel the text it is composing, not the search. */
describe('Escape while an IME is composing', () => {
it('keeps the query during composition and clears it after', () => {
render(<SearchBar />);
type('konnichiwa');
fireEvent.keyDown(input(), { key: 'Escape', isComposing: true });
expect(input().value).toBe('konnichiwa');
fireEvent.keyDown(input(), { key: 'Escape' });
expect(input().value).toBe('');
});
});
});

View file

@ -252,7 +252,7 @@ export default function ProjectsView() {
};
return (
<main className="bg-presentation text-text-primary flex h-full min-h-0 flex-col overflow-auto">
<main className="bg-surface-primary-alt text-text-primary flex h-full min-h-0 flex-col overflow-auto">
<ProjectsNavBar onCreate={() => setIsCreating(true)} />
<div className="mx-auto flex w-full max-w-6xl flex-1 flex-col px-4 pt-6 pb-10 md:px-6 md:pt-8">

View file

@ -1,5 +1,5 @@
import { useRecoilState } from 'recoil';
import { Button, Checkbox } from '@librechat/client';
import { Button, CheckboxGlyph } from '@librechat/client';
import { useLocalize } from '~/hooks';
import store from '~/store';
@ -25,15 +25,11 @@ export default function AutoSendPrompt({
onClick={() => handleCheckedChange(!autoSendPrompts)}
aria-label={localize('com_nav_auto_send_prompts')}
aria-pressed={autoSendPrompts}
className={`relative h-9 w-full gap-2 rounded-lg border-border-light font-medium ${autoSendPrompts ? 'bg-surface-hover hover:bg-surface-hover' : ''}`}
className={`border-border-light relative h-9 w-full gap-2 rounded-lg font-medium ${autoSendPrompts ? 'bg-surface-hover hover:bg-surface-hover' : ''}`}
>
<Checkbox
checked={autoSendPrompts}
tabIndex={-1}
aria-hidden="true"
aria-label={localize('com_nav_auto_send_prompts')}
className="pointer-events-none"
/>
{/* The button owns the state through `aria-pressed`; this is the mark, not a
second control inside it. */}
<CheckboxGlyph checked={autoSendPrompts} />
{localize('com_nav_auto_send_prompts')}
</Button>
);

View file

@ -25,9 +25,9 @@ export default function CreatePromptButton() {
side="bottom"
render={
<Button
variant="outline"
variant="ghost"
size="icon"
className="size-9 shrink-0 bg-transparent"
className="size-8 shrink-0"
aria-label={localize('com_ui_create_prompt')}
onClick={() => setIsDialogOpen(true)}
>

View file

@ -10,7 +10,7 @@ const Command = ({
onValueChange,
disabled,
tabIndex,
labelBgClassName = 'bg-presentation',
labelBgClassName = 'bg-surface-primary-alt',
}: {
initialValue?: string;
onValueChange?: (value: string) => void;
@ -49,11 +49,11 @@ const Command = ({
}
return (
<div className="rounded-xl border border-border-medium">
<label htmlFor={commandId} className="block px-4 pt-2 text-sm text-text-secondary md:hidden">
<div className="border-border-medium rounded-xl border">
<label htmlFor={commandId} className="text-text-secondary block px-4 pt-2 text-sm md:hidden">
{localize('com_ui_command_placeholder')}
</label>
<div className="relative flex h-10 items-center gap-1 pl-4 pr-2 text-sm text-text-secondary">
<div className="text-text-secondary relative flex h-10 items-center gap-1 pr-2 pl-4 text-sm">
<SquareSlash className="icon-sm shrink-0" aria-hidden="true" />
<div className="relative min-w-0 flex-1">
<Input
@ -70,7 +70,7 @@ const Command = ({
<label
htmlFor={commandId}
className={cn(
'pointer-events-none absolute left-0 top-0.5 hidden max-w-[calc(100%-3.5rem)] origin-[0] translate-y-2 scale-100 rounded px-1 text-sm text-text-secondary transition-transform duration-200 peer-placeholder-shown:translate-y-2 peer-placeholder-shown:scale-100 peer-focus:-translate-y-3 peer-focus:scale-75 peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-translate-y-3 peer-[:not(:placeholder-shown)]:scale-75 md:block',
'text-text-secondary peer-focus:text-text-primary pointer-events-none absolute top-0.5 left-0 hidden max-w-[calc(100%-3.5rem)] origin-[0] translate-y-2 scale-100 rounded px-1 text-sm transition-transform duration-200 peer-placeholder-shown:translate-y-2 peer-placeholder-shown:scale-100 peer-focus:-translate-y-3 peer-focus:scale-75 peer-[:not(:placeholder-shown)]:-translate-y-3 peer-[:not(:placeholder-shown)]:scale-75 md:block',
labelBgClassName,
)}
>
@ -78,7 +78,7 @@ const Command = ({
</label>
</div>
{disabled !== true && (
<span className="absolute right-2 shrink-0 text-xs text-text-secondary md:text-sm">{`${charCount}/${Constants.COMMANDS_MAX_LENGTH}`}</span>
<span className="text-text-secondary absolute right-2 shrink-0 text-xs md:text-sm">{`${charCount}/${Constants.COMMANDS_MAX_LENGTH}`}</span>
)}
</div>
</div>

View file

@ -11,7 +11,7 @@ const Description = ({
onValueChange,
disabled,
tabIndex,
labelBgClassName = 'bg-presentation',
labelBgClassName = 'bg-surface-primary-alt',
}: {
initialValue?: string;
onValueChange?: (value: string) => void;
@ -46,14 +46,14 @@ const Description = ({
}
return (
<div className="rounded-xl border border-border-medium">
<div className="border-border-medium rounded-xl border">
<label
htmlFor={descriptionId}
className="block px-4 pt-2 text-sm text-text-secondary md:hidden"
className="text-text-secondary block px-4 pt-2 text-sm md:hidden"
>
{localize('com_ui_description_placeholder')}
</label>
<div className="relative flex h-10 items-center gap-1 pl-4 pr-2 text-sm text-text-secondary">
<div className="text-text-secondary relative flex h-10 items-center gap-1 pr-2 pl-4 text-sm">
<Info className="icon-sm shrink-0" aria-hidden="true" />
<div className="relative min-w-0 flex-1">
<Input
@ -70,7 +70,7 @@ const Description = ({
<label
htmlFor={descriptionId}
className={cn(
'pointer-events-none absolute left-0 top-0.5 hidden max-w-[calc(100%-3.5rem)] origin-[0] translate-y-2 scale-100 rounded px-1 text-sm text-text-secondary transition-transform duration-200 peer-placeholder-shown:translate-y-2 peer-placeholder-shown:scale-100 peer-focus:-translate-y-3 peer-focus:scale-75 peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-translate-y-3 peer-[:not(:placeholder-shown)]:scale-75 md:block',
'text-text-secondary peer-focus:text-text-primary pointer-events-none absolute top-0.5 left-0 hidden max-w-[calc(100%-3.5rem)] origin-[0] translate-y-2 scale-100 rounded px-1 text-sm transition-transform duration-200 peer-placeholder-shown:translate-y-2 peer-placeholder-shown:scale-100 peer-focus:-translate-y-3 peer-focus:scale-75 peer-[:not(:placeholder-shown)]:-translate-y-3 peer-[:not(:placeholder-shown)]:scale-75 md:block',
labelBgClassName,
)}
>
@ -78,7 +78,7 @@ const Description = ({
</label>
</div>
{!disabled && (
<span className="absolute right-2 shrink-0 text-xs text-text-secondary md:text-sm">{`${charCount}/${MAX_LENGTH}`}</span>
<span className="text-text-secondary absolute right-2 shrink-0 text-xs md:text-sm">{`${charCount}/${MAX_LENGTH}`}</span>
)}
</div>
</div>

View file

@ -94,7 +94,7 @@ const CreatePromptForm = ({
const isCreating = createPromptMutation.isLoading;
const isBlocked = !isDirty || isSubmitting || !isValid || isCreating;
/** Floating labels notch out the surface behind them: the dialog sits on `surface-primary`, the page on `presentation` */
const labelBgClassName = isDialog ? 'bg-surface-primary' : 'bg-presentation';
const labelBgClassName = isDialog ? 'bg-surface-primary' : 'bg-surface-primary-alt';
const onSubmit = (data: CreateFormValues) => {
const { name, category, oneliner, command, ...rest } = data;

View file

@ -16,7 +16,7 @@ export default function InlinePromptsView() {
}
return (
<div className="flex h-full w-full flex-col overflow-y-auto bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full flex-col overflow-y-auto">
<PromptForm promptId={promptId} />
</div>
);

View file

@ -15,12 +15,12 @@ import {
} from '@librechat/client';
import type { TPromptGroup } from 'librechat-data-provider';
import { useLocalize, useAuthContext, useSubmitMessage, useResourcePermissions } from '~/hooks';
import { detectVariables, cn, rowActionClasses, rowActionSlotClasses } from '~/utils';
import { useRecordPromptUsage, useDeletePromptGroup } from '~/data-provider';
import VariableDialog from '../dialogs/VariableDialog';
import PreviewPrompt from '../dialogs/PreviewPrompt';
import CategoryIcon from '../utils/CategoryIcon';
import { useLiveAnnouncer } from '~/Providers';
import { detectVariables, cn } from '~/utils';
const PROMPT_PATH = '/prompts';
@ -138,8 +138,8 @@ function ChatGroupItem({
<>
<div
className={cn(
'group/prompt border-border-light hover:bg-surface-secondary relative mb-1.5 rounded-xl border bg-transparent transition-colors',
!isChatRoute && params.promptId === group._id && 'bg-surface-hover',
'group hover:bg-surface-active-alt relative mb-0.5 rounded-lg bg-transparent',
!isChatRoute && params.promptId === group._id && 'bg-surface-active-alt',
)}
>
{/* Clickable overlay for card */}
@ -161,7 +161,7 @@ function ChatGroupItem({
description={group.name}
side="top"
render={
<span className="text-text-primary truncate text-sm font-semibold">
<span className="text-text-primary truncate text-sm font-medium">
{group.name}
</span>
}
@ -198,38 +198,37 @@ function ChatGroupItem({
}
/>
)}
{/* The menu shares the title's line, so only the title gives way to it.
The snippet below keeps the full width of the row either way. */}
<div
className={cn(rowActionSlotClasses({ open: menuOpen }), 'relative z-10 ml-auto')}
>
<DropdownPopup
portal={true}
menuId={menuId}
focusLoop={true}
className="z-[125]"
unmountOnHide={true}
isOpen={menuOpen}
setIsOpen={setMenuOpen}
trigger={
<Ariakit.MenuButton
ref={menuButtonRef}
aria-label={localize('com_nav_convo_menu_options')}
className={rowActionClasses({ open: menuOpen })}
onClick={(e) => e.stopPropagation()}
>
<Ellipsis className="size-4" aria-hidden="true" />
</Ariakit.MenuButton>
}
items={dropdownItems}
/>
</div>
</div>
<p className="text-text-secondary mt-0.5 line-clamp-2 text-xs leading-relaxed">
{snippet}
</p>
</div>
<div className="relative z-10 shrink-0">
<DropdownPopup
portal={true}
menuId={menuId}
focusLoop={true}
className="z-[125]"
unmountOnHide={true}
isOpen={menuOpen}
setIsOpen={setMenuOpen}
trigger={
<Ariakit.MenuButton
ref={menuButtonRef}
aria-label={localize('com_nav_convo_menu_options')}
className={cn(
'text-text-secondary hover:bg-surface-hover focus-visible:ring-ring-primary flex size-7 items-center justify-center rounded-md transition-opacity focus-visible:ring-2 focus-visible:outline-hidden',
menuOpen
? 'opacity-100'
: 'opacity-0 group-hover/prompt:opacity-100 focus-visible:opacity-100',
)}
onClick={(e) => e.stopPropagation()}
>
<Ellipsis className="size-4" aria-hidden="true" />
</Ariakit.MenuButton>
}
items={dropdownItems}
/>
</div>
</div>
</div>
<PreviewPrompt

View file

@ -43,7 +43,7 @@ export default function ListCard({
<CategoryIcon category={category} className="icon-md shrink-0" aria-hidden="true" />
<Label
id={titleId}
className="text-text-primary min-w-0 truncate text-sm font-semibold select-none"
className="text-text-primary min-w-0 truncate text-sm font-medium select-none"
title={name}
>
{name}

View file

@ -7,15 +7,19 @@ import type { Option } from '~/common';
import { useLocalize, useCategories, useDebounce } from '~/hooks';
import CreatePromptButton from '../buttons/CreatePromptButton';
import { usePromptGroupsContext } from '~/Providers';
import { PanelHeader } from '~/components/ui';
import { cn } from '~/utils';
import store from '~/store';
export default function FilterPrompts({
className = '',
dropdownClassName = '',
children,
}: {
className?: string;
dropdownClassName?: string;
/** Panel-specific controls that sit under the search, e.g. the auto-send toggle */
children?: React.ReactNode;
}) {
const localize = useLocalize();
const { name, setName, hasAccess, promptGroups } = usePromptGroupsContext() ?? {};
@ -30,17 +34,17 @@ export default function FilterPrompts({
{
value: SystemCategories.ALL,
label: localize('com_ui_all_proper'),
icon: <ListFilter className="h-4 w-4 text-text-primary" />,
icon: <ListFilter className="text-text-primary h-4 w-4" />,
},
{
value: SystemCategories.MY_PROMPTS,
label: localize('com_ui_my_prompts'),
icon: <User className="h-4 w-4 text-text-primary" />,
icon: <User className="text-text-primary h-4 w-4" />,
},
{
value: SystemCategories.SHARED_PROMPTS,
label: localize('com_ui_shared_prompts'),
icon: <Share2 className="h-4 w-4 text-text-primary" />,
icon: <Share2 className="text-text-primary h-4 w-4" />,
},
{ divider: true, value: null },
];
@ -98,29 +102,37 @@ export default function FilterPrompts({
}, [debouncedSearchTerm, resultCount, localize]);
return (
<div role="search" className={cn('flex items-center gap-2', className)}>
<div aria-live="polite" aria-atomic="true" className="sr-only">
{searchResultsAnnouncement}
</div>
<Dropdown
value={categoryFilter || SystemCategories.ALL}
onChange={onSelect}
options={filterOptions}
className={cn('shrink-0 [&>button]:size-9', dropdownClassName)}
triggerClassName="rounded-lg bg-transparent"
icon={<ListFilter className="h-4 w-4" />}
label="Filter: "
ariaLabel={localize('com_ui_filter_prompts')}
iconOnly
/>
<FilterInput
inputId="prompts-filter"
label={localize('com_ui_filter_prompts_name')}
value={searchTerm}
onChange={handleSearchChange}
containerClassName="flex-1"
/>
<CreatePromptButton />
</div>
<PanelHeader
className={className}
title={localize('com_ui_prompts')}
action={<CreatePromptButton />}
search={
<div role="search" className="flex items-center gap-2">
<div aria-live="polite" aria-atomic="true" className="sr-only">
{searchResultsAnnouncement}
</div>
<Dropdown
value={categoryFilter || SystemCategories.ALL}
onChange={onSelect}
options={filterOptions}
className={cn('shrink-0 [&>button]:size-9', dropdownClassName)}
triggerClassName="rounded-lg bg-transparent"
icon={<ListFilter className="h-4 w-4" />}
label="Filter: "
ariaLabel={localize('com_ui_filter_prompts')}
iconOnly
/>
<FilterInput
inputId="prompts-filter"
label={localize('com_ui_filter_prompts_name')}
value={searchTerm}
onChange={handleSearchChange}
containerClassName="flex-1"
/>
</div>
}
>
{children}
</PanelHeader>
);
}

View file

@ -73,7 +73,7 @@ export default function GroupSidePanel({
data-testid="close-prompts-panel-button"
aria-label={localize('com_nav_close_sidebar')}
aria-expanded={true}
className="rounded-full border-none bg-transparent p-2 hover:bg-surface-hover md:rounded-xl"
className="hover:bg-surface-hover rounded-full border-none bg-transparent p-2 md:rounded-xl"
onClick={onClose}
>
<Sidebar />
@ -83,13 +83,13 @@ export default function GroupSidePanel({
</div>
)}
<div className="relative flex min-h-0 flex-1 flex-col">
{/* Sticky header: filter and toggles stay put while the list scrolls */}
<div className="shrink-0 space-y-2 px-3 pb-2 text-text-primary">{children}</div>
{/* Sticky header: it brings its own padding via PanelHeader */}
<div className="text-text-primary shrink-0">{children}</div>
<PanelContent
ref={containerRef}
isLoading={!!groupsQuery.isLoading}
skeleton={<PromptGroupSkeleton />}
className="scrollbar-gutter-stable flex flex-col gap-2 overflow-x-hidden pb-3 pl-3 pr-1 text-text-primary"
className="text-text-primary flex scrollbar-gutter-stable flex-col gap-2 overflow-x-hidden pr-1 pb-3 pl-3"
>
<List groups={promptGroups} isChatRoute={isChatRoute} />
{/* Appending the next page, so the loaded rows stay put */}

View file

@ -19,8 +19,9 @@ export default function PromptsAccordion() {
) : null
}
>
<FilterPrompts />
<AutoSendPrompt />
<FilterPrompts>
<AutoSendPrompt />
</FilterPrompts>
</PromptSidePanel>
);
}

View file

@ -1,11 +1,11 @@
import React, { useRef } from 'react';
import { useDrag, useDrop } from 'react-dnd';
import { GripVertical } from 'lucide-react';
import { useDrag, useDrop } from 'react-dnd';
import { useToastContext } from '@librechat/client';
import type { TConversationTag } from 'librechat-data-provider';
import { TooltipAnchor, useToastContext } from '@librechat/client';
import { useConversationTagMutation } from '~/data-provider';
import { NotificationSeverity } from '~/common';
import BookmarkCardActions from './BookmarkCardActions';
import { NotificationSeverity } from '~/common';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
@ -77,35 +77,21 @@ export default function BookmarkCard({ bookmark, position, moveRow }: BookmarkCa
<div
ref={ref}
className={cn(
'flex cursor-move items-center gap-2 rounded-lg px-3 py-2.5',
'border border-border-light bg-transparent',
'hover:bg-surface-secondary',
'group flex cursor-move items-center gap-2 rounded-lg px-3 py-2.5',
'hover:bg-surface-active-alt bg-transparent',
isDragging && 'opacity-50',
)}
>
{/* Drag handle */}
<GripVertical className="size-4 shrink-0 text-text-tertiary" aria-hidden="true" />
<GripVertical className="text-text-tertiary size-4 shrink-0" aria-hidden="true" />
{/* Tag name */}
<span className="min-w-0 flex-1 truncate text-sm font-semibold text-text-primary">
<span className="text-text-primary min-w-0 flex-1 truncate text-sm font-medium">
{bookmark.tag}
</span>
{/* Count badge */}
<TooltipAnchor
description={`${bookmark.count} ${localize(bookmark.count === 1 ? 'com_ui_conversation' : 'com_ui_conversations')}`}
side="top"
render={
<span className="shrink-0 rounded-full bg-surface-tertiary px-2 py-0.5 text-xs text-text-secondary">
{bookmark.count}
</span>
}
/>
{/* Actions */}
<div className="shrink-0">
<BookmarkCardActions bookmark={bookmark} />
</div>
<BookmarkCardActions bookmark={bookmark} />
</div>
);
}

View file

@ -12,6 +12,7 @@ import type { TConversationTag } from 'librechat-data-provider';
import { useDeleteConversationTagMutation } from '~/data-provider';
import { BookmarkEditDialog } from '~/components/Bookmarks';
import { NotificationSeverity } from '~/common';
import { rowActionSlotClasses } from '~/utils';
import { useLocalize } from '~/hooks';
interface BookmarkCardActionsProps {
@ -47,7 +48,7 @@ export default function BookmarkCardActions({ bookmark }: BookmarkCardActionsPro
}, [bookmark.tag, deleteBookmarkMutation]);
return (
<div className="flex items-center gap-1">
<div className={rowActionSlotClasses({ open: editOpen || deleteOpen })}>
{/* Edit button */}
<BookmarkEditDialog
context="BookmarkCardActions"
@ -63,9 +64,10 @@ export default function BookmarkCardActions({ bookmark }: BookmarkCardActionsPro
render={
<Button
ref={editTriggerRef}
variant="ghost"
size="icon"
className="size-7"
type="button"
variant="row-action-reveal"
size="icon-xs"
data-open={editOpen || undefined}
aria-label={localize('com_ui_bookmarks_edit')}
onClick={() => setEditOpen(true)}
>
@ -85,9 +87,10 @@ export default function BookmarkCardActions({ bookmark }: BookmarkCardActionsPro
render={
<Button
ref={deleteTriggerRef}
variant="ghost"
size="icon"
className="size-7"
type="button"
variant="row-action-reveal"
size="icon-xs"
data-open={deleteOpen || undefined}
aria-label={localize('com_ui_bookmarks_delete')}
onClick={() => setDeleteOpen(true)}
>
@ -101,8 +104,13 @@ export default function BookmarkCardActions({ bookmark }: BookmarkCardActionsPro
title={localize('com_ui_bookmarks_delete')}
className="max-w-[450px]"
main={
<p className="text-left text-sm text-text-secondary">
{localize('com_ui_bookmark_delete_confirm')} <strong>{bookmark.tag}</strong>
<p className="text-text-secondary text-left text-sm">
{localize('com_ui_bookmark_delete_confirm')}{' '}
{/* The name is the user's and can be one unbroken run of characters. It
breaks anywhere rather than wrapping on spaces it does not have,
which is also what stops it setting the dialog's width. The sentence
around it still breaks on its own words. */}
<strong className="break-all">{bookmark.tag}</strong>
</p>
}
selection={{

View file

@ -1,17 +1,13 @@
import { Skeleton } from '@librechat/client';
/** Mirrors BookmarkCard: small icon, title, then the conversation count pill */
/** Mirrors BookmarkCard: drag handle, then the tag name */
export default function BookmarkCardSkeleton({ count = 6 }: { count?: number }) {
return (
<div className="flex flex-col gap-2" aria-hidden="true">
{Array.from({ length: count }, (_, i) => (
<div
key={i}
className="flex items-center gap-2 rounded-lg border border-border-light px-3 py-2.5"
>
<div key={i} className="flex items-center gap-2 rounded-lg px-3 py-2.5">
<Skeleton className="size-4 shrink-0 rounded" />
<Skeleton className="h-4 min-w-0 flex-1 rounded" />
<Skeleton className="h-4 w-8 shrink-0 rounded-full" />
</div>
))}
</div>

View file

@ -1,11 +1,11 @@
import React, { useCallback, useEffect, useState } from 'react';
import React, { useCallback, useEffect, useId, useState } from 'react';
import { Plus } from 'lucide-react';
import { Button, FilterInput, OGDialogTrigger, TooltipAnchor } from '@librechat/client';
import type { ConversationTagsResponse, TConversationTag } from 'librechat-data-provider';
import { BookmarkContext, useBookmarkContext } from '~/Providers/BookmarkContext';
import { BookmarkEditDialog } from '~/components/Bookmarks';
import { PanelContent, PanelHeader } from '~/components/ui';
import BookmarkCardSkeleton from './BookmarkCardSkeleton';
import { PanelContent } from '~/components/ui';
import BookmarkList from './BookmarkList';
import { useLocalize } from '~/hooks';
@ -20,6 +20,7 @@ const removeDuplicates = (bookmarks: TConversationTag[]) => {
const BookmarkTable = ({ isLoading = false }: { isLoading?: boolean }) => {
const localize = useLocalize();
const headingId = useId();
const [rows, setRows] = useState<ConversationTagsResponse>([]);
const [searchQuery, setSearchQuery] = useState('');
const [createOpen, setCreateOpen] = useState(false);
@ -46,40 +47,41 @@ const BookmarkTable = ({ isLoading = false }: { isLoading?: boolean }) => {
return (
<BookmarkContext.Provider value={{ bookmarks }}>
<div
role="region"
aria-label={localize('com_ui_bookmarks')}
className="flex min-h-0 flex-1 flex-col"
>
{/* Sticky header: filter + create */}
<div className="flex shrink-0 items-center gap-2 px-3 pb-2">
<FilterInput
inputId="bookmarks-filter"
label={localize('com_ui_bookmarks_filter')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
containerClassName="flex-1"
/>
<BookmarkEditDialog context="BookmarkTable" open={createOpen} setOpen={setCreateOpen}>
<OGDialogTrigger asChild>
<TooltipAnchor
description={localize('com_ui_bookmarks_new')}
side="bottom"
render={
<Button
variant="outline"
size="icon"
className="size-9 shrink-0 bg-transparent"
aria-label={localize('com_ui_bookmarks_new')}
onClick={() => setCreateOpen(true)}
>
<Plus className="size-4" aria-hidden="true" />
</Button>
}
/>
</OGDialogTrigger>
</BookmarkEditDialog>
</div>
<div role="region" aria-labelledby={headingId} className="flex min-h-0 flex-1 flex-col">
{/* Sticky header: title, create, filter */}
<PanelHeader
title={localize('com_ui_bookmarks')}
titleId={headingId}
action={
<BookmarkEditDialog context="BookmarkTable" open={createOpen} setOpen={setCreateOpen}>
<OGDialogTrigger asChild>
<TooltipAnchor
description={localize('com_ui_bookmarks_new')}
side="bottom"
render={
<Button
variant="ghost"
size="icon"
className="size-8 shrink-0"
aria-label={localize('com_ui_bookmarks_new')}
onClick={() => setCreateOpen(true)}
>
<Plus className="size-4" aria-hidden="true" />
</Button>
}
/>
</OGDialogTrigger>
</BookmarkEditDialog>
}
search={
<FilterInput
inputId="bookmarks-filter"
label={localize('com_ui_bookmarks_filter')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
}
/>
{/* Only the list scrolls */}
<PanelContent

View file

@ -249,17 +249,18 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
onChange={(event) => table.getColumn('filename')?.setFilterValue(event.target.value)}
/>
<div className="border-border-light rounded-lg border bg-transparent shadow-xs transition-colors">
<div className="rounded-lg bg-transparent transition-colors">
<div className="overflow-hidden">
<Table className="table-fixed">
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id} className="border-border-light border-b">
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header, index) => (
<TableHead
key={header.id}
size="sm"
style={{ width: index === 0 ? '75%' : '25%' }}
className="bg-surface-secondary text-text-secondary py-2 text-sm font-medium"
className="py-2"
>
<div className={index === 0 ? 'px-2' : 'flex justify-end px-1'}>
{header.isPlaceholder
@ -274,11 +275,7 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
<TableBody>
{table.getRowModel().rows.length ? (
table.getRowModel().rows.map((row) => (
<TableRow
key={row.id}
data-state={row.getIsSelected() && 'selected'}
className="border-border-light hover:bg-surface-secondary border-b transition-colors [&:last-child]:border-0"
>
<TableRow key={row.id} data-state={row.getIsSelected() && 'selected'}>
{row.getVisibleCells().map((cell) => {
const isFilenameCell = cell.column.id === 'filename';

View file

@ -1,4 +1,4 @@
import { useState, useRef, useMemo, useEffect } from 'react';
import { useState, useRef, useMemo, useEffect, useId } from 'react';
import { Plus } from 'lucide-react';
import { useRecoilValue } from 'recoil';
import { useLocation } from 'react-router-dom';
@ -11,8 +11,8 @@ import {
useAuthContext,
activateCatalog,
} from '~/hooks';
import { PanelFooter, PanelContent, PanelHeader } from '~/components/ui';
import MCPConfigDialog from '~/components/MCP/MCPConfigDialog';
import { PanelFooter, PanelContent } from '~/components/ui';
import MCPServerCardSkeleton from './MCPServerCardSkeleton';
import { useMCPRefresh } from '~/hooks/MCP/useMCPRefresh';
import MCPAdminSettings from './MCPAdminSettings';
@ -22,6 +22,7 @@ import store from '~/store';
export default function MCPBuilderPanel() {
const localize = useLocalize();
const headingId = useId();
const location = useLocation();
/** The panel stays mounted while the sidebar is hidden (collapsed, mobile
* drawer, or the insights route collapsing it), so only a visible panel
@ -63,20 +64,15 @@ export default function MCPBuilderPanel() {
return (
<div
role="region"
aria-label={localize('com_ui_mcp_servers')}
aria-labelledby={headingId}
className="flex h-full w-full flex-col overflow-hidden pt-2"
>
{/* Sticky header: Search + Add Button */}
<div className="shrink-0 px-3 pb-2">
<div className="flex items-center gap-2">
<FilterInput
inputId="mcp-filter"
label={localize('com_ui_filter_mcp_servers')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
containerClassName="flex-1"
/>
{hasCreateAccess && (
{/* Sticky header: title, create, search */}
<PanelHeader
title={localize('com_ui_mcp_servers')}
titleId={headingId}
action={
hasCreateAccess && (
<MCPServerDialog
open={showDialog}
onOpenChange={setShowDialog}
@ -89,9 +85,9 @@ export default function MCPBuilderPanel() {
render={
<Button
ref={addButtonRef}
variant="outline"
variant="ghost"
size="icon"
className="size-9 shrink-0 bg-transparent"
className="size-8 shrink-0"
onClick={() => setShowDialog(true)}
aria-label={localize('com_ui_add_mcp')}
>
@ -101,9 +97,17 @@ export default function MCPBuilderPanel() {
/>
</OGDialogTrigger>
</MCPServerDialog>
)}
</div>
</div>
)
}
search={
<FilterInput
inputId="mcp-filter"
label={localize('com_ui_filter_mcp_servers')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
}
/>
{/* Only the list scrolls */}
<PanelContent

View file

@ -9,15 +9,20 @@ jest.mock('~/hooks', () => ({
}));
jest.mock('@librechat/client', () => ({
Button: jest.requireActual('@librechat/client').Button,
buttonVariants: jest.requireActual('@librechat/client').buttonVariants,
Spinner: (props: React.ComponentProps<'span'>) => <span {...props} />,
TooltipAnchor: ({
children,
render,
description: _description,
side: _side,
...props
}: React.ComponentProps<'div'> & { description: string; side?: string }) => (
<div {...props}>{children}</div>
),
}: React.ComponentProps<'div'> & {
description: string;
side?: string;
render?: React.ReactElement;
}) => render ?? <div {...props}>{children}</div>,
}));
const connectedOAuthStatus = {
@ -44,7 +49,9 @@ describe('MCPCardActions', () => {
);
const revokeButton = screen.getByRole('button', { name: 'com_ui_revoke' });
expect(revokeButton).toHaveClass('hover:text-text-secondary');
/** The control takes the shared row-action appearance, and the icon states its
* own colour, so hovering the row cannot repaint a destructive action. */
expect(revokeButton).toHaveClass('hover:bg-surface-hover-alt', 'rounded-md');
expect(revokeButton.querySelector('svg')).toHaveClass('text-text-destructive');
});

View file

@ -1,9 +1,9 @@
import React from 'react';
import { Spinner, TooltipAnchor } from '@librechat/client';
import { Pencil, PlugZap, SlidersHorizontal, RefreshCw, X, Trash2 } from 'lucide-react';
import { Button, Spinner, TooltipAnchor } from '@librechat/client';
import { KeyRound, Pencil, PlugZap, RefreshCw, Unlink, X } from 'lucide-react';
import type { MCPServerStatus } from 'librechat-data-provider';
import { cn, rowActionClasses, rowActionSlotClasses } from '~/utils';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
interface MCPCardActionsProps {
serverName: string;
@ -21,15 +21,21 @@ interface MCPCardActionsProps {
}
/**
* Standardized action buttons for MCP server cards.
* The actions on an MCP server row.
*
* Unified icon system (each icon has ONE meaning):
* - Pencil: Edit server definition (Settings panel only)
* - PlugZap: Connect/Authenticate (for disconnected/error servers)
* - SlidersHorizontal: Configure custom variables (for connected servers with vars)
* - Trash2: Revoke OAuth access (for connected OAuth servers)
* - RefreshCw: Reconnect/Refresh (for connected servers)
* - Spinner: Loading state (with X on hover for cancel)
* One icon, one meaning, and the meaning is the noun the action acts on rather
* than a generic verb:
* - Pencil: the server definition (Settings panel only)
* - KeyRound: the credentials this server asks each user for, which is also what
* marks a server as needing authentication
* - PlugZap: the connection, made
* - Unlink: the account grant, given up. Revoking is dropping the link between
* this user and the provider, NOT deleting the server, which is what a trash can
* said here before and what it stays reserved for. A broken link rather than a
* pulled plug, because the grant and the transport are different things: revoking
* one does not close the other
* - RefreshCw: reconnecting a server that is already connected
* - Spinner, with X on hover: a connection in flight, and cancelling it
*/
export default function MCPCardActions({
serverName,
@ -53,52 +59,61 @@ export default function MCPCardActions({
const isDisconnected = connectionState === 'disconnected';
const isError = connectionState === 'error';
const buttonBaseClass = cn(
'flex size-7 items-center justify-center rounded-md',
'transition-colors duration-150',
'text-text-secondary hover:text-text-secondary',
'hover:bg-surface-tertiary',
'focus-visible:ring-2 focus-visible:ring-text-primary',
);
/** A run in flight is a state of the row, not an action waiting to be found:
* the spinner and the cancel that replaces it stay put without a hover. */
const loadingClass = rowActionClasses({ visible: true });
// Loading state - show spinner (with cancel option)
if (isInitializing || isConnecting) {
return (
<div className="flex items-center gap-0.5">
<div className={rowActionSlotClasses({ open: true })}>
{/* Edit button stays visible during loading */}
{canEdit && (
<TooltipAnchor
focusOutline="hidden"
ref={editButtonRef}
description={localize('com_ui_edit')}
side="top"
className={buttonBaseClass}
aria-label={localize('com_ui_edit')}
role="button"
onClick={onEditClick}
>
<Pencil className="size-3.5" aria-hidden="true" />
</TooltipAnchor>
render={
<Button
type="button"
variant="row-action"
size="icon-xs"
aria-label={localize('com_ui_edit')}
onClick={onEditClick}
>
<Pencil className="text-text-secondary size-4" aria-hidden="true" />
</Button>
}
/>
)}
{/* Spinner with cancel on hover */}
{canCancel ? (
<TooltipAnchor
focusOutline="hidden"
description={localize('com_ui_cancel')}
side="top"
className={cn(buttonBaseClass, 'group')}
aria-label={localize('com_ui_cancel')}
role="button"
onClick={onCancel}
>
<div className="relative size-4">
<Spinner className="size-4 group-hover:opacity-0" />
<X className="text-text-destructive absolute inset-0 size-4 opacity-0 group-hover:opacity-100" />
</div>
</TooltipAnchor>
render={
<Button
type="button"
variant="row-action"
size="icon-xs"
className="group/cancel"
aria-label={localize('com_ui_cancel')}
onClick={onCancel}
>
<div className="relative size-4">
{/* The fade belongs to the wrapper: the spinner's own opacity is the
primitive's, and so is the cancel cross's to the icon. */}
<span className="text-text-secondary absolute inset-0 flex items-center justify-center group-hover/cancel:opacity-0">
<Spinner className="size-4" />
</span>
<X className="text-text-destructive absolute inset-0 size-4 opacity-0 group-hover/cancel:opacity-100" />
</div>
</Button>
}
/>
) : (
<div className={cn(buttonBaseClass, 'cursor-default hover:bg-transparent')}>
<div className={cn(loadingClass, 'cursor-default hover:bg-transparent')}>
<Spinner
className="size-4"
aria-label={localize('com_nav_mcp_status_connecting', { 0: serverName })}
@ -110,83 +125,67 @@ export default function MCPCardActions({
}
return (
<div className="flex items-center gap-0.5">
<div className={rowActionSlotClasses()}>
{/* Edit button - opens MCPServerDialog to edit server definition */}
{canEdit && (
<TooltipAnchor
focusOutline="hidden"
ref={editButtonRef}
description={localize('com_ui_edit')}
side="top"
className={buttonBaseClass}
aria-label={localize('com_ui_edit')}
role="button"
onClick={onEditClick}
>
<Pencil className="size-3.5" aria-hidden="true" />
</TooltipAnchor>
<RowAction ref={editButtonRef} label={localize('com_ui_edit')} onClick={onEditClick}>
<Pencil className="size-4" aria-hidden="true" />
</RowAction>
)}
{/* Connect button - for disconnected or error states */}
{(isDisconnected || isError) && !serverStatus?.requestScoped && (
<TooltipAnchor
focusOutline="hidden"
description={localize('com_nav_mcp_connect')}
side="top"
className={buttonBaseClass}
aria-label={localize('com_nav_mcp_connect')}
role="button"
onClick={() => onInitialize()}
>
<RowAction label={localize('com_nav_mcp_connect')} onClick={() => onInitialize()}>
<PlugZap className="size-4" aria-hidden="true" />
</TooltipAnchor>
</RowAction>
)}
{/* On-demand servers stay idle between requests, so their user variables
must remain configurable without a live transport connection. */}
{(isConnected || serverStatus?.requestScoped) && hasCustomUserVars && (
<TooltipAnchor
focusOutline="hidden"
description={localize('com_ui_configure')}
side="top"
className={buttonBaseClass}
aria-label={localize('com_ui_configure')}
role="button"
onClick={onConfigClick}
>
<SlidersHorizontal className="size-3.5" aria-hidden="true" />
</TooltipAnchor>
<RowAction label={localize('com_ui_configure')} onClick={onConfigClick}>
<KeyRound className="size-4" aria-hidden="true" />
</RowAction>
)}
{/* Refresh button - for connected servers (allows reconnection) */}
{isConnected && !serverStatus?.requestScoped && (
<TooltipAnchor
focusOutline="hidden"
description={localize('com_nav_mcp_reconnect')}
side="top"
className={buttonBaseClass}
aria-label={localize('com_nav_mcp_reconnect')}
role="button"
onClick={() => onInitialize()}
>
<RefreshCw className="size-3.5" aria-hidden="true" />
</TooltipAnchor>
<RowAction label={localize('com_nav_mcp_reconnect')} onClick={() => onInitialize()}>
<RefreshCw className="size-4" aria-hidden="true" />
</RowAction>
)}
{/* Revoke button - for OAuth servers (available regardless of connection state) */}
{serverStatus?.requiresOAuth && onRevoke && (
<TooltipAnchor
focusOutline="hidden"
description={localize('com_ui_revoke')}
side="top"
className={buttonBaseClass}
aria-label={localize('com_ui_revoke')}
role="button"
onClick={onRevoke}
>
<Trash2 className="text-text-destructive size-3.5" aria-hidden="true" />
</TooltipAnchor>
<RowAction label={localize('com_ui_revoke')} onClick={onRevoke}>
<Unlink className="text-text-destructive size-4" aria-hidden="true" />
</RowAction>
)}
</div>
);
}
/** A revealed row action with its tooltip: the label is both the tooltip and the name. */
const RowAction = React.forwardRef<
HTMLDivElement,
{ label: string; onClick: (e: React.MouseEvent) => void; children: React.ReactNode }
>(function RowAction({ label, onClick, children }, ref) {
return (
<TooltipAnchor
ref={ref}
description={label}
side="top"
render={
<Button
type="button"
variant="row-action-reveal"
size="icon-xs"
aria-label={label}
onClick={onClick}
>
{children}
</Button>
}
/>
);
});

View file

@ -111,7 +111,8 @@ export default function MCPServerCard({
<div
className={cn(
'group flex items-center gap-3 rounded-lg px-3 py-2.5',
'border-border-light border bg-transparent',
/** Flat row, not a card: the hover fill is the only affordance a list needs. */
'hover:bg-surface-active-alt bg-transparent',
)}
aria-label={`${displayName} - ${getStatusText()}`}
>

View file

@ -5,10 +5,7 @@ export default function MCPServerCardSkeleton({ count = 5 }: { count?: number })
return (
<div className="flex flex-col gap-2" aria-hidden="true">
{Array.from({ length: count }, (_, i) => (
<div
key={i}
className="flex items-center gap-3 rounded-lg border border-border-light px-3 py-2.5"
>
<div key={i} className="flex items-center gap-3 rounded-lg px-3 py-2.5">
<Skeleton className="size-8 shrink-0 rounded-lg" />
<div className="flex min-w-0 flex-1 flex-col gap-1.5">
<Skeleton className="h-4 w-28 rounded" />

View file

@ -118,7 +118,7 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
{/* API Key Fields */}
<Collapse open={authType === AuthTypeEnum.ServiceHttp} className="pt-3">
<div className="space-y-3 rounded-lg border border-border-light p-3">
<div className="bg-surface-secondary space-y-3 rounded-lg p-3">
{/* User provides own key checkbox + admin-provided key */}
<div>
<div className="flex items-center gap-2">
@ -193,7 +193,7 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
{/* OAuth Fields */}
<Collapse open={authType === AuthTypeEnum.OAuth} className="pt-3">
<div className="space-y-3 rounded-lg border border-border-light p-3">
<div className="bg-surface-secondary space-y-3 rounded-lg p-3">
{/* Client ID & Secret in a grid */}
<div className="grid grid-cols-2 gap-3">
<div className="space-y-1.5">
@ -228,7 +228,7 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
<p
id="oauth-client-id-error"
role="alert"
className="text-xs text-text-destructive"
className="text-text-destructive text-xs"
>
{localize('com_ui_field_required')}
</p>
@ -325,7 +325,7 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
type="text"
readOnly
value={redirectUri}
className="flex-1 text-xs text-text-secondary"
className="text-text-secondary flex-1 text-xs"
/>
<button
type="button"
@ -334,7 +334,7 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
if (!copyLink(setIsCopying)) return;
showToast({ message: localize('com_ui_copied_to_clipboard') });
}}
className="flex size-10 shrink-0 items-center justify-center rounded-lg border border-border-light text-text-secondary transition-colors hover:bg-surface-hover hover:text-text-primary"
className="border-border-light text-text-secondary hover:bg-surface-hover hover:text-text-primary flex size-10 shrink-0 items-center justify-center rounded-lg border transition-colors"
aria-label={localize('com_ui_copy_link')}
>
<MorphIcon icon={isCopying ? CopyCheck : Copy} className="size-4" />
@ -347,7 +347,7 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
{/* OBO Fields */}
<Collapse open={authType === AuthTypeEnum.OBO} className="pt-3">
<div className="space-y-3 rounded-lg border border-border-light p-3">
<div className="bg-surface-secondary space-y-3 rounded-lg p-3">
<div className="space-y-1.5">
<Label htmlFor="obo_scopes" className="text-sm font-medium">
{localize('com_ui_obo_scopes')}{' '}
@ -370,16 +370,16 @@ export default function AuthSection({ isEditMode, serverName }: AuthSectionProps
className={cn(errors.auth?.obo_scopes && 'border-border-destructive')}
/>
{errors.auth?.obo_scopes && (
<p role="alert" className="text-xs text-text-destructive">
<p role="alert" className="text-text-destructive text-xs">
{localize('com_ui_field_required')}
</p>
)}
{canConfigureObo ? (
<p id="obo-scopes-description" className="text-xs text-text-secondary">
<p id="obo-scopes-description" className="text-text-secondary text-xs">
{localize('com_ui_obo_scopes_description')}
</p>
) : (
<p id="obo-scopes-readonly-description" className="text-xs text-text-secondary">
<p id="obo-scopes-readonly-description" className="text-text-secondary text-xs">
{localize('com_ui_obo_readonly_no_permission')}
</p>
)}

View file

@ -1,10 +1,10 @@
import { useMemo } from 'react';
import { useFormContext, Controller } from 'react-hook-form';
import { Checkbox, Label } from '@librechat/client';
import { useFormContext, Controller } from 'react-hook-form';
import type { MCPServerFormData } from '../hooks/useMCPServerForm';
import { createConfigHtmlSanitizer } from '~/utils/configHtml';
import { useLocalize, useLocalizedConfig } from '~/hooks';
import { useGetStartupConfig } from '~/data-provider';
import { createConfigHtmlSanitizer } from '~/utils/configHtml';
import type { MCPServerFormData } from '../hooks/useMCPServerForm';
export default function TrustSection() {
const localize = useLocalize();
@ -22,7 +22,7 @@ export default function TrustSection() {
);
return (
<div className="rounded-lg border border-border-light bg-surface-secondary p-2">
<div className="bg-surface-secondary rounded-lg p-2">
<div className="flex items-start gap-3">
<Controller
name="trust"
@ -44,19 +44,19 @@ export default function TrustSection() {
)}
/>
<Label htmlFor="trust" className="flex cursor-pointer flex-col gap-0.5 text-sm">
<span id="trust-label" className="font-medium text-text-primary">
<span id="trust-label" className="text-text-primary font-medium">
<span dangerouslySetInnerHTML={{ __html: labelHTML }} />{' '}
<span aria-hidden="true" className="text-text-secondary">
*
</span>
</span>
<span id="trust-description" className="text-xs font-normal text-text-secondary">
<span id="trust-description" className="text-text-secondary text-xs font-normal">
<span dangerouslySetInnerHTML={{ __html: subLabelHTML }} />
</span>
</Label>
</div>
{errors.trust && (
<p id="trust-error" role="alert" className="mt-2 text-xs text-text-destructive">
<p id="trust-error" role="alert" className="text-text-destructive mt-2 text-xs">
{localize('com_ui_field_required')}
</p>
)}

View file

@ -1,4 +1,4 @@
import { MCPIcon } from '@librechat/client';
import { EmptyState, MCPIcon } from '@librechat/client';
import { PermissionTypes, Permissions } from 'librechat-data-provider';
import type { MCPServerStatusIconProps } from '~/components/MCP/MCPServerStatusIcon';
import type { MCPServerDefinition } from '~/hooks';
@ -26,24 +26,15 @@ export default function MCPServerList({
});
if (servers.length === 0) {
if (isFiltered) {
return <EmptyState icon={MCPIcon} description={localize('com_ui_no_mcp_servers_match')} />;
}
return (
<div className="flex flex-col items-center justify-center rounded-lg border border-border-light bg-transparent p-6 text-center">
<div className="mb-2 flex size-10 items-center justify-center rounded-full bg-surface-tertiary">
<MCPIcon className="size-5 text-text-secondary" aria-hidden="true" />
</div>
{isFiltered ? (
<p className="text-sm text-text-secondary">{localize('com_ui_no_mcp_servers_match')}</p>
) : (
<>
<p className="text-sm font-medium text-text-primary">
{localize('com_ui_no_mcp_servers')}
</p>
<p className="mt-0.5 text-xs text-text-secondary">
{localize('com_ui_add_first_mcp_server')}
</p>
</>
)}
</div>
<EmptyState
icon={MCPIcon}
title={localize('com_ui_no_mcp_servers')}
description={localize('com_ui_add_first_mcp_server')}
/>
);
}

View file

@ -1,5 +1,5 @@
import { Spinner } from '@librechat/client';
import { Check, PlugZap, Zap } from 'lucide-react';
import { Check, KeyRound, Zap } from 'lucide-react';
import type { MCPServerStatus } from 'librechat-data-provider';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
@ -84,7 +84,10 @@ export default function MCPStatusBadge({
role="status"
className={cn(badgeBaseClass, 'bg-status-warning-subtle text-status-warning')}
>
<PlugZap className="size-3" aria-hidden="true" />
{/* Credentials, the same glyph the config dialog puts on this state and
the row puts on the control that supplies them. A plug belongs to the
action that connects, not to the state of not being able to. */}
<KeyRound className="size-3" aria-hidden="true" />
<span>{localize('com_nav_mcp_status_needs_auth')}</span>
</div>
);

View file

@ -23,28 +23,23 @@ export default function MemoryCard({ memory, hasUpdateAccess }: MemoryCardProps)
return (
<div
className={cn(
'rounded-lg px-3 py-2.5',
'border border-border-light bg-transparent',
'hover:bg-surface-secondary',
'group rounded-lg px-3 py-2.5',
/** No border: a column of boxed rows reads as a stack of cards rather than
* as one list. The hover fill is what says "row" instead. */
'hover:bg-surface-active-alt bg-transparent',
)}
>
{/* Row 1: Key + Agent badge + Token count + Actions */}
{/* Row 1: Key + Agent badge + Actions */}
<div className="flex items-center gap-2">
<span className="truncate text-sm font-semibold text-text-primary">{displayKey}</span>
<span className="text-text-primary truncate text-sm font-medium">{displayKey}</span>
{memory.agentId != null && (
<span
className="shrink-0 truncate rounded-full border border-border-light px-2 py-0.5 text-xs text-text-secondary"
className="bg-surface-tertiary text-text-secondary shrink-0 truncate rounded-full px-2 py-0.5 text-xs"
title={localize('com_ui_memory_agent_badge')}
>
{memory.agentName ?? memory.agentId}
</span>
)}
{memory.tokenCount !== undefined && (
<span className="shrink-0 text-xs text-text-secondary">
{memory.tokenCount}{' '}
{localize(memory.tokenCount === 1 ? 'com_ui_token' : 'com_ui_tokens')}
</span>
)}
{hasUpdateAccess && (
<div className="ml-auto shrink-0">
<MemoryCardActions memory={memory} />
@ -54,10 +49,10 @@ export default function MemoryCard({ memory, hasUpdateAccess }: MemoryCardProps)
{/* Row 2: Value + Date */}
<div className="mt-1 flex items-baseline gap-2">
<p className="min-w-0 flex-1 truncate text-sm text-text-primary" title={memory.value}>
<p className="text-text-primary min-w-0 flex-1 truncate text-sm" title={memory.value}>
{memory.value}
</p>
<span className="shrink-0 text-xs text-text-secondary">
<span className="text-text-secondary shrink-0 text-xs">
{formatDate(memory.updated_at)}
</span>
</div>

View file

@ -15,9 +15,9 @@ import {
import type { TUserMemory } from 'librechat-data-provider';
import { useDeleteMemoryMutation } from '~/data-provider';
import MemoryEditDialog from './MemoryEditDialog';
import { rowActionSlotClasses } from '~/utils';
import { getMemoryAddress } from './address';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
interface MemoryCardActionsProps {
memory: TUserMemory;
@ -33,14 +33,6 @@ export default function MemoryCardActions({ memory }: MemoryCardActionsProps) {
const { mutate: deleteMemory, isLoading: isDeleting } = useDeleteMemoryMutation();
const buttonBaseClass = cn(
'flex size-7 items-center justify-center rounded-md',
'transition-colors duration-150',
'text-text-secondary hover:text-text-primary',
'hover:bg-surface-tertiary',
'focus-visible:ring-2 focus-visible:ring-border-heavy',
);
const confirmDelete = () => {
if (!memoryAddress) {
return;
@ -64,7 +56,7 @@ export default function MemoryCardActions({ memory }: MemoryCardActionsProps) {
}
return (
<div className="flex items-center gap-0.5">
<div className={rowActionSlotClasses({ open: editOpen || deleteOpen })}>
{/* Edit Button */}
<MemoryEditDialog
open={editOpen}
@ -79,13 +71,14 @@ export default function MemoryCardActions({ memory }: MemoryCardActionsProps) {
render={
<Button
ref={triggerRef}
variant="ghost"
size="icon"
className={buttonBaseClass}
type="button"
variant="row-action-reveal"
size="icon-xs"
data-open={editOpen || undefined}
aria-label={localize('com_ui_edit')}
onClick={() => setEditOpen(true)}
>
<Pencil className="size-3.5" aria-hidden="true" />
<Pencil className="size-4" aria-hidden="true" />
</Button>
}
/>
@ -100,16 +93,17 @@ export default function MemoryCardActions({ memory }: MemoryCardActionsProps) {
side="top"
render={
<Button
variant="ghost"
size="icon"
className={buttonBaseClass}
type="button"
variant="row-action-reveal"
size="icon-xs"
data-open={deleteOpen || undefined}
aria-label={localize('com_ui_delete')}
onClick={() => setDeleteOpen(true)}
>
{isDeleting ? (
<Spinner className="size-3.5" />
<Spinner className="size-4" />
) : (
<TrashIcon className="size-3.5" aria-hidden="true" />
<TrashIcon className="size-4" aria-hidden="true" />
)}
</Button>
}
@ -120,11 +114,13 @@ export default function MemoryCardActions({ memory }: MemoryCardActionsProps) {
title={localize('com_ui_delete_memory')}
className="w-11/12 max-w-lg"
main={
<Label className="text-left text-sm font-medium">
<Label className="block text-left text-sm font-medium">
{/* The key is the user's: it breaks anywhere, so a long one wraps inside
the dialog instead of setting its width. */}
<Trans
i18nKey="com_ui_delete_confirm_strong"
values={{ title: memory.key || localize('com_ui_memory') }}
components={{ strong: <strong /> }}
components={{ strong: <strong className="break-all" /> }}
/>
</Label>
}

View file

@ -1,11 +1,11 @@
import { Skeleton } from '@librechat/client';
/** Mirrors MemoryCard: key + token pill on the first row, value + date on the second */
/** Mirrors MemoryCard: key + agent badge on the first row, value + date on the second */
export default function MemoryCardSkeleton({ count = 6 }: { count?: number }) {
return (
<div className="flex flex-col gap-2" aria-hidden="true">
{Array.from({ length: count }, (_, i) => (
<div key={i} className="rounded-lg border border-border-light px-3 py-2.5">
<div key={i} className="rounded-lg px-3 py-2.5">
<div className="flex items-center gap-2">
<Skeleton className="h-4 w-32 rounded" />
<Skeleton className="h-4 w-16 rounded-full" />

View file

@ -109,7 +109,7 @@ export default function MemoryCreateDialog({
<OGDialogTemplate
title={localize('com_ui_create_memory')}
showCloseButton={false}
className="w-11/12 md:max-w-lg"
className="w-11/12 md:max-w-2xl"
main={
<div className="space-y-4">
<div className="space-y-2">
@ -145,8 +145,8 @@ export default function MemoryCreateDialog({
onBlur={() => setTouched((prev) => ({ ...prev, value: true }))}
onKeyDown={handleKeyPress}
placeholder={localize('com_ui_enter_value')}
className="border-border-light text-text-primary focus-visible:ring-border-heavy min-h-[100px] w-full resize-none rounded-lg border bg-transparent px-3 py-2 text-sm focus-visible:ring-1"
rows={4}
className="border-border-light text-text-primary focus-visible:ring-border-heavy max-h-[45vh] min-h-[180px] w-full resize-y rounded-lg border bg-transparent px-3 py-2 text-sm focus-visible:ring-1"
rows={8}
aria-invalid={showValueError && valueError != null}
aria-describedby="memory-value-message"
/>

View file

@ -152,28 +152,17 @@ export default function MemoryEditDialog({
<OGDialogTemplate
title={hasUpdateAccess ? localize('com_ui_edit_memory') : localize('com_ui_view_memory')}
showCloseButton={false}
className="w-11/12 md:max-w-lg"
className="w-11/12 md:max-w-2xl"
main={
<div className="space-y-4">
{/* Memory metadata */}
{/* When it last changed, and what it costs. The size is the badge's to
state when a limit gives it something to be a share of, and a plain
count otherwise: two slots, so neither is stranded mid-bar. */}
{memory && (
<div className="border-border-light bg-surface-secondary flex items-center justify-between rounded-lg border px-3 py-2">
{/* Token count - Left */}
{memory.tokenCount !== undefined ? (
<span className="text-text-secondary text-xs">
{memory.tokenCount.toLocaleString()}{' '}
{localize(memory.tokenCount === 1 ? 'com_ui_token' : 'com_ui_tokens')}
</span>
) : (
<div />
)}
{/* Date - Center */}
<span className="text-text-secondary text-xs">
<div className="border-border-light bg-surface-secondary flex items-center justify-between gap-3 rounded-lg border px-3 py-2">
<span className="text-text-secondary min-w-0 truncate text-xs">
{formatDateTime(memory.updated_at, hour12)}
</span>
{/* Usage badge - Right (memory-specific) */}
{memoryUsage ? (
<MemoryUsageBadge
percentage={memoryUsage.percentage}
@ -182,7 +171,12 @@ export default function MemoryEditDialog({
tooltipMax={memoryUsage.availableForMemory}
/>
) : (
<div />
memory.tokenCount !== undefined && (
<span className="text-text-secondary shrink-0 text-xs">
{memory.tokenCount.toLocaleString()}{' '}
{localize(memory.tokenCount === 1 ? 'com_ui_token' : 'com_ui_tokens')}
</span>
)
)}
</div>
)}
@ -224,8 +218,8 @@ export default function MemoryEditDialog({
onBlur={() => setTouched((prev) => ({ ...prev, value: true }))}
onKeyDown={handleKeyPress}
placeholder={localize('com_ui_enter_value')}
className="border-border-light text-text-primary focus-visible:ring-border-heavy min-h-[100px] w-full resize-none rounded-lg border bg-transparent px-3 py-2 text-sm focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50"
rows={4}
className="border-border-light text-text-primary focus-visible:ring-border-heavy max-h-[45vh] min-h-[180px] w-full resize-y rounded-lg border bg-transparent px-3 py-2 text-sm focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50"
rows={8}
disabled={!hasUpdateAccess}
aria-invalid={showValueError && valueError != null}
aria-describedby="memory-value-message"

View file

@ -1,10 +1,10 @@
import { useMemo, useState, useEffect } from 'react';
import { useMemo, useState, useEffect, useId } from 'react';
import { Plus } from 'lucide-react';
import { matchSorter } from 'match-sorter';
import { SystemRoles, PermissionTypes, Permissions } from 'librechat-data-provider';
import {
Button,
Checkbox,
CheckboxGlyph,
Dropdown,
FilterInput,
TooltipAnchor,
@ -17,8 +17,8 @@ import {
useMemoriesQuery,
useGetUserQuery,
} from '~/data-provider';
import { PanelFooter, PanelContent, PanelHeader } from '~/components/ui';
import { useLocalize, useAuthContext, useHasAccess } from '~/hooks';
import { PanelFooter, PanelContent } from '~/components/ui';
import MemoryCardSkeleton from './MemoryCardSkeleton';
import MemoryCreateDialog from './MemoryCreateDialog';
import MemoryUsageBadge from './MemoryUsageBadge';
@ -32,6 +32,7 @@ const PARTITION_PERSONAL = 'personal';
export default function MemoryPanel() {
const localize = useLocalize();
const headingId = useId();
const { user } = useAuthContext();
const { data: userData } = useGetUserQuery();
const { data: memData, isLoading } = useMemoriesQuery();
@ -137,7 +138,7 @@ export default function MemoryPanel() {
return (
<div className="flex h-full w-full items-center justify-center p-4">
<div className="text-center">
<p className="text-sm text-text-secondary">{localize('com_ui_no_read_access')}</p>
<p className="text-text-secondary text-sm">{localize('com_ui_no_read_access')}</p>
</div>
</div>
);
@ -149,21 +150,15 @@ export default function MemoryPanel() {
return (
<div
role="region"
aria-label={localize('com_ui_memories')}
aria-labelledby={headingId}
className="flex h-full w-full flex-col overflow-hidden pt-2"
>
{/* Sticky header: filter, partition, usage + toggle */}
<div className="shrink-0 space-y-2 px-3 pb-2">
{/* Header: Filter + Create Button */}
<div className="flex items-center gap-2">
<FilterInput
inputId="memory-search"
label={localize('com_ui_memories_filter')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
containerClassName="flex-1"
/>
{hasCreateAccess && (
{/* Sticky header: title, create, filter, partition, usage + toggle */}
<PanelHeader
title={localize('com_ui_memories')}
titleId={headingId}
action={
hasCreateAccess && (
<MemoryCreateDialog open={createDialogOpen} onOpenChange={setCreateDialogOpen}>
<OGDialogTrigger asChild>
<TooltipAnchor
@ -171,9 +166,9 @@ export default function MemoryPanel() {
side="bottom"
render={
<Button
variant="outline"
variant="ghost"
size="icon"
className="size-9 shrink-0 bg-transparent"
className="size-8 shrink-0"
aria-label={localize('com_ui_create_memory')}
onClick={() => setCreateDialogOpen(true)}
>
@ -183,9 +178,17 @@ export default function MemoryPanel() {
/>
</OGDialogTrigger>
</MemoryCreateDialog>
)}
</div>
)
}
search={
<FilterInput
inputId="memory-search"
label={localize('com_ui_memories_filter')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
}
>
{/* Partition filter (only when agent-scoped memories exist) */}
{partitionOptions && (
<Dropdown
@ -225,19 +228,15 @@ export default function MemoryPanel() {
aria-pressed={referenceSavedMemories}
disabled={updateMemoryPreferencesMutation.isLoading}
>
<Checkbox
checked={referenceSavedMemories}
tabIndex={-1}
aria-hidden="true"
aria-label={localize('com_ui_use_memory')}
className="pointer-events-none"
/>
{/* The button owns the state through `aria-pressed`; this is the
mark, not a second control inside it. */}
<CheckboxGlyph checked={referenceSavedMemories} />
{localize('com_ui_use_memory')}
</Button>
)}
</div>
)}
</div>
</PanelHeader>
{/* Only the list scrolls */}
<PanelContent isLoading={isLoading} skeleton={<MemoryCardSkeleton />} className="px-3 pb-3">

View file

@ -1,3 +1,4 @@
import { useState } from 'react';
import { TooltipAnchor } from '@librechat/client';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
@ -22,6 +23,12 @@ const getStatusColor = (pct: number): string => {
return 'bg-status-success-subtle text-status-success';
};
/**
* How full the memory is, in either of the two ways that answer it: the share of
* the budget, or the count against it. Which one is wanted depends on the question
* being asked, so the badge carries both and a click swaps them, with the one that
* is hidden shown on hover.
*/
export default function MemoryUsageBadge({
percentage,
tokenLimit,
@ -30,34 +37,48 @@ export default function MemoryUsageBadge({
tooltipMax,
}: MemoryUsageBadgeProps) {
const localize = useLocalize();
const [showTokens, setShowTokens] = useState(false);
const tokenLabel = localize('com_ui_tokens');
const current = tooltipCurrent ?? totalTokens;
const max = tooltipMax ?? tokenLimit;
const tooltipText =
const tokenText =
current !== undefined
? `${current.toLocaleString()} / ${max.toLocaleString()} ${tokenLabel}`
: `${max.toLocaleString()} ${tokenLabel}`;
const percentText = `${percentage}% ${localize('com_ui_used').toLowerCase()}`;
return (
<TooltipAnchor
description={tooltipText}
side="top"
render={
<div
className={cn(
'inline-flex items-center gap-1.5 rounded-full px-2.5 py-1',
'text-xs font-medium',
getStatusColor(percentage),
)}
role="status"
aria-label={`${localize('com_ui_usage')}: ${percentage}%`}
>
<span>{percentage}%</span>
<span className="opacity-70">{localize('com_ui_used').toLowerCase()}</span>
</div>
}
/>
<>
{/* The button's name changes silently while focus is elsewhere, so a create,
edit or delete that moves the usage is announced from here instead. */}
<span className="sr-only" role="status" aria-atomic="true">
{`${localize('com_ui_usage')}: ${percentage}%`}
</span>
<TooltipAnchor
/** The reading the badge is not showing, so hovering answers the other
* question without having to click for it. */
description={showTokens ? percentText : tokenText}
side="top"
render={
<button
type="button"
onClick={() => setShowTokens((shown) => !shown)}
/** The name has to carry the words on the face of the control, or a voice
* command that reads them back matches nothing (WCAG 2.5.3). */
aria-label={`${localize('com_ui_usage')}: ${showTokens ? tokenText : percentText}`}
className={cn(
'inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1',
'text-xs font-medium hover:underline',
'focus-visible:ring-border-heavy focus-visible:ring-2 focus-visible:outline-hidden',
getStatusColor(percentage),
)}
>
{showTokens ? tokenText : percentText}
</button>
}
/>
</>
);
}

View file

@ -0,0 +1,19 @@
import React from 'react';
import '@testing-library/jest-dom/extend-expect';
import { render, screen } from '@testing-library/react';
import MemoryUsageBadge from '../MemoryUsageBadge';
jest.mock('~/hooks', () => ({
useLocalize: () => (key: string) => key,
}));
describe('MemoryUsageBadge', () => {
test('keeps the usage in a polite status region that follows changes', () => {
const { rerender } = render(<MemoryUsageBadge percentage={40} tokenLimit={1000} />);
expect(screen.getByRole('status')).toHaveTextContent('com_ui_usage: 40%');
rerender(<MemoryUsageBadge percentage={55} tokenLimit={1000} />);
expect(screen.getByRole('status')).toHaveTextContent('com_ui_usage: 55%');
expect(screen.getByRole('button', { name: /com_ui_usage/ })).toBeInTheDocument();
});
});

View file

@ -1,9 +1,9 @@
import { useId, useRef, useMemo, useState, useCallback } from 'react';
import * as Ariakit from '@ariakit/react';
import { useNavigate } from 'react-router-dom';
import { Link, useNavigate } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import { Play, Trash, Folder, Pencil, Ellipsis } from 'lucide-react';
import { PermissionTypes, Permissions } from 'librechat-data-provider';
import { Play, Trash, Pencil, Ellipsis, TriangleAlert } from 'lucide-react';
import {
Label,
Chip,
@ -14,9 +14,10 @@ import {
OGDialogTemplate,
useToastContext,
} from '@librechat/client';
import type { TSchedule, ScheduleRunStatus, ScheduleDisabledReason } from 'librechat-data-provider';
import type { TSchedule, ScheduleDisabledReason } from 'librechat-data-provider';
import type { ImmediateScheduleMCPFailure } from './errors';
import type { TranslationKeys } from '~/hooks';
import type { ScheduleRowTone } from './state';
import {
scheduleMCPErrorMessage,
scheduleMCPErrorOutcomes,
@ -31,11 +32,12 @@ import {
useRunScheduleNowMutation,
} from '~/data-provider';
import { useLocalize, useHasAccess, useClockFormat, useWeekStart } from '~/hooks';
import { cn, getMessageTimestamp, rowActionClasses } from '~/utils';
import ScheduleMCPRecovery from './ScheduleMCPRecovery';
import { useAgentsMapContext } from '~/Providers';
import { getMessageTimestamp } from '~/utils';
import ScheduleDialog from './ScheduleDialog';
import { describeCadence } from './cadence';
import { scheduleRowState } from './state';
interface ScheduleCardProps {
schedule: TSchedule;
@ -44,18 +46,6 @@ interface ScheduleCardProps {
projectName?: string | null;
}
type StatusTone = 'neutral' | 'success' | 'warning' | 'error';
const STATUS_CHIPS: Record<ScheduleRunStatus, { label: TranslationKeys; tone: StatusTone }> = {
success: { label: 'com_ui_schedule_last_run', tone: 'success' },
error: { label: 'com_ui_schedule_last_run_failed', tone: 'error' },
interrupted: { label: 'com_ui_schedule_last_run_failed', tone: 'error' },
requires_action: { label: 'com_ui_schedule_needs_approval', tone: 'warning' },
started: { label: 'com_ui_schedule_run_started', tone: 'neutral' },
skipped_overlap: { label: 'com_ui_schedule_run_skipped', tone: 'neutral' },
skipped_balance: { label: 'com_ui_schedule_run_skipped', tone: 'neutral' },
};
const DISABLED_REASON_LABELS: Record<ScheduleDisabledReason, TranslationKeys> = {
mcp_reauth_required: 'com_ui_schedule_disabled_mcp_reauth',
mcp_configuration_missing: 'com_ui_schedule_disabled_mcp_configuration',
@ -69,6 +59,99 @@ const DISABLED_REASON_LABELS: Record<ScheduleDisabledReason, TranslationKeys> =
project_required: 'com_ui_schedule_disabled_project_required',
};
const TRAILING_TONE: Record<ScheduleRowTone, string> = {
running: 'text-text-secondary',
paused: 'text-text-secondary',
warning: 'text-status-warning',
error: 'text-status-error',
};
/**
* The row's state, in the margin. A dot for the two states the clock owns, filled
* while the schedule is running to its cadence and hollow while it is paused, and a
* triangle for the two that want their owner: the shape changes with the meaning, so
* the marker does not rest on colour alone.
*/
function StateMarker({ tone }: { tone: ScheduleRowTone }) {
if (tone === 'error' || tone === 'warning') {
return (
<TriangleAlert
aria-hidden="true"
className={cn(
'mt-0.5 size-3.5 shrink-0',
tone === 'error' ? 'text-status-error' : 'text-status-warning',
)}
/>
);
}
return (
<span
aria-hidden="true"
className={cn(
'mt-1.5 size-2 shrink-0 rounded-full',
tone === 'running' ? 'bg-status-success' : 'border-border-heavy border',
)}
/>
);
}
/**
* What the state means, at the end of the title line: when the next run lands, or
* the one word that explains why none is coming. When a previous run has a
* conversation, keep its navigation available alongside the current state.
*/
function TrailingState({
label,
tone,
nextRun,
conversationId,
onOpenRun,
openRunLabel,
}: {
label: string | null;
tone: ScheduleRowTone;
nextRun: { relative: string; full: string } | null;
conversationId?: string;
onOpenRun: () => void;
openRunLabel: string;
}) {
if (label == null && nextRun == null) {
return null;
}
const content =
label != null ? (
label
) : (
<>
{/* The bare time is what the eye needs; the sentence is what a screen
reader needs, since "Mon 9:00 AM" alone does not say which run. */}
<span aria-hidden="true">{nextRun?.relative}</span>
<span className="sr-only">{nextRun?.full}</span>
</>
);
const className = cn('shrink-0 text-xs', TRAILING_TONE[tone]);
if (conversationId == null || conversationId === '') {
return <span className={className}>{content}</span>;
}
return (
<button
type="button"
title={openRunLabel}
aria-label={label == null ? openRunLabel : `${label}: ${openRunLabel}`}
onClick={onOpenRun}
className={cn(
className,
'focus-visible:ring-text-primary rounded-sm hover:underline focus-visible:ring-2 focus-visible:outline-hidden',
)}
>
{content}
</button>
);
}
export default function ScheduleCard({ schedule, projectName }: ScheduleCardProps) {
const localize = useLocalize();
const navigate = useNavigate();
@ -177,7 +260,7 @@ export default function ScheduleCard({ schedule, projectName }: ScheduleCardProp
weekStartsOn,
);
const nextRunText = useMemo(() => {
const nextRun = useMemo(() => {
if (!schedule.enabled || schedule.nextRunAt == null) {
return null;
}
@ -185,7 +268,10 @@ export default function ScheduleCard({ schedule, projectName }: ScheduleCardProp
if (!timestamp) {
return null;
}
return localize('com_ui_schedule_next_run', { time: timestamp.relative });
return {
relative: timestamp.relative,
full: localize('com_ui_schedule_next_run', { time: timestamp.relative }),
};
}, [schedule.enabled, schedule.nextRunAt, i18n.language, hour12, localize]);
const dropdownItems = useMemo(
@ -223,91 +309,103 @@ export default function ScheduleCard({ schedule, projectName }: ScheduleCardProp
[localize, handleRunNow, runSchedule.isLoading],
);
const statusChip = schedule.lastRun ? STATUS_CHIPS[schedule.lastRun.status] : null;
const lastRunConvoId = schedule.lastRun?.conversationId;
/** One state per row, derived once so the marker and the word cannot disagree. */
const rowState = useMemo(() => scheduleRowState(schedule, localize), [schedule, localize]);
/** The agent, the cadence and the project are the row's detail, on one line in the
* order you would say them. The full text stays in `title`, since the line is the
* first thing a narrow panel truncates. */
const detailText = [agentName, cadenceText, projectName].filter(Boolean).join(' · ');
return (
<div
data-testid="schedule-card"
className="border-border-light duration-theme-fast hover:bg-surface-secondary rounded-lg border bg-transparent px-3 py-2.5 transition-colors"
className="group hover:bg-surface-active-alt rounded-lg bg-transparent px-3 py-2.5"
>
<div className="flex items-center gap-2">
<span className="text-text-primary min-w-0 flex-1 truncate text-sm font-semibold">
{schedule.name}
</span>
{canWrite && (
<>
<Switch
checked={schedule.enabled}
onCheckedChange={handleToggle}
disabled={updateSchedule.isLoading}
aria-label={`${localize('com_ui_schedule_enabled')}: ${schedule.name}`}
className="shrink-0"
<div className="flex items-start gap-2.5">
{/* The state, in the margin: a filled dot for a schedule that is running to
its cadence, a hollow one for a paused one, and a triangle for the two
states that want the owner rather than the clock. */}
<StateMarker tone={rowState.tone} />
<div className="min-w-0 flex-1">
<div className="flex items-baseline gap-2">
<span className="text-text-primary min-w-0 flex-1 truncate text-sm font-medium">
{schedule.name}
</span>
<TrailingState
label={rowState.label}
tone={rowState.tone}
nextRun={nextRun}
conversationId={rowState.tone === 'running' ? undefined : lastRunConvoId}
onOpenRun={() => navigate(`/c/${lastRunConvoId}`)}
openRunLabel={localize('com_ui_schedule_last_run')}
/>
<DropdownPopup
portal={true}
menuId={menuId}
focusLoop={true}
className="z-[125]"
unmountOnHide={true}
isOpen={menuOpen}
setIsOpen={setMenuOpen}
trigger={
<Ariakit.MenuButton
id={`schedule-menu-${schedule.id}`}
aria-label={`${localize('com_ui_schedule_options')}: ${schedule.name}`}
className="text-text-secondary hover:bg-surface-tertiary hover:text-text-primary focus-visible:ring-border-heavy inline-flex size-7 shrink-0 items-center justify-center rounded-md focus:outline-hidden focus-visible:ring-2"
>
<Ellipsis className="size-4" aria-hidden={true} />
</Ariakit.MenuButton>
}
items={dropdownItems}
/>
</>
)}
</div>
<p className="text-text-secondary mt-0.5 truncate text-xs" title={agentName}>
{agentName}
</p>
{projectName != null && projectName !== '' && (
<p
className="text-text-secondary mt-0.5 flex items-center gap-1 truncate text-xs"
title={projectName}
>
<Folder className="size-3 shrink-0" aria-hidden="true" />
<span className="truncate">{projectName}</span>
</p>
)}
<p className="text-text-primary mt-1 text-sm">{cadenceText}</p>
{nextRunText != null && <p className="text-text-secondary mt-0.5 text-xs">{nextRunText}</p>}
{(statusChip != null || schedule.disabledReason != null) && (
<div className="mt-1.5 flex flex-wrap items-center gap-1.5">
{statusChip != null &&
(lastRunConvoId != null && lastRunConvoId !== '' ? (
<button
type="button"
className="focus-visible:ring-text-primary rounded-full hover:underline focus-visible:ring-2 focus-visible:outline-hidden"
onClick={() => navigate(`/c/${lastRunConvoId}`)}
</div>
<div className="mt-0.5 flex items-center gap-2">
<p className="text-text-secondary min-w-0 flex-1 truncate text-xs" title={detailText}>
{detailText}
</p>
{rowState.tone === 'running' && lastRunConvoId && (
<Link
to={`/c/${lastRunConvoId}`}
aria-label={`${localize('com_ui_schedule_last_run')}: ${schedule.name}`}
className="text-text-secondary focus-visible:ring-text-primary shrink-0 rounded-sm text-xs hover:underline focus-visible:ring-2 focus-visible:outline-hidden"
>
<Chip tone={statusChip.tone}>{localize(statusChip.label)}</Chip>
</button>
) : (
<Chip tone={statusChip.tone}>{localize(statusChip.label)}</Chip>
))}
{localize('com_ui_schedule_last_run')}
</Link>
)}
{canWrite && (
/* Not the collapsible slot other rows use: this panel's rows end at
the sidebar's resize handle, and a slot collapsed to zero width
puts the switch's clickable point outside the panel entirely,
under that handle, where no hover can ever reveal it. The menu
trigger still fades in on row hover by itself. */
<div className="flex shrink-0 items-center gap-2">
<Switch
checked={schedule.enabled}
onCheckedChange={handleToggle}
disabled={updateSchedule.isLoading}
aria-label={`${localize('com_ui_schedule_enabled')}: ${schedule.name}`}
className="shrink-0"
/>
<DropdownPopup
portal={true}
menuId={menuId}
focusLoop={true}
className="z-[125]"
unmountOnHide={true}
isOpen={menuOpen}
setIsOpen={setMenuOpen}
trigger={
<Ariakit.MenuButton
id={`schedule-menu-${schedule.id}`}
aria-label={`${localize('com_ui_schedule_options')}: ${schedule.name}`}
className={rowActionClasses({ open: menuOpen })}
>
<Ellipsis className="size-4" aria-hidden={true} />
</Ariakit.MenuButton>
}
items={dropdownItems}
/>
</div>
)}
</div>
{/* Only what the two lines above cannot say: why the clock stopped, and how
to get an MCP server back. A healthy schedule shows neither. */}
{schedule.disabledReason != null && (
<Chip tone="error">
{localize(disabledMCPLabel ?? DISABLED_REASON_LABELS[schedule.disabledReason])}
</Chip>
<div className="mt-1.5">
<Chip tone="error">{localize(DISABLED_REASON_LABELS[schedule.disabledReason])}</Chip>
</div>
)}
<ScheduleMCPRecovery
outcomes={mcpOutcomes}
fallbackAgentId={schedule.agent_id}
agentNames={agentNames}
onOpenAgent={(ownerId) => navigate(`/c/new?agent_id=${encodeURIComponent(ownerId)}`)}
/>
</div>
)}
<div className="mt-1">
<ScheduleMCPRecovery
outcomes={mcpOutcomes}
fallbackAgentId={schedule.agent_id}
agentNames={agentNames}
onOpenAgent={(ownerId) => navigate(`/c/new?agent_id=${encodeURIComponent(ownerId)}`)}
/>
</div>
{editOpen && (
<ScheduleDialog

View file

@ -1,22 +1,27 @@
import { Skeleton } from '@librechat/client';
/** Mirrors the schedule card's title controls, agent, cadence, and next-run rows. */
/** Mirrors the healthy schedule row: a state marker, a title line with its trailing
* state, and one detail line beside the row's always-present actions. A healthy
* row shows no chip. */
export default function ScheduleCardSkeleton({ count = 5 }: { count?: number }) {
return (
<div className="flex flex-col gap-2" aria-hidden="true">
{Array.from({ length: count }, (_, index) => (
<div
key={index}
className="rounded-lg border border-border-light bg-transparent px-3 py-2.5"
>
<div className="flex items-center gap-2">
<Skeleton className="h-4 min-w-0 flex-1 rounded" />
<Skeleton className="h-5 w-9 shrink-0 rounded-full" />
<Skeleton className="size-7 shrink-0 rounded-md" />
<div key={index} className="rounded-lg bg-transparent px-3 py-2.5">
<div className="flex items-start gap-2.5">
<Skeleton className="mt-1.5 size-2 shrink-0 rounded-full" />
<div className="min-w-0 flex-1">
<div className="flex items-baseline gap-2">
<Skeleton className="h-5 min-w-0 flex-1 rounded" />
<Skeleton className="h-3 w-12 shrink-0 rounded" />
</div>
<div className="mt-0.5 flex items-center gap-2">
<Skeleton className="h-3.5 min-w-0 flex-1 rounded" />
<Skeleton className="h-6 w-11 shrink-0 rounded-full" />
<Skeleton className="size-7 shrink-0 rounded-md" />
</div>
</div>
</div>
<Skeleton className="mt-1 h-3 w-2/5 rounded" />
<Skeleton className="mt-2 h-4 w-3/4 rounded" />
<Skeleton className="mt-1 h-3 w-1/2 rounded" />
</div>
))}
</div>

View file

@ -5,12 +5,14 @@ import { useLocalize } from '~/hooks';
interface ScheduleEmptyStateProps {
canCreate?: boolean;
isError?: boolean;
isFiltered?: boolean;
onRetry?: () => void;
}
export default function ScheduleEmptyState({
canCreate = false,
isError = false,
isFiltered = false,
onRetry,
}: ScheduleEmptyStateProps) {
const localize = useLocalize();
@ -29,6 +31,10 @@ export default function ScheduleEmptyState({
);
}
if (isFiltered) {
return <EmptyState icon={CalendarClock} description={localize('com_ui_no_schedules_match')} />;
}
return (
<EmptyState
icon={CalendarClock}

View file

@ -1,8 +1,8 @@
import { useState, type ReactNode } from 'react';
import { useState, type ReactNode, useId } from 'react';
import { Plus } from 'lucide-react';
import { Button, TooltipAnchor } from '@librechat/client';
import { Button, FilterInput, TooltipAnchor } from '@librechat/client';
import { PermissionTypes, Permissions } from 'librechat-data-provider';
import { PanelContent, PanelFooter } from '~/components/ui';
import { PanelContent, PanelFooter, PanelHeader } from '~/components/ui';
import { useChatProjectNames } from './useScheduleProjects';
import ScheduleCardSkeleton from './ScheduleCardSkeleton';
import ScheduleEmptyState from './ScheduleEmptyState';
@ -14,18 +14,27 @@ import useRunSync from './useRunSync';
export default function SchedulePanel() {
const localize = useLocalize();
const headingId = useId();
const { data, dataUpdatedAt, isLoading, isError, refetch } = useSchedulesQuery();
/** The cards refresh themselves from this query; the sidebar cannot, so the
* chat a run just produced is read out of the same poll. */
useRunSync(data?.schedules, dataUpdatedAt);
const [createOpen, setCreateOpen] = useState(false);
const [searchQuery, setSearchQuery] = useState('');
const hasCreateAccess = useHasAccess({
permissionType: PermissionTypes.SCHEDULES,
permission: Permissions.CREATE,
});
const schedules = data?.schedules ?? [];
const allSchedules = data?.schedules ?? [];
/** Filtering is client-side because the panel already holds every schedule the
* limit allows; a query per keystroke would buy nothing. */
const query = searchQuery.trim().toLowerCase();
const schedules =
query.length > 0
? allSchedules.filter((schedule) => schedule.name.toLowerCase().includes(query))
: allSchedules;
/** ONE lookup for the whole list. Resolving a name inside each card would re-walk
* every loaded project per card, per render. Skipped entirely until some schedule
* actually has a scope, so an unscoped panel issues no project request at all. */
@ -33,13 +42,22 @@ export default function SchedulePanel() {
schedules.some((schedule) => schedule.chatProjectId != null),
);
const maxPerUser = data?.limits.maxPerUser;
const atLimit = maxPerUser !== undefined && schedules.length >= maxPerUser;
const atLimit = maxPerUser !== undefined && allSchedules.length >= maxPerUser;
let filterAnnouncement = '';
if (query.length > 0 && !isLoading && !isError) {
filterAnnouncement =
schedules.length === 1
? localize('com_ui_search_result_count', { count: schedules.length })
: localize('com_ui_search_results_count', { count: schedules.length });
}
let panelContent: ReactNode;
if (isError) {
panelContent = <ScheduleEmptyState isError onRetry={() => refetch()} />;
} else if (schedules.length === 0) {
panelContent = <ScheduleEmptyState canCreate={hasCreateAccess && !atLimit} />;
panelContent = (
<ScheduleEmptyState canCreate={hasCreateAccess && !atLimit} isFiltered={query.length > 0} />
);
} else {
panelContent = (
<div className="space-y-2" role="list" aria-label={localize('com_ui_schedules')}>
@ -64,23 +82,22 @@ export default function SchedulePanel() {
return (
<div
role="region"
aria-label={localize('com_ui_schedules')}
aria-labelledby={headingId}
className="flex h-full w-full flex-col overflow-hidden pt-2"
>
<div className="shrink-0 px-3 pb-2">
<div className="flex items-center justify-between gap-2">
<span className="text-sm font-medium text-text-primary">
{localize('com_ui_schedules')}
</span>
{hasCreateAccess && (
<PanelHeader
title={localize('com_ui_schedules')}
titleId={headingId}
action={
hasCreateAccess && (
<TooltipAnchor
description={localize('com_ui_schedule_new')}
side="bottom"
render={
<Button
variant="outline"
variant="ghost"
size="icon"
className="size-9 shrink-0 bg-transparent"
className="size-8 shrink-0"
aria-label={localize('com_ui_schedule_new')}
disabled={atLimit || isError || isLoading}
onClick={() => setCreateOpen(true)}
@ -89,9 +106,24 @@ export default function SchedulePanel() {
</Button>
}
/>
)}
</div>
</div>
)
}
search={
<>
{/* Focus stays in the field while the list changes, so the match count
is announced rather than left for the user to go and find. */}
<div aria-live="polite" aria-atomic="true" className="sr-only">
{filterAnnouncement}
</div>
<FilterInput
inputId="schedules-filter"
label={localize('com_ui_schedules_filter')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
</>
}
/>
<PanelContent isLoading={isLoading} skeleton={<ScheduleCardSkeleton />} className="px-3 pb-3">
{/* A failed query must not masquerade as an empty list or enable creation
@ -101,8 +133,8 @@ export default function SchedulePanel() {
{!isLoading && !isError && maxPerUser !== undefined && (
<PanelFooter className="justify-start">
<p className="text-xs text-text-secondary">
{localize('com_ui_schedules_used', { used: schedules.length, max: maxPerUser })}
<p className="text-text-secondary text-xs">
{localize('com_ui_schedules_used', { used: allSchedules.length, max: maxPerUser })}
</p>
</PanelFooter>
)}

View file

@ -0,0 +1,100 @@
import type { TSchedule } from 'librechat-data-provider';
import type { LocalizeFunction } from '~/common';
import { scheduleRowState } from '../state';
const localize = ((key: string) => key) as unknown as LocalizeFunction;
const schedule = (
over: Partial<TSchedule> = {},
): Pick<TSchedule, 'enabled' | 'disabledReason' | 'lastRun'> => ({
enabled: true,
disabledReason: undefined,
lastRun: undefined,
...over,
});
describe('scheduleRowState', () => {
it('says nothing while the clock is in charge', () => {
/** A running schedule's row shows when the next run lands, so a label here would
* take that slot and say less. */
expect(scheduleRowState(schedule(), localize)).toEqual({ tone: 'running', label: null });
});
it('treats a clean last run as still running', () => {
expect(
scheduleRowState(
schedule({ lastRun: { status: 'success' } } as Partial<TSchedule>),
localize,
),
).toEqual({ tone: 'running', label: null });
});
it('calls a paused schedule paused', () => {
expect(scheduleRowState(schedule({ enabled: false }), localize)).toEqual({
tone: 'paused',
label: 'com_ui_schedule_paused',
});
});
/** The clock has stopped either way, and the reason is printed under the row, so
* the word stays "paused" while the marker turns to the error shape. */
it('marks a schedule the system disabled as an error, still reading as paused', () => {
expect(scheduleRowState(schedule({ disabledReason: 'too_many_failures' }), localize)).toEqual({
tone: 'error',
label: 'com_ui_schedule_paused',
});
});
it('surfaces a failed run over the next one', () => {
for (const status of ['error', 'interrupted'] as const) {
expect(
scheduleRowState(schedule({ lastRun: { status } } as Partial<TSchedule>), localize),
).toEqual({ tone: 'error', label: 'com_ui_schedule_last_run_failed' });
}
});
it('surfaces a run waiting on its owner as a warning', () => {
expect(
scheduleRowState(
schedule({ lastRun: { status: 'requires_action' } } as Partial<TSchedule>),
localize,
),
).toEqual({ tone: 'warning', label: 'com_ui_schedule_needs_approval' });
});
/** An overlapping or in-flight run is not a problem to report: the schedule is still
* keeping its cadence, so the row keeps showing the next one. */
it('leaves an overlap-skipped or started run alone', () => {
for (const status of ['started', 'skipped_overlap'] as const) {
expect(
scheduleRowState(schedule({ lastRun: { status } } as Partial<TSchedule>), localize),
).toEqual({ tone: 'running', label: null });
}
});
/** A run skipped for balance keeps the schedule enabled only until the skip count
* disables it, so the owner is told before the clock stops. */
it('warns when a run was skipped for balance', () => {
expect(
scheduleRowState(
schedule({ lastRun: { status: 'skipped_balance' } } as Partial<TSchedule>),
localize,
),
).toEqual({ tone: 'warning', label: 'com_ui_schedule_run_skipped' });
});
/** Disabled beats everything: a schedule the system stopped is not "failing", it
* is not running at all. */
it('prefers the stopped clock to whatever the last run did', () => {
expect(
scheduleRowState(
schedule({
enabled: false,
disabledReason: 'agent_deleted',
lastRun: { status: 'error' },
} as Partial<TSchedule>),
localize,
),
).toEqual({ tone: 'error', label: 'com_ui_schedule_paused' });
});
});

View file

@ -0,0 +1,54 @@
import type { TSchedule, ScheduleRunStatus } from 'librechat-data-provider';
import type { LocalizeFunction } from '~/common';
import type { TranslationKeys } from '~/hooks';
/**
* What a schedule row is doing, as one value.
*
* The marker in the margin and the word at the end of the title line are two faces
* of this, so deriving it once is what keeps a green dot from sitting beside the
* word "failed". `running` is the only state with nothing to say: its row shows when
* the next run lands instead.
*/
export type ScheduleRowTone = 'running' | 'paused' | 'warning' | 'error';
export interface ScheduleRowState {
tone: ScheduleRowTone;
/** Null while the clock is in charge, which is when the next run speaks instead. */
label: string | null;
}
/** How a finished run colours the row that owns it. */
const RUN_TONE: Record<ScheduleRunStatus, { tone: ScheduleRowTone; label: TranslationKeys }> = {
success: { tone: 'running', label: 'com_ui_schedule_last_run' },
error: { tone: 'error', label: 'com_ui_schedule_last_run_failed' },
interrupted: { tone: 'error', label: 'com_ui_schedule_last_run_failed' },
requires_action: { tone: 'warning', label: 'com_ui_schedule_needs_approval' },
started: { tone: 'running', label: 'com_ui_schedule_run_started' },
skipped_overlap: { tone: 'running', label: 'com_ui_schedule_run_skipped' },
skipped_balance: { tone: 'warning', label: 'com_ui_schedule_run_skipped' },
};
/**
* Read in the order the owner would ask: has something stopped it, is it paused,
* did the last run end badly, and otherwise it is simply running.
*
* A schedule the system disabled reads as paused with an error marker, because the
* clock has stopped either way and the reason is printed underneath.
*/
export function scheduleRowState(
schedule: Pick<TSchedule, 'enabled' | 'disabledReason' | 'lastRun'>,
localize: LocalizeFunction,
): ScheduleRowState {
if (schedule.disabledReason != null) {
return { tone: 'error', label: localize('com_ui_schedule_paused') };
}
if (!schedule.enabled) {
return { tone: 'paused', label: localize('com_ui_schedule_paused') };
}
const lastRun = schedule.lastRun ? RUN_TONE[schedule.lastRun.status] : null;
if (lastRun != null && lastRun.tone !== 'running') {
return { tone: lastRun.tone, label: localize(lastRun.label) };
}
return { tone: 'running', label: null };
}

View file

@ -26,25 +26,29 @@ const SidePanelGroup = memo(({ panel, children }: SidePanelProps) => {
return (
<>
<ResizablePanelGroup
orientation="horizontal"
defaultLayout={defaultLayout}
onLayoutChanged={onLayoutChanged}
className="relative flex-1 bg-presentation"
>
<ResizablePanel defaultSize="50" minSize={minSizeMain} id="messages-view">
{children}
</ResizablePanel>
{/* The surface behind the panels is this group's host, not the group
primitive: the resizer owns its own chrome, and the caller owns the
backdrop the panels sit on. */}
<div className="bg-surface-primary-alt relative min-w-0 flex-1">
<ResizablePanelGroup
orientation="horizontal"
defaultLayout={defaultLayout}
onLayoutChanged={onLayoutChanged}
>
<ResizablePanel defaultSize="50" minSize={minSizeMain} id="messages-view">
{children}
</ResizablePanel>
{!isSmallScreen && (
<ArtifactsPanel
panel={panel}
minSizeMain={minSizeMain}
shouldRender={shouldRenderPanel}
onRenderChange={setShouldRenderPanel}
/>
)}
</ResizablePanelGroup>
{!isSmallScreen && (
<ArtifactsPanel
panel={panel}
minSizeMain={minSizeMain}
shouldRender={shouldRenderPanel}
onRenderChange={setShouldRenderPanel}
/>
)}
</ResizablePanelGroup>
</div>
{panel != null && isSmallScreen && <div className="fixed inset-0 z-[100]">{panel}</div>}
</>
);

View file

@ -45,7 +45,7 @@ export default function CreateSkillMenu() {
render={
<Ariakit.MenuButton
aria-label={createLabel}
className="border-border-light text-text-primary hover:bg-surface-hover focus-visible:ring-text-primary inline-flex size-9 shrink-0 items-center justify-center rounded-lg border bg-transparent transition-colors focus:outline-hidden focus-visible:ring-2"
className="text-text-primary hover:bg-surface-hover focus-visible:ring-text-primary inline-flex size-8 shrink-0 items-center justify-center rounded-lg transition-colors focus:outline-hidden focus-visible:ring-2"
>
<Plus className="size-4" aria-hidden="true" />
</Ariakit.MenuButton>

View file

@ -177,12 +177,12 @@ export default function CreateSkillForm({
aria-invalid={errors.name ? 'true' : 'false'}
aria-describedby={errors.name ? 'skill-name-error' : undefined}
/>
<Label
<label
htmlFor="skill-name"
className="bg-presentation text-text-secondary peer-focus:text-text-primary pointer-events-none absolute -top-1 left-3 origin-[0] translate-y-3 scale-100 rounded px-1 text-base transition-transform duration-200 peer-placeholder-shown:translate-y-3 peer-placeholder-shown:scale-100 peer-focus:-translate-y-2 peer-focus:scale-75 peer-[:not(:placeholder-shown)]:-translate-y-2 peer-[:not(:placeholder-shown)]:scale-75"
className="bg-surface-primary-alt text-text-secondary peer-focus:text-text-primary pointer-events-none absolute -top-1 left-3 origin-[0] translate-y-3 scale-100 rounded px-1 text-base transition-transform duration-200 peer-placeholder-shown:translate-y-3 peer-placeholder-shown:scale-100 peer-focus:-translate-y-2 peer-focus:scale-75 peer-[:not(:placeholder-shown)]:-translate-y-2 peer-[:not(:placeholder-shown)]:scale-75"
>
{localize('com_ui_name')}*
</Label>
</label>
<div
id="skill-name-error"
className={cn(

View file

@ -206,7 +206,7 @@ export default function SkillForm({ skillId }: SkillFormProps) {
/>
<label
htmlFor="skill-name"
className="bg-presentation text-text-secondary peer-focus:text-text-primary pointer-events-none absolute -top-1 left-3 origin-[0] translate-y-3 scale-100 rounded px-1 text-base transition-transform duration-200 peer-placeholder-shown:translate-y-3 peer-placeholder-shown:scale-100 peer-focus:-translate-y-2 peer-focus:scale-75 peer-[:not(:placeholder-shown)]:-translate-y-2 peer-[:not(:placeholder-shown)]:scale-75"
className="bg-surface-primary-alt text-text-secondary peer-focus:text-text-primary pointer-events-none absolute -top-1 left-3 origin-[0] translate-y-3 scale-100 rounded px-1 text-base transition-transform duration-200 peer-placeholder-shown:translate-y-3 peer-placeholder-shown:scale-100 peer-focus:-translate-y-2 peer-focus:scale-75 peer-[:not(:placeholder-shown)]:-translate-y-2 peer-[:not(:placeholder-shown)]:scale-75"
>
{localize('com_ui_name')}*
</label>

View file

@ -38,7 +38,7 @@ export default function SkillsView() {
const rolesLoaded = user?.role != null && roles?.[user.role] != null;
if (!rolesLoaded) {
return (
<div className="flex h-full w-full items-center justify-center bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full items-center justify-center">
<Spinner className="text-text-secondary" aria-label={localize('com_ui_loading')} />
</div>
);
@ -59,7 +59,7 @@ export default function SkillsView() {
// No skill selected — empty state
if (!skillId) {
return (
<div className="flex h-full w-full flex-col bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full flex-col">
<MobileSidebarToggle />
<div className="flex flex-1 flex-col items-center justify-center">
<SkillState
@ -76,7 +76,7 @@ export default function SkillsView() {
function CreateView() {
return (
<div className="flex h-full w-full flex-col overflow-y-auto bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full flex-col overflow-y-auto">
<MobileSidebarToggle />
<CreateSkillForm />
</div>
@ -94,7 +94,7 @@ function DetailView({ skillId }: { skillId: string }) {
// Show file content when a file is selected from the sidebar tree
if (activeFile) {
return (
<div className="flex h-full w-full flex-col bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full flex-col">
<MobileSidebarToggle />
<SkillFileViewer
key={`${skillId}:${activeFile}`}
@ -108,7 +108,7 @@ function DetailView({ skillId }: { skillId: string }) {
if (skillQuery.isLoading) {
return (
<div className="flex h-full w-full items-center justify-center bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full items-center justify-center">
<Spinner className="text-text-secondary" aria-label={localize('com_ui_loading')} />
</div>
);
@ -116,7 +116,7 @@ function DetailView({ skillId }: { skillId: string }) {
if (skillQuery.isError || !skillQuery.data) {
return (
<div className="flex h-full w-full flex-col bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full flex-col">
<MobileSidebarToggle />
<SkillState
variant="error"
@ -128,7 +128,7 @@ function DetailView({ skillId }: { skillId: string }) {
}
return (
<div className="flex h-full w-full flex-col bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full flex-col">
<MobileSidebarToggle />
<SkillDetail
skill={skillQuery.data}
@ -142,7 +142,7 @@ function DetailView({ skillId }: { skillId: string }) {
/** Edit form — reached via the Edit button or `/skills/:id/edit` URL. */
function EditView({ skillId }: { skillId: string }) {
return (
<div className="flex h-full w-full flex-col overflow-y-auto bg-presentation">
<div className="bg-surface-primary-alt flex h-full w-full flex-col overflow-y-auto">
<MobileSidebarToggle />
<SkillForm skillId={skillId} />
</div>

View file

@ -156,10 +156,10 @@ function FileTreeNode({
}
}}
className={cn(
'flex w-full items-center gap-1.5 rounded-lg text-sm transition-colors select-none',
'flex w-full items-center gap-1.5 rounded-lg text-sm select-none',
isFileActive
? 'bg-surface-active text-text-primary font-medium'
: 'text-text-secondary hover:bg-surface-hover hover:text-text-primary',
: 'text-text-secondary hover:bg-surface-active-alt hover:text-text-primary',
)}
aria-expanded={isFolder ? isOpen : undefined}
>
@ -299,47 +299,46 @@ function SkillListItem({
return (
<div className="flex flex-col gap-px">
{/* Skill row */}
{/* The row and its expander are siblings, not one inside the other: a control
nested in another control is unreachable for a keyboard and ambiguous for a
screen reader, which announces one name for two different actions. */}
<div
role="button"
tabIndex={0}
onClick={handleSkillClick}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleSkillClick();
}
}}
className={cn(
'text-text-primary flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-1.5 text-left text-sm transition-colors select-none',
'text-text-primary flex w-full items-center gap-1 rounded-lg pr-1 text-sm select-none',
isActive && !activeFile && 'bg-surface-active',
!isActive && 'hover:bg-surface-hover',
!isActive && 'hover:bg-surface-active-alt',
)}
aria-current={isActive ? 'true' : undefined}
aria-expanded={hasFiles ? expanded : undefined}
>
<span className="flex size-6 shrink-0 items-center justify-center">
<span className="border-border-light bg-surface-primary flex size-6 items-center justify-center rounded-md border shadow-xs">
<ScrollText className="text-text-secondary size-3.5" aria-hidden="true" />
<button
type="button"
onClick={handleSkillClick}
className="focus-visible:ring-text-primary flex min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-lg py-1.5 pl-3 text-left outline-hidden focus-visible:ring-2 focus-visible:ring-inset"
aria-current={isActive ? 'true' : undefined}
>
<span className="flex size-6 shrink-0 items-center justify-center">
<span className="bg-surface-tertiary flex size-6 items-center justify-center rounded-md">
<ScrollText className="text-text-secondary size-3.5" aria-hidden="true" />
</span>
</span>
</span>
<span className="flex min-w-0 flex-1 items-center gap-1.5">
<span className="truncate">{skill.name}</span>
{skill.alwaysApply === true && (
<Pin
className="text-status-info size-3 shrink-0"
aria-label={localize('com_ui_skills_always_apply_pin_title')}
/>
)}
</span>
<span className="flex min-w-0 flex-1 items-center gap-1.5">
<span className="truncate">{skill.name}</span>
{skill.alwaysApply === true && (
<Pin
className="text-status-info size-3 shrink-0"
aria-label={localize('com_ui_skills_always_apply_pin_title')}
/>
)}
</span>
</button>
{hasFiles && (
<button
type="button"
onClick={handleChevronClick}
className="text-text-secondary hover:text-text-primary -mr-1 inline-flex size-6 shrink-0 items-center justify-center rounded-md"
aria-label="Toggle files"
tabIndex={-1}
className="text-text-secondary hover:text-text-primary focus-visible:ring-text-primary inline-flex size-6 shrink-0 items-center justify-center rounded-md outline-hidden focus-visible:ring-2 focus-visible:ring-inset"
aria-label={localize('com_ui_skills_toggle_files', { 0: skill.name })}
aria-expanded={expanded}
>
<ChevronDown
className={cn(

View file

@ -3,8 +3,12 @@ import { FilterInput } from '@librechat/client';
import { PermissionTypes, Permissions } from 'librechat-data-provider';
import { CreateSkillMenu } from '~/components/Skills/buttons';
import { useHasAccess, useLocalize } from '~/hooks';
import { cn } from '~/utils';
import { PanelHeader } from '~/components/ui';
/**
* The skills panel head. Built on the shared `PanelHeader` so the title, the create
* action and the filter sit where every other panel puts them.
*/
export default function FilterSkills({
searchTerm,
onSearchChange,
@ -21,17 +25,20 @@ export default function FilterSkills({
});
return (
<div className={cn('flex flex-col gap-2', className)}>
<div role="search" className="flex items-center gap-2">
<FilterInput
inputId="skills-filter"
label={localize('com_ui_filter_skills_name')}
value={searchTerm}
onChange={onSearchChange}
containerClassName="flex-1"
/>
{hasCreateAccess && <CreateSkillMenu />}
</div>
</div>
<PanelHeader
className={className}
title={localize('com_ui_skills')}
action={hasCreateAccess && <CreateSkillMenu />}
search={
<div role="search">
<FilterInput
inputId="skills-filter"
label={localize('com_ui_filter_skills_name')}
value={searchTerm}
onChange={onSearchChange}
/>
</div>
}
/>
);
}

View file

@ -49,15 +49,11 @@ export default function SkillsSidePanel({ className }: SkillsSidePanelProps) {
return (
<div
className={cn(
'flex h-full w-full flex-col overflow-hidden border-r border-border-light pt-2',
'border-border-light flex h-full w-full flex-col overflow-hidden border-r pt-2',
className,
)}
>
<FilterSkills
className="shrink-0 px-3 pb-2"
searchTerm={searchTerm}
onSearchChange={(e) => setSearchTerm(e.target.value)}
/>
<FilterSkills searchTerm={searchTerm} onSearchChange={(e) => setSearchTerm(e.target.value)} />
{/* Only the list scrolls */}
<PanelContent

View file

@ -40,11 +40,10 @@ function Sidebar({
<nav
className={cn(
/** The resize separator to the right is transparent until hovered, so
* the panel has no resting right edge. That is deliberate in the
* standard themes, where `surface-primary-alt` carries the boundary
* on its own; in high contrast both sides are the same pure white or
* pure black, so the edge has to be drawn. */
'min-h-0 flex-1 overflow-hidden bg-surface-primary-alt high-contrast:border-r high-contrast:border-border-light',
* the edge is drawn here. The panel and the content beside it now sit
* on the same surface, so the fill no longer separates them on its
* own and the boundary has to be a line in every theme. */
'border-border-light bg-surface-primary-alt min-h-0 flex-1 overflow-hidden border-r',
expanded ? 'opacity-100' : 'pointer-events-none opacity-0',
)}
style={{ transition: expanded ? 'opacity 200ms ease 80ms' : 'opacity 150ms ease' }}
@ -62,7 +61,7 @@ function Sidebar({
aria-valuemax={Math.round(maxWidth)}
tabIndex={expanded ? 0 : -1}
className={cn(
'absolute right-0 top-0 z-10 h-full w-1 cursor-col-resize transition-colors hover:bg-border-medium active:bg-border-heavy',
'hover:bg-border-medium active:bg-border-heavy absolute top-0 right-0 z-10 h-full w-1 cursor-col-resize transition-colors',
expanded ? 'opacity-100' : 'pointer-events-none opacity-0',
)}
style={{ transition: expanded ? 'opacity 200ms ease 80ms' : 'opacity 150ms ease' }}

View file

@ -1,6 +1,6 @@
import React from 'react';
import type { ReactNode } from 'react';
import { useLocalize } from '~/hooks';
import { useLocalize, useScrollFade } from '~/hooks';
import { cn } from '~/utils';
/**
@ -25,6 +25,20 @@ const PanelContent = React.forwardRef<
}
>(({ isLoading, isEmpty, skeleton, empty, children, className }, ref) => {
const localize = useLocalize();
const { attach, hasMore } = useScrollFade<HTMLDivElement>();
/** The caller's ref and the fade's both need the same node. */
const setNode = React.useCallback(
(node: HTMLDivElement | null) => {
attach(node);
if (typeof ref === 'function') {
ref(node);
} else if (ref) {
ref.current = node;
}
},
[attach, ref],
);
const renderContent = () => {
if (isLoading) {
@ -45,12 +59,23 @@ const PanelContent = React.forwardRef<
};
return (
<div
ref={ref}
aria-busy={isLoading}
className={cn('min-h-0 flex-1 overflow-y-auto', className)}
>
{renderContent()}
<div className="relative flex min-h-0 flex-1 flex-col">
<div
ref={setNode}
aria-busy={isLoading}
className={cn('min-h-0 flex-1 overflow-y-auto', className)}
>
{renderContent()}
</div>
{/* The last row fades rather than being cut off, so a list that continues
below the fold says so without a scrollbar having to appear. */}
<div
aria-hidden="true"
className={cn(
'from-surface-primary-alt pointer-events-none absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t to-transparent transition-opacity duration-200 motion-reduce:transition-none',
hasMore ? 'opacity-100' : 'opacity-0',
)}
/>
</div>
);
});

View file

@ -0,0 +1,48 @@
import { useId } from 'react';
import type { ReactNode } from 'react';
import { cn } from '~/utils';
/**
* The head of a side panel, and the reason every panel reads the same way: a title,
* the one thing this panel creates, then the field that narrows what is below.
*
* The title and the create action share a row so the search keeps the full width, and
* the whole header stays out of the scroll. A panel with nothing to create passes no
* `action`; a list short enough to read at a glance passes no `search`.
*
* `titleId` is handed back so the panel's landmark can point `aria-labelledby` at this
* heading instead of repeating the same words in an `aria-label`, which a screen reader
* would otherwise announce twice on entering the region.
*/
export default function PanelHeader({
title,
titleId,
action,
search,
children,
className,
}: {
title: string;
/** Pass the id the surrounding region references, so the two cannot drift. */
titleId?: string;
action?: ReactNode;
search?: ReactNode;
/** Controls that belong to this panel alone, below the search. */
children?: ReactNode;
className?: string;
}) {
const fallbackId = useId();
return (
<div className={cn('shrink-0 space-y-2 px-3 pb-2', className)}>
<div className="flex h-9 items-center justify-between gap-2">
<h2 id={titleId ?? fallbackId} className="text-text-primary truncate text-sm font-medium">
{title}
</h2>
{action}
</div>
{search}
{children}
</div>
);
}

View file

@ -1,6 +1,6 @@
import '@testing-library/jest-dom/extend-expect';
import { createRef } from 'react';
import { render, screen } from '@testing-library/react';
import { act, fireEvent, render, screen } from '@testing-library/react';
import PanelContent from '../PanelContent';
describe('PanelContent', () => {
@ -24,10 +24,11 @@ describe('PanelContent', () => {
test('marks the scroll container busy only while loading', () => {
const { container, rerender } = render(<PanelContent isLoading={true} skeleton={skeleton} />);
expect(container.firstChild).toHaveAttribute('aria-busy', 'true');
const scroller = () => container.querySelector('.overflow-y-auto');
expect(scroller()).toHaveAttribute('aria-busy', 'true');
rerender(<PanelContent isLoading={false} skeleton={skeleton} />);
expect(container.firstChild).toHaveAttribute('aria-busy', 'false');
expect(scroller()).toHaveAttribute('aria-busy', 'false');
});
test('renders children once loaded', () => {
@ -74,7 +75,88 @@ describe('PanelContent', () => {
<PanelContent ref={ref} isLoading={false} skeleton={skeleton} className="px-4" />,
);
expect(ref.current).toBe(container.firstChild);
expect(ref.current).toBe(container.querySelector('.overflow-y-auto'));
expect(ref.current).toHaveClass('overflow-y-auto', 'px-4');
});
test('hints at content below the fold only while there is some', () => {
const { container } = render(
<PanelContent isLoading={false} skeleton={skeleton}>
<span data-testid="rows" />
</PanelContent>,
);
/** jsdom reports every element as zero-height, so nothing overflows and the
* fade stays hidden. What this pins is that it renders, is decorative, and
* never intercepts a click aimed at the last row. */
const fade = container.querySelector('.pointer-events-none.absolute');
expect(fade).toBeInTheDocument();
expect(fade).toHaveAttribute('aria-hidden', 'true');
expect(fade).toHaveClass('opacity-0');
});
test('tracks overflowing content after loading and after more rows arrive', async () => {
const originalObserver = global.ResizeObserver;
const observed = new Set<Element>();
let notifyResize = () => {};
global.ResizeObserver = jest.fn().mockImplementation((callback) => {
notifyResize = () => callback([], {});
return {
observe: (node: Element) => observed.add(node),
unobserve: (node: Element) => observed.delete(node),
disconnect: () => observed.clear(),
};
});
try {
const ref = createRef<HTMLDivElement>();
const { container, rerender } = render(
<PanelContent ref={ref} isLoading={true} skeleton={skeleton} />,
);
const scroller = ref.current!;
Object.defineProperties(scroller, {
clientHeight: { value: 100, configurable: true },
scrollHeight: { value: 200, configurable: true },
});
const fade = container.querySelector('.pointer-events-none.absolute');
const resizeContent = () => {
// Only live content boxes resize here; the scroller stays 100px tall.
if ([...observed].some((node) => node !== scroller && scroller.contains(node))) {
act(notifyResize);
}
};
await act(async () => {
rerender(
<PanelContent ref={ref} isLoading={false} skeleton={skeleton}>
<div>
<div data-testid="row-1" />
</div>
</PanelContent>,
);
});
resizeContent();
expect(fade).toHaveClass('opacity-100');
scroller.scrollTop = 100;
fireEvent.scroll(scroller);
expect(fade).toHaveClass('opacity-0');
Object.defineProperty(scroller, 'scrollHeight', { value: 300, configurable: true });
await act(async () => {
rerender(
<PanelContent ref={ref} isLoading={false} skeleton={skeleton}>
<div>
<div data-testid="row-1" />
<div data-testid="row-2" />
</div>
</PanelContent>,
);
});
resizeContent();
expect(fade).toHaveClass('opacity-100');
} finally {
global.ResizeObserver = originalObserver;
}
});
});

View file

@ -5,6 +5,7 @@ export { getPlainDescription, isHtmlDescription } from './Description';
export { default as CustomIcon } from './CustomIcon';
export { default as PanelFooter } from './PanelFooter';
export { default as PanelContent } from './PanelContent';
export { default as PanelHeader } from './PanelHeader';
export { default as TermsAndConditionsModal } from './TermsAndConditionsModal';
export { default as AdminSettingsDialog } from './AdminSettingsDialog';
export { default as LocalizedDateRangePicker } from './LocalizedDateRangePicker';

View file

@ -53,3 +53,4 @@ export {
export type { CatalogId } from './useCatalogWarmup';
export { default as useClockFormat } from './useClockFormat';
export { default as useWeekStart } from './useWeekStart';
export { default as useScrollFade } from './useScrollFade';

View file

@ -0,0 +1,82 @@
import { useCallback, useEffect, useRef, useState } from 'react';
/** Below this the remaining scroll is a rounding error, not content worth hinting at. */
const THRESHOLD = 4;
/**
* Whether a scroll container still has content below the fold, for the fade that
* hints at it. Tracks three things because a list changes size in three ways: the
* user scrolls, the panel is resized, and rows arrive from a query.
*
* Returns a callback ref so a caller can attach it to whichever element actually
* scrolls, and so the observers are torn down with that element rather than on an
* effect's schedule.
*/
export default function useScrollFade<T extends HTMLElement>(): {
attach: (node: T | null) => void;
hasMore: boolean;
} {
const [hasMore, setHasMore] = useState(false);
const nodeRef = useRef<T | null>(null);
const observerRef = useRef<ResizeObserver | null>(null);
const contentObserverRef = useRef<MutationObserver | null>(null);
const measure = useCallback(() => {
const node = nodeRef.current;
if (!node) {
return;
}
setHasMore(node.scrollHeight - node.scrollTop - node.clientHeight > THRESHOLD);
}, []);
const attach = useCallback(
(node: T | null) => {
observerRef.current?.disconnect();
observerRef.current = null;
contentObserverRef.current?.disconnect();
contentObserverRef.current = null;
nodeRef.current?.removeEventListener('scroll', measure);
nodeRef.current = node;
if (!node) {
setHasMore(false);
return;
}
node.addEventListener('scroll', measure, { passive: true });
if (typeof ResizeObserver !== 'undefined') {
const observer = new ResizeObserver(measure);
/** The container catches a resize of the panel; its content box catches rows
* arriving, which changes the scroll height without changing the container. */
const observeContent = () => {
observer.disconnect();
observer.observe(node);
for (const content of node.children) {
observer.observe(content);
}
measure();
};
observeContent();
// Loading announcements, skeletons, lists, and pagination indicators can
// replace one another without changing the scroll container itself.
const contentObserver = new MutationObserver(observeContent);
contentObserver.observe(node, { childList: true });
contentObserverRef.current = contentObserver;
observerRef.current = observer;
}
measure();
},
[measure],
);
useEffect(
() => () => {
observerRef.current?.disconnect();
contentObserverRef.current?.disconnect();
nodeRef.current?.removeEventListener('scroll', measure);
},
[measure],
);
return { attach, hasMore };
}

View file

@ -1,57 +1,5 @@
{
"com_ui_background_tasks": "Background tasks",
"com_ui_background_tasks_cancel_disabled": "Stopping background tools is not enabled on this server",
"com_ui_background_tasks_checked": "Checked background tasks",
"com_ui_background_tasks_checking": "Checking background tasks",
"com_ui_background_tasks_completed": "Completed",
"com_ui_background_tasks_control_not_found": "Control not found",
"com_ui_background_tasks_control_queued": "Control queued",
"com_ui_background_tasks_empty": "No background tasks yet",
"com_ui_background_tasks_failed_label": "Background tasks, {{0}} results not delivered",
"com_ui_background_tasks_finished": "Finished",
"com_ui_background_tasks_incomplete": "Some background results may not be shown. Check again later.",
"com_ui_background_tasks_label": "Background tasks, {{0}} running",
"com_ui_background_tasks_n_checks": "{{0}} checks",
"com_ui_background_tasks_no_output": "No output returned",
"com_ui_background_tasks_not_running": "No longer running",
"com_ui_background_tasks_pending_label": "Background tasks, {{0}} results pending",
"com_ui_background_tasks_raw_details": "Raw task details",
"com_ui_background_tasks_result_available": "Result available on request",
"com_ui_background_tasks_result_claimed": "Result claimed",
"com_ui_background_tasks_result_pending": "Result pending",
"com_ui_background_tasks_result_undelivered": "Result not delivered",
"com_ui_background_tasks_running": "Running",
"com_ui_background_tasks_stop": "Stop task",
"com_ui_background_tasks_stop_all": "Stop all running tasks",
"com_ui_background_tasks_stop_available": "Stop available running tasks",
"com_ui_background_tasks_stop_failed": "Could not stop some tasks. Try again.",
"com_ui_background_tasks_load_failed": "Could not load all tasks. The list may be incomplete. Try again.",
"com_ui_background_tasks_stopping": "Stopping…",
"com_ui_background_tasks_subagent": "Subagent",
"com_ui_background_tasks_artifact_not_inline": "This task produced an artifact that is not shown here.",
"com_ui_background_tasks_cancellation_requested": "Cancellation requested. The task may still be running; check again for its final status.",
"com_ui_background_tasks_failed_delivery_guidance": "Automatic delivery failed. Poll each affected task to collect its result; it will not arrive as a new turn.",
"com_ui_background_tasks_failed_delivery_note": "Automatic delivery failed. Poll this task to collect its result; it will not arrive as a new turn.",
"com_ui_background_tasks_files_attached": "Generated files are attached to the original tool call.",
"com_ui_background_tasks_files_attaching": "Output and generated files are being attached to the original tool call.",
"com_ui_background_tasks_more_in_raw_details": "More information in raw task details.",
"com_ui_background_tasks_notice_delivery_scheduled": "Result assigned to another poll or automatic delivery. It may still arrive as a new turn.",
"com_ui_background_tasks_notice_discard_unavailable": "Could not discard the pending result. It may still arrive as a new turn; try again shortly.",
"com_ui_background_tasks_notice_error": "The background-task check failed. See raw task details.",
"com_ui_background_tasks_notice_invalid": "Invalid background-task request. Check the task ID or control arguments.",
"com_ui_background_tasks_notice_not_found": "No background task with that ID was found in this conversation.",
"com_ui_background_tasks_notice_outcome_unknown": "The task's outcome is unknown. Inspect the target system before repeating an action.",
"com_ui_background_tasks_notice_rejected": "The request was rejected. Check raw details before trying again.",
"com_ui_background_tasks_notice_result_persisting": "The result is being saved or recovered. Check again shortly; do not rerun the task.",
"com_ui_background_tasks_notice_result_unavailable": "The result is temporarily unavailable. Check again later; do not automatically repeat a mutating action.",
"com_ui_background_tasks_notice_subagent_only": "This control action is available only for subagent tasks.",
"com_ui_background_tasks_notice_unavailable": "Task or control temporarily unavailable. Check again; do not assume the task stopped or its result will not arrive.",
"com_ui_background_tasks_pending_delivery_guidance": "Finished results are pending delivery. Poll to collect now or wait for the agent to resume; do not treat them as delivered yet.",
"com_ui_background_tasks_pending_delivery_note": "Result pending delivery. It may still arrive as a new turn; poll to collect it sooner.",
"com_ui_background_tasks_result_discarded": "Finished result discarded. It will not arrive as a new turn.",
"com_ui_background_tasks_running_elsewhere": "Still running outside this turn. Its result may arrive as a new turn.",
"com_ui_background_tasks_subagent_pending_guidance": "Finished subagent results are pending delivery. Poll to collect now or wait for the agent to resume.",
"com_ui_background_tasks_subagent_wakeup_guidance": "This subagent will automatically resume the agent when it finishes; there is no need to poll it repeatedly.",
"com_ui_no_schedules_match": "No schedules match your search",
"com_ui_repository_instructions": "Repository instructions",
"com_ui_repository_instructions_prefer": "Prefer repository conventions",
"com_ui_repository_instructions_defer": "Prefer agent conventions",
@ -1363,7 +1311,6 @@
"com_ui_conversation_load_error": "Could not load this chat. Please try again.",
"com_ui_conversation_not_found": "Conversation not found",
"com_ui_conversation_summarized": "Conversation summarized",
"com_ui_conversations": "conversations",
"com_ui_convert_to_queue": "Queue for after the response",
"com_ui_convo_archived": "Conversation archived",
"com_ui_convo_delete_error": "Failed to delete conversation",
@ -2065,6 +2012,8 @@
"com_ui_permissions_failed_load": "Failed to load permissions. Please try again.",
"com_ui_permissions_failed_update": "Failed to update permissions. Please try again.",
"com_ui_permissions_updated_success": "Permissions updated successfully",
"com_ui_schedules_filter": "Filter schedules...",
"com_ui_skills_toggle_files": "Toggle files for {{0}}",
"com_ui_view_agent_insights": "View insights",
"com_ui_view_agent_insights_description": "Allows this principal to view usage and conversation content for this agent.",
"com_ui_view_agent_insights_admin_description": "Administrators always have access to insights.",
@ -2221,6 +2170,7 @@
"com_ui_result": "Result",
"com_ui_result_found": "{{count}} result found",
"com_ui_results_found": "{{count}} results found",
"com_ui_results_found_more": "{{count}}+ results found",
"com_ui_retrieved_files": "Searched your files",
"com_ui_retry": "Retry",
"com_ui_revoke": "Revoke",
@ -2296,6 +2246,7 @@
"com_ui_schedule_next_run": "Next run {{time}}",
"com_ui_schedule_next_runs": "Next",
"com_ui_schedule_options": "Schedule options",
"com_ui_schedule_paused": "Paused",
"com_ui_schedule_pm": "PM",
"com_ui_schedule_project_none": "No project",
"com_ui_schedule_prompt_placeholder": "Summarize the top AI news from the last 24 hours and highlight anything worth acting on.",
@ -2325,6 +2276,7 @@
"com_ui_scroll_to_bottom": "Scroll to bottom",
"com_ui_scroll_to_top": "Scroll to top",
"com_ui_search": "Search",
"com_ui_search_a_message": "Type to search your messages",
"com_ui_search_above_to_add": "Search above to add users or groups",
"com_ui_search_above_to_add_all": "Search above to add users, groups, or roles",
"com_ui_search_above_to_add_people": "Search above to add people",

View file

@ -2,10 +2,12 @@ import { memo, useCallback, useEffect, useMemo, useRef, type FC } from 'react';
import { useAtomValue } from 'jotai';
import throttle from 'lodash/throttle';
import { useRecoilValue } from 'recoil';
import { Spinner, useToastContext } from '@librechat/client';
import { Search as SearchIcon, SearchX } from 'lucide-react';
import { EmptyState, Spinner, useToastContext } from '@librechat/client';
import { List, CellMeasurer, CellMeasurerCache } from 'react-virtualized';
import type { Index, ListRowProps } from 'react-virtualized';
import type { TMessage } from 'librechat-data-provider';
import { getMessageRowWidthClass } from '~/components/Chat/Messages/ui/MessageRow';
import { useElementSize, useLocalize, useAuthContext } from '~/hooks';
import SearchMessage from '~/components/Chat/Messages/SearchMessage';
import { useMessagesInfiniteQuery } from '~/data-provider';
@ -273,11 +275,15 @@ export default function Search() {
if (resultsCount === 0) {
return localize('com_ui_nothing_found');
}
/** More pages remain, so the loaded count is a floor rather than the total. */
if (hasNextPage) {
return localize('com_ui_results_found_more', { count: resultsCount });
}
if (resultsCount === 1) {
return localize('com_ui_result_found', { count: resultsCount });
}
return localize('com_ui_results_found', { count: resultsCount });
}, [resultsCount, localize]);
}, [resultsCount, hasNextPage, localize]);
const loadingSpinner = (
<div className="absolute inset-0 flex items-center justify-center">
@ -288,7 +294,21 @@ export default function Search() {
if (!searchQuery) {
/** A fresh query is typed but its debounce hasn't fired yet: show loading
* rather than a blank route during that first delay. */
return search.query && search.isTyping ? loadingSpinner : null;
if (search.query && search.isTyping) {
return loadingSpinner;
}
/** Standing on the results route with nothing to show results for: cleared the
* field, or arrived here directly. A blank page reads as a failure, so the
* route says what it is waiting for instead. */
return (
<div className="absolute inset-0 flex items-center justify-center">
<EmptyState
icon={SearchIcon}
title={localize('com_nav_search_placeholder')}
description={localize('com_ui_search_a_message')}
/>
</div>
);
}
const hasResults = resultsCount > 0;
@ -308,18 +328,21 @@ export default function Search() {
{resultsAnnouncement}
</div>
<div className="absolute inset-0 flex items-center justify-center">
<div className="bg-surface-secondary text-text-secondary rounded-lg p-6 text-lg">
{localize('com_ui_nothing_found')}
</div>
<EmptyState icon={SearchX} description={localize('com_ui_nothing_found')} />
</div>
</>
);
}
return (
<div className="bg-presentation relative flex h-full w-full flex-col pt-4">
<div className="sr-only" role="alert" aria-atomic="true">
{resultsAnnouncement}
<div className="bg-surface-primary-alt relative flex h-full w-full flex-col pt-4">
{/* The count is the page's one heading, and the live region at the same time:
announced to a screen reader and read by everyone else, rather than said
twice out of two nodes. Aligned to the column the results sit in. */}
<div className={cn('mx-auto px-4 pb-2', getMessageRowWidthClass())}>
<p className="text-text-secondary text-sm" role="status" aria-atomic="true">
{resultsAnnouncement}
</p>
</div>
<div ref={listContainerRef} className="min-h-0 flex-1">
<List
@ -345,7 +368,7 @@ export default function Search() {
<Spinner className="text-text-primary" />
</div>
)}
<div className="from-presentation pointer-events-none absolute right-0 bottom-0 left-0 h-[5%] bg-gradient-to-t to-transparent" />
<div className="from-surface-primary-alt pointer-events-none absolute right-0 bottom-0 left-0 h-[5%] bg-gradient-to-t to-transparent" />
</div>
);
}

View file

@ -54,6 +54,14 @@ jest.mock('~/data-provider', () => ({ useMessagesInfiniteQuery: jest.fn() }));
jest.mock('~/Providers', () => ({ useFileMapContext: () => ({}) }));
jest.mock('@librechat/client', () => ({
Spinner: () => <div data-testid="spinner" />,
/* The shared panel empty state, with the glyph dropped: what this route's tests
read is the line it carries. */
EmptyState: ({ title, description }: { title?: string; description?: string }) => (
<div>
{title != null && <p>{title}</p>}
{description != null && <p>{description}</p>}
</div>
),
useToastContext: () => ({ showToast: jest.fn() }),
}));
jest.mock('~/hooks', () => ({
@ -108,8 +116,8 @@ describe('Search route', () => {
'focus-visible:ring-2',
'focus-visible:ring-ring-primary',
);
expect(container.firstElementChild).toHaveClass('bg-presentation');
expect(container.querySelector('.bg-gradient-to-t')).toHaveClass('from-presentation');
expect(container.firstElementChild).toHaveClass('bg-surface-primary-alt');
expect(container.querySelector('.bg-gradient-to-t')).toHaveClass('from-surface-primary-alt');
});
it('keeps results mounted while typing (does NOT flash the full spinner)', () => {
@ -150,11 +158,14 @@ describe('Search route', () => {
expect(screen.queryByText('com_ui_nothing_found')).not.toBeInTheDocument();
});
it('renders nothing when there is no query and the user is idle', () => {
mockUseRecoilValue.mockReturnValue(searchState({ debouncedQuery: '' }));
/** Standing on the results route with nothing searched for: a blank page reads as
* a failure, so the route says what it is waiting for. */
it('invites a query when there is none and the user is idle', () => {
mockUseRecoilValue.mockReturnValue(searchState({ query: '', debouncedQuery: '' }));
mockUseQuery.mockReturnValue(queryResult({ data: undefined }));
const { container } = render(<Search />);
expect(container).toBeEmptyDOMElement();
render(<Search />);
expect(screen.getByText('com_ui_search_a_message')).toBeInTheDocument();
expect(screen.queryByTestId('spinner')).not.toBeInTheDocument();
});
it('shows the spinner during the initial debounce (query typed, not yet debounced)', () => {
@ -166,6 +177,25 @@ describe('Search route', () => {
expect(screen.getByTestId('spinner')).toBeInTheDocument();
});
it('states the result count above the list, once', () => {
mockUseRecoilValue.mockReturnValue(searchState());
mockUseQuery.mockReturnValue(queryResult());
render(<Search />);
expect(screen.getByRole('status')).toHaveTextContent('com_ui_result_found');
/** The visible line IS the live region: a second, off-screen copy would have a
* screen reader announce the count twice. */
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
});
it('marks the count as partial while more pages remain', () => {
mockUseRecoilValue.mockReturnValue(searchState());
mockUseQuery.mockReturnValue(queryResult({ hasNextPage: true }));
render(<Search />);
expect(screen.getByRole('status')).toHaveTextContent('com_ui_results_found_more');
});
it('announces empty results through a live region', () => {
mockUseRecoilValue.mockReturnValue(searchState());
mockUseQuery.mockReturnValue(

View file

@ -378,9 +378,11 @@ html {
--surface-code: var(--presentation);
--surface-code-body: var(--surface-primary-alt);
--surface-qr: var(--white);
--border-light: var(--gray-700);
--border-medium-alt: var(--gray-600);
--border-medium: var(--gray-600);
/* One step off the page instead of two: in dark the edge only has to separate
a surface from the one behind it, and a brighter line reads as a seam. */
--border-light: var(--gray-800);
--border-medium-alt: var(--gray-650);
--border-medium: var(--gray-650);
--border-heavy: var(--gray-500);
--border-xheavy: var(--gray-400);
--border-destructive: var(--red-500);
@ -1744,8 +1746,7 @@ html {
}
.dark body,
.dark html {
--tw-bg-opacity: 1;
background-color: rgba(33, 33, 33, var(--tw-bg-opacity));
background-color: rgb(var(--surface-primary-alt));
}
#__next,
#root {

View file

@ -8,6 +8,7 @@ export * from './policies';
export * from './json';
export * from './icons';
export * from './svg';
export * from './row';
export * from './email';
export * from './share';
export * from './files';

52
client/src/utils/row.ts Normal file
View file

@ -0,0 +1,52 @@
import { buttonVariants } from '@librechat/client';
import cn from './cn';
/**
* The trailing control on a list row: the conversation overflow menu and every
* action that sits where it sits, in the bookmark, memory, MCP, prompt and
* project lists.
*
* One recipe because a row action is one idea. Each list had grown its own
* version, and they disagreed about size, hover fill and when the control was
* even visible, so the same gesture looked different depending on which list
* the pointer was over.
*
* `open` keeps the control lit and visible while the menu or dialog it owns is
* open: the pointer has left the row for the popup by then, and a trigger that
* vanishes underneath an open menu reads as a different control on the way
* back.
*
* `visible` is for a row that already stands out on its own, such as the active
* conversation, where the action should not wait to be found.
*/
export const rowActionClasses = ({
open = false,
visible = false,
}: { open?: boolean; visible?: boolean } = {}): string =>
cn(
buttonVariants({ variant: 'row-action-reveal', size: 'icon-xs' }),
open && 'bg-surface-active text-text-primary',
(visible || open) && 'opacity-100 [@media(hover:hover)]:opacity-100',
);
/**
* The slot a row's actions sit in.
*
* Collapsed to nothing while the row rests, so the title and the description are
* measured against the whole row rather than against what is left beside a control
* no one can see. A slot that always reserved its width truncated text that had the
* room to be read, and the ellipsis then said the name was longer than it was.
*
* Where a pointer cannot hover there is no reveal to wait for, so the slot keeps its
* width and the actions stay reachable. Only the collapsed slot clips: once focus is
* inside, the focused action's ring has to draw past the slot's edge.
*/
export const rowActionSlotClasses = ({ open = false }: { open?: boolean } = {}): string =>
cn(
'flex shrink-0 items-center gap-0.5',
!open && [
'[@media(hover:hover)]:w-0 [@media(hover:hover)]:overflow-hidden',
'[@media(hover:hover)]:group-hover:w-auto',
'[@media(hover:hover)]:group-focus-within:w-auto [@media(hover:hover)]:group-focus-within:overflow-visible',
],
);

View file

@ -1,5 +1,6 @@
import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { openPanel } from './panels';
/**
* The panels share one empty card: a bordered box with a circular icon, a title
@ -21,9 +22,6 @@ test.describe('empty panel cards', () => {
test('the empty prompts panel is drawn like the other panels @scenario:empty-prompts-panel-matches-other-panels', async ({
page,
}) => {
const width = page.viewportSize()?.width ?? 0;
test.skip(width < 768, 'the side panels open as a drawer below md');
await page.goto('/c/new', { timeout: 10000 });
const prompts = await openPanelCard(page, 'Prompts', 'No prompts yet');
@ -35,7 +33,7 @@ test.describe('empty panel cards', () => {
/** Open a side panel from the rail and measure the empty card it renders. */
async function openPanelCard(page: Page, panel: string, title: string): Promise<CardStyle> {
await page.getByRole('button', { name: panel }).first().click();
await openPanel(page, panel.toLowerCase(), panel);
await expect(page.getByText(title, { exact: true }).first()).toBeVisible({ timeout: 20000 });
return page.evaluate((heading) => {

View file

@ -0,0 +1,73 @@
import { expect, test } from '@playwright/test';
import type { Locator } from '@playwright/test';
import {
MOCK_ENDPOINTS,
NEW_CHAT_PATH,
messagesView,
selectMockEndpoint,
sendMessage,
} from '../helpers';
/**
* A floating label breaks its field's top border, so it paints over the border
* with the colour behind it. When a page moves to another surface, a label still
* painting the old one shows as a patch across the border.
*/
async function paintsItsBackdrop(notch: Locator): Promise<{ notch: string; backdrop: string }> {
return notch.evaluate((element) => {
const opaque = (node: Element) => {
const color = getComputedStyle(node).backgroundColor;
return color !== 'transparent' && !/rgba\(.*,\s*0\)$/.test(color);
};
let node = element.parentElement;
while (node && !opaque(node)) {
node = node.parentElement;
}
return {
notch: getComputedStyle(element).backgroundColor,
backdrop: node ? getComputedStyle(node).backgroundColor : 'none',
};
});
}
test.describe('page surfaces', () => {
test('floating field labels paint the surface of the page they sit on @scenario:field-labels-match-page-surface', async ({
page,
}) => {
await page.goto('/agents');
const search = page.locator('#agent-search');
await expect(search).toBeVisible({ timeout: 20_000 });
const marketplace = await paintsItsBackdrop(search.locator('..'));
expect(marketplace.notch).toBe(marketplace.backdrop);
await page.goto('/skills/new');
const nameLabel = page.locator('label[for="skill-name"]');
await expect(nameLabel).toBeVisible({ timeout: 20_000 });
const skill = await paintsItsBackdrop(nameLabel);
expect(skill.notch).toBe(skill.backdrop);
});
test('a reply with a wide table stays inside the chat column @scenario:chat-column-fits-beside-sidebar', async ({
page,
}) => {
await page.setViewportSize({ width: 900, height: 600 });
await page.goto(NEW_CHAT_PATH);
await selectMockEndpoint(page, MOCK_ENDPOINTS[0]);
const response = await sendMessage(page, 'E2E_PARAGRAPHS_REPLY');
expect(response.ok()).toBeTruthy();
const view = messagesView(page);
await expect(view.getByText('E2E closing paragraph')).toBeVisible({ timeout: 20_000 });
await expect(view.locator('.markdown-table-wrapper')).toBeVisible();
const bounds = await view.evaluate((element) => {
const wrapper = element.querySelector('.markdown-table-wrapper')!;
return {
viewRight: element.getBoundingClientRect().right,
viewport: window.innerWidth,
tableScrolls: wrapper.scrollWidth > wrapper.clientWidth,
};
});
expect(bounds.viewRight).toBeLessThanOrEqual(bounds.viewport);
expect(bounds.tableScrolls).toBe(true);
});
});

View file

@ -0,0 +1,19 @@
import { expect } from '@playwright/test';
import type { Page } from '@playwright/test';
import { openSidebar } from './sidebar';
export async function openPanel(page: Page, id: string, label: string): Promise<void> {
await openSidebar(page);
if ((page.viewportSize()?.width ?? 0) < 768) {
await page.getByTestId('panel-switcher-button').click();
await page.getByRole('menuitemcheckbox', { name: label, exact: true }).click();
return;
}
const trigger = page.getByTestId(`nav-panel-${id}`);
await expect(trigger).toBeVisible();
if ((await trigger.getAttribute('aria-pressed')) !== 'true') {
await trigger.click();
}
}

View file

@ -0,0 +1,501 @@
import { expect, test } from '@playwright/test';
import { FileSources } from 'librechat-data-provider';
import type {
TFile,
TSchedule,
TConversationTag,
TSchedulesResponse,
} from 'librechat-data-provider';
import type { Page, Locator } from '@playwright/test';
import type { AgentSummary } from '../agents.helpers';
import { getAccessToken, requestJson, uniqueName } from '../helpers';
import { cleanupAgent } from '../agents.helpers';
import { openPanel } from './panels';
async function seedSchedules(page: Page, count: number) {
const token = await getAccessToken(page);
const agent = await requestJson<AgentSummary>(page, {
path: '/api/agents',
token,
method: 'POST',
body: { name: uniqueName('Panel agent'), provider: 'Mock Provider A', model: 'mock-model-a' },
});
const schedules: TSchedule[] = [];
try {
for (let index = 0; index < count; index++) {
schedules.push(
await requestJson<TSchedule>(page, {
path: '/api/schedules',
token,
method: 'POST',
body: {
name: uniqueName(`Panel schedule ${index}`),
prompt: 'Summarize the day',
agent_id: agent.id,
cadence: { frequency: 'daily', hour: 0, minute: 0 },
timezone: 'UTC',
target: 'new',
enabled: true,
clientRequestId: uniqueName('panel-intent'),
},
}),
);
}
} catch (error) {
await cleanupSchedules(page, { token, agent, schedules });
throw error;
}
return { token, agent, schedules };
}
async function cleanupSchedules(page: Page, fixture: Awaited<ReturnType<typeof seedSchedules>>) {
for (const schedule of fixture.schedules) {
await requestJson(page, {
path: `/api/schedules/${encodeURIComponent(schedule.id)}`,
token: fixture.token,
method: 'DELETE',
});
}
await cleanupAgent(page, fixture.agent.id);
}
/** Whether a focused control's ring (2px plus its 2px offset) is drawn in full, rather
* than cut off by an ancestor that clips its overflow. */
async function ringIsUnclipped(control: Locator): Promise<boolean> {
return control.evaluate((element) => {
const ring = 4;
const box = element.getBoundingClientRect();
if (getComputedStyle(element).boxShadow === 'none') {
return false;
}
for (
let node = element.parentElement;
node && node !== document.body;
node = node.parentElement
) {
const style = getComputedStyle(node);
if (style.overflowX === 'visible' && style.overflowY === 'visible') {
continue;
}
const clip = node.getBoundingClientRect();
if (
box.left - ring < clip.left ||
box.right + ring > clip.right ||
box.top - ring < clip.top ||
box.bottom + ring > clip.bottom
) {
return false;
}
}
return true;
});
}
const hasRing = (control: Locator) =>
control.evaluate((element) => getComputedStyle(element).boxShadow !== 'none');
function syntheticSchedule(
id: string,
name: string,
status: 'skipped_balance' | 'skipped_overlap',
): TSchedule {
return {
id,
user: 'schedule-fixture-user',
name,
prompt: 'Summarize the day',
agent_id: 'schedule-fixture-agent',
cadence: { frequency: 'daily', hour: 0, minute: 0 },
timezone: 'UTC',
target: 'new',
enabled: true,
nextRunAt: '2099-01-01T00:00:00.000Z',
lastRun: { status, firedAt: '2026-09-01T00:00:00.000Z' },
runCount: 3,
failureCount: 0,
createdAt: '2026-09-01T00:00:00.000Z',
updatedAt: '2026-09-01T00:00:00.000Z',
};
}
test.describe('quieter management panels', () => {
test('filtering preserves capacity and usable row controls @scenario:schedule-filter-keeps-quota-and-actions', async ({
page,
}) => {
test.setTimeout(120_000);
await page.goto('/c/new');
const token = await getAccessToken(page);
const initial = await requestJson<TSchedulesResponse>(page, { path: '/api/schedules', token });
expect(initial.schedules).toHaveLength(0);
const fixture = await seedSchedules(page, initial.limits.maxPerUser);
try {
await openPanel(page, 'schedules', 'Scheduled chats');
const panel = page.getByRole('region', { name: 'Scheduled chats', exact: true });
const count = fixture.schedules.length;
const quota = panel.getByText(`${count} of ${initial.limits.maxPerUser} schedules used`);
const create = panel.getByRole('button', { name: 'New schedule', exact: true });
const filter = panel.getByRole('textbox', { name: 'Filter schedules...' });
const fade = panel.locator('[aria-hidden="true"].pointer-events-none');
const schedule = fixture.schedules[0];
await expect(panel.getByTestId('schedule-card')).toHaveCount(count);
await expect(fade).toHaveCSS('opacity', '1');
const announcement = panel.locator('[aria-live="polite"]');
await filter.fill(schedule.name);
await expect(panel.getByTestId('schedule-card')).toHaveCount(1);
await expect(announcement).toHaveText('1 result found');
await expect(fade).toHaveCSS('opacity', '0');
await expect(quota).toBeVisible();
await expect(create).toBeDisabled();
await filter.fill('no matching schedule');
await expect(panel.getByText('No schedules match your search')).toBeVisible();
await expect(announcement).toHaveText('0 results found');
await expect(quota).toBeVisible();
await expect(create).toBeDisabled();
await filter.clear();
await expect(fade).toHaveCSS('opacity', '1');
const card = panel.getByTestId('schedule-card').filter({ hasText: schedule.name });
const toggle = card.getByRole('switch', { name: `Enabled: ${schedule.name}`, exact: true });
await expect(toggle).toBeChecked();
await toggle.click();
await expect(toggle).not.toBeChecked();
await toggle.press('Tab');
const menu = card.getByRole('button', {
name: `Schedule options: ${schedule.name}`,
exact: true,
});
await expect(menu).toBeFocused();
await menu.press('Enter');
await page.getByRole('menuitem', { name: 'Edit', exact: true }).click();
await expect(page.getByRole('dialog', { name: 'Edit schedule' })).toBeVisible();
await page.keyboard.press('Escape');
await expect(page.getByRole('dialog', { name: 'Edit schedule' })).toBeHidden();
await page.reload();
await openPanel(page, 'schedules', 'Scheduled chats');
await expect(toggle).not.toBeChecked();
// Supply the historical run variant without starting the scheduling engine.
await page.route('**/api/schedules', async (route) => {
if (route.request().method() !== 'GET') {
await route.continue();
return;
}
const response = await route.fetch();
const data = (await response.json()) as TSchedulesResponse;
await route.fulfill({
response,
json: {
...data,
schedules: data.schedules.map((item) =>
item.id === schedule.id
? {
...item,
lastRun: {
status: 'success',
firedAt: '2026-09-01T00:00:00.000Z',
conversationId: 'historical-schedule-run',
},
}
: item,
),
},
});
});
await page.reload();
await openPanel(page, 'schedules', 'Scheduled chats');
const lastRun = card.getByRole('button', { name: 'Paused: Last run', exact: true });
await expect(lastRun).toBeVisible();
await expect(lastRun).toHaveText('Paused');
await toggle.click();
await expect(toggle).toBeChecked();
const historyLink = card.getByRole('link', {
name: `Last run: ${schedule.name}`,
exact: true,
});
await expect(historyLink).toHaveAttribute('href', '/c/historical-schedule-run');
// Keep the panel visible while removing schedule-writing controls.
await page.route('**/api/roles/*', async (route) => {
const response = await route.fetch();
const role = await response.json();
await route.fulfill({
response,
json: {
...role,
permissions: {
...role.permissions,
SCHEDULES: { ...role.permissions.SCHEDULES, USE: true, CREATE: false },
},
},
});
});
await page.reload();
await openPanel(page, 'schedules', 'Scheduled chats');
await expect(card.getByRole('switch')).toHaveCount(0);
await expect(historyLink).toBeVisible();
await expect(historyLink).toHaveAttribute('href', '/c/historical-schedule-run');
} finally {
await page.unroute('**/api/schedules');
await page.unroute('**/api/roles/*');
await cleanupSchedules(page, fixture);
}
});
test('loading rows keep their height and failed lists offer retry @scenario:schedule-loading-and-error-preserve-panel-usability', async ({
page,
}) => {
test.setTimeout(120_000);
await page.goto('/c/new');
const fixture = await seedSchedules(page, 5);
let releaseLoading = () => {};
const loading = new Promise<void>((resolve) => {
releaseLoading = resolve;
});
let failRequests = false;
await page.route('**/api/schedules', async (route) => {
if (route.request().method() !== 'GET') {
await route.continue();
return;
}
if (failRequests) {
await route.fulfill({ status: 503, json: { message: 'Schedule service unavailable' } });
return;
}
const response = await route.fetch();
await loading;
await route.fulfill({ response });
});
try {
await openPanel(page, 'schedules', 'Scheduled chats');
const panel = page.getByRole('region', { name: 'Scheduled chats', exact: true });
const create = panel.getByRole('button', { name: 'New schedule', exact: true });
const busy = panel.locator('[aria-busy="true"]');
const placeholders = busy.locator(':scope > [aria-hidden="true"] > div');
await expect(placeholders).toHaveCount(5);
await expect(create).toBeDisabled();
const loadingHeight = await placeholders
.first()
.evaluate((row) => row.getBoundingClientRect().height);
releaseLoading();
const rows = panel.getByTestId('schedule-card');
await expect(rows).toHaveCount(5);
const loadedHeight = await rows.first().evaluate((row) => row.getBoundingClientRect().height);
expect(Math.abs(loadedHeight - loadingHeight)).toBeLessThanOrEqual(1);
await expect(create).toBeEnabled();
failRequests = true;
await page.reload();
await openPanel(page, 'schedules', 'Scheduled chats');
await expect(panel.getByText("Couldn't load your scheduled chats")).toBeVisible({
timeout: 20_000,
});
await expect(create).toBeDisabled();
failRequests = false;
await panel.getByRole('button', { name: 'Retry', exact: true }).click();
await expect(rows).toHaveCount(5);
await expect(create).toBeEnabled();
} finally {
releaseLoading();
await page.unroute('**/api/schedules');
await cleanupSchedules(page, fixture);
}
});
test('skill files expand and collapse from the keyboard @scenario:skill-files-disclosure-opens-by-keyboard', async ({
page,
}) => {
await page.goto('/c/new');
await openPanel(page, 'skills', 'Skills');
const disclosure = page.getByRole('button', {
name: 'Toggle files for e2e-deployment-skill',
exact: true,
});
await expect(disclosure).toHaveAttribute('aria-expanded', 'false');
await disclosure.focus();
await disclosure.press('Enter');
await expect(disclosure).toHaveAttribute('aria-expanded', 'true');
const file = page.getByRole('button', { name: 'guide.txt', exact: true });
await expect(file).toBeVisible();
await disclosure.press('Space');
await expect(disclosure).toHaveAttribute('aria-expanded', 'false');
await expect(file).toHaveCount(0);
await disclosure.press('Enter');
await file.click();
await expect(page).toHaveURL(/\/skills\/[^?]+\?file=guide.txt$/);
await expect(page.getByText('deployment skill file fixture', { exact: true })).toBeVisible();
});
test('file table headers stay opaque over scrolling rows @scenario:file-picker-sticky-header-stays-opaque', async ({
page,
}) => {
await page.setViewportSize({ width: page.viewportSize()?.width ?? 1280, height: 600 });
const files: TFile[] = Array.from({ length: 10 }, (_, index) => ({
file_id: `header-file-${index}`,
filename: `Header fixture ${index}.txt`,
filepath: `/files/header-file-${index}.txt`,
user: 'header-fixture-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',
}));
await page.route('**/api/files', (route) => route.fulfill({ json: files }));
await page.goto('/c/new');
await openPanel(page, 'files', 'Attach Files');
await page.getByRole('button', { name: 'Manage Files', exact: true }).click();
const dialog = page.getByRole('dialog', { name: 'My Files' });
const header = dialog.locator('thead');
await expect(header).toBeVisible();
// Actionability waits for the dialog's opening animation before measuring.
await header.click({ trial: true });
const metrics = await header.evaluate(async (element) => {
let scroller = element.parentElement;
while (
scroller &&
(!['auto', 'scroll'].includes(getComputedStyle(scroller).overflowY) ||
scroller.scrollHeight <= scroller.clientHeight)
) {
scroller = scroller.parentElement;
}
if (!scroller) throw new Error('The fixture must overflow the file table');
const before = element.getBoundingClientRect().top;
scroller.scrollTop = 100;
await new Promise(requestAnimationFrame);
const context = document.createElement('canvas').getContext('2d')!;
const isOpaque = (node: Element) => {
context.clearRect(0, 0, 1, 1);
context.fillStyle = getComputedStyle(node).backgroundColor;
context.fillRect(0, 0, 1, 1);
return context.getImageData(0, 0, 1, 1).data[3] === 255;
};
return {
scrollTop: scroller.scrollTop,
topShift: Math.abs(element.getBoundingClientRect().top - before),
opaque: isOpaque(element) || [...element.querySelectorAll('th')].every(isOpaque),
};
});
expect(metrics.scrollTop).toBeGreaterThan(0);
expect(metrics.topShift).toBeLessThanOrEqual(1);
expect(metrics.opaque).toBe(true);
await test.info().attach('file-table-header', {
body: await page.screenshot(),
contentType: 'image/png',
});
});
test('a run skipped for balance warns its owner while an overlap skip does not @scenario:balance-skipped-schedule-warns-owner', async ({
page,
}) => {
const balance = syntheticSchedule(
'balance-fixture',
uniqueName('Balance skipped'),
'skipped_balance',
);
const overlap = syntheticSchedule(
'overlap-fixture',
uniqueName('Overlap skipped'),
'skipped_overlap',
);
await page.route('**/api/schedules', async (route) => {
if (route.request().method() !== 'GET') {
await route.continue();
return;
}
const response = await route.fetch();
const data = (await response.json()) as TSchedulesResponse;
await route.fulfill({ response, json: { ...data, schedules: [balance, overlap] } });
});
try {
await page.goto('/c/new');
await openPanel(page, 'schedules', 'Scheduled chats');
const panel = page.getByRole('region', { name: 'Scheduled chats', exact: true });
const balanceCard = panel.getByTestId('schedule-card').filter({ hasText: balance.name });
const overlapCard = panel.getByTestId('schedule-card').filter({ hasText: overlap.name });
await expect(balanceCard).toBeVisible();
await expect(overlapCard).toBeVisible();
await expect(balanceCard.getByText('Skipped', { exact: true })).toBeVisible();
await expect(overlapCard.getByText('Skipped', { exact: true })).toHaveCount(0);
await expect(balanceCard.locator('svg.text-status-warning')).toHaveCount(1);
await expect(overlapCard.locator('svg.text-status-warning')).toHaveCount(0);
} finally {
await page.unroute('**/api/schedules');
}
});
test('a focused row action draws its whole focus ring @scenario:row-actions-keep-focus-ring-visible', async ({
page,
}) => {
const bookmark: TConversationTag = {
_id: 'focus-ring-fixture',
user: 'focus-ring-fixture-user',
tag: uniqueName('Focus ring bookmark'),
description: '',
count: 0,
position: 0,
createdAt: '2026-09-01T00:00:00.000Z',
updatedAt: '2026-09-01T00:00:00.000Z',
};
await page.route('**/api/tags', (route) =>
route.request().method() === 'GET' ? route.fulfill({ json: [bookmark] }) : route.continue(),
);
try {
await page.goto('/c/new');
await openPanel(page, 'bookmarks', 'Bookmarks');
const edit = page.getByRole('button', { name: 'Edit Bookmark', exact: true });
const remove = page.getByRole('button', { name: 'Delete Bookmark', exact: true });
await expect(page.getByText(bookmark.tag, { exact: true })).toBeVisible();
await edit.focus();
await page.keyboard.press('Tab');
await expect(remove).toBeFocused();
expect(await ringIsUnclipped(remove)).toBe(true);
await page.keyboard.press('Shift+Tab');
await expect(edit).toBeFocused();
expect(await ringIsUnclipped(edit)).toBe(true);
expect(await hasRing(remove)).toBe(false);
} finally {
await page.unroute('**/api/tags');
}
});
test('each control in a skill row shows its own keyboard focus @scenario:skill-row-controls-show-own-focus', async ({
page,
}) => {
await page.goto('/c/new');
await openPanel(page, 'skills', 'Skills');
const disclosure = page.getByRole('button', {
name: 'Toggle files for e2e-deployment-skill',
exact: true,
});
const row = disclosure.locator('..');
const open = row.getByRole('button', { name: /^e2e-deployment-skill/ });
await expect(disclosure).toBeVisible();
await disclosure.focus();
await page.keyboard.press('Shift+Tab');
await expect(open).toBeFocused();
expect(await hasRing(open)).toBe(true);
expect(await hasRing(disclosure)).toBe(false);
expect(await hasRing(row)).toBe(false);
await page.keyboard.press('Tab');
await expect(disclosure).toBeFocused();
expect(await hasRing(disclosure)).toBe(true);
expect(await hasRing(open)).toBe(false);
expect(await hasRing(row)).toBe(false);
});
});

View file

@ -310,7 +310,7 @@
},
"client/src/components/Chat/Input/Files/Table/DataTable.tsx": {
"shadcn/no-restyle": {
"count": 28
"count": 17
},
"shadcn/no-unknown-classes": {
"count": 1
@ -1113,7 +1113,7 @@
},
"client/src/components/Conversations/ProjectsSection.tsx": {
"shadcn/no-restyle": {
"count": 28
"count": 11
}
},
"client/src/components/Conversations/RenameForm.tsx": {
@ -1338,11 +1338,6 @@
"count": 4
}
},
"client/src/components/Nav/SearchBar.tsx": {
"shadcn/no-raw-colors": {
"count": 1
}
},
"client/src/components/Nav/Settings/Dialog.tsx": {
"shadcn/no-restyle": {
"count": 8
@ -1529,11 +1524,6 @@
"count": 6
}
},
"client/src/components/Prompts/buttons/CreatePromptButton.tsx": {
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/Prompts/dialogs/SharePrompt.tsx": {
"shadcn/no-restyle": {
"count": 1
@ -1982,7 +1972,7 @@
},
"client/src/components/SidePanel/Bookmarks/BookmarkTable.tsx": {
"shadcn/no-restyle": {
"count": 3
"count": 2
}
},
"client/src/components/SidePanel/Builder/Action.tsx": {
@ -2060,17 +2050,12 @@
"count": 3
},
"shadcn/no-restyle": {
"count": 17
"count": 6
}
},
"client/src/components/SidePanel/MCPBuilder/MCPBuilderPanel.tsx": {
"shadcn/no-restyle": {
"count": 3
}
},
"client/src/components/SidePanel/MCPBuilder/MCPCardActions.tsx": {
"shadcn/no-restyle": {
"count": 57
"count": 2
}
},
"client/src/components/SidePanel/MCPBuilder/MCPServerCard.tsx": {
@ -2103,16 +2088,6 @@
"count": 1
}
},
"client/src/components/SidePanel/MCPBuilder/MCPServerList.tsx": {
"shadcn/no-restyle": {
"count": 1
}
},
"client/src/components/SidePanel/Memories/MemoryCardActions.tsx": {
"shadcn/no-restyle": {
"count": 16
}
},
"client/src/components/SidePanel/Memories/MemoryCreateDialog.tsx": {
"shadcn/no-restyle": {
"count": 12
@ -2125,7 +2100,7 @@
},
"client/src/components/SidePanel/Memories/MemoryPanel.tsx": {
"shadcn/no-restyle": {
"count": 5
"count": 4
}
},
"client/src/components/SidePanel/Parameters/DynamicCombobox.tsx": {
@ -2178,12 +2153,7 @@
},
"client/src/components/SidePanel/Schedules/SchedulePanel.tsx": {
"shadcn/no-restyle": {
"count": 3
}
},
"client/src/components/SidePanel/SidePanelGroup.tsx": {
"shadcn/no-restyle": {
"count": 1
"count": 2
}
},
"client/src/components/Skills/buttons/ShareSkill.tsx": {
@ -2226,7 +2196,7 @@
},
"client/src/components/Skills/forms/CreateSkillForm.tsx": {
"shadcn/no-restyle": {
"count": 24
"count": 17
}
},
"client/src/components/Skills/forms/SkillContentEditor.tsx": {

View file

@ -15,11 +15,7 @@ const AccordionItem: React.ForwardRefExoticComponent<
React.ElementRef<typeof AccordionPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className = '', ...props }, ref) => (
<AccordionPrimitive.Item
ref={ref}
className={cn('border-border-light border-b', className)}
{...props}
/>
<AccordionPrimitive.Item ref={ref} className={cn(className)} {...props} />
));
AccordionItem.displayName = 'AccordionItem';

View file

@ -17,6 +17,7 @@ type ButtonVariantOptions =
| 'secondary'
| 'ghost'
| 'row-action'
| 'row-action-reveal'
| 'section-header'
| 'section-action'
| 'header-action'
@ -28,6 +29,7 @@ type ButtonVariantOptions =
| 'icon-sm'
| 'icon-xs'
| 'icon-theme'
| 'xs'
| 'sm'
| 'lg'
| 'theme'
@ -68,6 +70,10 @@ const buttonVariantRecipe = cva(
* overrides the base radius rather than matching its host.
*/
'row-action': 'rounded-md hover:bg-surface-hover-alt hover:text-text-primary',
/** A row action revealed by hover or keyboard focus, and kept visible
* while its dialog or menu is open. Touch users always see it. */
'row-action-reveal':
'shrink-0 rounded-md text-text-secondary transition-opacity hover:bg-surface-hover-alt hover:text-text-primary data-[open]:bg-surface-active data-[open]:text-text-primary data-[open]:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:focus-visible:opacity-100 [@media(hover:hover)]:group-focus-within:opacity-100 [@media(hover:hover)]:group-hover:opacity-100',
link: 'text-text-primary underline-offset-4 hover:underline',
submit: 'bg-surface-submit text-text-on-status hover:bg-surface-submit-hover',
/**
@ -79,7 +85,7 @@ const buttonVariantRecipe = cva(
* below, since a section heading is sized by its text.
*/
'section-header':
'justify-start gap-1 rounded-lg px-1 py-2 text-xs font-bold text-text-secondary focus-visible:ring-inset focus-visible:ring-offset-0',
'justify-start gap-1 rounded-lg px-1 py-2 text-xs font-medium text-text-secondary focus-visible:ring-inset focus-visible:ring-offset-0',
/**
* A quiet icon action sitting beside a section heading in the sidebar.
* Unlike `row-action`, it recedes until hovered so the heading stays
@ -108,6 +114,12 @@ const buttonVariantRecipe = cva(
},
size: {
default: 'h-10 px-4 py-2',
/**
* A chip, the text counterpart of `icon-xs`: the reset beside a list that
* matched nothing, and anything else that offers a way out without asking
* to be the thing the eye lands on.
*/
xs: 'h-7 rounded-md px-2.5 text-xs',
sm: 'h-9 rounded-lg px-3',
lg: 'h-11 rounded-lg px-8',
icon: 'size-10',

View file

@ -40,4 +40,28 @@ const Checkbox: React.ForwardRefExoticComponent<
);
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
export { Checkbox };
/**
* The checkbox's appearance without its behaviour, for a control that already carries
* the state itself, e.g. a `Button` with `aria-pressed`. Radix's checkbox is a
* `<button>`, so nesting one inside another control puts two interactive elements in
* the same place: unreachable by keyboard, and announced twice by a screen reader.
* This is a span, so the control around it stays the only thing there.
*/
const CheckboxGlyph: React.FC<{ checked: boolean; className?: string }> = ({
checked,
className = '',
}) => (
<span
aria-hidden="true"
className={cn(
'border-border-xheavy flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border',
checked && 'bg-surface-inverted text-text-inverted',
className,
)}
>
{checked && <Check className="h-4 w-4" />}
</span>
);
CheckboxGlyph.displayName = 'CheckboxGlyph';
export { Checkbox, CheckboxGlyph };

View file

@ -89,13 +89,7 @@ const DialogHeader: {
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element;
displayName: string;
} = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element => (
<div
className={cn(
'border-border-light flex flex-col space-y-2 border-b p-6 pb-4 text-left',
className ?? '',
)}
{...props}
/>
<div className={cn('flex flex-col space-y-2 p-6 pb-4 text-left', className ?? '')} {...props} />
);
DialogHeader.displayName = 'DialogHeader';

View file

@ -1,10 +1,11 @@
import type { ComponentType, ReactNode } from 'react';
import type { LucideIcon } from 'lucide-react';
import type { ReactNode } from 'react';
import { cn } from '~/utils';
export interface EmptyStateProps {
/** Decorative, rendered inside the circular surface at a fixed size. */
icon: LucideIcon;
/** Decorative, drawn at a fixed size above the text. Any icon component with a
* `className` fits, so a Lucide glyph and a project SVG can share this state. */
icon: LucideIcon | ComponentType<{ className?: string }>;
/** Omitted for the "nothing matched your filter" shape, which is a line on its own. */
title?: string;
description?: string;
@ -14,10 +15,13 @@ export interface EmptyStateProps {
}
/**
* The panel empty state: a bordered card with a circular icon, a title and a line of
* explanation. Owned here because bookmarks, memories and schedules each render the
* same card, and three copies of one appearance means a theme or spacing change has
* to be made three times and will eventually be made twice.
* The panel empty state: a circular icon, a title and a line of explanation, centred
* in the space the list would have filled. Owned here because bookmarks, memories and
* schedules each render the same thing, and three copies of one appearance means a
* theme or spacing change has to be made three times and will eventually be made twice.
*
* It carries no border. An empty list is the absence of content, and drawing a box
* around nothing turns a quiet state into the loudest element on the panel.
*/
export default function EmptyState({
icon: Icon,
@ -29,14 +33,12 @@ export default function EmptyState({
return (
<div
className={cn(
'flex flex-col items-center justify-center rounded-lg border border-border-light bg-transparent p-6 text-center',
'flex flex-col items-center justify-center bg-transparent px-6 py-10 text-center',
className,
)}
>
<div className="mb-2 flex size-10 items-center justify-center rounded-full bg-surface-tertiary">
<Icon className="size-5 text-text-secondary" aria-hidden={true} />
</div>
{title != null && <p className="text-sm font-medium text-text-primary">{title}</p>}
<Icon className="text-text-tertiary mb-3 size-5" aria-hidden={true} />
{title != null && <p className="text-text-primary text-sm font-medium">{title}</p>}
{description != null && (
// Without a title the description IS the message, so it carries the title's
// size rather than reading as a caption under nothing.

View file

@ -10,7 +10,7 @@ export interface FilterInputProps
/** Container className for custom styling */
containerClassName?: string;
/** Surface behind the floating label, matching the input's surrounding panel. */
surface?: 'primary' | 'presentation';
surface?: 'primary' | 'presentation' | 'dialog';
}
/**
@ -25,12 +25,22 @@ export interface FilterInputProps
* onChange={(e) => setSearchQuery(e.target.value)}
* />
*/
/** The floating label breaks the field's top border, so it has to paint the
* surface behind it. The surface is painted on the container and inherited by the
* label, so a field on another panel names it through `surface` rather than the
* label drifting from its host. */
const SURFACE_CLASSES: Record<NonNullable<FilterInputProps['surface']>, string> = {
primary: 'bg-surface-primary-alt',
presentation: 'bg-presentation',
dialog: 'bg-surface-dialog',
};
const FilterInput: React.ForwardRefExoticComponent<
FilterInputProps & React.RefAttributes<HTMLInputElement>
> = React.forwardRef<HTMLInputElement, FilterInputProps>(
({ className, label, inputId, containerClassName, surface = 'primary', ...props }, ref) => {
return (
<div className={cn('relative', containerClassName)}>
<div className={cn('relative', SURFACE_CLASSES[surface], containerClassName)}>
<input
id={inputId}
ref={ref}
@ -44,12 +54,7 @@ const FilterInput: React.ForwardRefExoticComponent<
/>
<label
htmlFor={inputId}
className={cn(
'text-text-secondary pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-sm transition-all duration-200 peer-focus:top-0 peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs',
surface === 'presentation'
? 'peer-focus:bg-presentation peer-[:not(:placeholder-shown)]:bg-presentation'
: 'peer-focus:bg-surface-primary peer-[:not(:placeholder-shown)]:bg-surface-primary',
)}
className="text-text-secondary pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-sm transition-all duration-200 peer-focus:top-0 peer-focus:bg-inherit peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:bg-inherit peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs"
>
{label}
</label>

View file

@ -1,4 +1,5 @@
import * as React from 'react';
import { cva } from 'class-variance-authority';
import { cn } from '~/utils';
interface TableProps extends React.HTMLAttributes<HTMLTableElement> {
@ -21,15 +22,24 @@ const Table: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<HT
);
Table.displayName = 'Table';
interface TableHeaderProps extends React.HTMLAttributes<HTMLTableSectionElement> {
sticky?: boolean;
}
const tableHeaderVariants = cva('', {
variants: {
sticky: {
true: 'bg-surface-secondary sticky top-0 z-50',
false: '',
},
},
});
const TableHeader: React.ForwardRefExoticComponent<
React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>
> = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<thead
ref={ref}
className={cn('[&_tr]:border-border-light [&_tr]:border-b', className)}
{...props}
/>
TableHeaderProps & React.RefAttributes<HTMLTableSectionElement>
> = React.forwardRef<HTMLTableSectionElement, TableHeaderProps>(
({ className, sticky = false, ...props }, ref) => (
<thead ref={ref} className={cn(tableHeaderVariants({ sticky }), className)} {...props} />
),
);
TableHeader.displayName = 'TableHeader';
@ -47,14 +57,7 @@ const TableFooter: React.ForwardRefExoticComponent<
React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>
> = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<tfoot
ref={ref}
className={cn(
'border-border-light bg-surface-tertiary border-t font-medium [&>tr]:last:border-b-0',
className,
)}
{...props}
/>
<tfoot ref={ref} className={cn('bg-surface-secondary font-medium', className)} {...props} />
),
);
TableFooter.displayName = 'TableFooter';
@ -66,7 +69,9 @@ const TableRow: React.ForwardRefExoticComponent<
<tr
ref={ref}
className={cn(
'border-border-light hover:bg-surface-tertiary data-[state=selected]:bg-surface-tertiary border-b transition-colors',
/** Rows are separated by their own padding and the hover fill, not by rules:
* a ruled table reads as a grid, and a list of records rarely needs one. */
'hover:bg-surface-hover data-[state=selected]:bg-surface-hover transition-colors',
className,
)}
{...props}
@ -75,20 +80,36 @@ const TableRow: React.ForwardRefExoticComponent<
);
TableRow.displayName = 'TableRow';
/** A compact table's header: a side panel lists records rather than presenting
* a grid, and a full-height, full-size heading over two text lines reads as
* scaffolding rather than as the column names those rows sit under. */
const tableHeadVariants = cva('', {
variants: {
size: {
default: '',
sm: 'h-auto text-xs',
},
},
defaultVariants: { size: 'default' },
});
const TableHead: React.ForwardRefExoticComponent<
React.ThHTMLAttributes<HTMLTableCellElement> & React.RefAttributes<HTMLTableCellElement>
> = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(
({ className, ...props }, ref) => (
<th
ref={ref}
className={cn(
'text-text-secondary h-12 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
className,
)}
{...props}
/>
),
);
React.ThHTMLAttributes<HTMLTableCellElement> &
React.RefAttributes<HTMLTableCellElement> & { size?: 'default' | 'sm' }
> = React.forwardRef<
HTMLTableCellElement,
React.ThHTMLAttributes<HTMLTableCellElement> & { size?: 'default' | 'sm' }
>(({ className, size, ...props }, ref) => (
<th
ref={ref}
className={cn(
'text-text-secondary h-12 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',
tableHeadVariants({ size }),
className,
)}
{...props}
/>
));
TableHead.displayName = 'TableHead';
const TableCell: React.ForwardRefExoticComponent<

View file

@ -33,7 +33,7 @@ const TabsTrigger: React.ForwardRefExoticComponent<
>(({ className = '', ...props }, ref) => (
<TabsPrimitive.Trigger
className={cn(
'text-text-secondary data-[state=active]:bg-surface-primary data-[state=active]:text-text-primary inline-flex min-w-[100px] items-center justify-center rounded-[0.185rem] px-3 py-1.5 text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-xs',
'text-text-secondary data-[state=active]:bg-surface-primary data-[state=active]:text-text-primary inline-flex min-w-[100px] items-center justify-center rounded-[0.185rem] px-3 py-1.5 text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50',
className,
)}
{...props}

View file

@ -63,9 +63,9 @@ export const darkTheme: IThemeRGB = {
'rgb-text-fixed': '33 33 33', // #212121 (gray-800) — same in light + dark
// Border colors
'rgb-border-light': '47 47 47', // #2f2f2f (gray-700)
'rgb-border-medium': '66 66 66', // #424242 (gray-600)
'rgb-border-medium-alt': '66 66 66', // #424242 (gray-600)
'rgb-border-light': '33 33 33', // #212121 (gray-800)
'rgb-border-medium': '57 57 57', // #393939 (gray-650)
'rgb-border-medium-alt': '57 57 57', // #393939 (gray-650)
'rgb-border-heavy': '89 89 89', // #595959 (gray-500)
'rgb-border-xheavy': '153 150 150', // #999696 (gray-400)
'rgb-border-destructive': '239 68 68', // #ef4444 (red-500)

View file

@ -52,6 +52,9 @@ export const composerControlClasses = (): string =>
cn(
'group relative inline-flex items-center justify-center gap-theme-compact',
'h-theme-control rounded-theme-control-round border border-border-medium',
'bg-transparent text-sm font-medium text-text-primary shadow-xs transition-all',
'hover:bg-surface-hover hover:shadow-md active:shadow-inner',
'bg-transparent text-sm font-medium text-text-primary transition-all',
/** No elevation: a row of raised pills inside the composer competes with the
* composer itself. The edge stays, because a fill alone against the composer
* surface is under 1.2:1 and would leave the control with no visible boundary. */
'hover:bg-surface-hover',
);