feat(webui): add catalog loading skeletons (#6092)

* feat(webui): add catalog loading skeletons

* feat(webui): add MCP tool loading skeleton

* fix(webui): make skill discovery skeletons visible

* refactor(webui): share skeleton status markup
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-07 21:28:53 +08:00
1 parent 7cb396788c
commit f24969d282
25 files changed
+538 -99

No files matched your search

@@ -31,6 +31,8 @@ import {
} from "lucide-react";
import { useTranslation } from "react-i18next";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import {
DismissibleStatusMessage,
RestartRequiredNotice,
@@ -218,10 +220,8 @@ export function AppsCatalogSettings({
const focusedApp = cliFocusName
? (cliApps?.apps ?? []).find((app) => app.name === cliFocusName && app.installed)
: null;
const loading =
(cliAppsLoading || mcpPresetsLoading) &&
!cliApps &&
!mcpPresets;
const loading = (mcpPresetsLoading && !mcpPresets)
|| ((filter !== "mcp" || Boolean(normalizedQuery)) && cliAppsLoading && !cliApps);
const cliAppCount = cliApps?.apps.length ?? 0;
const emptyTitle = normalizedQuery
? tx("settings.apps.empty", "No tools match your search.")
@@ -305,15 +305,10 @@ export function AppsCatalogSettings({
: tx("settings.apps.featured", "Tools")}
</SettingsSectionTitle>
<span className="text-[12px] tabular-nums text-muted-foreground">
{items.length}
{loading ? "—" : items.length}
</span>
</div>
{loading ? (
<div className="flex h-36 items-center justify-center text-sm text-muted-foreground">
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
{tx("settings.apps.loading", "Loading apps…")}
</div>
) : items.length ? (
{items.length ? (
<div className="grid grid-cols-1 gap-x-10 gap-y-1 py-3 xl:grid-cols-2">
{items.map((item) =>
item.kind === "cli" ? (
@@ -351,7 +346,10 @@ export function AppsCatalogSettings({
),
)}
</div>
) : (
) : null}
{loading ? (
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps" />
) : !items.length && !statusIsError ? (
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
<p>{emptyTitle}</p>
{normalizedQuery ? (
@@ -383,7 +381,7 @@ export function AppsCatalogSettings({
</p>
)}
</div>
)}
) : null}
</section>
{filter === "mcp" ? (
@@ -1,10 +1,11 @@
import { useCallback, useLayoutEffect, useRef, useState } from "react";
import { Loader2, Search, X } from "lucide-react";
import { Search, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SETTINGS_SEARCH_INPUT_CLASS } from "@/components/settings/shared/SettingsControls";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import type { ChannelFeatureAction } from "@/channel-plugins/types";
import { ChannelCatalogRow } from "@/components/settings/channels/ChannelCatalogRow";
import { localizedChannelDisplayName } from "@/components/settings/channels/ChannelIdentity";
@@ -120,10 +121,9 @@ export function ChannelsSettings({
onRestart={onRestart} isRestarting={isRestarting} />
) : null}
{loading && !nanobotFeatures ? (
<div className="flex h-36 items-center justify-center text-sm text-muted-foreground">
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
{t("settings.channels.loading")}
</div>
<SettingsGroup>
<CatalogSkeleton label={t("settings.channels.loading")} layout="channels" />
</SettingsGroup>
) : visibleChannels.length ? (
channelGroups.map((group) => (
<section
@@ -151,11 +151,11 @@ export function ChannelsSettings({
</SettingsGroup>
</section>
))
) : (
) : !error ? (
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
{t(channels.length ? "settings.channels.noResults" : "settings.channels.empty")}
</div>
)}
) : null}
<Dialog open={Boolean(selectedChannel)} onOpenChange={(open) => { if (!open) requestChannelClose(); }}>
<DialogContent ref={dialogRef} showCloseButton={false} aria-describedby={undefined} className="max-h-[85dvh] w-[min(calc(100vw-2rem),40rem)] max-w-none overflow-hidden p-0 outline-none"
onOpenAutoFocus={(event) => {
@@ -5,6 +5,7 @@ import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { Check, ExternalLink, Loader2, RotateCcw, Search, Server, Trash2, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -363,6 +364,29 @@ function ToolsPanel({
}) {
const { t } = useTranslation();
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
if (!toolNames.length && testBusy) {
return (
<SkeletonStatus label={tx("settings.mcp.loadingTools", "Loading tools…")} className="space-y-4">
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
<div className="h-10 min-w-0 rounded-full bg-muted-foreground/20 sm:flex-1" />
<div className="flex h-8 items-center justify-between gap-4 sm:justify-end">
<div className="mr-auto h-3 w-20 rounded bg-muted-foreground/20 sm:mr-1" />
<div className="h-3 w-6 rounded bg-muted-foreground/20" />
<div className="h-3 w-9 rounded bg-muted-foreground/20" />
</div>
</div>
<div className="overflow-hidden rounded-floating border border-border/55">
{Array.from({ length: 6 }, (_, index) => (
<div key={index} className="flex min-h-11 items-center gap-3 border-b border-border/45 px-3.5 py-2.5 last:border-b-0">
<div className="h-5 w-5 shrink-0 rounded-compact bg-muted-foreground/20" />
<div className={cn("h-3.5 max-w-[70%] rounded bg-muted-foreground/20", index % 2 ? "w-40" : "w-52")} />
</div>
))}
</div>
</SkeletonStatus>
);
}
if (!toolNames.length) {
return (
<div
@@ -373,39 +397,31 @@ function ToolsPanel({
>
<div className="flex min-w-0 items-center gap-3">
<div className="grid h-9 w-9 shrink-0 place-items-center rounded-full bg-background text-muted-foreground">
{testBusy ? (
<Loader2 className="h-4 w-4 animate-spin motion-reduce:animate-none" aria-hidden />
) : (
<AppActionsIcon className="h-4 w-4" aria-hidden />
)}
<AppActionsIcon className="h-4 w-4" aria-hidden />
</div>
<p
role={preset.error ? "alert" : undefined}
className={cn("min-w-0 text-[14px] font-medium", preset.error ? "text-destructive" : "text-foreground")}
>
{testBusy
? tx("common.loading", "Loading…")
: preset.error || tx("settings.mcp.noToolsAvailable", "No tools available")}
{preset.error || tx("settings.mcp.noToolsAvailable", "No tools available")}
</p>
</div>
{!testBusy ? (
<Button
type="button"
size="sm"
variant="outline"
onClick={configuredInstalled ? onTest : onOpenConnection}
className="h-9 shrink-0 rounded-full px-4 text-[13px] font-semibold"
>
{configuredInstalled ? (
<RotateCcw className="mr-1.5 h-3.5 w-3.5" aria-hidden />
) : (
<Server className="mr-1.5 h-3.5 w-3.5" aria-hidden />
)}
{configuredInstalled
? tx("settings.mcp.reloadTools", "Reload tools")
: tx("settings.mcp.setup", "Connect")}
</Button>
) : null}
<Button
type="button"
size="sm"
variant="outline"
onClick={configuredInstalled ? onTest : onOpenConnection}
className="h-9 shrink-0 rounded-full px-4 text-[13px] font-semibold"
>
{configuredInstalled ? (
<RotateCcw className="mr-1.5 h-3.5 w-3.5" aria-hidden />
) : (
<Server className="mr-1.5 h-3.5 w-3.5" aria-hidden />
)}
{configuredInstalled
? tx("settings.mcp.reloadTools", "Reload tools")
: tx("settings.mcp.setup", "Connect")}
</Button>
</div>
);
}