feat(webui): unify the Apps catalog (#6700)

* feat(webui): unify the Apps catalog

* fix(webui): serve all channel branding locally

* fix(webui): refine Apps navigation and sidebar
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-18 15:05:57 +08:00
1 parent 5997a714f2
commit 2b232c9133
89 files changed
+1576 -1024

No files matched your search

+42 -14
View File
@@ -3,13 +3,15 @@ import { useCallback, useEffect, useRef, useState, type ReactNode } from "react"
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogLayoutContext, DialogTitle } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import type { SettingsExitGuard, SettingsFocusTarget } from "@/components/settings/contracts";
import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts";
import { isAppsSection, isCapabilitySection, type AppsSectionKey, type SettingsSectionKey } from "@/components/settings/contracts";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SettingsFeature } from "@/components/settings/shared/SettingsFeature";
import type { EditCompletion } from "@/components/settings/shared/useEditCompletion";
import { SharedProxySetupDialog } from "@/components/settings/shared/SharedProxySetupDialog";
import { SettingsSectionSkeleton } from "@/components/settings/shared/SettingsSectionSkeleton";
import { SkillsCatalogSettings } from "@/components/settings/SkillsCatalogSettings";
import { SkillsCatalogPage, useSkillsCatalogSearch } from "@/components/settings/SkillsCatalogSettings";
import { CatalogSearch } from "@/components/settings/shared/CatalogToolbar";
import { ImageGenerationSettings } from "@/components/settings/capabilities/ImageGenerationSettings";
import { AdvancedSettings } from "@/components/settings/capabilities/SecuritySettings";
import { TranscriptionSettings } from "@/components/settings/capabilities/TranscriptionSettings";
@@ -99,6 +101,8 @@ export function SettingsPage({
const { client, webuiCapabilities } = useClient();
const [dialogLayoutAnchor, setDialogLayoutAnchor] = useState<HTMLDivElement | null>(null);
const [mcpSetupName, setMcpSetupName] = useState<string | null>(null);
const [channelsQuery, setChannelsQuery] = useState("");
const skillsSearch = useSkillsCatalogSearch();
const presetDeletedCallback = useRef<(() => void) | null>(null);
const [providerPanel, setProviderPanel] = useState<ProviderSettingsEntry | null>(null);
const [proxySetupOpen, setProxySetupOpen] = useState(false);
@@ -494,6 +498,7 @@ export function SettingsPage({
case "channels":
return (
<ChannelsSettings
query={channelsQuery}
onBeforeCloseChange={registerChannelCompletion}
onConfigureMcp={(name) => {
setMcpSetupName(name);
@@ -519,7 +524,6 @@ export function SettingsPage({
);
case "apps":
return (
<div className="settings-stack">
<AppsCatalogPage
onConfigureProxy={configureProxy}
setupName={mcpSetupName}
@@ -581,7 +585,6 @@ export function SettingsPage({
onRestart={restartViaSettingsSurface}
isRestarting={restartInProgress}
/>
</div>
);
case "automations":
return (
@@ -612,12 +615,24 @@ export function SettingsPage({
</div>
);
case "skills":
return <SkillsCatalogSettings skills={skills} loading={skillsLoading} error={skillsError} />;
return <SkillsCatalogPage skills={skills} loading={skillsLoading} error={skillsError} searchState={skillsSearch} />;
default:
return renderSettingsSection(section, embedded);
}
};
// Appearance reads only browser-local preferences, not the gateway settings snapshot.
const appsSection = isAppsSection(activeSection);
const catalogSearch = activeSection === "skills" ? skillsSearch.search
: activeSection === "channels" ? {
type: "search",
value: channelsQuery,
onChange: (event: React.ChangeEvent<HTMLInputElement>) => setChannelsQuery(event.target.value),
placeholder: t("settings.channels.search"),
} : activeSection === "apps" ? {
value: systemState.appsQuery,
onChange: (event: React.ChangeEvent<HTMLInputElement>) => systemState.setAppsQuery(event.target.value),
placeholder: t("settings.apps.searchPlaceholder"),
} : null;
const localSection = activeSection === "appearance";
const sectionReady = localSection || settings !== null || activeSection === "skills" || activeSection === "apps"
|| activeSection === "channels" || activeSection === "automations";
@@ -731,12 +746,12 @@ export function SettingsPage({
<div
className={cn(
"min-w-0 flex-1 bg-settings-canvas [scrollbar-gutter:stable]",
"overflow-y-auto",
"min-w-0 flex-1 overflow-y-auto bg-settings-canvas [scrollbar-gutter:stable]",
!showSidebar && (appsSection || activeSection === "automations") && "sm:[scrollbar-gutter:stable_both-edges]",
)}
>
<div
key={activeSection}
key={appsSection ? "apps" : activeSection}
data-testid="settings-section-transition"
ref={setDialogLayoutAnchor}
data-settings-section={activeSection}
@@ -747,7 +762,6 @@ export function SettingsPage({
"settings-grid",
activeSection === "about" && "flex min-h-full flex-col",
!showSidebar && "settings-feature-page",
!showSidebar && activeSection === "automations" && "settings-automations-grid",
hostChromeInset && "pt-[4.25rem] sm:pt-[4.25rem] lg:pt-[4.75rem]",
)}
>
@@ -762,7 +776,7 @@ export function SettingsPage({
{t("settings.backToChat")}
</button>
{activeSection !== "automations" ? <h1 className="text-[24px] font-normal leading-tight tracking-normal text-foreground sm:text-[28px]">
{t(`settings.nav.${activeSection}`, {
{t(`settings.nav.${appsSection ? "apps" : activeSection}`, {
defaultValue: standaloneSectionTitle(activeSection),
})}
</h1> : null}
@@ -781,17 +795,31 @@ export function SettingsPage({
) : sectionReady ? (
<div
className={cn(
"settings-stack",
appsSection ? "apps-catalog-layout" : "settings-stack",
activeSection === "about" && "flex flex-1 flex-col",
activeSection === "channels" &&
"flex min-h-0 flex-1 flex-col xl:overflow-hidden",
)}
>
{error && (!localSection || settings !== null) ? (
<div className="rounded-floating border border-destructive/20 bg-destructive/5 px-4 py-3 text-[13px] text-destructive">
<div className="col-span-full rounded-floating border border-destructive/20 bg-destructive/5 px-4 py-3 text-[13px] text-destructive">
{error}
</div>
) : null}
{appsSection && !showSidebar ? (
<SegmentedControl<AppsSectionKey>
value={activeSection}
onChange={selectSection}
ariaLabel={t("settings.nav.apps")}
className="catalog-tabs min-h-9 shrink-0 rounded-control"
itemClassName="min-h-7 rounded-compact px-3 py-0"
indicatorClassName="rounded-compact"
options={[
{ value: "apps", label: t("settings.apps.featured") },
{ value: "skills", label: t("settings.nav.skills") },
{ value: "channels", label: t("settings.nav.channels") },
]}
/>
) : null}
{catalogSearch && <CatalogSearch {...catalogSearch} />}
{renderSection(isCapabilitySection(activeSection) ? "capabilities" : activeSection)}
</div>
) : null}
@@ -7,7 +7,6 @@ import {
KeyRound,
PowerOff,
RefreshCw,
Search,
Terminal,
Trash2,
} from "lucide-react";
@@ -26,33 +25,55 @@ import {
import { Button } from "@/components/ui/button";
import { Disclosure } from "@/components/ui/disclosure";
import { ExpandableText } from "@/components/ui/expandable-text";
import { SearchInput } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { CatalogControls, CatalogFilter, CatalogToolbar } from "@/components/settings/shared/CatalogToolbar";
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
import { SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
import { MarketplaceProviderFilter, SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { ToggleButton } from "@/components/ui/toggle-button";
import { deleteSkill, fetchSkillDetail, updateSkillEnabled } from "@/lib/api";
import { notifySkillsChanged, requestSkillsRefresh } from "@/lib/skill-events";
import type { SkillDetail, SkillSummary } from "@/lib/types";
import type { MarketplaceProvider, SkillDetail, SkillSummary } from "@/lib/types";
import { cn } from "@/lib/utils";
import { useClient } from "@/providers/ClientProvider";
export function SkillsCatalogSettings({ skills, loading = false, error = false }: {
export function useSkillsCatalogSearch() {
const { t } = useTranslation();
const [view, setView] = useState<"installed" | "discover">("installed");
const [installedQuery, setInstalledQuery] = useState("");
const [marketplaceQuery, setMarketplaceQuery] = useState("");
return { view, setView, search: {
value: view === "installed" ? installedQuery : marketplaceQuery,
onChange: (event: React.ChangeEvent<HTMLInputElement>) =>
(view === "installed" ? setInstalledQuery : setMarketplaceQuery)(event.target.value),
placeholder: t(view === "installed" ? "settings.skills.searchInstalled" : "settings.skills.marketplaceSearchPlaceholder"),
} };
}
type SkillsCatalogProps = {
skills: SkillSummary[];
loading?: boolean;
error?: boolean;
};
export function SkillsCatalogSettings(props: SkillsCatalogProps) {
const searchState = useSkillsCatalogSearch();
return <SkillsCatalogPage {...props} searchState={searchState} showSearch />;
}
export function SkillsCatalogPage({ skills, loading = false, error = false, searchState, showSearch }: SkillsCatalogProps & {
searchState: ReturnType<typeof useSkillsCatalogSearch>;
showSearch?: boolean;
}) {
const { t } = useTranslation();
const { view, setView, search } = searchState;
const [selectedSkill, setSelectedSkill] = useState<SkillSummary | null>(null);
const [view, setView] = useState<"installed" | "discover">("installed");
const [installingSkill, setInstallingSkill] = useState("");
const [installedQuery, setInstalledQuery] = useState("");
const [marketplaceProvider, setMarketplaceProvider] = useState<MarketplaceProvider>("all");
const [installedFilter, setInstalledFilter] = useState<"all" | "enabled" | "disabled">(
"all",
);
const normalizedQuery = installedQuery.trim().toLowerCase();
const normalizedQuery = view === "installed" ? search.value.trim().toLowerCase() : "";
const filteredSkills = skills.filter((skill) => {
const enabled = skill.enabled !== false;
if (installedFilter === "enabled" && !enabled) return false;
@@ -85,73 +106,29 @@ export function SkillsCatalogSettings({ skills, loading = false, error = false }
const disabledCount = skills.filter((skill) => skill.enabled === false).length;
return (
<div className="settings-stack">
<SegmentedControl
value={view}
mode="tabs"
ariaLabel={t("settings.skills.views", { defaultValue: "Skills views" })}
className="w-fit text-[13px]"
itemClassName="px-3.5"
options={[
{
value: "installed",
label: t("settings.skills.installedTab", { defaultValue: "Installed" }),
},
{
value: "discover",
label: t("settings.skills.discoverTab", { defaultValue: "Discover" }),
},
]}
onChange={setView}
/>
{view === "installed" ? (
<section className="overflow-hidden rounded-panel bg-settings-surface">
<div className="flex flex-col gap-3 px-4 pb-2 pt-4 sm:flex-row sm:items-center sm:justify-between">
<div className="relative w-full sm:max-w-[320px]">
<Search
className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
aria-hidden
/>
<SearchInput
value={installedQuery}
onChange={(event) => setInstalledQuery(event.target.value)}
placeholder={t("settings.skills.searchInstalled", {
defaultValue: "Search installed skills",
})}
aria-label={t("settings.skills.searchInstalled", {
defaultValue: "Search installed skills",
})}
className="h-9 bg-background pl-9 text-[13px]"
/>
</div>
<SegmentedControl
value={installedFilter}
className="sm:w-auto"
itemClassName="px-2.5 text-[11px]"
<div className="catalog-section">
<CatalogToolbar search={showSearch ? search : undefined}>
<CatalogControls>
<CatalogFilter label={t("settings.skills.views")} value={view} onChange={setView}
options={[
{ value: "installed", label: t("settings.skills.installedTab") },
{ value: "discover", label: t("settings.skills.discoverTab") },
]} />
{view === "installed" ? (
<CatalogFilter label={t("settings.apps.statusFilter")} value={installedFilter} onChange={setInstalledFilter}
options={([
["all", t("settings.skills.filterAll", { defaultValue: "All" }), skills.length],
[
"enabled",
t("settings.skills.filterEnabled", { defaultValue: "Enabled" }),
skills.length - disabledCount,
],
[
"disabled",
t("settings.skills.filterDisabled", { defaultValue: "Disabled" }),
disabledCount,
],
["all", t("settings.skills.filterAll"), skills.length],
["enabled", t("settings.skills.filterEnabled"), skills.length - disabledCount],
["disabled", t("settings.skills.filterDisabled"), disabledCount],
] as const).map(([value, label, count]) => ({
value,
label: (
<>
{label} <span className="ml-0.5 tabular-nums opacity-65">{loading || error ? "—" : count}</span>
</>
),
}))}
onChange={setInstalledFilter}
/>
</div>
label: <><span>{label}</span><span className="tabular-nums opacity-65">{loading || error ? "—" : count}</span></>,
}))} />
) : <MarketplaceProviderFilter value={marketplaceProvider} onChange={setMarketplaceProvider} />}
</CatalogControls>
</CatalogToolbar>
{view === "installed" ? (
<section className="overflow-hidden rounded-panel bg-settings-surface pt-3">
{loading ? (
<CatalogSkeleton label={t("settings.skills.loading")} layout="skills" />
) : error ? (
@@ -193,6 +170,8 @@ export function SkillsCatalogSettings({ skills, loading = false, error = false }
</section>
) : (
<SkillsMarketplace
query={search.value}
provider={marketplaceProvider}
installedSkills={skills}
installing={installingSkill}
onInstallingChange={setInstallingSkill}
@@ -5,7 +5,6 @@ import {
ExternalLink,
Loader2,
PackagePlus,
Search,
ShieldAlert,
} from "lucide-react";
import { useTranslation } from "react-i18next";
@@ -22,8 +21,7 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { SearchInput } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { CatalogFilter } from "@/components/settings/shared/CatalogToolbar";
import {
ApiError,
fetchMarketplaceSkillTrends,
@@ -41,17 +39,20 @@ import { cn } from "@/lib/utils";
import { useClient } from "@/providers/ClientProvider";
export function SkillsMarketplace({
query,
provider,
installedSkills,
installing,
onInstallingChange,
}: {
query: string;
provider: MarketplaceProvider;
installedSkills: SkillSummary[];
installing: string;
onInstallingChange: (skillId: string) => void;
}) {
const { client, getToken } = useClient();
const { t } = useTranslation();
const [query, setQuery] = useState("");
const [results, setResults] = useState<MarketplaceSkillSummary[]>([]);
const [trending, setTrending] = useState<MarketplaceSkillSummary[]>([]);
const [trends, setTrends] = useState<Record<string, number[]>>({});
@@ -59,7 +60,6 @@ export function SkillsMarketplace({
const [trendingLoading, setTrendingLoading] = useState(true);
const [error, setError] = useState("");
const [installError, setInstallError] = useState("");
const [provider, setProvider] = useState<MarketplaceProvider>("all");
const [selected, setSelected] = useState<MarketplaceSkillSummary | null>(null);
const installTrigger = useRef<HTMLElement | null>(null);
const selectSkill = (skill: MarketplaceSkillSummary) => {
@@ -196,38 +196,8 @@ export function SkillsMarketplace({
};
return (
<section className="space-y-4">
<div className="space-y-2">
<div className="relative">
<Search
className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
aria-hidden
/>
<SearchInput
value={query}
onChange={(event) => setQuery(event.target.value)}
placeholder={t("settings.skills.marketplaceSearchPlaceholder", {
defaultValue: "Search skills",
})}
aria-label={t("settings.skills.marketplaceSearchLabel", {
defaultValue: "Search skills",
})}
className="h-11 rounded-full bg-settings-surface pl-9"
/>
{loading ? (
<span
className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground"
role="status"
aria-label={t("settings.skills.marketplaceSearching", {
defaultValue: "Searching",
})}
>
<Loader2 className="h-4 w-4 animate-spin motion-reduce:animate-none" aria-hidden />
</span>
) : null}
</div>
<ProviderFilter value={provider} onChange={setProvider} />
</div>
<section className="grid gap-4">
{loading ? <span className="sr-only" role="status">{t("settings.skills.marketplaceSearching")}</span> : null}
{error || installError ? (
<div role="alert" className="rounded-control bg-destructive/10 px-3 py-2.5 text-[13px] text-destructive">
@@ -361,7 +331,7 @@ export function SkillsMarketplace({
);
}
function ProviderFilter({
export function MarketplaceProviderFilter({
value,
onChange,
}: {
@@ -371,24 +341,12 @@ function ProviderFilter({
const { t } = useTranslation();
const providers: MarketplaceProvider[] = ["all", "skills_sh", "skillhub"];
return (
<SegmentedControl
<CatalogFilter
value={value}
mode="tabs"
ariaLabel={t("settings.skills.marketplaceProviderFilter", {
defaultValue: "Skill source",
})}
className="w-fit bg-settings-surface"
itemClassName="inline-flex h-7 items-center gap-1.5"
label={t("settings.skills.marketplaceProviderFilter")}
options={providers.map((provider) => ({
value: provider,
label: (
<>
{provider !== "all" ? <ProviderDot provider={provider} /> : null}
{provider === "all"
? t("settings.skills.marketplaceProviderAll", { defaultValue: "All" })
: providerLabel(provider)}
</>
),
label: provider === "all" ? t("settings.skills.marketplaceProviderAll") : providerLabel(provider),
}))}
onChange={onChange}
/>
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from "react";
import { useEffect, useId, useRef, useState } from "react";
import { Download, Loader2, RotateCcw } from "lucide-react";
import { useTranslation } from "react-i18next";
@@ -16,6 +16,8 @@ import { Button } from "@/components/ui/button";
import type { NanobotFeatureInfo } from "@/lib/types";
import { cn } from "@/lib/utils";
const CHANNEL_ACTION_CLASS = "relative h-7 w-[38px] min-w-0 shrink-0 rounded-full border-border/70 bg-background p-0 after:absolute after:left-1/2 after:top-1/2 after:h-11 after:w-11 after:-translate-x-1/2 after:-translate-y-1/2 after:content-['']";
export function ChannelCatalogRow({
feature,
showBrandLogos,
@@ -28,7 +30,7 @@ export function ChannelCatalogRow({
}: {
feature: NanobotFeatureInfo;
showBrandLogos: boolean;
onSelect: (connect?: boolean) => void;
onSelect: (trigger: HTMLButtonElement | null, connect?: boolean) => void;
actionKey: string | null;
restartRequired?: boolean;
onAction: ChannelFeatureAction;
@@ -47,6 +49,9 @@ export function ChannelCatalogRow({
const actionsDisabled = restartRequired || isRestarting;
const showInstallRestartHint = feature.install_supported && actionsDisabled;
const installButtonRef = useRef<HTMLButtonElement | null>(null);
const toggleRef = useRef<HTMLButtonElement | null>(null);
const statusId = useId();
const failed = feature.runtime_status === "failed";
const [installHint, setInstallHint] = useState(false);
useEffect(() => {
@@ -55,17 +60,18 @@ export function ChannelCatalogRow({
return () => window.clearTimeout(timeout);
}, [installHint]);
const pointToInstall = () => {
setInstallHint(true);
installButtonRef.current?.focus();
};
const channelIdentity = (
<>
<ChannelLogo feature={feature} showBrandLogos={showBrandLogos} />
<div className="min-w-0 flex-1">
<h3 className="truncate text-[14px] font-semibold leading-5 text-foreground">
<h3 className="text-[14px] font-semibold leading-5 text-foreground [overflow-wrap:anywhere]">
{displayName}
</h3>
{failed ? (
<div id={statusId} className="mt-0.5">
<ChannelStatusBadge status="failed">{channelStatusLabel(feature, tx)}</ChannelStatusBadge>
</div>
) : null}
</div>
</>
);
@@ -86,22 +92,23 @@ export function ChannelCatalogRow({
name: displayName,
defaultValue: "View {{name}} settings",
})}
aria-haspopup="dialog"
aria-haspopup={feature.installed ? "dialog" : undefined}
aria-describedby={failed ? statusId : undefined}
disabled={actionsDisabled}
onClick={() => feature.installed ? onSelect() : pointToInstall()}
onClick={(event) => {
if (feature.installed) {
onSelect(event.currentTarget);
} else {
setInstallHint(true);
if (event.detail === 0) installButtonRef.current?.focus({ preventScroll: true });
}
}}
className="group flex min-w-0 flex-1 select-none items-center gap-3 rounded-control text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border/80"
>
{channelIdentity}
</button>
)}
{feature.runtime_status === "failed" ? (
<div className="min-w-0 shrink truncate">
<ChannelStatusBadge status={feature.runtime_status}>
{channelStatusLabel(feature, tx)}
</ChannelStatusBadge>
</div>
) : null}
<div className="flex w-16 shrink-0 items-center justify-center">
<div className="flex w-11 shrink-0 items-center justify-center">
{!feature.installed ? (
<HoverHint enabled={showInstallRestartHint}
content={t(isRestarting ? "app.system.restarting" : "settings.channels.restartBeforeInstall")}>
@@ -111,7 +118,7 @@ export function ChannelCatalogRow({
className="inline-flex rounded-full outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2">
<Button ref={installButtonRef} type="button" variant="outline" size="icon"
className={cn(
"h-[22px] w-[38px] min-w-0 shrink-0 rounded-full border-border/70 bg-background p-0",
CHANNEL_ACTION_CLASS,
installHint && "border-[#2997FF]/60 bg-[#2997FF]/10 text-[#087FE7] ring-2 ring-[#2997FF]/25 ring-offset-2",
)}
disabled={actionsDisabled || anyActionBusy || !feature.install_supported}
@@ -130,7 +137,7 @@ export function ChannelCatalogRow({
) : feature.restart_pending ? (
<HoverHint content={t("settings.channels.restartRequired")}>
<Button type="button" variant="outline" size="icon"
className="h-[22px] w-[38px] min-w-0 shrink-0 rounded-full border-border/70 bg-background p-0"
className={CHANNEL_ACTION_CLASS}
aria-label={t("app.system.restart")}
aria-busy={isRestarting}
disabled={isRestarting || anyActionBusy || !onRestart}
@@ -141,12 +148,12 @@ export function ChannelCatalogRow({
</Button>
</HoverHint>
) : (
<ToggleButton checked={checked}
<ToggleButton ref={toggleRef} checked={checked}
label={checked ? tx("settings.values.on", "On") : tx("settings.values.off", "Off")}
disabled={alwaysEnabled || actionsDisabled || anyActionBusy}
ariaLabel={t("settings.channels.toggleChannel", { name: displayName, defaultValue: "{{name}} channel" })}
onChange={(enabled) => {
if (enabled && feature.configured === false) onSelect(true);
if (enabled && feature.configured === false) onSelect(toggleRef.current, true);
else onAction(enabled ? "enable" : "disable", feature.name);
}} />
)}
@@ -1,5 +1,5 @@
import i18n from "i18next";
import { useMemo, type ReactNode } from "react";
import type { ReactNode } from "react";
import { useTranslation } from "react-i18next";
import {
@@ -19,7 +19,6 @@ import type {
import { channelValidationMessage } from "@/components/settings/channels/validationMessages";
import { useLogoFallback } from "@/hooks/useLogoFallback";
import { normalizeLocale } from "@/i18n/config";
import { logoFallbackUrls } from "@/lib/provider-brand";
import type { ChannelRuntimeStatus, NanobotFeatureInfo } from "@/lib/types";
import { cn } from "@/lib/utils";
@@ -154,23 +153,17 @@ export function ChannelLogo({
?? channelUiPresentation(feature.name);
const initials = presentation?.initials ?? feature.display_name.slice(0, 2).toUpperCase();
const Icon = presentation?.icon;
const logoUrls = useMemo(() => {
const fallbackUrls = logoFallbackUrls(presentation?.logoFallbackUrl ?? presentation?.logoUrl);
return presentation?.logoUrl && presentation.logoFallbackUrl
? [...new Set([presentation.logoUrl, ...fallbackUrls])]
: fallbackUrls;
}, [presentation?.logoUrl, presentation?.logoFallbackUrl]);
const { logoUrl, logoLoaded, onLogoError, onLogoLoad } = useLogoFallback(logoUrls);
const showRemoteLogo = showBrandLogos && Boolean(logoUrl);
const showLoadedLogo = showRemoteLogo && logoLoaded;
const isLogoTile = presentation?.logoLayout === "tile" && logoUrl === presentation.logoUrl;
const brandLogoUrl = presentation?.logoUrl;
const { logoUrl, logoLoaded, onLogoError, onLogoLoad } = useLogoFallback(brandLogoUrl ? [brandLogoUrl] : undefined);
const showLogo = showBrandLogos && Boolean(logoUrl);
const showLoadedLogo = showLogo && logoLoaded;
return (
<span
data-testid={`channel-logo-${feature.name}`}
className={cn(
"relative grid h-8 w-8 shrink-0 place-items-center overflow-hidden rounded-[9px] text-[11px] font-semibold text-muted-foreground",
showLoadedLogo ? (isLogoTile ? "bg-transparent" : "bg-white") : "bg-muted",
showLoadedLogo ? "bg-white" : "bg-muted",
)}
aria-hidden
>
@@ -180,7 +173,7 @@ export function ChannelLogo({
)}>
{Icon ? <Icon className="h-6 w-6" strokeWidth={2} /> : initials}
</span>
{showRemoteLogo ? <img
{showLogo ? <img
src={logoUrl}
alt=""
decoding="async"
@@ -188,8 +181,7 @@ export function ChannelLogo({
referrerPolicy="no-referrer"
draggable={false}
className={cn(
"absolute object-contain transition-opacity duration-150 motion-reduce:transition-none",
isLogoTile ? "h-8 w-8" : "h-6 w-6",
"absolute h-6 w-6 object-contain transition-opacity duration-150 motion-reduce:transition-none",
logoLoaded ? "opacity-100" : "opacity-0",
)}
onLoad={onLogoLoad}
@@ -23,7 +23,6 @@ import {
} from "@/components/settings/channels/ChannelIdentity";
import { Button } from "@/components/ui/button";
import { useLogoFallback } from "@/hooks/useLogoFallback";
import { logoFallbackUrls } from "@/lib/provider-brand";
import type {
NanobotChannelInstanceInfo,
NanobotFeatureInfo,
@@ -344,8 +343,8 @@ function ChannelInstanceAvatar({
}) {
const presentation = channelUiPresentation(feature.name, feature.webui);
const [avatarFailed, setAvatarFailed] = useState(false);
const fallbackLogoUrls = useMemo(() => logoFallbackUrls(presentation?.logoUrl), [presentation?.logoUrl]);
const { logoUrl, onLogoError, onLogoLoad } = useLogoFallback(fallbackLogoUrls);
const brandLogoUrl = presentation?.logoUrl;
const { logoUrl, onLogoError, onLogoLoad } = useLogoFallback(brandLogoUrl ? [brandLogoUrl] : undefined);
const remoteAvatarUrl = !avatarFailed ? instance.avatar_url?.trim() : "";
const imageUrl = remoteAvatarUrl || (showBrandLogos ? logoUrl : "");
const Icon = presentation?.icon;
@@ -20,6 +20,12 @@ export type SettingsSectionKey =
| "runtime"
| "advanced";
export type AppsSectionKey = "apps" | "skills" | "channels";
export function isAppsSection(section: SettingsSectionKey): section is AppsSectionKey {
return section === "apps" || section === "skills" || section === "channels";
}
export function isCapabilitySection(section: SettingsSectionKey): boolean {
return ["capabilities", "image", "voice", "browser", "memory"].includes(section);
}
@@ -47,7 +47,7 @@ export function CatalogSkeleton({ label, layout, appActionLabel }: {
</div>
) : <>{icon}{text}</>}
<div className={cn("flex shrink-0 items-center justify-center",
channels && "w-16", skills && "hidden h-[16.5px] w-[92px] justify-end sm:flex",
channels && "w-11", skills && "hidden h-[16.5px] w-[92px] justify-end sm:flex",
appActionLabel && "ml-auto")}>
{appActionLabel ? <div className={cn(block, "flex h-8 items-center gap-1.5 rounded-full px-3 text-[12px] font-semibold")}>
<span className="h-4 w-4 shrink-0" />
@@ -0,0 +1,67 @@
import { useId, type ComponentPropsWithRef, type ReactNode } from "react";
import { Search } from "lucide-react";
import { SearchInput } from "@/components/ui/input";
import { ToggleButton } from "@/components/ui/toggle-button";
import { SETTINGS_SEARCH_INPUT_CLASS } from "@/components/settings/shared/SettingsControls";
import { cn } from "@/lib/utils";
type CatalogSearchProps = Omit<ComponentPropsWithRef<typeof SearchInput>, "className">;
export function CatalogSearch(props: CatalogSearchProps) {
return (
<div className="catalog-search">
<Search className="pointer-events-none absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
<SearchInput aria-label={props.placeholder} {...props}
className={cn("h-9 rounded-control ps-9 text-ui-label", SETTINGS_SEARCH_INPUT_CLASS)} />
</div>
);
}
export function CatalogToolbar({ search, children }: { search?: CatalogSearchProps; children: ReactNode }) {
return (
<div className="catalog-toolbar">
{children}
{search && <CatalogSearch {...search} />}
</div>
);
}
export function CatalogControls({ children }: { children: ReactNode }) {
return <div className="catalog-controls text-ui-label">{children}</div>;
}
export function CatalogToggle({ label, checked, onChange }: {
label: string;
checked: boolean;
onChange: (checked: boolean) => void;
}) {
return (
<label className="catalog-toggle cursor-pointer text-muted-foreground hover:text-foreground">
<span>{label}</span>
<ToggleButton label={label} checked={checked} onChange={onChange} />
</label>
);
}
export function CatalogFilter<T extends string>({ label, value, options, onChange }: {
label: string;
value: T;
options: ReadonlyArray<{ value: T; label: ReactNode }>;
onChange: (value: T) => void;
}) {
const name = useId();
return (
<div className="catalog-choices" role="radiogroup" aria-label={label}>
{options.map((option) => (
<label key={option.value} className="relative cursor-pointer">
<input className="peer sr-only" type="radio" name={name} value={option.value}
checked={value === option.value} onChange={() => onChange(option.value)} />
<span className="flex min-h-8 items-center gap-1 rounded-compact px-2 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground peer-checked:bg-muted peer-checked:text-foreground peer-focus-visible:ring-2 peer-focus-visible:ring-inset peer-focus-visible:ring-ring">
{option.label}
</span>
</label>
))}
</div>
);
}
@@ -0,0 +1,62 @@
/* Shared with the document's first paint; keep catalog geometry independent of loaded data. */
.apps-catalog-layout, .catalog-toolbar {
display: grid;
grid-template-columns: minmax(0, 1fr);
align-items: center;
gap: 12px;
min-inline-size: 0;
}
.apps-catalog-layout > .catalog-section,
.apps-catalog-layout > .catalog-section > .catalog-toolbar { display: contents; }
.apps-catalog-layout { reading-flow: grid-rows; }
.apps-catalog-layout > .catalog-tabs { justify-self: start; }
.apps-catalog-layout > .catalog-search { order: 1; }
.apps-catalog-layout > .catalog-section > :not(.catalog-toolbar),
.apps-catalog-layout > .catalog-body {
grid-column: 1 / -1;
order: 2;
min-inline-size: 0;
margin-block-start: 8px;
}
.catalog-search { position: relative; grid-column: 1 / -1; min-inline-size: 0; }
.catalog-controls, .catalog-choices, .catalog-toggle {
display: flex;
align-items: center;
min-block-size: 36px;
min-inline-size: 0;
}
.catalog-controls { justify-self: end; justify-content: flex-end; gap: 12px; inline-size: 100%; }
.catalog-choices { flex-wrap: wrap; gap: 2px; }
.catalog-toggle { flex: none; gap: 8px; padding-inline-end: 4px; }
@container (min-width: 24rem) {
.catalog-controls:not(.startup-controls) .catalog-choices + .catalog-choices { position: relative; }
.catalog-controls:not(.startup-controls) .catalog-choices + .catalog-choices::before {
content: "";
position: absolute;
inset-inline-start: -6px;
inset-block-start: 10px;
block-size: 16px;
border-inline-start: 1px solid hsl(var(--border));
pointer-events: none;
}
}
@container (width < 40rem) {
.apps-catalog-layout, .catalog-toolbar { gap: 8px; }
.apps-catalog-layout > .catalog-tabs { inline-size: 100%; }
.catalog-tabs > button { flex: 1 1 auto; }
.catalog-controls > :last-child { margin-inline-start: auto; }
}
@container (width < 24rem) {
.catalog-tabs > button {
padding-inline: 0.25rem;
white-space: normal;
overflow-wrap: anywhere;
line-height: 1.25;
}
.catalog-controls { flex-direction: column; align-items: start; gap: 4px; }
.catalog-controls > :last-child { align-self: end; }
}
@container (min-width: 40rem) {
.apps-catalog-layout { grid-template-columns: minmax(0, 1fr) 24.5rem; }
.apps-catalog-layout .catalog-controls { grid-column: 2; }
}
@@ -26,19 +26,18 @@ import {
PauseCircle,
PlayCircle,
Plus,
Search,
TriangleAlert,
Trash2,
} from "lucide-react";
import { useTranslation } from "react-i18next";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import { CatalogControls, CatalogFilter, CatalogToggle, CatalogToolbar } from "@/components/settings/shared/CatalogToolbar";
import { ProxySettingsControl } from "@/components/settings/shared/ProxySettingsControl";
import {
DismissibleStatusMessage,
RestartRequiredNotice,
SETTINGS_SEARCH_INPUT_CLASS,
SettingsSectionTitle,
} from "@/components/settings/shared/SettingsControls";
import { AgentPluginDialog } from "@/components/settings/system/AgentPluginDialog";
@@ -53,7 +52,7 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Input, SearchInput } from "@/components/ui/input";
import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { Textarea } from "@/components/ui/textarea";
import { SettingsTextEditor } from "@/components/settings/shared/SettingsTextEditor";
@@ -68,7 +67,10 @@ import type {
} from "@/lib/types";
import { cn } from "@/lib/utils";
export type AppsKindFilter = "ready" | "cli" | "plugins" | "mcp";
export type AppsCatalogFilter = {
kind: "all" | "cli" | "plugins" | "mcp";
status: "all" | "ready";
};
type AppsCatalogItem =
| { id: string; kind: "cli"; app: CliAppInfo }
| { id: string; kind: "mcp"; preset: McpPresetInfo };
@@ -104,20 +106,20 @@ export const DEFAULT_CUSTOM_MCP_FORM: CustomMcpForm = {
};
export function AppsCatalogPage(props: Omit<ComponentProps<typeof AppsCatalogSettings>, "filter" | "onFilterChange">) {
const [selection, setSelection] = useState<AppsKindFilter | null>(() => props.setupName ? "mcp" : null);
const [selection, setSelection] = useState<AppsCatalogFilter | null>(() => props.setupName ? { kind: "mcp", status: "all" } : null);
const hasReady = Boolean(
props.cliApps?.apps.some((app) => app.installed) || props.mcpPresets?.presets.some(mcpPresetReady),
);
const waiting = (props.cliAppsLoading && !props.cliApps) || (props.mcpPresetsLoading && !props.mcpPresets);
const filter = selection ?? (hasReady || waiting ? "ready" : "cli");
const filter: AppsCatalogFilter = selection ?? { kind: "all", status: hasReady || waiting ? "ready" : "all" };
useEffect(() => {
if (selection === null && (hasReady || (props.cliApps && props.mcpPresets))) {
setSelection(hasReady ? "ready" : "cli");
setSelection({ kind: "all", status: hasReady ? "ready" : "all" });
}
}, [selection, hasReady, props.cliApps, props.mcpPresets]);
return <AppsCatalogSettings {...props} filter={filter} onFilterChange={setSelection} />;
return <AppsCatalogSettings {...props} filter={filter} onFilterChange={setSelection} showSearch={false} />;
}
export function AppsCatalogSettings({
@@ -129,6 +131,7 @@ export function AppsCatalogSettings({
cliAppsLoading,
mcpPresetsLoading,
query,
showSearch = true,
filter,
cliActionKey,
mcpActionKey,
@@ -175,7 +178,8 @@ export function AppsCatalogSettings({
cliAppsLoading: boolean;
mcpPresetsLoading: boolean;
query: string;
filter: AppsKindFilter;
showSearch?: boolean;
filter: AppsCatalogFilter;
cliActionKey: string | null;
mcpActionKey: string | null;
mcpOAuthFlow: McpOAuthFlowPayload | null;
@@ -194,7 +198,7 @@ export function AppsCatalogSettings({
showBrandLogos: boolean;
requiresRestartPending: boolean;
onQueryChange: (value: string) => void;
onFilterChange: (value: AppsKindFilter) => void;
onFilterChange: (value: AppsCatalogFilter) => void;
onCliAction: (action: "install" | "update" | "uninstall" | "test", name: string) => void;
onMcpAction: (action: "enable" | "disable" | "remove" | "test" | "reconnect" | "proxy", name: string, values?: Record<string, string>) => void;
onMcpOAuthConnect: (name: string, reset?: boolean, values?: Record<string, string>) => void;
@@ -215,12 +219,12 @@ export function AppsCatalogSettings({
}) {
const { t } = useTranslation();
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
const filterOptions = [
{ value: "ready", label: tx("settings.apps.filterAll", "Ready") },
const kindOptions = [
{ value: "all", label: t("settings.apps.allTypes") },
{ value: "cli", label: tx("settings.apps.filterCli", "CLI Apps") },
{ value: "plugins", label: tx("settings.apps.filterPlugins", "Plugins") },
{ value: "mcp", label: tx("settings.apps.filterMcp", "MCP") },
];
] as const;
const normalizedQuery = query.trim().toLowerCase();
const installedCliNames = new Set((cliApps?.apps ?? []).filter((app) => app.installed).map((app) => app.name));
const managedPlugins = new Map(
@@ -228,50 +232,39 @@ export function AppsCatalogSettings({
.filter((preset) => preset.source === "agent-plugin" && preset.managed_by_cli)
.map((preset) => [preset.managed_by_cli!, preset]),
);
const items: AppsCatalogItem[] = [
const catalogItems: AppsCatalogItem[] = [
...(cliApps?.apps ?? []).map((app) => ({ id: `cli:${app.name}`, kind: "cli" as const, app })),
...(mcpPresets?.presets ?? [])
.filter((preset) => !preset.managed_by_cli || !installedCliNames.has(preset.managed_by_cli))
.map((preset) => ({ id: `mcp:${preset.name}`, kind: "mcp" as const, preset })),
]
.filter((item) => {
const matchesFilter = filter === "ready"
? appsReady(item)
: filter === "cli"
? item.kind === "cli"
: filter === "plugins"
? item.kind === "mcp" && item.preset.source === "agent-plugin"
: item.kind === "mcp" && item.preset.source !== "agent-plugin";
return matchesFilter && (!normalizedQuery || appsSearchText(item).includes(normalizedQuery));
})
.sort((left, right) => {
const rank = Number(!appsReady(left)) - Number(!appsReady(right));
return rank || appsTitle(left).localeCompare(appsTitle(right));
});
];
const matches = catalogItems.filter((item) => {
const matchesKind = filter.kind === "all" || (filter.kind === "cli"
? item.kind === "cli"
: filter.kind === "plugins"
? item.kind === "mcp" && item.preset.source === "agent-plugin"
: item.kind === "mcp" && item.preset.source !== "agent-plugin");
return matchesKind && (!normalizedQuery || appsSearchText(item).includes(normalizedQuery));
});
const items = (filter.status === "ready" ? matches.filter(appsReady) : matches).sort((left, right) => {
const rank = Number(!appsReady(left)) - Number(!appsReady(right));
return rank || appsTitle(left).localeCompare(appsTitle(right));
});
const hiddenByReadyFilter = matches.length > items.length;
const focusedApp = cliFocusName
? (cliApps?.apps ?? []).find((app) => app.name === cliFocusName && app.installed)
: null;
const loading = (mcpPresetsLoading && !mcpPresets)
|| (filter !== "mcp" && cliAppsLoading && !cliApps);
const cliAppCount = cliApps?.apps.length ?? 0;
const emptyTitle = normalizedQuery
? tx("settings.apps.empty", "No tools match your search.")
: filter === "cli"
? tx("settings.apps.emptyApps", "No apps available.")
: filter === "plugins"
? tx("settings.apps.emptyPlugins", "No Agent Plugins installed.")
: filter === "mcp"
? tx("settings.apps.emptyIntegrations", "No MCP tools available.")
: tx("settings.apps.emptyReady", "No tools are ready yet.");
const emptyBrowseTarget: AppsKindFilter | null = normalizedQuery || filter === "plugins"
? null
: filter === "cli"
? "mcp"
: filter === "mcp"
? (cliAppCount ? "cli" : null)
: cliAppCount
? "cli"
: "mcp";
|| (filter.kind !== "mcp" && cliAppsLoading && !cliApps);
const emptyTitle = hiddenByReadyFilter
? tx("settings.apps.emptyReady", "No tools are ready yet")
: normalizedQuery
? tx("settings.apps.empty", "No tools match your search")
: filter.kind === "plugins"
? tx("settings.apps.emptyPlugins", "No Agent Plugins installed")
: filter.kind === "mcp"
? tx("settings.apps.emptyIntegrations", "No MCP tools available")
: tx("settings.apps.emptyApps", "No tools available");
const statusMessage =
cliError ||
mcpError ||
@@ -286,30 +279,20 @@ export function AppsCatalogSettings({
)
: "";
return (
<div className="settings-stack">
<div className="catalog-section">
<CatalogToolbar search={showSearch ? {
value: query,
onChange: (event) => onQueryChange(event.target.value),
placeholder: t("settings.apps.searchPlaceholder"),
} : undefined}>
<CatalogControls>
<CatalogFilter label={t("settings.apps.typeFilter")} value={filter.kind} options={kindOptions}
onChange={(kind) => onFilterChange({ ...filter, kind })} />
<CatalogToggle label={t("settings.apps.readyOnly")} checked={filter.status === "ready"}
onChange={(ready) => onFilterChange({ ...filter, status: ready ? "ready" : "all" })} />
</CatalogControls>
</CatalogToolbar>
<div role="status" className="sr-only">{oauthStatusAnnouncement}</div>
<section className="space-y-4">
<div className="flex flex-col gap-3 lg:flex-row lg:items-center">
<div className="relative flex-1">
<Search className="pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
<SearchInput
value={query}
onChange={(event) => onQueryChange(event.target.value)}
placeholder={tx("settings.apps.searchPlaceholder", "Search Apps")}
className={cn(
"h-12 pl-11 text-[15px]",
SETTINGS_SEARCH_INPUT_CLASS,
)}
/>
</div>
<SegmentedControl
value={filter}
options={filterOptions}
onChange={(value) => onFilterChange(value as AppsKindFilter)}
className="max-[480px]:grid max-[480px]:w-full max-[480px]:grid-cols-2 max-[480px]:rounded-2xl"
/>
</div>
</section>
{statusMessage ? (
<DismissibleStatusMessage
@@ -334,9 +317,9 @@ export function AppsCatalogSettings({
<section className="rounded-panel bg-settings-surface px-3 py-3 sm:px-4">
<div className="settings-section-heading border-b border-border/45 pb-2">
<SettingsSectionTitle>
{filter === "mcp"
{filter.kind === "mcp"
? tx("settings.apps.mcpTools", "MCP tools")
: filter === "plugins"
: filter.kind === "plugins"
? tx("settings.apps.filterPlugins", "Plugins")
: tx("settings.apps.featured", "Tools")}
</SettingsSectionTitle>
@@ -373,7 +356,7 @@ export function AppsCatalogSettings({
oauthCompleting={mcpOAuthCompleting}
oauthCallbackError={mcpOAuthCallbackError}
showBrandLogos={showBrandLogos}
showTypeBadge={filter !== "mcp"}
showTypeBadge={filter.kind !== "mcp"}
onFieldChange={onMcpFieldChange}
onAction={onMcpAction}
onOAuthConnect={onMcpOAuthConnect}
@@ -389,11 +372,11 @@ export function AppsCatalogSettings({
) : null}
{loading ? (
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps"
appActionLabel={filter === "cli" ? undefined : tx("settings.mcp.manage", "Manage")} />
appActionLabel={filter.kind === "cli" ? undefined : tx("settings.mcp.manage", "Manage")} />
) : !items.length && !statusIsError ? (
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
<p>{emptyTitle}</p>
{normalizedQuery ? (
{hiddenByReadyFilter ? null : normalizedQuery ? (
<Button
type="button"
variant="outline"
@@ -402,29 +385,18 @@ export function AppsCatalogSettings({
>
{tx("settings.apps.clearSearch", "Clear search")}
</Button>
) : emptyBrowseTarget ? (
<Button
type="button"
variant="outline"
className="mt-4 rounded-full"
onClick={() => onFilterChange(emptyBrowseTarget)}
>
{emptyBrowseTarget === "cli"
? tx("settings.apps.browseApps", "Browse apps")
: tx("settings.apps.browseIntegrations", "Browse MCP tools")}
</Button>
) : (
) : filter.kind === "mcp" || filter.kind === "plugins" ? (
<p className="mx-auto mt-2 max-w-[28rem] text-[12px] leading-5">
{filter === "plugins"
? tx("settings.apps.emptyPluginsHint", "Add a plugin to the workspace plugins directory to enable it here.")
: tx("settings.apps.emptyIntegrationsHint", "Add a custom MCP server below.")}
{filter.kind === "mcp"
? tx("settings.apps.emptyIntegrationsHint", "Add a custom MCP server below")
: tx("settings.apps.emptyPluginsHint", "Add a plugin to the workspace plugins directory to enable it here")}
</p>
)}
) : null}
</div>
) : null}
</section>
{filter === "mcp" ? (
{filter.kind === "mcp" ? (
<McpCustomServerPanel
onConfigureProxy={onConfigureProxy}
form={customMcpForm}
@@ -1,10 +1,8 @@
import { useCallback, useLayoutEffect, useRef, useState } from "react";
import { Search, X } from "lucide-react";
import { X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { SearchInput } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SETTINGS_SEARCH_INPUT_CLASS } from "@/components/settings/shared/SettingsControls";
import { CatalogControls, CatalogToggle, CatalogToolbar } from "@/components/settings/shared/CatalogToolbar";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import type { ChannelFeatureAction } from "@/channel-plugins/types";
import { ChannelCatalogRow } from "@/components/settings/channels/ChannelCatalogRow";
@@ -18,7 +16,7 @@ import { Dialog, DialogClose, DialogContent, DialogTitle } from "@/components/ui
type ChannelFilter = "all" | "enabled";
export function ChannelsSettings({
token, nanobotFeatures, loading, actionKey, chatAppsDocsUrl, showBrandLogos,
token, nanobotFeatures, loading, actionKey, chatAppsDocsUrl, showBrandLogos, query,
error, requiresRestartPending, onAction, onFeaturesUpdate, onDismissStatus,
onRestart, isRestarting, onConfigureMcp, onBeforeCloseChange,
}: {
@@ -28,6 +26,7 @@ export function ChannelsSettings({
actionKey: string | null;
chatAppsDocsUrl?: string;
showBrandLogos: boolean;
query: string;
error: string | null;
requiresRestartPending: boolean;
onAction: ChannelFeatureAction;
@@ -40,11 +39,10 @@ export function ChannelsSettings({
}) {
const { t } = useTranslation();
const [selectedChannelName, setSelectedChannelName] = useState<string | null>(null);
const [query, setQuery] = useState("");
const [filter, setFilter] = useState<ChannelFilter>("enabled");
const [connectRequestId, setConnectRequestId] = useState(0);
const filterInitializedRef = useRef(false);
const triggerRef = useRef<HTMLElement | null>(null);
const triggerRef = useRef<HTMLButtonElement | null>(null);
const dialogRef = useRef<HTMLDivElement | null>(null);
const beforeCloseRef = useRef<(() => Promise<boolean>) | null>(null);
const closePendingRef = useRef(false);
@@ -103,23 +101,16 @@ export function ChannelsSettings({
);
return (
<div className="settings-stack">
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
<div className="relative min-w-0 flex-1">
<Search className="pointer-events-none absolute start-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
<SearchInput type="search" value={query} onChange={(event) => setQuery(event.target.value)}
aria-label={t("settings.channels.search")}
placeholder={t("settings.channels.search")}
className={`h-12 ps-11 text-[15px] ${SETTINGS_SEARCH_INPUT_CLASS}`} />
</div>
<SegmentedControl value={filter} onChange={(value) => {
filterInitializedRef.current = true;
setFilter(value);
}} options={[
{ value: "all", label: t("settings.channels.filterAll") },
{ value: "enabled", label: t("settings.channels.filterEnabled") },
]} />
</div>
<div className="catalog-section">
<CatalogToolbar>
<CatalogControls>
<CatalogToggle label={t("settings.channels.enabledOnly")} checked={filter === "enabled"}
onChange={(enabled) => {
filterInitializedRef.current = true;
setFilter(enabled ? "enabled" : "all");
}} />
</CatalogControls>
</CatalogToolbar>
{error && !selectedChannel ? <DismissibleStatusMessage message={error} isError onDismiss={onDismissStatus} /> : null}
{restartRequired && !hasPendingChannelRestart ? (
<RestartRequiredNotice message={t("settings.channels.restartRequired")}
@@ -146,8 +137,8 @@ export function ChannelsSettings({
<ChannelCatalogRow key={feature.name} feature={feature} showBrandLogos={showBrandLogos}
actionKey={actionKey} restartRequired={restartRequired} onAction={onAction}
onRestart={onRestart} isRestarting={isRestarting}
onSelect={(connect = false) => {
triggerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
onSelect={(trigger, connect = false) => {
triggerRef.current = trigger;
beforeCloseRef.current = null;
setConnectRequestId(connect ? 1 : 0);
setSelectedChannelName(feature.name);
@@ -168,7 +159,10 @@ export function ChannelsSettings({
event.preventDefault();
dialogRef.current?.focus({ preventScroll: true });
}}
onCloseAutoFocus={(event) => { event.preventDefault(); triggerRef.current?.focus(); }}>
onCloseAutoFocus={(event) => {
event.preventDefault();
triggerRef.current?.focus({ preventScroll: true });
}}>
<DialogTitle className="sr-only">{t("settings.nav.channels")}</DialogTitle>
<div className="max-h-[85dvh] min-h-0 overflow-y-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
<div className="relative">