Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

📱 fix: Fit the Tool Library and Skills Pickers to Small Screens (#16067)

Marco Beretta5c72d4146e41
diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialog.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialog.tsx
index 5d96880ebb..9bc726a286 100644
--- a/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialog.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialog.tsx
@@ -16,13 +16,13 @@ export default function ItemDialog({ item, agentId, onClose }: Props) {
<OGDialog open={item !== null} onOpenChange={(next) => !next && onClose()}>
<OGDialogContent
className={cn(
- 'w-11/12 gap-0 overflow-hidden rounded-2xl p-0 md:max-h-[85vh]',
+ 'w-11/12 gap-0 overflow-hidden rounded-2xl p-0 md:max-h-[85dvh]',
isAction ? 'max-w-5xl' : 'max-w-[560px]',
)}
data-testid="item-dialog"
>
{item && (
- <div className="flex max-h-[85vh] flex-col">
+ <div className="flex max-h-[85dvh] flex-col">
<ItemDialogHeader item={item} />
<div
className={cn(
diff --git a/client/src/components/SidePanel/Agents/Tools/MarketplaceSidebar.tsx b/client/src/components/SidePanel/Agents/Tools/MarketplaceSidebar.tsx
index e4f3f8f338..143831daf3 100644
--- a/client/src/components/SidePanel/Agents/Tools/MarketplaceSidebar.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/MarketplaceSidebar.tsx
@@ -22,7 +22,8 @@ interface MarketplaceSidebarProps {
onCreateNew?: (kind: 'mcp' | 'action') => void;
}
-interface SidebarItemProps {
+interface SidebarEntry {
+ id: string;
icon: ReactNode;
label: string;
active: boolean;
@@ -30,39 +31,90 @@ interface SidebarItemProps {
count?: number;
}
-function SidebarItem({ icon, label, active, onClick, count }: SidebarItemProps) {
- return (
- <button
- type="button"
- onClick={onClick}
- aria-pressed={active}
- className={cn(
- 'flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left text-sm transition-colors',
- active
- ? 'bg-surface-active font-medium text-text-primary'
- : 'text-text-secondary hover:bg-surface-hover hover:text-text-primary',
- )}
- >
- <span className="flex size-4 shrink-0 items-center justify-center">{icon}</span>
- <span className="flex-1 truncate">{label}</span>
- {count !== undefined && count > 0 && (
- <span className="text-[11px] tabular-nums text-text-secondary">{count}</span>
- )}
- </button>
- );
-}
-
-export default function MarketplaceSidebar({
+/** Kind and view navigation shared by the desktop rail and the mobile chip row. */
+function useMarketplaceNav({
activeView,
activeKind,
onSelectView,
onSelectKind,
counts,
totalCount,
- onCreateNew,
}: MarketplaceSidebarProps) {
const localize = useLocalize();
- const [createOpen, setCreateOpen] = useState(false);
+ const selectKind = (kind: Kind) => {
+ onSelectView('marketplace');
+ onSelectKind(kind);
+ };
+ const selectView = (view: View) => {
+ onSelectView(view);
+ onSelectKind('all');
+ };
+
+ const kindEntries: SidebarEntry[] = [
+ {
+ id: 'all',
+ icon: <LayoutGrid className="size-4" />,
+ label: localize('com_ui_all_proper'),
+ active: activeKind === 'all' && activeView === 'marketplace',
+ onClick: () => selectKind('all'),
+ count: totalCount,
+ },
+ {
+ id: 'builtin',
+ icon: <ListFilter className="size-4" />,
+ label: localize('com_ui_tools_kind_official'),
+ active: activeKind === 'builtin' && activeView === 'marketplace',
+ onClick: () => selectKind('builtin'),
+ count: counts.builtin,
+ },
+ {
+ id: 'tool',
+ icon: <Wrench className="size-4" />,
+ label: localize('com_ui_tools_kind_tools'),
+ active: activeKind === 'tool' && activeView === 'marketplace',
+ onClick: () => selectKind('tool'),
+ count: counts.tool,
+ },
+ {
+ id: 'mcp',
+ icon: <Server className="size-4" />,
+ label: localize('com_ui_tools_kind_mcp'),
+ active: activeKind === 'mcp' && activeView === 'marketplace',
+ onClick: () => selectKind('mcp'),
+ count: counts.mcp,
+ },
+ {
+ id: 'action',
+ icon: <Workflow className="size-4" />,
+ label: localize('com_ui_tools_kind_actions'),
+ active: activeKind === 'action' && activeView === 'marketplace',
+ onClick: () => selectKind('action'),
+ count: counts.action,
+ },
+ ];
+
+ const viewEntries: SidebarEntry[] = [
+ {
+ id: 'mine',
+ icon: <User className="size-4" />,
+ label: localize('com_ui_tools_view_made_by_you'),
+ active: activeView === 'mine',
+ onClick: () => selectView('mine'),
+ },
+ {
+ id: 'favorites',
+ icon: <Star className="size-4" />,
+ label: localize('com_ui_tools_view_favorites'),
+ active: activeView === 'favorites',
+ onClick: () => selectView('favorites'),
+ },
+ ];
+
+ return { kindEntries, viewEntries };
+}
+
+function useCreateItems(onCreateNew?: (kind: 'mcp' | 'action') => void) {
+ const localize = useLocalize();
const { agentsConfig } = useAgentPanelContext();
const hasMcpCreateAccess = useHasAccess({
permissionType: PermissionTypes.MCP_SERVERS,
@@ -73,7 +125,7 @@ export default function MarketplaceSidebar({
[agentsConfig],
);
- const createItems = useMemo(() => {
+ return useMemo(() => {
const items: Array<{ label: string; icon: ReactNode; onClick: () => void }> = [];
if (hasMcpCreateAccess) {
items.push({
@@ -91,6 +143,61 @@ export default function MarketplaceSidebar({
}
return items;
}, [localize, onCreateNew, hasMcpCreateAccess, actionsEnabled]);
+}
+
+function SidebarItem({ icon, label, active, onClick, count }: SidebarEntry) {
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ aria-pressed={active}
+ className={cn(
+ 'flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left text-sm transition-colors',
+ active
+ ? 'bg-surface-active font-medium text-text-primary'
+ : 'text-text-secondary hover:bg-surface-hover hover:text-text-primary',
+ )}
+ >
+ <span className="flex size-4 shrink-0 items-center justify-center">{icon}</span>
+ <span className="flex-1 truncate">{label}</span>
+ {count !== undefined && count > 0 && (
+ <span className="text-[11px] tabular-nums text-text-secondary">{count}</span>
+ )}
+ </button>
+ );
+}
+
+/** The chip row is this layout's primary navigation, and it only exists where a
+ * finger is what reaches it, so the chips carry the shared tap-target floor
+ * rather than the compact height a mouse would be happy with. */
+function SidebarChip({ icon, label, active, onClick, count }: SidebarEntry) {
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ aria-pressed={active}
+ className={cn(
+ 'flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-xs transition-colors',
+ 'touch:min-h-theme-control-touch touch:px-4',
+ active
+ ? 'border-border-medium bg-surface-active font-medium text-text-primary'
+ : 'border-border-light text-text-secondary hover:bg-surface-hover hover:text-text-primary',
+ )}
+ >
+ <span className="flex size-4 shrink-0 items-center justify-center">{icon}</span>
+ <span>{label}</span>
+ {count !== undefined && count > 0 && (
+ <span className="text-[10px] tabular-nums text-text-secondary">{count}</span>
+ )}
+ </button>
+ );
+}
+
+export default function MarketplaceSidebar(props: MarketplaceSidebarProps) {
+ const localize = useLocalize();
+ const [createOpen, setCreateOpen] = useState(false);
+ const { kindEntries, viewEntries } = useMarketplaceNav(props);
+ const createItems = useCreateItems(props.onCreateNew);
return (
<aside className="flex w-56 shrink-0 flex-col gap-0.5 border-r border-border-light bg-surface-primary-alt p-3">
@@ -125,77 +232,69 @@ export default function MarketplaceSidebar({
/>
)}
- <SidebarItem
- icon={<LayoutGrid className="size-4" />}
- label={localize('com_ui_all_proper')}
- active={activeKind === 'all' && activeView === 'marketplace'}
- onClick={() => {
- onSelectView('marketplace');
- onSelectKind('all');
- }}
- count={totalCount}
- />
- <SidebarItem
- icon={<ListFilter className="size-4" />}
- label={localize('com_ui_tools_kind_official')}
- active={activeKind === 'builtin' && activeView === 'marketplace'}
- onClick={() => {
- onSelectView('marketplace');
- onSelectKind('builtin');
- }}
- count={counts.builtin}
- />
- <SidebarItem
- icon={<Wrench className="size-4" />}
- label={localize('com_ui_tools_kind_tools')}
- active={activeKind === 'tool' && activeView === 'marketplace'}
- onClick={() => {
- onSelectView('marketplace');
- onSelectKind('tool');
- }}
- count={counts.tool}
- />
- <SidebarItem
- icon={<Server className="size-4" />}
- label={localize('com_ui_tools_kind_mcp')}
- active={activeKind === 'mcp' && activeView === 'marketplace'}
- onClick={() => {
- onSelectView('marketplace');
- onSelectKind('mcp');
- }}
- count={counts.mcp}
- />
- <SidebarItem
- icon={<Workflow className="size-4" />}
- label={localize('com_ui_tools_kind_actions')}
- active={activeKind === 'action' && activeView === 'marketplace'}
- onClick={() => {
- onSelectView('marketplace');
- onSelectKind('action');
- }}
- count={counts.action}
- />
+ {kindEntries.map((entry) => (
+ <SidebarItem key={entry.id} {...entry} />
+ ))}
<div className="mx-2 my-3 h-px bg-border-light" />
- <SidebarItem
- icon={<User className="size-4" />}
- label={localize('com_ui_tools_view_made_by_you')}
- active={activeView === 'mine'}
- onClick={() => {
- onSelectView('mine');
- onSelectKind('all');
- }}
- />
- <SidebarItem
- icon={<Star className="size-4" />}
- label={localize('com_ui_tools_view_favorites')}
- active={activeView === 'favorites'}
- onClick={() => {
- onSelectView('favorites');
- onSelectKind('all');
- }}
- />
+ {viewEntries.map((entry) => (
+ <SidebarItem key={entry.id} {...entry} />
+ ))}
</aside>
);
}
+
+/** Mobile stand-in for the sidebar rail: a horizontally scrollable chip row
+ * rendered under the search field when the rail is hidden. */
+export function MarketplaceFilterBar(props: MarketplaceSidebarProps) {
+ const localize = useLocalize();
+ const [createOpen, setCreateOpen] = useState(false);
+ const { kindEntries, viewEntries } = useMarketplaceNav(props);
+ const createItems = useCreateItems(props.onCreateNew);
+
+ return (
+ /* The scrollbar hides only where a finger can drag the row instead. A narrow
+ desktop window is below md too, and there a wheel scrolls the page rather
+ than this row, so the bar is the only way to reach the trailing views. */
+ <div
+ role="group"
+ className="flex shrink-0 items-center gap-1.5 overflow-x-auto border-b border-border-light px-4 pb-2.5 touch:[scrollbar-width:none] touch:[&::-webkit-scrollbar]:hidden"
+ aria-label={localize('com_ui_tools_marketplace')}
+ >
+ {createItems.length > 0 && (
+ <DropdownPopup
+ portal={true}
+ mountByState={true}
+ unmountOnHide={true}
+ isOpen={createOpen}
+ setIsOpen={setCreateOpen}
+ menuId="marketplace-create-new-mobile"
+ className="pointer-events-auto"
+ trigger={
+ <Ariakit.MenuButton
+ render={
+ <Button
+ variant="outline"
+ size="sm"
+ className="h-8 w-8 shrink-0 justify-center p-0 touch:size-theme-control-touch"
+ aria-label={localize('com_ui_tools_create_new')}
+ >
+ <Plus className="size-4" aria-hidden="true" />
+ </Button>
+ }
+ />
+ }
+ items={createItems}
+ />
+ )}
+ {kindEntries.map((entry) => (
+ <SidebarChip key={entry.id} {...entry} />
+ ))}
+ <span className="h-4 w-px shrink-0 bg-border-light" aria-hidden="true" />
+ {viewEntries.map((entry) => (
+ <SidebarChip key={entry.id} {...entry} />
+ ))}
+ </div>
+ );
+}
diff --git a/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx b/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx
index 92e343fd8e..063481f475 100644
--- a/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx
@@ -11,6 +11,7 @@ import {
OGDialogTitle,
OGDialogContent,
OGDialogDescription,
+ useMediaQuery,
} from '@librechat/client';
import type { TSkill, TSkillSummary } from 'librechat-data-provider';
import type { TranslationKeys } from '~/hooks/useLocalize';
@@ -27,6 +28,7 @@ import ItemDialog from './ItemDialog/ItemDialog';
import { applyFilter } from './items/filtering';
import CategoryFilter from './CategoryFilter';
import { itemKey } from './items/selectors';
+import { cn } from '~/utils';
interface SkillsDialogProps {
open: boolean;
@@ -46,6 +48,9 @@ export default function SkillsDialog({ open, onOpenChange, agentId }: SkillsDial
const localize = useLocalize();
const { user } = useAuthContext();
const { control, getValues, setValue } = useFormContext<AgentForm>();
+ /** The header's two layouts read in different orders, so the breakpoint selects
+ * which DOM order renders; same query as the marketplace dialog's rail. */
+ const isDesktop = useMediaQuery('(min-width: 768px)');
const hasSkillsAccess = useHasAccess({
permissionType: PermissionTypes.SKILLS,
@@ -180,65 +185,96 @@ export default function SkillsDialog({ open, onOpenChange, agentId }: SkillsDial
? 'com_ui_no_skills_found'
: undefined;
+ /** The header is one row from md and two below it, and the two read in different
+ * orders, so the breakpoint picks the DOM order rather than `order-*` reshuffling
+ * one. Each control is built once and placed by whichever branch renders. */
+ const viewRadio = (
+ <Radio
+ wrap
+ options={viewOptions}
+ value={view}
+ onChange={(value) => {
+ setView(value as SkillView);
+ setCategory('all');
+ }}
+ className="p-1"
+ aria-labelledby="skills-view-label"
+ />
+ );
+ const createButton = hasCreateAccess ? (
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => setCreateOpen(true)}
+ aria-label={localize('com_ui_create_skill')}
+ className={cn('h-[42px] w-[42px] shrink-0 p-0', !isDesktop && 'ml-auto')}
+ >
+ <Plus className="size-4" aria-hidden="true" />
+ </Button>
+ ) : null;
+ const filterField = (
+ <div
+ className={cn('flex items-center gap-2', isDesktop ? 'min-w-0 grow basis-0' : 'basis-full')}
+ >
+ <div className="relative min-w-0 flex-1">
+ <Search
+ className="pointer-events-none absolute left-3 top-1/2 z-[1] size-4 -translate-y-1/2 text-text-tertiary"
+ aria-hidden="true"
+ />
+ <Input
+ type="text"
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ placeholder={localize('com_ui_search_skills')}
+ aria-label={localize('com_ui_search_skills')}
+ className="h-[42px] bg-transparent pl-9"
+ />
+ </div>
+ <CategoryFilter options={categoryOptions} value={category} onChange={setCategory} />
+ </div>
+ );
+
return (
<OGDialog open={open} onOpenChange={onOpenChange}>
<OGDialogContent className="w-11/12 max-w-[900px] overflow-hidden rounded-2xl border-border-medium p-0 shadow-xl md:max-h-[92vh]">
<OGDialogDescription className="sr-only">
{localize('com_ui_skills_dialog_description')}
</OGDialogDescription>
- <div className="flex h-[80vh] max-h-[760px] flex-col">
- <div className="flex flex-col gap-3 border-b border-border-light px-6 pb-4 pt-5">
+ <div className="flex h-[80dvh] max-h-[760px] flex-col">
+ <div className="flex flex-col gap-3 border-b border-border-light px-4 pb-3 pt-4 md:px-6 md:pb-4 md:pt-5">
<div className="flex items-center gap-2 pr-10">
<OGDialogTitle className="text-base font-semibold text-text-primary">
{localize('com_ui_skills')}
</OGDialogTitle>
</div>
- <div className="flex items-center gap-2">
- {hasCreateAccess && (
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => setCreateOpen(true)}
- aria-label={localize('com_ui_create_skill')}
- className="h-[42px] w-[42px] shrink-0 p-0"
- >
- <Plus className="size-4" aria-hidden="true" />
- </Button>
- )}
- <div className="relative min-w-0 flex-1">
- <Search
- className="pointer-events-none absolute left-3 top-1/2 z-[1] size-4 -translate-y-1/2 text-text-tertiary"
- aria-hidden="true"
- />
- <Input
- type="text"
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- placeholder={localize('com_ui_search_skills')}
- aria-label={localize('com_ui_search_skills')}
- className="h-[42px] bg-transparent pl-9"
- />
- </div>
- <CategoryFilter options={categoryOptions} value={category} onChange={setCategory} />
+ {/* DOM order is the order each breakpoint reads in, so tab order follows
+ the eye: from md the row is create, field, radio, exactly as before;
+ below md the radio and the create button take the first line and the
+ field the second. `order-*` would have kept one subtree, but it left
+ desktop tabbing from the rightmost radio back to the create button. */}
+ <div className="flex flex-wrap items-center gap-2">
<Label id="skills-view-label" className="sr-only">
{localize('com_ui_skills_filter')}
</Label>
- <Radio
- options={viewOptions}
- value={view}
- onChange={(value) => {
- setView(value as SkillView);
- setCategory('all');
- }}
- className="flex-shrink-0 p-1"
- aria-labelledby="skills-view-label"
- />
+ {isDesktop ? (
+ <>
+ {createButton}
+ {filterField}
+ {viewRadio}
+ </>
+ ) : (
+ <>
+ {viewRadio}
+ {createButton}
+ {filterField}
+ </>
+ )}
</div>
</div>
- <div className="flex-1 overflow-y-auto px-6 py-4">
+ <div className="min-h-0 flex-1 overflow-y-auto px-4 py-3 md:px-6 md:py-4">
{isSkillsError && (
<div
role="alert"
diff --git a/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx b/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx
index d3cd5e0f7e..a4397c6018 100644
--- a/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ToolCard.tsx
@@ -105,9 +105,13 @@ function ToolCardImpl({
const DetailIcon = canConfigure ? Settings : Info;
return (
+ /* touch:h-36 with touch:pb-9 on the content: where a coarse pointer exists the
+ action cluster below is permanent rather than revealed on hover, so the card
+ owes it a strip of its own. Without that the last line of a three-line
+ description sits under the buttons for as long as the card is on screen. */
<div
className={cn(
- 'group relative flex h-32 w-full flex-col overflow-hidden rounded-2xl border',
+ 'group relative flex h-32 w-full flex-col overflow-hidden rounded-2xl border touch:h-36',
selected
? 'border-status-success bg-status-success/10 shadow-sm'
: 'border-border-light bg-transparent hover:border-border-medium hover:bg-surface-tertiary hover:shadow-sm',
@@ -118,7 +122,7 @@ function ToolCardImpl({
onClick={() => onToggle(item)}
aria-pressed={selected}
className={cn(
- 'flex h-full w-full cursor-pointer flex-col gap-2 rounded-2xl p-4 text-left',
+ 'flex h-full w-full cursor-pointer flex-col gap-2 rounded-2xl p-4 text-left touch:pb-9',
'focus:outline-none focus-visible:ring-2 focus-visible:ring-ring-primary',
)}
>
@@ -204,8 +208,8 @@ function ToolCardImpl({
}
className={cn(
'flex size-7 items-center justify-center rounded-lg text-text-secondary',
- 'opacity-0 transition duration-150 hover:bg-surface-hover hover:text-text-primary',
- 'group-focus-within:opacity-100 group-hover:opacity-100',
+ 'transition duration-150 hover:bg-surface-hover hover:text-text-primary',
+ 'group-focus-within:opacity-100 group-hover:opacity-100 no-touch:opacity-0',
'focus:outline-none focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring-primary',
)}
>
@@ -223,10 +227,11 @@ function ToolCardImpl({
aria-label={localize(isFavorited ? 'com_ui_unfavorite' : 'com_ui_favorite')}
className={cn(
'flex size-7 items-center justify-center rounded-lg text-text-secondary',
- 'opacity-0 transition duration-150 hover:bg-surface-hover hover:text-text-primary',
+ 'transition duration-150 hover:bg-surface-hover hover:text-text-primary',
'group-focus-within:opacity-100 group-hover:opacity-100',
'focus:outline-none focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring-primary',
- isFavorited && 'text-series-4 opacity-100 hover:text-series-4',
+ !isFavorited && 'no-touch:opacity-0',
+ isFavorited && 'text-series-4 hover:text-series-4',
)}
>
<Star className={cn('size-4', isFavorited && 'fill-current')} aria-hidden="true" />
diff --git a/client/src/components/SidePanel/Agents/Tools/ToolRow.tsx b/client/src/components/SidePanel/Agents/Tools/ToolRow.tsx
index ef8d3131f3..398b18fe19 100644
--- a/client/src/components/SidePanel/Agents/Tools/ToolRow.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ToolRow.tsx
@@ -75,8 +75,8 @@ function ToolRowImpl({ item, onInfo, onRemove }: Props) {
)}
<div
className={cn(
- 'flex shrink-0 items-center gap-0.5 opacity-0',
- 'group-focus-within:opacity-100 group-hover:opacity-100',
+ 'flex shrink-0 items-center gap-0.5',
+ 'group-focus-within:opacity-100 group-hover:opacity-100 no-touch:opacity-0',
)}
>
<Button
diff --git a/client/src/components/SidePanel/Agents/Tools/ToolsMarketplaceDialog.tsx b/client/src/components/SidePanel/Agents/Tools/ToolsMarketplaceDialog.tsx
index ea1ea38cff..6db685769a 100644
--- a/client/src/components/SidePanel/Agents/Tools/ToolsMarketplaceDialog.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ToolsMarketplaceDialog.tsx
@@ -8,6 +8,7 @@ import {
OGDialogTitle,
OGDialogContent,
OGDialogDescription,
+ useMediaQuery,
useToastContext,
} from '@librechat/client';
import type { AgentItem, AgentItemKind, ItemFilter } from './items/types';
@@ -21,11 +22,11 @@ import {
mcpServerIds,
} from './items/selectors';
import { useAgentFileEntries, useAgentItems, useUninstallToolCredentials } from './hooks';
+import MarketplaceSidebar, { MarketplaceFilterBar } from './MarketplaceSidebar';
import { requiresFileManagerRemoval } from './items/capabilities';
import AddMcpServerDialog from './ItemDialog/AddMcpServerDialog';
import { computeToggleAction } from './items/mutations';
import { useLocalize, useToolFavorites } from '~/hooks';
-import MarketplaceSidebar from './MarketplaceSidebar';
import MarketplaceCatalog from './MarketplaceCatalog';
import ItemDialog from './ItemDialog/ItemDialog';
import { applyFilter } from './items/filtering';
@@ -62,6 +63,9 @@ export default function ToolsMarketplaceDialog({
const [detailItem, setDetailItem] = useState<AgentItem | null>(null);
const [addMcpOpen, setAddMcpOpen] = useState(false);
+ /** The rail is md+; below it the same navigation renders as a chip row. */
+ const isDesktop = useMediaQuery('(min-width: 768px)');
+
const handleCreateNew = useCallback(
(createKind: 'mcp' | 'action') => {
if (createKind === 'mcp') {
@@ -218,23 +222,36 @@ export default function ToolsMarketplaceDialog({
return (
<OGDialog open={open} onOpenChange={onOpenChange}>
- <OGDialogContent className="w-11/12 max-w-[1200px] overflow-hidden rounded-2xl border-border-medium p-0 shadow-xl md:max-h-[92vh]">
+ {/* The body carries the height from md, the way it did before this change, so
+ the shell wraps it and the two cannot disagree: an explicit height on the
+ shell would leave its difference from the body's 840px ceiling as dead
+ space below the catalog on a tall screen. Below md the shell is the
+ full-bleed sheet and the body is capped to the same 100dvh, because its
+ `h-full` resolves against a grid area sized to the whole catalog. */}
+ <OGDialogContent className="h-[100dvh] max-h-[100dvh] w-full max-w-full overflow-hidden rounded-none border-border-medium p-0 shadow-xl md:h-auto md:max-h-[92vh] md:w-11/12 md:max-w-[1200px] md:rounded-2xl">
<OGDialogTitle className="sr-only">{localize('com_ui_tools_marketplace')}</OGDialogTitle>
<OGDialogDescription className="sr-only">
{localize('com_ui_tools_marketplace_description')}
</OGDialogDescription>
- <div className="flex h-[88vh] max-h-[840px]">
- <MarketplaceSidebar
- activeView={view}
- activeKind={kind}
- onSelectView={setView}
- onSelectKind={setKind}
- counts={counts}
- totalCount={catalog.length}
- onCreateNew={handleCreateNew}
- />
- <div className="flex min-w-0 flex-1 flex-col">
- <div className="flex items-center gap-2 px-6 py-4 pr-12">
+ {/* min-w-0: as a grid item of the dialog content, an `auto` minimum would
+ size this column to the chip row's min-content and overflow the viewport. */}
+ <div className="flex h-full max-h-[100dvh] min-w-0 flex-col md:h-[88vh] md:max-h-[840px] md:flex-row">
+ {isDesktop && (
+ <MarketplaceSidebar
+ activeView={view}
+ activeKind={kind}
+ onSelectView={setView}
+ onSelectKind={setKind}
+ counts={counts}
+ totalCount={catalog.length}
+ onCreateNew={handleCreateNew}
+ />
+ )}
+ <div className="flex min-h-0 min-w-0 flex-1 flex-col">
+ {/* md:pl-6, not md:px-6: a responsive variant is emitted after the base
+ utilities, so md:px-6 would reset the pr-12 that keeps the search
+ field clear of the dialog's close button. */}
+ <div className="flex items-center gap-2 px-4 py-3 pr-12 md:py-4 md:pl-6">
<div className="relative flex-1">
<Search
className="pointer-events-none absolute left-3 top-1/2 z-[1] size-4 -translate-y-1/2 text-text-tertiary"
@@ -250,7 +267,18 @@ export default function ToolsMarketplaceDialog({
/>
</div>
</div>
- <div className="flex-1 overflow-y-auto p-4">
+ {!isDesktop && (
+ <MarketplaceFilterBar
+ activeView={view}
+ activeKind={kind}
+ onSelectView={setView}
+ onSelectKind={setKind}
+ counts={counts}
+ totalCount={catalog.length}
+ onCreateNew={handleCreateNew}
+ />
+ )}
+ <div className="min-h-0 flex-1 overflow-y-auto p-3 md:p-4">
<MarketplaceCatalog
items={filtered}
selectedIds={selectedIds}
diff --git a/client/src/components/SidePanel/Agents/Tools/__tests__/SkillsDialog.spec.tsx b/client/src/components/SidePanel/Agents/Tools/__tests__/SkillsDialog.spec.tsx
index a9684d54c6..7c07a94b6d 100644
--- a/client/src/components/SidePanel/Agents/Tools/__tests__/SkillsDialog.spec.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/__tests__/SkillsDialog.spec.tsx
@@ -105,6 +105,9 @@ jest.mock('@librechat/client', () => ({
),
OGDialogTitle: ({ children }: { children: React.ReactNode }) => <h2>{children}</h2>,
OGDialogDescription: ({ children }: { children: React.ReactNode }) => <p>{children}</p>,
+ /** The header renders one DOM order per breakpoint; these cases are about
+ * pagination, so they run as the desktop one. */
+ useMediaQuery: () => true,
}));
function makeSkill(id: string, name: string): TSkillSummary {
diff --git a/client/src/components/SidePanel/Agents/Tools/__tests__/ToolCard.spec.tsx b/client/src/components/SidePanel/Agents/Tools/__tests__/ToolCard.spec.tsx
index 3c45b1abfa..2f71378500 100644
--- a/client/src/components/SidePanel/Agents/Tools/__tests__/ToolCard.spec.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/__tests__/ToolCard.spec.tsx
@@ -146,7 +146,6 @@ describe('ToolCard', () => {
);
const star = screen.getByRole('button', { name: 'com_ui_unfavorite' });
expect(star).toHaveAttribute('aria-pressed', 'true');
- expect(star).toHaveClass('opacity-100');
});
test('renders no star without an onToggleFavorite handler', () => {
diff --git a/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx b/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx
index 930150ff6b..0ddb103916 100644
--- a/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/__tests__/ToolsMarketplaceDialog.spec.tsx
@@ -8,6 +8,7 @@ const mockGetValues = jest.fn((_: string): unknown => []);
let mockWatchedTools: string[] = [];
let mockExecuteCode = false;
let mockMcpServersMap = new Map<string, object>();
+let mockIsDesktop = true;
jest.mock('react-hook-form', () => ({
useFormContext: () => ({
@@ -147,6 +148,7 @@ jest.mock('@librechat/client', () => {
? React.createElement(React.Fragment, null, children)
: React.createElement('button', { type: 'button' }, children),
VerifiedIcon: (props: SVGProps<SVGSVGElement>) => React.createElement('svg', props),
+ useMediaQuery: () => mockIsDesktop,
useToastContext: () => ({ showToast: jest.fn() }),
};
});
@@ -170,6 +172,7 @@ describe('ToolsMarketplaceDialog', () => {
mockMcpServersMap = new Map();
mockToggleFavorite.mockClear();
mockFavoriteKeys = new Set<string>();
+ mockIsDesktop = true;
mockFileEntries = { contextFiles: [], knowledgeFiles: [], codeFiles: [] };
});
@@ -397,4 +400,13 @@ describe('ToolsMarketplaceDialog', () => {
fireEvent.click(screen.getByRole('button', { name: /com_ui_tools_view_favorites/ }));
expect(screen.getByText('com_ui_tools_view_favorites_empty')).toBeInTheDocument();
});
+
+ test('below md the rail is replaced by a functional filter chip row', () => {
+ mockIsDesktop = false;
+ render(<ToolsMarketplaceDialog open onOpenChange={jest.fn()} agentId="a1" />);
+ expect(screen.getByRole('group', { name: 'com_ui_tools_marketplace' })).toBeInTheDocument();
+ expect(screen.queryByText('com_ui_tools_create_new')).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: /com_ui_tools_view_favorites/ }));
+ expect(screen.getByText('com_ui_tools_view_favorites_empty')).toBeInTheDocument();
+ });
});
diff --git a/e2e/specs/mock/scenarios/skills-picker-narrow-header.spec.ts b/e2e/specs/mock/scenarios/skills-picker-narrow-header.spec.ts
new file mode 100644
index 0000000000..4c77a6a74c
--- /dev/null
+++ b/e2e/specs/mock/scenarios/skills-picker-narrow-header.spec.ts
@@ -0,0 +1,214 @@
+import { devices, expect, test, type Locator, type Page } from '@playwright/test';
+import { openAgentBuilder } from '../agents.helpers';
+
+const TOLERANCE = 2;
+/** The dialog scales as it opens, so a box read on the first frame is smaller
+ * than the one the reader sees; poll until two reads agree. */
+const STABLE_EPSILON = 0.5;
+
+type Box = { x: number; y: number; width: number; height: number };
+
+async function settledBox(locator: Locator): Promise<Box> {
+ const last: { box: Box | null } = { box: null };
+ await expect
+ .poll(
+ async () => {
+ const box = await locator.boundingBox();
+ if (!box) {
+ return false;
+ }
+ const previous = last.box;
+ last.box = box;
+ return (
+ previous !== null &&
+ Math.abs(box.x - previous.x) < STABLE_EPSILON &&
+ Math.abs(box.y - previous.y) < STABLE_EPSILON &&
+ Math.abs(box.width - previous.width) < STABLE_EPSILON &&
+ Math.abs(box.height - previous.height) < STABLE_EPSILON
+ );
+ },
+ { timeout: 15000 },
+ )
+ .toBe(true);
+ return last.box!;
+}
+
+async function openSkillsPicker(page: Page): Promise<Locator> {
+ const form = await openAgentBuilder(page);
+ await form.getByRole('radio', { name: 'Selected', exact: true }).click();
+ /** With nothing selected the only trigger is the dashed empty-state card, and
+ * its accessible name carries the hint line as well as the label. */
+ const addSkill = form.getByRole('button', { name: /Add skill/ }).first();
+ await expect(addSkill).toBeVisible();
+ await addSkill.click();
+
+ const dialog = page.getByRole('dialog', { name: 'Skills', exact: true });
+ await expect(dialog).toBeVisible();
+ await settledBox(dialog);
+ return dialog;
+}
+
+function headerParts(dialog: Locator) {
+ return {
+ header: dialog
+ .getByRole('heading', { name: 'Skills', exact: true })
+ .locator('..')
+ .locator('..'),
+ view: dialog.getByRole('radiogroup', { name: 'Filter skills', exact: true }),
+ create: dialog.getByRole('button', { name: 'Create Skill', exact: true }),
+ filter: dialog.getByRole('textbox', { name: 'Search skills...', exact: true }),
+ };
+}
+
+async function expectNoHeaderOverflow(header: Locator): Promise<void> {
+ await expect
+ .poll(() => header.evaluate((element) => element.scrollWidth === element.clientWidth))
+ .toBe(true);
+}
+
+/** Every option has to sit inside the dialog, which is `overflow-hidden`: an
+ * option past its edge is not scrollable into view, it is simply gone. */
+async function expectOptionsInsideDialog(dialog: Locator, view: Locator): Promise<void> {
+ const dialogBox = await settledBox(dialog);
+ const options = view.getByRole('radio');
+ const count = await options.count();
+ expect(count).toBeGreaterThan(0);
+
+ for (let index = 0; index < count; index += 1) {
+ const optionBox = await options.nth(index).boundingBox();
+ expect(optionBox).not.toBeNull();
+ expect(optionBox!.x).toBeGreaterThanOrEqual(dialogBox.x - TOLERANCE);
+ expect(optionBox!.y).toBeGreaterThanOrEqual(dialogBox.y - TOLERANCE);
+ expect(optionBox!.x + optionBox!.width).toBeLessThanOrEqual(
+ dialogBox.x + dialogBox.width + TOLERANCE,
+ );
+ expect(optionBox!.y + optionBox!.height).toBeLessThanOrEqual(
+ dialogBox.y + dialogBox.height + TOLERANCE,
+ );
+ }
+}
+
+test.describe('skills picker header on a phone', () => {
+ test.use({ viewport: devices['Pixel 7'].viewport, hasTouch: true });
+
+ test('@scenario:skills-picker-header-splits-on-a-phone-viewport splits the skills header into two rows on a phone', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openSkillsPicker(page);
+ const { header, view, create, filter } = headerParts(dialog);
+ const row = view.locator('..');
+ const dialogBox = await settledBox(dialog);
+ const viewBox = await settledBox(view);
+ const createBox = await settledBox(create);
+ const filterBox = await settledBox(filter);
+ const rowBox = await settledBox(row);
+
+ expect(Math.abs(viewBox.y - createBox.y)).toBeLessThanOrEqual(TOLERANCE);
+ expect(createBox.x).toBeGreaterThan(viewBox.x);
+ expect(createBox.x + createBox.width).toBeLessThanOrEqual(
+ dialogBox.x + dialogBox.width + TOLERANCE,
+ );
+ /** `ml-auto` puts the create button on the row's right edge. */
+ expect(Math.abs(createBox.x + createBox.width - (rowBox.x + rowBox.width))).toBeLessThanOrEqual(
+ TOLERANCE,
+ );
+ expect(filterBox.y).toBeGreaterThan(viewBox.y + viewBox.height);
+ expect(Math.abs(filterBox.x - rowBox.x)).toBeLessThanOrEqual(TOLERANCE);
+ expect(Math.abs(filterBox.x + filterBox.width - (rowBox.x + rowBox.width))).toBeLessThanOrEqual(
+ TOLERANCE,
+ );
+
+ /** DOM order is tab order, so it has to read the way this layout does:
+ * radio, then create, then the field on the line below. */
+ await view.getByRole('radio', { name: 'All', exact: true }).focus();
+ await page.keyboard.press('Tab');
+ await expect(create).toBeFocused();
+ await page.keyboard.press('Tab');
+ await expect(filter).toBeFocused();
+ await expectNoHeaderOverflow(header);
+ });
+});
+
+test.describe('skills picker view options at narrow widths', () => {
+ test.use({ viewport: { width: 320, height: 800 }, hasTouch: true });
+
+ test('@scenario:skills-picker-view-options-stay-reachable-at-320px keeps every wrapped view option reachable at narrow widths', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openSkillsPicker(page);
+ const { header, view } = headerParts(dialog);
+
+ await expectOptionsInsideDialog(dialog, view);
+ await expectNoHeaderOverflow(header);
+
+ /** Narrower than the group's own 261px minimum, so the segments have to flow
+ * onto a second row rather than run past the dialog. */
+ await page.setViewportSize({ width: 280, height: 800 });
+ await expect(dialog).toBeVisible();
+ await expectOptionsInsideDialog(dialog, view);
+ await expectNoHeaderOverflow(header);
+
+ const favorites = view.getByRole('radio', { name: 'Favorites', exact: true });
+ await favorites.click();
+ await expect(favorites).toHaveAttribute('aria-checked', 'true');
+ await expect(
+ dialog.getByText("You haven't favorited anything yet", { exact: true }),
+ ).toBeVisible();
+
+ /** The moving indicator has to follow the checked segment onto the second
+ * row: it reproduced `inset-y-1` by assuming the group had no vertical
+ * padding, which left it 8px short of a padded group's segment. */
+ const indicator = view.locator(':scope > div').first();
+ await expect(indicator).toBeVisible();
+ await expect
+ .poll(async () => {
+ const indicatorBox = await indicator.boundingBox();
+ const checkedBox = await favorites.boundingBox();
+ if (!indicatorBox || !checkedBox) {
+ return false;
+ }
+ return (
+ Math.abs(indicatorBox.x - checkedBox.x) <= TOLERANCE &&
+ Math.abs(indicatorBox.y - checkedBox.y) <= TOLERANCE &&
+ Math.abs(indicatorBox.width - checkedBox.width) <= TOLERANCE &&
+ Math.abs(indicatorBox.height - checkedBox.height) <= TOLERANCE
+ );
+ })
+ .toBe(true);
+ });
+});
+
+/** The point of this one is that the rearrangement did not reach desktop, so it
+ * pins a desktop context instead of inheriting the run's project. */
+test.describe('skills picker header on a desktop viewport', () => {
+ test.use({ viewport: { width: 1280, height: 860 }, hasTouch: false, isMobile: false });
+
+ test('@scenario:skills-picker-header-is-one-row-on-desktop keeps desktop header controls on one row', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openSkillsPicker(page);
+ const { view, create, filter } = headerParts(dialog);
+ const createBox = await settledBox(create);
+ const filterBox = await settledBox(filter);
+ const viewBox = await settledBox(view);
+
+ expect(Math.abs(createBox.y - filterBox.y)).toBeLessThanOrEqual(TOLERANCE);
+ expect(Math.abs(filterBox.y - viewBox.y)).toBeLessThanOrEqual(TOLERANCE);
+ expect(createBox.x).toBeLessThan(filterBox.x);
+ expect(filterBox.x).toBeLessThan(viewBox.x);
+ expect(filterBox.width).toBeGreaterThan(createBox.width);
+ expect(filterBox.width).toBeGreaterThan(viewBox.width);
+
+ /** Tab order follows the eye here too: create, then the field, then the radio.
+ * A visual-only reorder left desktop tabbing from the rightmost radio back to
+ * the create button. */
+ await create.focus();
+ await page.keyboard.press('Tab');
+ await expect(filter).toBeFocused();
+ await page.keyboard.press('Tab');
+ await expect(view.getByRole('radio', { name: 'All', exact: true })).toBeFocused();
+ });
+});
diff --git a/e2e/specs/mock/scenarios/tool-library-small-screen.spec.ts b/e2e/specs/mock/scenarios/tool-library-small-screen.spec.ts
new file mode 100644
index 0000000000..99bf1ab735
--- /dev/null
+++ b/e2e/specs/mock/scenarios/tool-library-small-screen.spec.ts
@@ -0,0 +1,294 @@
+import { devices, expect, test } from '@playwright/test';
+import type { Locator, Page } from '@playwright/test';
+import { openAgentBuilder } from '../agents.helpers';
+
+const TOOL_LIBRARY = 'Tool Library';
+/** The dialog's own open animation moves it by a fraction of a pixel per frame,
+ * so geometry is only meaningful once two consecutive reads agree. */
+const STABLE_EPSILON = 0.5;
+const EDGE_TOLERANCE = 1;
+
+type Box = { x: number; y: number; width: number; height: number };
+
+async function settledBox(locator: Locator): Promise<Box> {
+ const last: { box: Box | null } = { box: null };
+ await expect
+ .poll(
+ async () => {
+ const box = await locator.boundingBox();
+ if (!box) {
+ return false;
+ }
+ const previous = last.box;
+ last.box = box;
+ return (
+ previous !== null &&
+ Math.abs(box.x - previous.x) < STABLE_EPSILON &&
+ Math.abs(box.y - previous.y) < STABLE_EPSILON &&
+ Math.abs(box.width - previous.width) < STABLE_EPSILON &&
+ Math.abs(box.height - previous.height) < STABLE_EPSILON
+ );
+ },
+ { timeout: 15000 },
+ )
+ .toBe(true);
+ return last.box!;
+}
+
+async function openToolLibrary(page: Page): Promise<Locator> {
+ const form = await openAgentBuilder(page);
+ await form.getByRole('button', { name: 'Add tools' }).click();
+ const dialog = page.getByRole('dialog', { name: TOOL_LIBRARY });
+ await expect(dialog).toBeVisible();
+ return dialog;
+}
+
+/** The actions fade over the shared motion duration, so the resting value is
+ * what matters, not the frame the assertion happened to land on. */
+async function expectOpacity(locator: Locator, value: string): Promise<void> {
+ await expect
+ .poll(() => locator.evaluate((element) => getComputedStyle(element).opacity), {
+ timeout: 10000,
+ })
+ .toBe(value);
+}
+
+async function blurAndMovePointer(page: Page): Promise<void> {
+ await page.evaluate(() => {
+ const active = document.activeElement;
+ if (active instanceof HTMLElement) {
+ active.blur();
+ }
+ });
+ await page.mouse.move(0, 0);
+}
+
+/** The dialog's close button is absolutely positioned over the search row, so the
+ * field has to stop short of it at every width. */
+async function expectClearOfCloseButton(page: Page, dialog: Locator): Promise<void> {
+ const close = page.getByRole('dialog').locator('button.absolute.right-4');
+ if ((await close.count()) === 0) {
+ return;
+ }
+ const field = await dialog.getByRole('textbox', { name: 'Search tools…' }).boundingBox();
+ const button = await close.first().boundingBox();
+ expect(field).not.toBeNull();
+ expect(button).not.toBeNull();
+ const sameRow = field!.y < button!.y + button!.height && button!.y < field!.y + field!.height;
+ expect(sameRow && field!.x + field!.width > button!.x).toBe(false);
+}
+
+test.describe('tool library on a touch viewport', () => {
+ test.use({ viewport: devices['Pixel 7'].viewport, hasTouch: true });
+
+ test('@scenario:tool-library-fills-a-phone-viewport the catalog stays within a phone viewport', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openToolLibrary(page);
+ const viewport = page.viewportSize();
+ expect(viewport).not.toBeNull();
+
+ const dialogBox = await settledBox(dialog);
+ expect(dialogBox.x).toBeLessThanOrEqual(EDGE_TOLERANCE);
+ expect(Math.abs(dialogBox.width - viewport!.width)).toBeLessThanOrEqual(EDGE_TOLERANCE);
+ await expect(dialog.locator('aside')).toHaveCount(0);
+ await expect(dialog.getByRole('group', { name: TOOL_LIBRARY })).toBeVisible();
+
+ /** The regression this pins: the dialog content is a grid, and without
+ * `min-w-0` its column sized to the chip row's 744px min-content, which
+ * pushed every card past the right edge of a 412px screen. */
+ const cards = dialog.getByRole('list', { name: TOOL_LIBRARY }).locator(':scope > li');
+ await expect(cards.first()).toBeVisible();
+ for (let index = 0; index < (await cards.count()); index += 1) {
+ const cardBox = await cards.nth(index).boundingBox();
+ expect(cardBox).not.toBeNull();
+ expect(cardBox!.x + cardBox!.width).toBeLessThanOrEqual(viewport!.width + EDGE_TOLERANCE);
+ }
+ expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(viewport!.width);
+
+ /** The chip row is this layout's primary navigation and only a finger reaches
+ * it, so every chip owes the shared 44px tap-target floor. */
+ const chips = dialog.getByRole('group', { name: TOOL_LIBRARY }).getByRole('button');
+ for (let index = 0; index < (await chips.count()); index += 1) {
+ const chipBox = await chips.nth(index).boundingBox();
+ expect(chipBox).not.toBeNull();
+ expect(chipBox!.height).toBeGreaterThanOrEqual(44);
+ }
+
+ /** The close button is absolutely positioned over this row, so the search
+ * field owes it clearance; a responsive padding utility silently reset it. */
+ await expectClearOfCloseButton(page, dialog);
+ });
+
+ test('@scenario:tool-library-filter-chips-narrow-the-catalog filter chips narrow the catalog and expose an empty favorites state', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openToolLibrary(page);
+ const cards = dialog.getByRole('list', { name: TOOL_LIBRARY }).locator(':scope > li');
+ const allChip = dialog.getByRole('button', { name: /^All(?:\s+\d+)?$/ });
+ await expect(allChip).toHaveAttribute('aria-pressed', 'true');
+ const allCount = await cards.count();
+
+ const mcpChip = dialog.getByRole('button', { name: /^MCP servers(?:\s+\d+)?$/ });
+ const mcpCount = Number.parseInt((await mcpChip.locator('span').last().innerText()).trim(), 10);
+ expect(mcpCount).toBeGreaterThan(0);
+ await mcpChip.click();
+ await expect.poll(() => cards.count()).toBe(mcpCount);
+ expect(await cards.count()).toBeLessThan(allCount);
+
+ await dialog.getByRole('button', { name: 'Favorites', exact: true }).click();
+ await expect(
+ dialog.getByText("You haven't favorited anything yet", { exact: true }),
+ ).toBeVisible();
+ await expect(cards).toHaveCount(0);
+ });
+
+ test('@scenario:tool-card-actions-are-visible-without-hover-on-touch card actions are visible without hover on a coarse pointer', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openToolLibrary(page);
+ await blurAndMovePointer(page);
+
+ const configure = dialog.getByRole('button', { name: 'Configure', exact: true }).first();
+ const favorite = dialog.getByRole('button', { name: 'Add to favorites', exact: true }).first();
+ await expect(configure).toBeVisible();
+ await expect(favorite).toBeVisible();
+ /** The reason the actions are visible: the hide rule is gated on the absence
+ * of a coarse pointer, not on the absence of hover. */
+ expect(await page.evaluate(() => matchMedia('(any-pointer: coarse)').matches)).toBe(true);
+ await expectOpacity(configure, '1');
+ await expectOpacity(favorite, '1');
+
+ /** The actions rest over the card's content, and on touch they never fade out,
+ * so the card has to keep its description clear of them. */
+ const overlap = await dialog
+ .locator('ul > li')
+ .first()
+ .evaluate((card) => {
+ const cluster = card.querySelector('div.absolute')?.getBoundingClientRect();
+ const paragraphs = Array.from(card.querySelectorAll('p'));
+ const description = paragraphs[paragraphs.length - 1]?.getBoundingClientRect();
+ if (!cluster || !description) {
+ return null;
+ }
+ return description.bottom > cluster.top && description.right > cluster.left;
+ });
+ expect(overlap).toBe(false);
+ });
+
+ test('@scenario:tool-row-actions-are-visible-without-hover-on-touch selected tool row actions stay visible without hover', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const form = await openAgentBuilder(page);
+ await form.getByRole('button', { name: 'Add tools' }).click();
+ const dialog = page.getByRole('dialog', { name: TOOL_LIBRARY });
+ await expect(dialog).toBeVisible();
+ await dialog.getByRole('textbox', { name: 'Search tools…' }).fill('Calculator');
+ const calculator = dialog.getByRole('button', { name: /^Calculator/ }).first();
+ await expect(calculator).toBeVisible();
+ await calculator.click();
+ await page.keyboard.press('Escape');
+ await expect(dialog).not.toBeVisible();
+
+ const row = form.locator('li').filter({ hasText: 'Calculator' }).first();
+ await expect(row).toBeVisible();
+ const details = row.getByRole('button', { name: 'Tool details', exact: true });
+ const remove = row.getByRole('button', { name: 'Remove from agent', exact: true });
+ /** The row hides the whole action cluster, so the wrapper is what the gate
+ * applies to; a visible button inside a transparent parent is still invisible. */
+ const actionWrapper = details.locator('xpath=..');
+ await expect(details).toBeVisible();
+ await expect(remove).toBeVisible();
+ await expectOpacity(actionWrapper, '1');
+ });
+});
+
+/** A mouse device, asserted as one: these scenarios describe what a pointer that
+ * can hover and cannot tap sees, so they pin their own context rather than
+ * inheriting the run's project, one of which is a touch phone. */
+test.describe('tool library on a mouse viewport', () => {
+ test.use({ viewport: { width: 1280, height: 860 }, hasTouch: false, isMobile: false });
+
+ test('@scenario:tool-card-actions-stay-hover-gated-with-a-mouse card actions remain hidden until hover on a mouse', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openToolLibrary(page);
+ await blurAndMovePointer(page);
+
+ const configure = dialog.getByRole('button', { name: 'Configure', exact: true }).first();
+ const card = configure.locator('xpath=ancestor::li[1]');
+ expect(await page.evaluate(() => matchMedia('(any-pointer: coarse)').matches)).toBe(false);
+ await expectOpacity(configure, '0');
+ await card.hover();
+ await expectOpacity(configure, '1');
+ });
+
+ test('@scenario:tool-card-action-is-revealed-by-keyboard-focus keyboard focus reveals a card action', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openToolLibrary(page);
+ await blurAndMovePointer(page);
+
+ const configure = dialog.getByRole('button', { name: 'Configure', exact: true }).first();
+ const card = configure.locator('xpath=ancestor::li[1]');
+ const cardButton = card.getByRole('button').first();
+ await cardButton.focus();
+ await cardButton.press('Tab');
+ await expect(configure).toBeFocused();
+ expect(await configure.evaluate((element) => element.matches(':focus-visible'))).toBe(true);
+ await expectOpacity(configure, '1');
+ });
+
+ test('@scenario:tool-library-keeps-its-rail-on-desktop the desktop rail contains kind entries', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openToolLibrary(page);
+ const rail = dialog.locator('aside');
+ await expect(rail).toBeVisible();
+ for (const name of ['All', 'Native', 'Tools', 'MCP servers', 'Actions']) {
+ await expect(
+ rail.getByRole('button', { name: new RegExp(`^${name}(?:\\s+\\d+)?$`) }),
+ ).toBeVisible();
+ }
+ await expect(dialog.getByRole('group', { name: TOOL_LIBRARY })).toHaveCount(0);
+ await expectClearOfCloseButton(page, dialog);
+ });
+});
+
+/** A narrow desktop window is below md as well, so it gets the chip row without
+ * getting a finger to drag it. */
+test.describe('tool library in a narrow mouse window', () => {
+ test.use({ viewport: { width: 520, height: 900 }, hasTouch: false, isMobile: false });
+
+ test('@scenario:tool-library-chips-stay-scrollable-with-a-mouse the overflowing chip row keeps a scrollbar without touch', async ({
+ page,
+ }) => {
+ test.setTimeout(120000);
+ const dialog = await openToolLibrary(page);
+ const chips = dialog.getByRole('group', { name: TOOL_LIBRARY });
+ await expect(chips).toBeVisible();
+ expect(await page.evaluate(() => matchMedia('(any-pointer: coarse)').matches)).toBe(false);
+
+ const row = await chips.evaluate((element) => ({
+ overflows: element.scrollWidth > element.clientWidth,
+ scrollbar: element.offsetHeight - element.clientHeight,
+ }));
+ expect(row.overflows).toBe(true);
+ /** The affordance itself: with the scrollbar hidden this is 0 and a wheel
+ * scrolls the page instead, so the trailing views cannot be reached. */
+ expect(row.scrollbar).toBeGreaterThan(0);
+
+ /** And it does scroll: the last view has to become reachable. */
+ const favorites = chips.getByRole('button', { name: 'Favorites', exact: true });
+ await favorites.scrollIntoViewIfNeeded();
+ await favorites.click();
+ await expect(favorites).toHaveAttribute('aria-pressed', 'true');
+ });
+});
diff --git a/packages/client/src/components/Radio.tsx b/packages/client/src/components/Radio.tsx
index ed7e2a9029..0383fbf5c8 100644
--- a/packages/client/src/components/Radio.tsx
+++ b/packages/client/src/components/Radio.tsx
@@ -102,14 +102,21 @@ const Radio: React.NamedExoticComponent<RadioProps> = memo(function Radio({
return;
}
// Wrapped, the indicator also has to move vertically, so it carries its own
- // height rather than stretching between the container's insets. INDICATOR_INSET
- // reproduces the `inset-y-1` of the single-row default exactly, so switching a
- // group to `wrap` does not change how it looks on a row that still fits.
+ // height rather than stretching between the container's insets, and it has to
+ // reproduce what `inset-y-1` produces for a row that still fits.
+ //
+ // That geometry depends on the container's own vertical padding, because the
+ // insets resolve against its padding box: a group styled `px-1` gets a pill
+ // inset inside its segment, while one styled `p-1` gets a pill that covers the
+ // segment exactly. The first row's `offsetTop` is that padding, so measuring it
+ // keeps both cases identical when a group turns `wrap` on; assuming zero shrank
+ // a padded group's pill by 8px and left it floating inside the segment.
+ const rowInset = buttonRefs.current[0]?.offsetTop ?? 0;
setBackgroundStyle({
width: `${selectedButton.offsetWidth}px`,
- height: `${selectedButton.offsetHeight - INDICATOR_INSET * 2}px`,
+ height: `${selectedButton.offsetHeight + rowInset * 2 - INDICATOR_INSET * 2}px`,
transform: `translate(${selectedButton.offsetLeft}px, ${
- selectedButton.offsetTop + INDICATOR_INSET
+ selectedButton.offsetTop - rowInset + INDICATOR_INSET
}px)`,
});
}, [currentValue, options, wrap]);
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index 741d381e10..084d12fcd3 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -68,6 +68,9 @@ describe('LibreChat Tailwind preset', () => {
/** `any-pointer`, not `pointer`: the floor has to apply to a 2-in-1's
* touchscreen while its trackpad is the primary device and reports `fine`. */
expect(variants.touch).toBe('@media (any-pointer: coarse)');
+ /** Its inverse gates hidden-until-hover states, so a 2-in-1's finger user —
+ * whose trackpad makes `(hover: hover)` true — never loses the control. */
+ expect(variants['no-touch']).toBe('@media not all and (any-pointer: coarse)');
expect(variants['high-contrast']).toBe('html.high-contrast &');
});
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index 71182d8335..0950bcc27d 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -70,6 +70,19 @@ module.exports = {
* control at all — so the two queries differ on purpose.
*/
addVariant('touch', '@media (any-pointer: coarse)');
+
+ /**
+ * The inverse of `touch`, for hiding something until hover: hover-gating
+ * alone strands the finger user of a 2-in-1, because `(hover: hover)` is
+ * true there — it describes the trackpad — while the touchscreen sits
+ * right next to it. Gating the hidden state on the absence of any coarse
+ * pointer keeps a reveal-on-hover affordance from ever hiding a control
+ * that only a tap can reach.
+ *
+ * `not all and`, not the Media Queries Level 4 `not (...)`, because
+ * lightningcss lowers this for the production build's browser targets.
+ */
+ addVariant('no-touch', '@media not all and (any-pointer: coarse)');
},
],
};