🚪 fix: Gate Artifacts Toggle on Agent Capability Flag (#13665)

* fix: hide artifacts toggle when capability is disabled

The artifacts badge ignored the agent capabilities config, so a pinned
toggle stayed visible after the artifacts capability was turned off.
Gate the component on artifactsEnabled via useAgentCapabilities, matching
how Skills, FileSearch and CodeInterpreter already handle their capability.

* style: fix import order in Artifacts.tsx

* style: Sort mutation type imports

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
Serhii Zghama 2026-06-20 22:52:36 +07:00 committed by GitHub
parent dfc1178031
commit 8824e8f918
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,10 +1,10 @@
import React, { memo, useState, useCallback, useMemo, useEffect } from 'react';
import * as Ariakit from '@ariakit/react';
import { CheckboxButton } from '@librechat/client';
import { ArtifactModes } from 'librechat-data-provider';
import { WandSparkles, ChevronDown } from 'lucide-react';
import { ArtifactModes, defaultAgentCapabilities } from 'librechat-data-provider';
import { useLocalize, useAgentCapabilities } from '~/hooks';
import { useBadgeRowContext } from '~/Providers';
import { useLocalize } from '~/hooks';
import { cn } from '~/utils';
interface ArtifactsToggleState {
@ -17,6 +17,10 @@ function Artifacts() {
const context = useBadgeRowContext();
const { toggleState, debouncedChange, isPinned } = context?.artifacts ?? {};
const { artifactsEnabled } = useAgentCapabilities(
context?.agentsConfig?.capabilities ?? defaultAgentCapabilities,
);
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [isButtonExpanded, setIsButtonExpanded] = useState(false);
@ -73,6 +77,10 @@ function Artifacts() {
}
}, [isCustomEnabled, debouncedChange]);
if (!artifactsEnabled) {
return null;
}
if (!isEnabled && !isPinned) {
return null;
}