fix(webui): show route-aligned skeletons from first paint (#6303)
This commit is contained in:
1 parent
af68da3280
commit
5d886fbb20
43 files changed
+1592
-213
No files matched your search
+4
-18
@@ -170,22 +170,6 @@ const RenameDialog = lazy(async () => {
|
||||
return { default: module.RenameDialog };
|
||||
});
|
||||
|
||||
function SurfaceLoadingFallback({ label }: { label?: string }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div
|
||||
aria-busy="true"
|
||||
className="flex h-full w-full flex-col gap-5 px-5 py-8 sm:px-8 lg:px-12"
|
||||
>
|
||||
<span className="sr-only">{label ?? t("settings.status.loading")}</span>
|
||||
<div className="h-4 w-20 animate-pulse rounded bg-muted/70 motion-reduce:animate-none" />
|
||||
<div className="h-9 w-48 animate-pulse rounded bg-muted/70 motion-reduce:animate-none" />
|
||||
<div className="mt-4 h-12 w-full max-w-3xl animate-pulse rounded-md bg-muted/55 motion-reduce:animate-none" />
|
||||
<div className="h-28 w-full max-w-3xl animate-pulse rounded-md bg-muted/40 motion-reduce:animate-none" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const SETTINGS_SECTION_KEYS: SettingsSectionKey[] = [
|
||||
"capabilities",
|
||||
"overview",
|
||||
@@ -1199,6 +1183,7 @@ function Shell({
|
||||
const {
|
||||
sessions,
|
||||
loading,
|
||||
initialLoading: sessionsInitialLoading,
|
||||
error: sessionsError,
|
||||
refresh,
|
||||
createChat,
|
||||
@@ -2760,6 +2745,7 @@ function Shell({
|
||||
? (temporaryChatActive ? activeKey : activeSidebarKey)
|
||||
: null,
|
||||
loading: loading || sidebarStateLoading,
|
||||
initialLoading: sessionsInitialLoading || sidebarStateLoading,
|
||||
newChatActive: !managingConnections && view === "chat" && activeKey === null,
|
||||
onNewChat,
|
||||
onSelect: onSelectSidebarItem,
|
||||
@@ -2953,7 +2939,7 @@ function Shell({
|
||||
)}
|
||||
>
|
||||
<ThreadVisibilityContext.Provider value={localActive && !managingConnections && view === "chat"}>
|
||||
<Suspense fallback={<StartupShell embedded />}>
|
||||
<Suspense fallback={<StartupShell embedded surface="chat" sidebarExpanded={hostSidebarOpen} />}>
|
||||
<PaneWorkbench
|
||||
panes={renderedWorkbenchPanes}
|
||||
activePaneKey={renderedActivePaneKey}
|
||||
@@ -3104,7 +3090,7 @@ function Shell({
|
||||
mainNavigationExpanded={showMainSidebar && hostSidebarOpen}
|
||||
hostChromeInset={showHostChrome}
|
||||
onBackToChat={onBackToChat}
|
||||
/> : <Suspense fallback={<SurfaceLoadingFallback />}>
|
||||
/> : <Suspense fallback={<StartupShell embedded surface={view} sidebarExpanded={hostSidebarOpen} />}>
|
||||
<SettingsView
|
||||
registerExitGuard={registerSettingsExitGuard}
|
||||
theme={theme}
|
||||
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
} from "@/components/ui/tooltip";
|
||||
import { MAX_WORKBENCH_PANES } from "@/components/workbench/workbench-model";
|
||||
import { SidebarTopicRename } from "@/components/SidebarTopicRename";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import {
|
||||
SIDEBAR_SELECTION_ITEM_CLASS,
|
||||
SidebarSelectionHighlight,
|
||||
@@ -258,6 +259,7 @@ interface ChatListProps {
|
||||
defaultWorkspacePath?: string | null;
|
||||
actionMenuPortalContainer?: HTMLElement | null;
|
||||
loading?: boolean;
|
||||
initialLoading?: boolean;
|
||||
emptyLabel?: string;
|
||||
}
|
||||
|
||||
@@ -299,6 +301,7 @@ export const ChatList = memo(function ChatList({
|
||||
defaultWorkspacePath,
|
||||
actionMenuPortalContainer,
|
||||
loading,
|
||||
initialLoading = loading,
|
||||
emptyLabel,
|
||||
}: ChatListProps) {
|
||||
const { t } = useTranslation();
|
||||
@@ -573,11 +576,22 @@ export const ChatList = memo(function ChatList({
|
||||
for (const animation of layoutAnimationsRef.current.values()) animation.cancel();
|
||||
}, []);
|
||||
|
||||
if (loading && sessions.length === 0 && temporarySessions.length === 0) {
|
||||
if (initialLoading && sessions.length === 0 && temporarySessions.length === 0) {
|
||||
return (
|
||||
<div className="px-3 py-6 text-[12px] text-sidebar-muted-foreground">
|
||||
{t("chat.loading")}
|
||||
</div>
|
||||
<SkeletonStatus label={t("chat.loading")} className="px-2 py-1.5">
|
||||
<div className="flex h-8 items-center px-2"><div className="h-2.5 w-14 rounded bg-sidebar-muted-foreground/15" /></div>
|
||||
<div className="space-y-0.5">
|
||||
{[64, 76, 56, 70, 60, 72].map((width, index) => (
|
||||
<div key={index} data-chat-skeleton-row className={cn("flex items-center gap-1 px-2", density === "compact" ? "h-[30px]" : "h-[34px]", "[@media(pointer:coarse)]:h-11")}>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5">
|
||||
<div className="h-2.5 w-10 shrink-0 rounded bg-sidebar-muted-foreground/15" />
|
||||
<div className="h-3 rounded bg-sidebar-muted-foreground/20" style={{ width: `${width}%` }} />
|
||||
</div>
|
||||
<div className="h-4 w-4 shrink-0" /><div className="h-6 w-6 shrink-0" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</SkeletonStatus>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [mode, setMode] = useState<"preview" | "source">("preview");
|
||||
const previewKind = fileKindForPath(path);
|
||||
const markdown = state.status === "ready" && state.payload.kind !== "image"
|
||||
&& state.payload.language === "markdown";
|
||||
const displayPath = state.status === "ready" ? state.payload.display_path : path;
|
||||
@@ -50,12 +51,29 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
|
||||
className="min-h-0 flex-1 overflow-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/60">
|
||||
{state.status === "loading" ? (
|
||||
<div role="status" aria-label={t("filePreview.loading", { defaultValue: "Loading preview..." })}
|
||||
className="flex h-full flex-col justify-center gap-3 p-6" aria-busy="true">
|
||||
className="h-full" aria-busy="true">
|
||||
<span className="sr-only">{t("filePreview.loading", { defaultValue: "Loading preview..." })}</span>
|
||||
<div aria-hidden className="mx-auto w-full max-w-sm space-y-3 animate-pulse [animation-duration:900ms] motion-reduce:animate-none">
|
||||
{fileKindForPath(path) === "image" ? <div className="aspect-[8/5] rounded-compact bg-muted/40" />
|
||||
: <>{["w-2/3", "w-full", "w-5/6", "w-3/4"].map((width) =>
|
||||
<div key={width} className={`h-1.5 rounded-full bg-muted/40 ${width}`} />)}</>}
|
||||
<div aria-hidden className="h-full animate-pulse [animation-duration:900ms] motion-reduce:animate-none">
|
||||
{previewKind === "image" ? <div className="flex h-full items-center justify-center p-4">
|
||||
<div className="aspect-[8/5] w-full max-w-sm rounded-compact bg-muted/40" />
|
||||
</div> : <>
|
||||
{previewKind === "markdown" ? <div className="flex justify-end px-4 py-2">
|
||||
<div className="inline-flex min-h-8 items-center gap-1 rounded-full bg-muted/40 p-1 text-[12px] font-medium">
|
||||
{[t("filePreview.preview"), t("filePreview.source")].map((label) => <span key={label} className="invisible px-3 py-1 [@media(pointer:coarse)]:min-h-9">{label}</span>)}
|
||||
</div>
|
||||
</div> : null}
|
||||
{previewKind === "markdown" && mode === "preview" ? <div className="px-5 pb-6 pt-1 text-sm sm:px-6">
|
||||
<div className="flex h-7 items-center"><div className="h-5 w-2/3 rounded bg-muted/40" /></div>
|
||||
{["w-full", "w-5/6", "w-3/4"].map((width) => <div key={width} className="mt-4 flex h-[1.625em] items-center">
|
||||
<div className={`h-3 rounded bg-muted/40 ${width}`} />
|
||||
</div>)}
|
||||
</div> : <div className="px-4 py-3 font-mono text-[13px] leading-[1.55]">
|
||||
{["w-2/3", "w-full", "w-5/6", "w-3/4", "w-1/2", "w-3/5"].map((width) => <div key={width} className="flex h-[1.55em] items-center">
|
||||
<div className="w-[4.25em] shrink-0 pr-[1.15rem]"><div className="ml-auto h-3 w-2 rounded bg-muted/40" /></div>
|
||||
<div className={`h-3 max-w-[calc(100%-4.25em)] rounded bg-muted/40 ${width}`} />
|
||||
</div>)}
|
||||
</div>}
|
||||
</>}
|
||||
</div>
|
||||
</div>
|
||||
) : state.status === "error" ? (
|
||||
|
||||
@@ -42,6 +42,7 @@ interface SidebarProps {
|
||||
temporarySessions?: ChatSummary[];
|
||||
activeKey: string | null;
|
||||
loading: boolean;
|
||||
initialLoading?: boolean;
|
||||
newChatActive: boolean;
|
||||
onNewChat: () => void;
|
||||
onSelect: (key: string) => void;
|
||||
@@ -272,6 +273,7 @@ export function Sidebar(props: SidebarProps) {
|
||||
temporarySessions={props.temporarySessions}
|
||||
activeKey={props.activeKey}
|
||||
loading={props.loading}
|
||||
initialLoading={props.initialLoading}
|
||||
emptyLabel={t("chat.noSessions")}
|
||||
onSelect={props.onSelect}
|
||||
onCloseTemporaryChat={props.onCloseTemporaryChat}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
/** Quiet layout placeholders while the authenticated application starts. */
|
||||
export function StartupShell({ embedded = false }: { embedded?: boolean }) {
|
||||
import { readStartupLayout, StartupSkeleton, type StartupSurface } from "./StartupSkeleton";
|
||||
|
||||
export function StartupShell({ embedded = false, surface, sidebarExpanded }: {
|
||||
embedded?: boolean;
|
||||
surface?: StartupSurface;
|
||||
sidebarExpanded?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const Root = embedded ? "section" : "main";
|
||||
return (
|
||||
<Root className="startup-shell" aria-busy="true">
|
||||
<div className="startup-header" aria-hidden="true">
|
||||
<span className="startup-control-shadow" />
|
||||
<span className="startup-control-shadow" />
|
||||
</div>
|
||||
<div className="startup-composer" aria-hidden="true" />
|
||||
<span className="startup-status" role="status">{t("app.loading.connecting")}</span>
|
||||
</Root>
|
||||
);
|
||||
const layout = readStartupLayout();
|
||||
return <StartupSkeleton {...layout} embedded={embedded} surface={surface ?? layout.surface}
|
||||
sidebarExpanded={sidebarExpanded ?? layout.sidebarExpanded} label={t("app.loading.boot")} />;
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
export type StartupSurface = "chat" | "settings" | "skills" | "apps" | "channels" | "automations" | "remote";
|
||||
|
||||
/** Also inlined in index.html: keep document startup independent of app modules. */
|
||||
export function readStartupLayout() {
|
||||
let hash = window.location.hash.slice(1);
|
||||
let sidebarExpanded = true;
|
||||
let sidebarWidth = 272;
|
||||
try {
|
||||
if ((!hash || hash === "/" || hash === "/new")
|
||||
&& Date.now() - Number(localStorage.getItem("nanobot-webui.restartStartedAt") || 0) < 300_000) {
|
||||
hash = (localStorage.getItem("nanobot-webui.restartRoute") || hash).replace(/^#/, "");
|
||||
}
|
||||
const stored = localStorage.getItem("nanobot-webui.sidebar");
|
||||
sidebarExpanded = stored === null || stored === "1";
|
||||
const width = Number(localStorage.getItem("nanobot-webui.sidebar.width"));
|
||||
if (Number.isFinite(width) && width >= 220) sidebarWidth = Math.min(480, width);
|
||||
} catch {
|
||||
// Storage can be unavailable in private browsing; use the shell's defaults.
|
||||
}
|
||||
const [path, query = ""] = hash.split("?", 2);
|
||||
const section = new URLSearchParams(query).get("section") || "overview";
|
||||
const page = path === "/settings" ? section : path.slice(1);
|
||||
let surface: StartupSurface = "chat";
|
||||
if (page === "skills" || page === "apps" || page === "channels" || page === "automations" || page === "remote") surface = page;
|
||||
else if (path === "/settings") surface = "settings";
|
||||
const now = new Date();
|
||||
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||
const days = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate();
|
||||
const calendarWeeks = Math.ceil(((firstDay.getDay() + 6) % 7 + days) / 7);
|
||||
return { surface, section, sidebarExpanded, sidebarWidth, calendarWeeks, existingChat: /^\/(chat|temporary)\/.+/.test(path) };
|
||||
}
|
||||
|
||||
interface StartupSkeletonProps {
|
||||
surface?: StartupSurface;
|
||||
section?: string;
|
||||
sidebarExpanded?: boolean;
|
||||
sidebarWidth?: number;
|
||||
existingChat?: boolean;
|
||||
calendarWeeks?: number;
|
||||
embedded?: boolean;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
function Block({ className = "" }: { className?: string }) {
|
||||
return <div className={`startup-block ${className}`} />;
|
||||
}
|
||||
|
||||
/** One markup/CSS contract for the HTML first paint and React's loading boundaries. */
|
||||
export function StartupSkeleton({
|
||||
surface = "chat", section = "overview", sidebarExpanded = true, sidebarWidth = 272,
|
||||
existingChat = false, calendarWeeks = 5, embedded = false, label = "Loading nanobot…",
|
||||
}: StartupSkeletonProps) {
|
||||
const Root = embedded ? "section" : "main";
|
||||
return (
|
||||
<Root className="startup-shell" aria-busy="true" data-startup-surface={surface}
|
||||
data-startup-section={section} data-sidebar-expanded={sidebarExpanded} data-existing-chat={existingChat}
|
||||
data-calendar-weeks={calendarWeeks} data-embedded={embedded}
|
||||
style={{ "--startup-sidebar-width": `${sidebarExpanded ? sidebarWidth : 56}px` } as CSSProperties}>
|
||||
<span className="startup-status" role="status" data-boot-copy>{label}</span>
|
||||
<div className="startup-navigation" aria-hidden="true">
|
||||
<Block className="startup-nav-brand" />
|
||||
{Array.from({ length: 7 }, (_, index) => <div key={index} className="startup-nav-row"><Block className="startup-nav-icon" /><Block className="startup-nav-label" /></div>)}
|
||||
</div>
|
||||
<div className="startup-content" aria-hidden="true">
|
||||
<div className="startup-chat">
|
||||
<div className="startup-chat-header">
|
||||
<div className="startup-header-leading"><div className="startup-header-menu"><Block /></div><Block className="startup-header-title" /></div>
|
||||
<div className="startup-header-actions"><div><Block /></div><div><Block /></div></div>
|
||||
</div>
|
||||
<div className="startup-chat-viewport">
|
||||
<div className="startup-chat-layout">
|
||||
<div className="startup-messages"><Block /><Block /><Block /></div>
|
||||
<div className="startup-welcome"><div className="startup-welcome-line"><Block /></div></div>
|
||||
<div className="startup-composer">
|
||||
<div className="startup-composer-surface">
|
||||
<div className="startup-composer-input"><Block /></div>
|
||||
<div className="startup-composer-footer">
|
||||
<div className="startup-composer-primary"><Block className="startup-attach" /><Block className="startup-workspace" /><Block className="startup-access" /><Block className="startup-mobile-model" /></div>
|
||||
<div className="startup-composer-actions"><Block className="startup-model" /><Block className="startup-send" /></div>
|
||||
</div>
|
||||
<div className="startup-workspace-row"><Block /><Block /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-chat-spacer" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-scroll">
|
||||
<div className="startup-page">
|
||||
<div className="startup-page-header"><div className="startup-back"><Block /></div><div className="startup-title"><Block /></div></div>
|
||||
<div className="startup-tabs"><Block /></div>
|
||||
<div className="startup-panel">
|
||||
<div className="startup-toolbar"><Block className="startup-search" /><Block className="startup-filters" /></div>
|
||||
<div className="startup-catalog-frame">
|
||||
<div className="startup-catalog-heading"><Block /></div>
|
||||
<div className="startup-catalog">
|
||||
<div className="startup-catalog-group"><Block /></div>
|
||||
{Array.from({ length: 6 }, (_, index) => <div key={index} className="startup-catalog-row">
|
||||
<Block className="startup-catalog-icon" /><div className="startup-catalog-copy"><Block /><Block /></div><Block className="startup-catalog-action" />
|
||||
</div>)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-automation">
|
||||
<div className="startup-automation-composer"><Block /></div>
|
||||
<div className="startup-calendar"><div className="startup-calendar-toolbar"><Block /><Block /><Block className="startup-calendar-navigation" /></div>
|
||||
<div className="startup-calendar-days">{Array.from({ length: 42 }, (_, index) => <div key={index}><Block /></div>)}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="startup-settings">
|
||||
{[0, 1].map((group) => <div key={group} className="startup-settings-group"><Block className="startup-settings-title" />
|
||||
{[0, 1, 2].map((row) => <div key={row} className="startup-settings-row"><Block /><Block /></div>)}
|
||||
</div>)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Root>
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import { ChevronLeft, Loader2 } from "lucide-react";
|
||||
import { ChevronLeft } from "lucide-react";
|
||||
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 } from "@/components/settings/contracts";
|
||||
import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts";
|
||||
import { SettingsFeature } from "@/components/settings/shared/SettingsFeature";
|
||||
import { SettingsSectionSkeleton } from "@/components/settings/shared/SettingsSectionSkeleton";
|
||||
|
||||
import { SkillsCatalogSettings } from "@/components/settings/SkillsCatalogSettings";
|
||||
import { ImageGenerationSettings } from "@/components/settings/capabilities/ImageGenerationSettings";
|
||||
@@ -162,7 +163,7 @@ export function SettingsPage({
|
||||
</RuntimeConfigSettings>
|
||||
);
|
||||
|
||||
const renderSection = (section: SettingsSectionKey, embedded = false): ReactNode => {
|
||||
const renderSettingsSection = (section: SettingsSectionKey, embedded = false): ReactNode => {
|
||||
if (!settings) return null;
|
||||
switch (section) {
|
||||
case "capabilities": {
|
||||
@@ -400,6 +401,40 @@ export function SettingsPage({
|
||||
</WebSettings>
|
||||
</div>
|
||||
);
|
||||
case "runtime":
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
{runtimeConfiguration("runtime")}
|
||||
<RuntimeSettings
|
||||
form={modelState.form}
|
||||
settings={settings}
|
||||
onRestart={showSidebar ? undefined : restartViaSettingsSurface}
|
||||
isRestarting={restartInProgress}
|
||||
requiresRestartPending={pendingRestartSections.runtime}
|
||||
apiService={systemState.apiService}
|
||||
apiServiceLoading={systemState.apiServiceLoading}
|
||||
apiServiceAction={systemState.apiServiceAction}
|
||||
apiServiceError={systemState.apiServiceError}
|
||||
langfuseFeature={featureCatalog.find((feature) => feature.name === "langfuse")}
|
||||
capabilitiesLoading={systemState.nanobotFeaturesLoading}
|
||||
capabilityAction={systemState.nanobotFeatureAction}
|
||||
capabilityError={systemState.nanobotFeaturesError}
|
||||
onApiServiceAction={systemActions.handleApiServiceAction}
|
||||
onInstallCapability={(name) => void systemActions.installCapabilities([name])}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
case "memory":
|
||||
return runtimeConfiguration("memory");
|
||||
case "advanced":
|
||||
return runtimeConfiguration("advanced");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const renderSection = (section: SettingsSectionKey, embedded = false): ReactNode => {
|
||||
switch (section) {
|
||||
case "channels":
|
||||
return (
|
||||
<ChannelsSettings
|
||||
@@ -413,7 +448,7 @@ export function SettingsPage({
|
||||
nanobotFeatures={systemState.nanobotFeatures}
|
||||
loading={systemState.nanobotFeaturesLoading}
|
||||
actionKey={systemState.nanobotFeatureAction}
|
||||
chatAppsDocsUrl={settings.docs?.chat_apps_url}
|
||||
chatAppsDocsUrl={settings?.docs?.chat_apps_url}
|
||||
showBrandLogos={localPrefs.brandLogos}
|
||||
error={systemState.nanobotFeaturesError}
|
||||
requiresRestartPending={pendingRestartSections.runtime}
|
||||
@@ -523,37 +558,12 @@ export function SettingsPage({
|
||||
);
|
||||
case "skills":
|
||||
return <SkillsCatalogSettings skills={skills} loading={skillsLoading} error={skillsError} />;
|
||||
case "runtime":
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
{runtimeConfiguration("runtime")}
|
||||
<RuntimeSettings
|
||||
form={modelState.form}
|
||||
settings={settings}
|
||||
onRestart={showSidebar ? undefined : restartViaSettingsSurface}
|
||||
isRestarting={restartInProgress}
|
||||
requiresRestartPending={pendingRestartSections.runtime}
|
||||
apiService={systemState.apiService}
|
||||
apiServiceLoading={systemState.apiServiceLoading}
|
||||
apiServiceAction={systemState.apiServiceAction}
|
||||
apiServiceError={systemState.apiServiceError}
|
||||
langfuseFeature={featureCatalog.find((feature) => feature.name === "langfuse")}
|
||||
capabilitiesLoading={systemState.nanobotFeaturesLoading}
|
||||
capabilityAction={systemState.nanobotFeatureAction}
|
||||
capabilityError={systemState.nanobotFeaturesError}
|
||||
onApiServiceAction={systemActions.handleApiServiceAction}
|
||||
onInstallCapability={(name) => void systemActions.installCapabilities([name])}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
case "memory":
|
||||
return runtimeConfiguration("memory");
|
||||
case "advanced":
|
||||
return runtimeConfiguration("advanced");
|
||||
default:
|
||||
return null;
|
||||
return renderSettingsSection(section, embedded);
|
||||
}
|
||||
};
|
||||
const sectionReady = settings !== null || activeSection === "skills" || activeSection === "apps"
|
||||
|| activeSection === "channels" || activeSection === "automations";
|
||||
|
||||
return (
|
||||
<DialogLayoutContext.Provider value={dialogLayoutAnchor}>
|
||||
@@ -702,18 +712,15 @@ export function SettingsPage({
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{loading ? (
|
||||
<div className="flex h-48 items-center justify-center rounded-panel bg-settings-surface text-sm text-muted-foreground">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
{t("settings.status.loading")}
|
||||
</div>
|
||||
) : error && !settings ? (
|
||||
{loading && !sectionReady ? (
|
||||
<SettingsSectionSkeleton section={activeSection} showRestart={!showSidebar} />
|
||||
) : error && !sectionReady ? (
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={t("settings.status.loadError")}>
|
||||
<span className="max-w-[520px] text-sm text-muted-foreground">{error}</span>
|
||||
</SettingsRow>
|
||||
</SettingsGroup>
|
||||
) : settings ? (
|
||||
) : sectionReady ? (
|
||||
<div
|
||||
className={cn(
|
||||
"settings-stack",
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
CircleAlert,
|
||||
Copy,
|
||||
KeyRound,
|
||||
Loader2,
|
||||
PowerOff,
|
||||
RefreshCw,
|
||||
Search,
|
||||
@@ -32,6 +31,7 @@ import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
|
||||
import { 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";
|
||||
@@ -200,6 +200,7 @@ export function SkillsCatalogSettings({ skills, loading = false, error = false }
|
||||
)}
|
||||
|
||||
<SkillDetailSheet
|
||||
key={selectedSkill ? `${selectedSkill.source}:${selectedSkill.name}` : "closed"}
|
||||
skill={selectedSkill}
|
||||
open={selectedSkill !== null}
|
||||
onOpenChange={(open) => {
|
||||
@@ -299,7 +300,6 @@ function SkillDetailSheet({
|
||||
useEffect(() => {
|
||||
if (!open || !skill) return;
|
||||
let cancelled = false;
|
||||
setDetail(null);
|
||||
setLoading(true);
|
||||
setLoadFailed(false);
|
||||
setActionError("");
|
||||
@@ -449,12 +449,22 @@ function SkillDetailSheet({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
<div className="mt-8 flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<Loader2 className="h-4 w-4 animate-spin" aria-hidden />
|
||||
{t("settings.skills.loadingDetail", { defaultValue: "Loading skill details..." })}
|
||||
{loading && !detail ? (
|
||||
<div className="mt-6">
|
||||
<SkeletonStatus label={t("settings.skills.loadingDetail", { defaultValue: "Loading skill details..." })} className="space-y-5">
|
||||
<div data-skill-toggle-skeleton className="flex min-h-16 items-center justify-between gap-3 border-y border-border/45 px-1 py-3.5">
|
||||
<div className="h-3 w-28 rounded bg-muted-foreground/20" /><div className="h-5 w-[38px] rounded-full bg-muted-foreground/20" />
|
||||
</div>
|
||||
{!skill.available && enabled ? <div className="rounded-floating border border-border/45 p-4">
|
||||
<div className="h-4 w-28 rounded bg-muted-foreground/20" /><div className="mt-3 h-3 w-4/5 rounded bg-muted-foreground/15" />
|
||||
<div className="mt-3 h-9 w-24 rounded-full bg-muted-foreground/15" />
|
||||
</div> : null}
|
||||
<div data-skill-instructions-skeleton className="flex min-h-[70px] items-center justify-between rounded-floating border border-border/45 bg-muted/20 px-3 py-3">
|
||||
<div className="h-3 w-32 rounded bg-muted-foreground/20" /><div className="h-2.5 w-12 rounded bg-muted-foreground/15" />
|
||||
</div>
|
||||
</SkeletonStatus>
|
||||
</div>
|
||||
) : loadFailed ? (
|
||||
) : loadFailed && !detail ? (
|
||||
<div className="mt-8 rounded-floating bg-destructive/10 px-3 py-3 text-sm text-destructive">
|
||||
{t("settings.skills.loadFailed", { defaultValue: "Could not load skill details." })}
|
||||
</div>
|
||||
@@ -477,14 +487,14 @@ function SkillDetailSheet({
|
||||
defaultValue: "Enable {{name}}",
|
||||
})
|
||||
}
|
||||
disabled={actionBusy}
|
||||
disabled={actionBusy || loading}
|
||||
onChange={() => void toggleEnabled()}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{actionError ? (
|
||||
<div className="rounded-control bg-destructive/10 px-3 py-2.5 text-[13px] text-destructive">
|
||||
{actionError}
|
||||
{actionError || loadFailed ? (
|
||||
<div role="alert" className="rounded-control bg-destructive/10 px-3 py-2.5 text-[13px] text-destructive">
|
||||
{actionError || t("settings.skills.loadFailed", { defaultValue: "Could not load skill details." })}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -513,7 +523,7 @@ function SkillDetailSheet({
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={actionBusy}
|
||||
disabled={actionBusy || loading}
|
||||
onClick={() => setDeleteOpen(true)}
|
||||
className={cn(
|
||||
"h-10 w-full shrink-0 rounded-full border-destructive/20 text-destructive",
|
||||
|
||||
@@ -253,7 +253,7 @@ export function SkillsMarketplace({
|
||||
) : null}
|
||||
</div>
|
||||
{trendingLoading ? (
|
||||
<MarketplaceSkeleton ranked />
|
||||
<MarketplaceSkeleton ranked provider={provider} />
|
||||
) : visibleTrending.length ? (
|
||||
<MarketplaceSkillGroups
|
||||
skills={visibleTrending}
|
||||
@@ -281,7 +281,7 @@ export function SkillsMarketplace({
|
||||
) : (
|
||||
<div className="overflow-hidden rounded-panel bg-settings-surface">
|
||||
{loading && !visibleResults.length ? (
|
||||
<MarketplaceSkeleton />
|
||||
<MarketplaceSkeleton provider={provider} />
|
||||
) : (
|
||||
<MarketplaceSkillGroups
|
||||
skills={visibleResults}
|
||||
@@ -674,26 +674,39 @@ function TrendSparkline({ values }: { values?: number[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
function MarketplaceSkeleton({ ranked = false }: { ranked?: boolean }) {
|
||||
function MarketplaceSkeleton({ ranked = false, provider }: { ranked?: boolean; provider: MarketplaceProvider }) {
|
||||
const { t } = useTranslation();
|
||||
const grouped = provider === "all";
|
||||
const providers: Array<Exclude<MarketplaceProvider, "all">> = grouped ? ["skills_sh", "skillhub"] : [provider];
|
||||
return (
|
||||
<SkeletonStatus
|
||||
label={t("settings.skills.loading")}
|
||||
className="space-y-1 px-3 pb-3 sm:px-4"
|
||||
className={grouped ? "space-y-5 pb-3 pt-2" : ""}
|
||||
>
|
||||
{Array.from({ length: 5 }, (_, index) => (
|
||||
<div key={index} className="flex min-w-0 items-center gap-2 px-1 py-3.5 sm:gap-3 sm:px-2">
|
||||
{ranked ? <div className="h-3 w-6 shrink-0 rounded bg-muted-foreground/20 sm:w-7" /> : null}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex h-7 items-center">
|
||||
<div className="h-3.5 w-48 max-w-[70%] rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
<div className="mt-1 flex h-5 items-center">
|
||||
<div className="h-3 w-32 max-w-[55%] rounded bg-muted-foreground/20 opacity-60" />
|
||||
</div>
|
||||
{providers.map((source) => (
|
||||
<section key={source} className={grouped ? "space-y-1" : undefined}>
|
||||
{grouped ? <div className="flex items-center justify-between px-5 py-1.5">
|
||||
<ProviderMark provider={source} />
|
||||
<div className="h-3.5 w-3.5 rounded bg-muted-foreground/20" />
|
||||
</div> : null}
|
||||
<div className="space-y-1 px-3 pb-3 sm:px-4">
|
||||
{Array.from({ length: 5 }, (_, index) => (
|
||||
<div key={index} className="flex min-w-0 items-center gap-2 px-1 py-3.5 sm:gap-3 sm:px-2">
|
||||
{ranked ? <div className="h-3 w-6 shrink-0 rounded bg-muted-foreground/20 sm:w-7" /> : null}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex h-7 items-center">
|
||||
<div className="h-3.5 w-48 max-w-[70%] rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
<div className="mt-1 flex h-[1.5em] items-center text-[12px]">
|
||||
<div className="h-3 w-32 max-w-[55%] rounded bg-muted-foreground/20 opacity-60" />
|
||||
</div>
|
||||
</div>
|
||||
{source === "skills_sh" ? <div className="hidden h-[30px] w-24 shrink-0 rounded bg-muted-foreground/10 sm:block" /> : null}
|
||||
<div className="h-9 w-9 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="h-9 w-9 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
</SkeletonStatus>
|
||||
);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function CatalogSkeleton({ label, layout }: {
|
||||
export function CatalogSkeleton({ label, layout, appActionLabel }: {
|
||||
label: string;
|
||||
layout: "apps" | "channels" | "skills";
|
||||
appActionLabel?: string;
|
||||
}) {
|
||||
const channels = layout === "channels";
|
||||
const skills = layout === "skills";
|
||||
@@ -18,20 +19,36 @@ export function CatalogSkeleton({ label, layout }: {
|
||||
channels && "gap-x-4 min-[640px]:grid-cols-2",
|
||||
)}
|
||||
>
|
||||
{skills ? (
|
||||
<div className="flex h-8 items-center gap-2 px-2 py-1.5">
|
||||
<div className={cn(block, "h-3 w-16")} />
|
||||
<div className={cn(block, "h-3 w-3 opacity-60")} />
|
||||
</div>
|
||||
) : null}
|
||||
{Array.from({ length: 6 }, (_, index) => (
|
||||
<div key={index} className={cn(
|
||||
"flex min-w-0 items-center gap-3",
|
||||
channels ? "settings-list-row py-2.5" : skills ? "px-2 py-3" : "px-3 py-3",
|
||||
appActionLabel && "flex-wrap gap-x-3 gap-y-2",
|
||||
)}>
|
||||
<div className={cn(block, "shrink-0", skills
|
||||
? "h-1.5 w-1.5 rounded-full" : "h-9 w-9 rounded-[10px]")} />
|
||||
<div className="min-w-0 flex-1 py-1">
|
||||
<div className={cn(block, "h-3.5", index % 2 ? "w-1/2" : "w-2/3")} />
|
||||
{!channels ? <div className={cn(block, "mt-2 h-3 w-4/5 opacity-60")} /> : null}
|
||||
? "h-1.5 w-1.5 rounded-full" : channels ? "h-8 w-8 rounded-[9px]" : "h-9 w-9 rounded-[10px]")} />
|
||||
<div className={cn("min-w-0 flex-1", appActionLabel && "min-w-[8rem] flex-[1_1_8rem]")}>
|
||||
<div className="flex h-5 items-center">
|
||||
<div className={cn(block, "h-3.5", index % 2 ? "w-1/2" : "w-2/3")} />
|
||||
</div>
|
||||
{!channels ? <div className="mt-0.5 flex h-5 items-center">
|
||||
<div className={cn(block, "h-3 w-4/5 opacity-60")} />
|
||||
</div> : null}
|
||||
</div>
|
||||
<div className={cn("flex shrink-0 items-center justify-center", channels && "w-16")}>
|
||||
<div className={cn(block, channels ? "h-[22px] w-[38px] rounded-full"
|
||||
: skills ? "hidden h-3 w-20 sm:block" : "h-7 w-7 rounded-full")} />
|
||||
<div className={cn("flex shrink-0 items-center justify-center",
|
||||
channels && "w-16", 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" />
|
||||
<span className="invisible">{appActionLabel}</span>
|
||||
</div> : <div className={cn(block, channels ? "h-5 w-[38px] rounded-full"
|
||||
: skills ? "h-3 w-20" : "h-9 w-9 rounded-full")} />}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -505,15 +505,20 @@ export function ModelIdPicker({
|
||||
) : loading ? (
|
||||
<SkeletonStatus
|
||||
label={tx("settings.models.loadingModels", "Loading models...")}
|
||||
className="space-y-0.5 py-1"
|
||||
className="text-[12px]"
|
||||
>
|
||||
{["w-3/5", "w-4/5", "w-1/2"].map((width) => (
|
||||
<div key={width} className="flex items-center gap-2 px-2 py-1.5">
|
||||
<div className="h-3.5 w-3.5 shrink-0 rounded-full bg-muted-foreground/20" />
|
||||
<div key={width} className="flex items-center justify-between gap-2 px-2 py-1.5">
|
||||
<div className="h-5 w-5 shrink-0 rounded-md bg-muted-foreground/20" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className={cn("h-3 rounded bg-muted-foreground/20", width)} />
|
||||
<div className="mt-1.5 h-2.5 w-2/5 rounded bg-muted-foreground/10" />
|
||||
<div className="flex h-[1.5em] items-center">
|
||||
<div className={cn("h-3 rounded bg-muted-foreground/20", width)} />
|
||||
</div>
|
||||
{providerHasManagedModels ? <div className="mt-0.5 flex h-[1.5em] items-center text-[10.5px]">
|
||||
<div className="h-2.5 w-2/5 rounded bg-muted-foreground/10" />
|
||||
</div> : null}
|
||||
</div>
|
||||
<div className="ml-2 h-2.5 w-7 shrink-0 rounded bg-muted-foreground/10" />
|
||||
</div>
|
||||
))}
|
||||
</SkeletonStatus>
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts";
|
||||
import { SettingsGroup } from "@/components/settings/shared/SettingsControls";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS, type RuntimeConfigPage } from "@/components/settings/system/runtime-config-fields";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type Control = "switch" | "input" | "duration" | "segments" | "theme" | "edit" | "text" | "feature";
|
||||
const block = "rounded bg-muted-foreground/20";
|
||||
|
||||
function Title({ heading = false }: { heading?: boolean }) {
|
||||
return <div className={cn("settings-section-title flex h-5 items-center", heading && "!m-0 !p-0")}>
|
||||
<div className={cn(block, "h-3 w-24")} />
|
||||
</div>;
|
||||
}
|
||||
|
||||
function Row({ control }: { control: Control }) {
|
||||
const toggle = control === "switch" || control === "feature";
|
||||
return <div data-settings-skeleton-row className="settings-row">
|
||||
<div className="flex h-5 items-center"><div className={cn(block, "h-3.5 w-32 max-w-full")} /></div>
|
||||
<div className="settings-control">
|
||||
{control === "feature" ? <div className={cn(block, "mr-3 h-3 w-14")} /> : null}
|
||||
{control === "duration" ? <div className="w-full"><div className={cn(block, "h-9 w-full rounded-full")} /><div className="mt-1.5 flex h-4 items-center"><div className={cn(block, "h-2.5 w-4/5 opacity-60")} /></div></div> : <div data-skeleton-switch={toggle ? "" : undefined} className={cn(block,
|
||||
toggle ? "h-5 w-[38px] shrink-0 rounded-full" : control === "input" ? "h-9 w-full rounded-full"
|
||||
: control === "segments" || control === "theme" ? "segmented-control w-44 rounded-full" : control === "edit" ? "ml-auto h-9 w-9 rounded-full" : "h-[19.5px] w-24",
|
||||
control === "segments" && "h-[34px]", control === "theme" && "h-8",
|
||||
)} />}
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
function Group({ controls }: { controls: Control[] }) {
|
||||
return <section><Title /><SettingsGroup>{controls.map((control, index) => <Row key={index} control={control} />)}</SettingsGroup></section>;
|
||||
}
|
||||
|
||||
function RuntimeGroups({ page }: { page: RuntimeConfigPage }) {
|
||||
return <>{RUNTIME_CONFIG_GROUPS.filter((group) => group.page === page).map((group) => group.id === "chat"
|
||||
? <Group key={group.id} controls={["switch", "segments"]} />
|
||||
: <Group key={group.id} controls={RUNTIME_CONFIG_FIELDS.filter((field) => field.group === group.id && (!field.when || field.when.value === true)).map((field) =>
|
||||
field.kind === "boolean" || field.kind === "toggle" ? "switch" : field.kind === "list" ? "edit" : field.kind === "duration" ? "duration" : "input",
|
||||
)} />)}</>;
|
||||
}
|
||||
|
||||
export function SettingsSectionSkeleton({ section, showRestart = false }: { section: SettingsSectionKey; showRestart?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
let content: ReactNode = null;
|
||||
if (isCapabilitySection(section)) content = <>
|
||||
<div className="settings-section-heading"><Title heading /></div>
|
||||
{[0, 1, 2, 3].map((index) => <SettingsGroup key={index}><Row control={index === 3 ? "switch" : "feature"} /></SettingsGroup>)}
|
||||
</>;
|
||||
else switch (section) {
|
||||
case "appearance":
|
||||
content = <><Group controls={["theme", "input"]} /><Group controls={["segments", "segments", "switch", "switch", "switch", "switch"]} /></>;
|
||||
break;
|
||||
case "overview":
|
||||
content = <>
|
||||
<section className="rounded-panel bg-settings-surface p-6">
|
||||
<div className="flex h-5 items-center"><div className={cn(block, "h-3.5 w-24")} /></div>
|
||||
<div className="mt-2 flex h-9 items-center"><div className={cn(block, "h-7 w-20")} /></div>
|
||||
<div className="mt-5 flex h-7 items-center"><div className={cn(block, "h-3.5 w-3/5")} /></div>
|
||||
</section>
|
||||
{[1, 3].map((count) => <section key={count}><Title /><SettingsGroup>{Array.from({ length: count }, (_, index) =>
|
||||
<div key={index} data-overview-skeleton-row className="flex min-h-[68px] items-center gap-3 px-4 py-3.5 sm:px-5">
|
||||
<div className={cn(block, "h-9 w-9 shrink-0 rounded-control")} /><div className={cn(block, "h-3.5 w-28")} />
|
||||
<div className={cn(block, "ml-auto h-3 w-20")} /><div className="h-4 w-4" />
|
||||
</div>,
|
||||
)}</SettingsGroup></section>)}
|
||||
</>;
|
||||
break;
|
||||
case "models":
|
||||
content = <section><Title /><SettingsGroup>
|
||||
<div data-model-preset-skeleton className="settings-list-inset grid grid-cols-[auto_minmax(0,1fr)_auto_auto_auto] items-center gap-x-3 py-5 sm:py-6">
|
||||
<div className={cn(block, "h-[54.25px] w-[54.25px] shrink-0 rounded-control sm:h-[59.75px] sm:w-[59.75px]")} />
|
||||
<div className="min-w-0"><div className="flex h-[30.25px] items-center sm:h-[35.75px]"><div className={cn(block, "h-4 w-2/3 sm:h-5")} /></div><div className="mt-1 flex h-5 items-center"><div className={cn(block, "h-3 w-4/5 opacity-60")} /></div></div>
|
||||
<div className="text-[13px]"><span className="invisible hidden sm:inline">{t("settings.configure")}</span><div className="h-4 w-4 sm:hidden" /></div>
|
||||
<div className="h-4 w-4" /><div className={cn(block, "h-5 w-[38px] shrink-0 rounded-full")} />
|
||||
</div>
|
||||
</SettingsGroup><div className="settings-footer flex items-center justify-between gap-2"><div className="flex h-11 items-center sm:h-9"><div className={cn(block, "h-3 w-20")} /></div><div className="flex h-11 items-center sm:h-9"><div className={cn(block, "h-3 w-28")} /></div></div></section>;
|
||||
break;
|
||||
case "runtime":
|
||||
content = <><RuntimeGroups page="runtime" /><Group controls={["input", "segments", "input", "input"]} /><Group controls={["input"]} /><Group controls={showRestart ? ["text", "text", "input"] : ["text", "text"]} /></>;
|
||||
break;
|
||||
case "advanced":
|
||||
content = <RuntimeGroups page="advanced" />;
|
||||
break;
|
||||
case "about":
|
||||
content = <>
|
||||
<div className="flex flex-col items-center gap-4 py-6">
|
||||
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16" />
|
||||
<img src="/brand/nanobot_wordmark.svg" alt="" className="h-auto w-40 dark:brightness-150" />
|
||||
<div className="flex flex-col items-center gap-4"><div className="mt-0.5 flex h-5 items-center"><div className={cn(block, "h-3 w-20")} /></div><div className={cn(block, "h-9 w-36 rounded-full")} /></div>
|
||||
</div>
|
||||
<SettingsGroup>{[0, 1, 2].map((index) => <div key={index} className="settings-list-row flex items-center gap-3"><div className={cn(block, "h-4 w-4")} /><div className={cn(block, "h-3.5 w-28")} /></div>)}</SettingsGroup>
|
||||
</>;
|
||||
break;
|
||||
}
|
||||
return <SkeletonStatus label={t("settings.status.loading")} className="settings-stack">{content}</SkeletonStatus>;
|
||||
}
|
||||
@@ -348,7 +348,8 @@ export function AppsCatalogSettings({
|
||||
</div>
|
||||
) : null}
|
||||
{loading ? (
|
||||
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps" />
|
||||
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps"
|
||||
appActionLabel={filter === "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>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { CircleAlert, Loader2, X } from "lucide-react";
|
||||
import { useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
|
||||
import type { AutomationRunRecord } from "@/components/settings/system/AutomationRunDialogView";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { formControlFocusClassName } from "@/components/ui/form-control";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
@@ -40,6 +41,7 @@ export interface AutomationCalendarRunProps {
|
||||
|
||||
interface AutomationCalendarProps {
|
||||
jobs: SessionAutomationJob[];
|
||||
loadingLabel?: string;
|
||||
month: Date;
|
||||
locale: string;
|
||||
copy: CalendarCopy;
|
||||
@@ -226,7 +228,7 @@ function CalendarOverflowEntries({ entries, dayLabel, locale, copy, onInspect }:
|
||||
);
|
||||
}
|
||||
|
||||
export function AutomationCalendar({ jobs, month, locale, copy, onInspect, renderRunDialog }: AutomationCalendarProps) {
|
||||
export function AutomationCalendar({ jobs, loadingLabel, month, locale, copy, onInspect, renderRunDialog }: AutomationCalendarProps) {
|
||||
const calendarRef = useRef<HTMLElement | null>(null);
|
||||
const runTrigger = useRef<HTMLElement | null>(null);
|
||||
const [selectedRun, setSelectedRun] = useState<{ job: SessionAutomationJob; run: AutomationRunRecord } | null>(null);
|
||||
@@ -273,8 +275,7 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<section ref={calendarRef} tabIndex={-1} className="automation-calendar overflow-hidden bg-[hsl(var(--settings-surface))]">
|
||||
const content = <>
|
||||
<div className="automation-calendar-header bg-foreground/[0.025]">
|
||||
{wideCalendar ? <div className="automation-calendar-weekdays" aria-hidden>
|
||||
{weekdayLabels.map((label) => <div key={label}>{label}</div>)}
|
||||
@@ -307,6 +308,7 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
</time>
|
||||
</div>
|
||||
<div className="space-y-0.5 px-1 pb-1">
|
||||
{loadingLabel ? <div className="flex h-7 items-center px-2"><div className="h-2.5 w-3/4 rounded bg-muted-foreground/15" /></div> : null}
|
||||
{entries.slice(0, 3).map((entry) => (
|
||||
<CalendarEntryRow
|
||||
key={entry.id}
|
||||
@@ -333,7 +335,15 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
</div> : null}
|
||||
|
||||
{!wideCalendar ? <div className="automation-calendar-agenda px-3 py-2 sm:px-4">
|
||||
{visibleEntries.length ? (
|
||||
{loadingLabel ? <div>
|
||||
{[0, 1, 2].map((index) => <div key={index} data-agenda-skeleton-row className="grid grid-cols-[5.25rem_minmax(0,1fr)] gap-2 py-2.5">
|
||||
<div className="pt-2"><div className="mt-1 h-2.5 w-16 rounded bg-muted-foreground/15" /></div>
|
||||
<div className="px-2 py-2">
|
||||
<div className="flex h-4 items-center"><div className="h-3 w-2/3 rounded bg-muted-foreground/20" /></div>
|
||||
<div className="mt-1 flex h-4 items-center"><div className="h-2.5 w-1/2 rounded bg-muted-foreground/15" /></div>
|
||||
</div>
|
||||
</div>)}
|
||||
</div> : visibleEntries.length ? (
|
||||
<ol>
|
||||
{days.filter((day) => entriesByDay.has(dateKey(day))).map((day) => (
|
||||
<li key={dateKey(day)} className="grid grid-cols-[5.25rem_minmax(0,1fr)] gap-2 py-2.5">
|
||||
@@ -357,7 +367,11 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
|
||||
<div className="flex min-h-28 items-center justify-center text-[13px] text-muted-foreground">{copy.noEntries}</div>
|
||||
)}
|
||||
</div> : null}
|
||||
</>;
|
||||
|
||||
return (
|
||||
<section ref={calendarRef} tabIndex={-1} className="automation-calendar overflow-hidden bg-[hsl(var(--settings-surface))]">
|
||||
{loadingLabel ? <SkeletonStatus label={loadingLabel} className="">{content}</SkeletonStatus> : content}
|
||||
{selectedRun ? renderRunDialog({
|
||||
job: selectedRun.job, run: selectedRun.run, locale, open: runOpen,
|
||||
onOpenChange: setRunOpen,
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { channelTranslator } from "@/channel-plugins/i18n";
|
||||
import { channelUiOwner, channelUiPresentation } from "@/channel-plugins/registry";
|
||||
import { AutomationCalendar } from "@/components/settings/system/AutomationCalendar";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { AutomationRunDialog } from "@/components/settings/system/AutomationRunDialog";
|
||||
import { AutomationChatBinding, type AutomationChatNames, type ChangeAutomationChat } from "@/components/settings/system/AutomationChatBinding";
|
||||
import { AutomationRunAtPicker, parseAutomationRunAt } from "@/components/settings/system/AutomationRunAtPicker";
|
||||
@@ -283,7 +284,7 @@ export function AutomationsSettings({
|
||||
{new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(month)}
|
||||
</h2>
|
||||
) : null}
|
||||
{filters ? <div className="automation-panel-filters min-w-0">{filters}</div> : null}
|
||||
{filters || (loading && !payload) ? <div className="automation-panel-filters min-w-0">{filters ?? <div className="h-8 w-8" aria-hidden />}</div> : null}
|
||||
{view === "calendar" ? (
|
||||
<div className="automation-calendar-navigation flex shrink-0 items-center gap-1">
|
||||
<Button type="button" variant="ghost" size="sm" className="h-8 rounded-full bg-background/60 px-3 text-[12px] text-foreground"
|
||||
@@ -303,11 +304,13 @@ export function AutomationsSettings({
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{loading && !payload ? (
|
||||
<div role="status" className="flex h-44 items-center justify-center rounded-panel border border-border/70 bg-[hsl(var(--settings-surface))] text-[13px] text-muted-foreground">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
||||
{tx("settings.automations.loading", "Loading automations...")}
|
||||
</div>
|
||||
{view === "tasks" && loading && !payload ? (
|
||||
<SkeletonStatus label={tx("settings.automations.loading", "Loading automations...")} className="space-y-1 p-1">
|
||||
{[0, 1, 2].map((index) => <div key={index} data-automation-task-skeleton className="px-3 py-3">
|
||||
<div className="flex h-[21px] items-center"><div className="h-3.5 w-2/5 rounded bg-muted-foreground/20" /></div>
|
||||
<div className="mt-1 flex h-5 items-center"><div className="h-3 w-1/4 rounded bg-muted-foreground/15" /></div>
|
||||
</div>)}
|
||||
</SkeletonStatus>
|
||||
) : view === "tasks" ? (
|
||||
<section className="p-1" aria-label={tx("settings.automations.views.tasks", "Tasks")}>
|
||||
{filtered.length ? (
|
||||
@@ -352,6 +355,7 @@ export function AutomationsSettings({
|
||||
<AutomationCalendar
|
||||
renderRunDialog={(props) => <AutomationRunDialog token={token} {...props} />}
|
||||
jobs={filtered}
|
||||
loadingLabel={loading && !payload ? tx("settings.automations.loading", "Loading automations...") : undefined}
|
||||
month={month}
|
||||
locale={locale}
|
||||
copy={{
|
||||
|
||||
@@ -369,10 +369,17 @@ function ToolsPanel({
|
||||
<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 className="flex items-center justify-between gap-2 sm:justify-end">
|
||||
<div className="relative mr-auto text-[13px] tabular-nums sm:mr-1">
|
||||
<span className="invisible">{tx("settings.mcp.selectedCount", "{{count}} selected").replace("{{count}}", String(selectedToolCount))}</span>
|
||||
<div className="absolute inset-x-0 top-1/2 h-3 -translate-y-1/2 rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
{[tx("settings.mcp.allTools", "All"), tx("settings.mcp.noTools", "None")].map((label) => (
|
||||
<div key={label} className="relative flex h-8 items-center px-2.5 text-[12.5px] font-semibold">
|
||||
<span className="invisible">{label}</span>
|
||||
<div className="absolute inset-x-2.5 top-1/2 h-3 -translate-y-1/2 rounded bg-muted-foreground/20" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="overflow-hidden rounded-floating border border-border/55">
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useSystemSettingsState() {
|
||||
const [cliAppsLoading, setCliAppsLoading] = useState(true);
|
||||
const [nanobotFeaturesLoading, setNanobotFeaturesLoading] = useState(true);
|
||||
const [mcpPresetsLoading, setMcpPresetsLoading] = useState(true);
|
||||
const [automationsLoading, setAutomationsLoading] = useState(false);
|
||||
const [automationsLoading, setAutomationsLoading] = useState(true);
|
||||
const [cliAppsAction, setCliAppsAction] = useState<string | null>(null);
|
||||
const [nanobotFeatureAction, setNanobotFeatureAction] = useState<string | null>(null);
|
||||
const nanobotFeatureActionRef = useRef<string | null>(null);
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
/* Critical first-paint styles are inlined by Vite and shared by StartupSkeleton. */
|
||||
.startup-shell { --startup-fill: hsl(240 4% 40% / .2); --startup-surface: hsl(60 6% 96.7%); --startup-nav: hsl(40 8% 96.8%); display: flex; width: 100%; height: 100%; overflow: hidden; }
|
||||
html.dark .startup-shell { --startup-fill: hsl(0 0% 72% / .2); --startup-surface: hsl(0 0% 22%); --startup-nav: hsl(0 0% 22%); }
|
||||
.startup-shell, .startup-shell * { box-sizing: border-box; }
|
||||
.startup-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
||||
.startup-block { height: 14px; border-radius: 4px; background: var(--startup-fill); }
|
||||
.startup-navigation { display: none; flex: 0 0 var(--startup-sidebar-width); padding: 20px 12px; background: var(--startup-nav); overflow: hidden; }
|
||||
.startup-nav-brand { width: 32px; height: 32px; margin-bottom: 28px; border-radius: 10px; }
|
||||
.startup-nav-row { display: flex; height: 40px; align-items: center; gap: 12px; padding: 0 8px; }
|
||||
.startup-nav-icon { flex: 0 0 16px; height: 16px; }
|
||||
.startup-nav-label { width: 96px; height: 12px; }
|
||||
.startup-content { flex: 1; min-width: 0; height: 100%; }
|
||||
.startup-scroll { height: 100%; overflow-y: auto; scrollbar-gutter: stable; scrollbar-width: thin; }
|
||||
.startup-page { width: 100%; max-width: 816px; padding: 24px 12px; margin: 0 auto; }
|
||||
.startup-page-header { margin-bottom: 28px; }
|
||||
.startup-back { display: flex; align-items: center; height: 30px; margin-bottom: 16px; padding-left: 10px; }
|
||||
@media (pointer: coarse) { .startup-back { height: 44px; } }
|
||||
.startup-back .startup-block { width: 96px; height: 12px; }
|
||||
.startup-title { display: flex; align-items: center; height: 30px; }
|
||||
.startup-title .startup-block { width: 112px; height: 24px; }
|
||||
.startup-tabs { display: none; height: 35.5px; margin-bottom: 20px; }
|
||||
.startup-tabs .startup-block { width: 174px; height: 100%; border-radius: 9999px; }
|
||||
.startup-toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
|
||||
.startup-search { flex: 1; height: 48px; min-height: 48px; border-radius: 9999px; }
|
||||
.startup-filters { width: 100%; height: 34px; border-radius: 9999px; }
|
||||
.startup-catalog-heading { display: none; height: 29px; align-items: start; padding: 3px 16px 8px; border-bottom: 1px solid var(--startup-fill); }
|
||||
.startup-catalog-heading .startup-block { width: 40px; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog-frame { padding: 12px; border-radius: 22px; background: var(--startup-surface); }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog-heading { display: flex; }
|
||||
.startup-catalog { display: grid; gap: 4px; padding: 12px 0; border-radius: 22px; background: var(--startup-surface); }
|
||||
.startup-catalog-group { display: none; align-items: center; height: 32px; padding: 0 8px; }
|
||||
.startup-catalog-group .startup-block { width: 64px; height: 12px; }
|
||||
.startup-catalog-row { display: flex; min-width: 0; align-items: center; gap: 12px; height: 66px; padding: 12px; }
|
||||
.startup-catalog-icon { flex: 0 0 36px; height: 36px; border-radius: 10px; }
|
||||
.startup-catalog-copy { flex: 1; min-width: 0; }
|
||||
.startup-catalog-copy .startup-block:first-child { width: 66.6667%; margin: 3px 0 5.5px; }
|
||||
.startup-catalog-copy .startup-block + .startup-block { width: 80%; height: 12px; opacity: .6; margin: 4px 0; }
|
||||
.startup-catalog-action { flex: 0 0 36px; height: 36px; border-radius: 9999px; }
|
||||
.startup-catalog-row:nth-child(odd) .startup-catalog-copy .startup-block:first-child { width: 50%; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-tabs { display: block; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-panel { overflow: hidden; border-radius: 22px; background: var(--startup-surface); }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-toolbar { padding: 16px 16px 8px; margin: 0; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-search { height: 36px; min-height: 36px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-filters { height: 32.5px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog { display: block; padding: 8px 12px 12px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-group { display: flex; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-row { margin-top: 4px; padding-inline: 8px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-icon { flex-basis: 6px; height: 6px; border-radius: 100%; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-action { display: none; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog { padding: 0; column-gap: 16px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-row { height: 60px; padding: 10px 16px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-icon { flex-basis: 32px; height: 32px; border-radius: 9px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-action { flex-basis: 38px; height: 20px; margin-inline: 13px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog-copy .startup-block + .startup-block { display: none; }
|
||||
.startup-automation, .startup-settings, .startup-chat { display: none; }
|
||||
.startup-shell:is([data-startup-surface="automations"], [data-startup-surface="settings"], [data-startup-surface="remote"]) .startup-panel { display: none; }
|
||||
.startup-shell[data-startup-surface="automations"] .startup-page { max-width: 984px; }
|
||||
.startup-shell[data-startup-surface="automations"] .startup-automation { display: block; }
|
||||
.startup-automation-composer { display: flex; align-items: center; height: 110px; margin-bottom: 20px; padding: 16px; border: 1px solid var(--startup-fill); border-radius: 28px; }
|
||||
.startup-automation-composer .startup-block { width: 60%; }
|
||||
.startup-calendar { background: var(--startup-surface); border-radius: 22px; overflow: hidden; container-type: inline-size; }
|
||||
.startup-calendar-toolbar { display: flex; gap: 8px 16px; align-items: center; flex-wrap: wrap; min-height: 64px; padding: 12px; }
|
||||
.startup-calendar-toolbar .startup-block { width: 156px; height: 40px; border-radius: 16px; }
|
||||
.startup-calendar-toolbar .startup-block + .startup-block { width: 100px; height: 12px; }
|
||||
.startup-calendar-toolbar .startup-block.startup-calendar-navigation { flex: 0 0 130px; height: 32px; }
|
||||
.startup-calendar-days { padding: 8px 12px; }
|
||||
.startup-calendar-days > div { display: none; align-items: center; height: 72px; }
|
||||
.startup-calendar-days > div:nth-child(-n+3) { display: flex; }
|
||||
.startup-calendar-days .startup-block { width: 55%; }
|
||||
@container (min-width: 704px) {
|
||||
.startup-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 32px 0 0; }
|
||||
.startup-calendar-days > div, .startup-calendar-days > div:nth-child(-n+3) { display: flex; align-items: start; height: 112px; padding: 12px; border-top: 1px solid var(--startup-fill); border-right: 1px solid var(--startup-fill); }
|
||||
.startup-calendar-days .startup-block { width: 18px; height: 10px; margin-left: auto; }
|
||||
.startup-shell[data-calendar-weeks="4"] .startup-calendar-days > div:nth-child(n+29),
|
||||
.startup-shell[data-calendar-weeks="5"] .startup-calendar-days > div:nth-child(n+36) { display: none; }
|
||||
}
|
||||
.startup-shell:is([data-startup-surface="settings"], [data-startup-surface="remote"]) .startup-settings { display: block; }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-page { max-width: 720px; padding-inline: 16px; }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-page-header { display: none; }
|
||||
.startup-settings-group + .startup-settings-group { margin-top: 20px; }
|
||||
.startup-settings-title { width: 96px; height: 12px; margin: 4px 16px 24px; }
|
||||
.startup-settings-row { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 12px 16px; gap: 24px; background: var(--startup-surface); }
|
||||
.startup-settings-row:nth-child(2) { border-radius: 22px 22px 0 0; }
|
||||
.startup-settings-row:last-child { border-radius: 0 0 22px 22px; }
|
||||
.startup-settings-row .startup-block { width: 128px; }
|
||||
.startup-settings-row .startup-block + .startup-block { width: 38px; height: 20px; border-radius: 9999px; }
|
||||
.startup-shell[data-startup-surface="chat"] .startup-scroll { display: none; }
|
||||
.startup-shell[data-startup-surface="chat"] .startup-content { container: startup-chat / inline-size; }
|
||||
.startup-shell[data-startup-surface="chat"] .startup-chat { position: relative; display: flex; flex-direction: column; height: 100%; }
|
||||
.startup-chat-header { z-index: 1; display: flex; flex: 0 0 44px; width: 100%; align-items: center; justify-content: space-between; padding: 4px 12px; }
|
||||
.startup-header-leading, .startup-header-actions { display: flex; align-items: center; gap: 2px; padding: 1px; }
|
||||
.startup-header-menu, .startup-header-actions > div { display: flex; width: 28px; height: 28px; align-items: center; justify-content: center; }
|
||||
.startup-chat-header .startup-block { width: 14px; height: 14px; }
|
||||
.startup-chat-header .startup-header-title { display: none; }
|
||||
.startup-chat-viewport { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
|
||||
/* Match ThreadViewport's hero grid: mobile docks the composer, desktop balances its trailing row. */
|
||||
.startup-chat-layout { display: grid; grid-template-rows: minmax(min-content, 1fr) auto 0fr; width: 100%; max-width: 1152px; min-height: 100%; margin: 0 auto; padding: 24px 12px calc(12px + env(safe-area-inset-bottom)); }
|
||||
.startup-messages { display: none; width: 100%; max-width: 816px; margin: 24px auto; padding: 0 20px; }
|
||||
.startup-messages .startup-block { width: 70%; margin-bottom: 20px; }
|
||||
.startup-messages .startup-block:first-child { width: 40%; margin-left: auto; height: 40px; border-radius: 20px; }
|
||||
.startup-messages .startup-block:last-child { width: 50%; }
|
||||
.startup-welcome { display: flex; min-height: 0; align-items: center; justify-content: center; }
|
||||
.startup-welcome-line { display: flex; width: 100%; max-width: 704px; height: 36.72px; align-items: center; justify-content: center; }
|
||||
.startup-welcome-line .startup-block { width: 60%; height: 24px; }
|
||||
.startup-composer { container: startup-composer / inline-size; width: 100%; max-width: 928px; margin: 0 auto; }
|
||||
.startup-composer-surface { overflow: hidden; border-radius: 28px; background: hsl(0 0% 96.1% / .8); }
|
||||
html.dark .startup-composer-surface { background: hsl(0 0% 22%); }
|
||||
.startup-composer-input { display: flex; align-items: start; height: 78px; padding: 27px 16px 8px; }
|
||||
.startup-composer-input .startup-block { width: 45%; height: 14px; margin-top: 5px; }
|
||||
.startup-composer-footer { display: flex; align-items: center; gap: 6px; padding: 0 12px 14px; }
|
||||
.startup-composer-primary, .startup-composer-actions { display: flex; align-items: center; gap: 6px; height: 32px; }
|
||||
.startup-composer-primary { flex: 1; min-width: 0; }
|
||||
.startup-composer-actions { flex-shrink: 0; }
|
||||
.startup-attach, .startup-send { flex: 0 0 32px; height: 32px; border-radius: 50%; }
|
||||
.startup-workspace { width: 112px; }
|
||||
.startup-access { width: 88px; }
|
||||
.startup-model { width: 88px; }
|
||||
.startup-mobile-model, .startup-workspace-row { display: none; }
|
||||
.startup-chat-spacer { min-height: 0; }
|
||||
@container startup-chat (width > 1152px) { .startup-chat-header { position: absolute; inset: 0 0 auto; height: 44px; } }
|
||||
.startup-shell[data-existing-chat="true"] .startup-header-title { display: block; width: 96px; height: 12px; }
|
||||
.startup-shell[data-existing-chat="true"] .startup-chat-layout { display: flex; flex-direction: column; }
|
||||
.startup-shell[data-existing-chat="true"] .startup-messages { display: block; }
|
||||
.startup-shell[data-existing-chat="true"] .startup-composer { max-width: 792px; margin-top: auto; }
|
||||
.startup-shell[data-existing-chat="true"] :is(.startup-welcome, .startup-workspace-row) { display: none; }
|
||||
@media (min-width: 640px) {
|
||||
.startup-chat-layout { grid-template-rows: minmax(min-content, 1fr) auto 1fr; padding: 48px 16px; }
|
||||
.startup-welcome { align-items: end; padding-bottom: 32px; }
|
||||
.startup-welcome-line { height: 60px; }
|
||||
.startup-welcome-line .startup-block { height: 36px; }
|
||||
.startup-composer-input { padding-inline: 20px; }
|
||||
.startup-composer-footer { padding-inline: 16px; }
|
||||
.startup-page { max-width: 824px; padding: 32px 16px; }
|
||||
.startup-title { height: 35px; }
|
||||
.startup-toolbar { flex-direction: row; align-items: center; }
|
||||
.startup-filters { width: 174px; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-toolbar { flex-direction: column; align-items: stretch; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-filters { width: 100%; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog-frame { padding-inline: 16px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-filters { width: 233px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-search { max-width: 320px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-toolbar { justify-content: space-between; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog { padding-inline: 16px; }
|
||||
.startup-shell[data-startup-surface="skills"] .startup-catalog-action { display: block; flex-basis: 80px; height: 12px; margin-left: 12px; }
|
||||
.startup-shell[data-startup-surface="channels"] .startup-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-page { padding-inline: 32px; }
|
||||
.startup-shell[data-startup-surface="automations"] .startup-page { max-width: 992px; }
|
||||
}
|
||||
@media (min-width: 1024px) {
|
||||
.startup-header-menu { display: none; }
|
||||
.startup-navigation { display: block; }
|
||||
.startup-shell[data-embedded="true"] .startup-navigation { display: none; }
|
||||
.startup-shell[data-sidebar-expanded="false"] .startup-nav-label { display: none; }
|
||||
.startup-shell[data-startup-surface="settings"] .startup-navigation { flex-basis: 192px; background: var(--startup-surface); }
|
||||
.startup-page { padding-top: 48px; }
|
||||
.startup-back { display: none; }
|
||||
.startup-shell[data-sidebar-expanded="true"]:not([data-startup-surface="settings"]) .startup-page-header { display: none; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-toolbar { flex-direction: row; align-items: center; }
|
||||
.startup-shell[data-startup-surface="apps"][data-sidebar-expanded="true"] .startup-toolbar { margin-top: 20px; }
|
||||
.startup-shell[data-startup-surface="apps"] .startup-filters { width: 156px; }
|
||||
.startup-automation-composer { height: 62px; }
|
||||
}
|
||||
@media (min-width: 1280px) {
|
||||
.startup-shell[data-startup-surface="apps"] .startup-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
|
||||
}
|
||||
@container startup-composer (max-width: 512px) {
|
||||
.startup-composer-input { height: 52px; padding: 12px 16px 8px; }
|
||||
.startup-composer-footer { gap: 4px; padding: 0 8px 8px; }
|
||||
.startup-composer-primary, .startup-composer-actions { gap: 4px; height: 44px; }
|
||||
.startup-attach, .startup-send { flex-basis: 36px; height: 36px; margin: 4px; }
|
||||
.startup-workspace, .startup-access, .startup-model { display: none; }
|
||||
.startup-mobile-model { display: block; width: 80px; }
|
||||
.startup-workspace-row { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 6px 12px; background: hsl(0 0% 96.1% / .45); }
|
||||
.startup-workspace-row .startup-block { width: 112px; }
|
||||
.startup-workspace-row .startup-block + .startup-block { width: 88px; }
|
||||
html.dark .startup-workspace-row { background: hsl(0 0% 100% / .045); }
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
CalendarClock,
|
||||
ChevronRight,
|
||||
CircleAlert,
|
||||
RefreshCcw,
|
||||
} from "lucide-react";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -15,6 +14,7 @@ import {
|
||||
} from "@/components/settings/system/AutomationsSettings";
|
||||
import type { AutomationAction } from "@/components/settings/system/AutomationsSettings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { formControlFocusClassName } from "@/components/ui/form-control";
|
||||
import {
|
||||
Popover,
|
||||
@@ -112,12 +112,18 @@ export function SessionInfoPopoverView({ title, jobs, loading, loadFailed, now,
|
||||
setActionKey(null);
|
||||
}
|
||||
};
|
||||
const automationContent = loading ? (
|
||||
<div className="mx-2 flex items-center gap-2 rounded-floating bg-muted/45 px-3 py-3 text-[12.5px] text-muted-foreground">
|
||||
<RefreshCcw className="h-3.5 w-3.5 animate-spin" />
|
||||
{t("thread.sessionInfo.loading")}
|
||||
</div>
|
||||
) : loadFailed ? (
|
||||
const automationContent = loading && jobs.length === 0 ? (
|
||||
<SkeletonStatus label={t("thread.sessionInfo.loading")} className="space-y-1 px-2">
|
||||
{[0, 1, 2].map((index) => <div key={index} data-session-job-skeleton className="grid min-h-12 grid-cols-[0.375rem_minmax(0,1fr)_1rem] items-center gap-2.5 px-3 py-2">
|
||||
<div className="h-1.5 w-1.5 rounded-full bg-muted-foreground/20" />
|
||||
<div className="min-w-0">
|
||||
<div className="flex h-5 items-center"><div className="h-3 w-2/3 rounded bg-muted-foreground/20" /></div>
|
||||
<div className="flex h-4 items-center"><div className="h-2.5 w-1/2 rounded bg-muted-foreground/15" /></div>
|
||||
</div>
|
||||
<div className="h-4 w-4" />
|
||||
</div>)}
|
||||
</SkeletonStatus>
|
||||
) : loadFailed && jobs.length === 0 ? (
|
||||
<div className="mx-2 flex items-center gap-2 rounded-floating bg-destructive/10 px-3 py-3 text-[12.5px] text-destructive">
|
||||
<CircleAlert className="h-3.5 w-3.5" />
|
||||
{t("thread.sessionInfo.loadFailed")}
|
||||
@@ -175,7 +181,7 @@ export function SessionInfoPopoverView({ title, jobs, loading, loadFailed, now,
|
||||
{t("thread.sessionInfo.automations")}
|
||||
</span>
|
||||
<span className="rounded-full bg-muted/70 px-2 py-0.5 text-[11px] tabular-nums text-muted-foreground">
|
||||
{t("thread.sessionInfo.count", { count: jobs.length })}
|
||||
{loading && jobs.length === 0 ? "—" : t("thread.sessionInfo.count", { count: jobs.length })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -121,7 +121,7 @@ function WorkspaceDirectorySkeleton() {
|
||||
useLayoutEffect(() => {
|
||||
const viewport = viewportRef.current;
|
||||
if (!viewport) return;
|
||||
const measure = () => setRows(Math.max(1, Math.ceil(viewport.clientHeight / DIRECTORY_ROW_HEIGHT)));
|
||||
const measure = () => setRows(Math.max(1, Math.floor(viewport.clientHeight / DIRECTORY_ROW_HEIGHT)));
|
||||
measure();
|
||||
const observer = new ResizeObserver(measure);
|
||||
observer.observe(viewport);
|
||||
@@ -129,7 +129,7 @@ function WorkspaceDirectorySkeleton() {
|
||||
}, []);
|
||||
const widths = ["64%", "78%", "52%", "70%", "60%", "74%"];
|
||||
return (
|
||||
<div ref={viewportRef} role="status" aria-label={t("workspace.picker.loading")} className="workspace-directory-loading h-full">
|
||||
<div ref={viewportRef} role="status" aria-label={t("workspace.picker.loading")} className="workspace-directory-loading flex h-full flex-col justify-center">
|
||||
<span className="sr-only">{t("workspace.picker.loading")}</span>
|
||||
<div aria-hidden="true">
|
||||
{Array.from({ length: rows }, (_, index) => (
|
||||
@@ -636,7 +636,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
|
||||
<div className={cn("mr-[var(--picker-toolbar-inset)] flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[var(--picker-field-radius)] bg-[#fcfcfc] dark:bg-muted", compact && showLocations && canBrowse && "hidden")}>
|
||||
<div ref={attachColumns} data-workspace-columns className="sidebar-scrollbar flex flex-1 min-h-0 min-w-0 overflow-x-auto overscroll-x-contain">
|
||||
{columns.map((column, columnIndex) => (!compact || columnIndex === currentColumnIndex) && <WorkspaceDirectoryColumn key={columnIndex} options={column.options} selectedPath={column.selectedPath} initialScrollTop={previewingPath ? 0 : currentVisit.scrollTops[columnIndex] ?? 0} visitRevision={history.revision} activeIndex={highlightActive && columnIndex === activeColumn ? activeOption : null}
|
||||
id={`${optionsId}-${columnIndex}`} data-workspace-column={columnIndex} data-current-directory={columnIndex === currentColumnIndex ? "" : undefined} role="listbox" tabIndex={0} aria-activedescendant={highlightActive && columnIndex === activeColumn && column.options.length ? `${optionsId}-${columnIndex}-${activeOption}` : undefined} aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === currentColumnIndex && loading} style={{ width: `${compact ? 100 : 100 / columnCount}%` }} className="sidebar-scrollbar relative min-w-0 shrink-0 overflow-x-hidden overflow-y-auto px-2 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50"
|
||||
id={`${optionsId}-${columnIndex}`} data-workspace-column={columnIndex} data-current-directory={columnIndex === currentColumnIndex ? "" : undefined} role="listbox" tabIndex={0} aria-activedescendant={highlightActive && columnIndex === activeColumn && column.options.length ? `${optionsId}-${columnIndex}-${activeOption}` : undefined} aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === currentColumnIndex && loading} style={{ width: `${compact ? 100 : 100 / columnCount}%` }} className="sidebar-scrollbar relative min-w-0 shrink-0 overflow-x-hidden overflow-y-auto px-2 outline-none [scrollbar-gutter:stable] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50"
|
||||
onFocus={event => { if (event.target === event.currentTarget) { setActiveColumn(columnIndex); setActiveIndex(0); } }}
|
||||
onKeyDown={event => {
|
||||
if (event.target !== event.currentTarget || event.altKey || event.metaKey || event.ctrlKey || pickingFolder) return;
|
||||
|
||||
@@ -1459,12 +1459,12 @@
|
||||
.settings-footer-auto { min-block-size: 40px; padding-block: 8px; row-gap: 0; }
|
||||
.settings-footer-auto > :first-child { grid-column: 1 / -1; font-size: 12px; }
|
||||
.settings-footer-auto > :nth-child(2):empty { display: none; }
|
||||
.settings-row:has(> .settings-control > [role="switch"]) {
|
||||
.settings-row:has(> .settings-control > :is([role="switch"], [data-skeleton-switch])) {
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
column-gap: 24px;
|
||||
}
|
||||
.settings-row:has(> .settings-control > [role="switch"]) > :first-child { grid-column: 1; }
|
||||
.settings-row:has(> .settings-control > [role="switch"]) > :nth-child(2) { grid-column: 2; }
|
||||
.settings-row:has(> .settings-control > :is([role="switch"], [data-skeleton-switch])) > :first-child { grid-column: 1; }
|
||||
.settings-row:has(> .settings-control > :is([role="switch"], [data-skeleton-switch])) > :nth-child(2) { grid-column: 2; }
|
||||
.settings-list-row, .settings-list-inset { padding-inline: var(--settings-inset, 16px); }
|
||||
.settings-list-row { min-block-size: 60px; border-radius: var(--radius-control); }
|
||||
.settings-list-row:focus-visible { outline: none; }
|
||||
|
||||
@@ -8,9 +8,11 @@ const AUTOMATIONS_REFRESH_MS = 3000;
|
||||
|
||||
export function useSessionAutomationJobs(open: boolean, token: string, sessionKey: string) {
|
||||
const pageVisible = usePageVisibility();
|
||||
const [jobs, setJobs] = useState<SessionAutomationJob[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [loadFailed, setLoadFailed] = useState(false);
|
||||
const [snapshot, setSnapshot] = useState<{
|
||||
sessionKey: string;
|
||||
jobs: SessionAutomationJob[] | null;
|
||||
loadFailed: boolean;
|
||||
}>({ sessionKey, jobs: null, loadFailed: false });
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
const tokenRef = useRef(token);
|
||||
tokenRef.current = token;
|
||||
@@ -18,34 +20,28 @@ export function useSessionAutomationJobs(open: boolean, token: string, sessionKe
|
||||
useEffect(() => {
|
||||
if (!open || !pageVisible) return;
|
||||
let cancelled = false;
|
||||
let loadedOnce = false;
|
||||
let refreshing = false;
|
||||
setSnapshot((current) => current.sessionKey === sessionKey
|
||||
? { ...current, loadFailed: false }
|
||||
: { sessionKey, jobs: null, loadFailed: false });
|
||||
|
||||
const refresh = async (showLoading = false) => {
|
||||
const refresh = async () => {
|
||||
if (refreshing) return;
|
||||
refreshing = true;
|
||||
if (showLoading) {
|
||||
setLoading(true);
|
||||
setLoadFailed(false);
|
||||
setJobs([]);
|
||||
}
|
||||
try {
|
||||
const next = await fetchSessionAutomations(tokenRef.current, sessionKey);
|
||||
if (cancelled) return;
|
||||
setJobs(next.jobs);
|
||||
setLoadFailed(false);
|
||||
loadedOnce = true;
|
||||
if (!cancelled) setSnapshot({ sessionKey, jobs: next.jobs, loadFailed: false });
|
||||
} catch {
|
||||
if (!cancelled && !loadedOnce) setLoadFailed(true);
|
||||
if (!cancelled) setSnapshot((current) => current.jobs !== null
|
||||
? current : { sessionKey, jobs: null, loadFailed: true });
|
||||
} finally {
|
||||
refreshing = false;
|
||||
if (!cancelled && showLoading) setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
void refresh(true);
|
||||
const refreshId = window.setInterval(() => void refresh(false), AUTOMATIONS_REFRESH_MS);
|
||||
const refreshOnFocus = () => void refresh(false);
|
||||
void refresh();
|
||||
const refreshId = window.setInterval(() => void refresh(), AUTOMATIONS_REFRESH_MS);
|
||||
const refreshOnFocus = () => void refresh();
|
||||
window.addEventListener("focus", refreshOnFocus);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
@@ -61,5 +57,11 @@ export function useSessionAutomationJobs(open: boolean, token: string, sessionKe
|
||||
return () => window.clearInterval(tickId);
|
||||
}, [open, pageVisible]);
|
||||
|
||||
return { jobs, loading, loadFailed, now };
|
||||
const current = snapshot.sessionKey === sessionKey ? snapshot : null;
|
||||
return {
|
||||
jobs: current?.jobs ?? [],
|
||||
loading: open && current?.jobs == null && !current?.loadFailed,
|
||||
loadFailed: current?.loadFailed ?? false,
|
||||
now,
|
||||
};
|
||||
}
|
||||
@@ -210,6 +210,7 @@ function cachedHistoryState(
|
||||
export function useSessions(): {
|
||||
sessions: ChatSummary[];
|
||||
loading: boolean;
|
||||
initialLoading: boolean;
|
||||
error: string | null;
|
||||
refresh: () => Promise<void>;
|
||||
createChat: (
|
||||
@@ -225,6 +226,7 @@ export function useSessions(): {
|
||||
} {
|
||||
const { client, token } = useClient();
|
||||
const [sessions, setSessions] = useState<ChatSummary[]>(readReloadSessions);
|
||||
const [loadedOnce, setLoadedOnce] = useState(() => sessions.length > 0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const tokenRef = useRef(token);
|
||||
@@ -247,6 +249,7 @@ export function useSessions(): {
|
||||
refreshPendingRef.current = false;
|
||||
try {
|
||||
const rows = await listSessions(tokenRef.current);
|
||||
setLoadedOnce(true);
|
||||
const serverKeys = new Set(rows.map((row) => row.key));
|
||||
setSessions((prev) => {
|
||||
const byKey = new Map(prev.map((row) => [row.key, row]));
|
||||
@@ -379,6 +382,7 @@ export function useSessions(): {
|
||||
return {
|
||||
sessions,
|
||||
loading,
|
||||
initialLoading: loading && !loadedOnce,
|
||||
error,
|
||||
refresh,
|
||||
createChat,
|
||||
|
||||
+11
-1
@@ -28,7 +28,17 @@ initializePairReturn();
|
||||
window.addEventListener("hashchange", initializePairReturn);
|
||||
|
||||
async function renderWebui(container: HTMLElement) {
|
||||
await initializeI18n();
|
||||
// The critical skeleton paints immediately; React must wait for the full stylesheet.
|
||||
const styles = [...document.querySelectorAll<HTMLLinkElement>("link[data-app-stylesheet]")]
|
||||
.map((link) => new Promise<void>((resolve, reject) => {
|
||||
const ready = () => { link.media = "all"; resolve(); };
|
||||
link.addEventListener("load", ready, { once: true });
|
||||
link.addEventListener("error", () => reject(new Error("Failed to load the WebUI stylesheet")), { once: true });
|
||||
link.media = "print";
|
||||
link.rel = "stylesheet";
|
||||
if (link.sheet) ready();
|
||||
}));
|
||||
await Promise.all([initializeI18n(), ...styles]);
|
||||
/* StrictMode disabled: dev double-invokes state updaters; delta accumulation must stay pure — see useNanobotStream. */
|
||||
ReactDOM.createRoot(container).render(<App />);
|
||||
}
|
||||
|
||||
@@ -369,15 +369,16 @@ describe("App layout", () => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("shows only layout shadows while bootstrap is pending", () => {
|
||||
vi.mocked(fetchBootstrap).mockReturnValueOnce(new Promise(() => {}));
|
||||
render(<App />);
|
||||
expect(screen.getByRole("main")).toHaveAttribute("aria-busy", "true");
|
||||
expect(screen.queryByRole("button")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("link")).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("status")).toHaveClass("startup-status");
|
||||
expect(screen.queryByText("Loading nanobot…")).not.toBeInTheDocument();
|
||||
});
|
||||
it.each(["skills", "apps", "channels", "automations", "settings", "chat"]) (
|
||||
"keeps the %s document skeleton while bootstrap is pending", (surface) => {
|
||||
window.history.replaceState(null, "", `/#/${surface}`);
|
||||
vi.mocked(fetchBootstrap).mockReturnValueOnce(new Promise(() => {}));
|
||||
render(<App />);
|
||||
expect(screen.getByRole("main")).toHaveAttribute("aria-busy", "true");
|
||||
expect(screen.getByRole("main")).toHaveAttribute("data-startup-surface", surface);
|
||||
expect(screen.getByRole("status")).toHaveTextContent("Loading nanobot…");
|
||||
},
|
||||
);
|
||||
|
||||
it.each([false, true])("enables task controls only when bootstrap advertises support: %s", async (supported) => {
|
||||
mockSessions = [{
|
||||
|
||||
@@ -85,6 +85,20 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("Automation task list and detail sheet", () => {
|
||||
it("keeps the toolbar during initial loading and retains populated views during refresh", () => {
|
||||
const view = render(<Harness payload={null} loading />);
|
||||
expect(screen.getByRole("status", { name: "Loading automations..." })).toHaveAttribute("aria-busy", "true");
|
||||
const toolbar = screen.getByRole("group", { name: "Task view" }).closest(".automation-panel-toolbar");
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Tasks$/ }));
|
||||
expect(document.querySelectorAll("[data-automation-task-skeleton]")).toHaveLength(3);
|
||||
view.rerender(<Harness loading />);
|
||||
expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible();
|
||||
expect(screen.queryByRole("status", { name: "Loading automations..." })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("group", { name: "Task view" }).closest(".automation-panel-toolbar")).toBe(toolbar);
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Calendar$/ }));
|
||||
expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps view selection and filters in one persistent panel toolbar", () => {
|
||||
render(<Harness />);
|
||||
const views = screen.getByRole("group", { name: "Task view" });
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { Window } from "happy-dom";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { LanguageSwitcher } from "@/components/LanguageSwitcher";
|
||||
import { StartupSkeleton } from "@/components/StartupSkeleton";
|
||||
import { MessageBubble } from "@/components/MessageBubble";
|
||||
import { ContextCompactionNotice } from "@/components/thread/ContextCompactionNotice";
|
||||
import { ThreadComposer } from "@/components/thread/ThreadComposer";
|
||||
@@ -338,7 +340,8 @@ const ACCIDENTALLY_SPANISH_SETTINGS_KEYS = [
|
||||
"settings.image.missingCredential",
|
||||
"settings.oauth.signInHelp",
|
||||
];
|
||||
const INDEX_HTML = readFileSync(resolve(process.cwd(), "index.html"), "utf8");
|
||||
const INDEX_HTML = readFileSync(resolve(process.cwd(), "index.html"), "utf8")
|
||||
.replace("<!--startup-shell-->", renderToStaticMarkup(<StartupSkeleton />));
|
||||
async function runPrebootLocale(storedLocale: string) {
|
||||
const preboot = new Window({
|
||||
url: "http://preboot.test",
|
||||
|
||||
@@ -168,7 +168,8 @@ describe("Linear member access", () => {
|
||||
expect(requestMutation).toHaveBeenCalledTimes(1);
|
||||
fireEvent.click(header());
|
||||
expect(requestMutation).toHaveBeenCalledTimes(1);
|
||||
expect(screen.getByText("Finding members…")).toBeVisible();
|
||||
expect(screen.getByRole("status", { name: "Finding members…" })).toHaveAttribute("aria-busy", "true");
|
||||
expect(document.querySelectorAll("[data-member-skeleton-row]")).toHaveLength(3);
|
||||
expect(screen.getByRole("textbox", { name: "Search members" })).toBeEnabled();
|
||||
expect(header()).toBeEnabled();
|
||||
expect(document.querySelector(".animate-spin")).toBeNull();
|
||||
|
||||
@@ -86,6 +86,31 @@ describe("SessionInfoPopover", () => {
|
||||
expect(screen.getByRole("button", { name: "Session details" })).toHaveFocus();
|
||||
});
|
||||
|
||||
it("uses a skeleton for the initial request and keeps jobs while reopening and refreshing", async () => {
|
||||
let finish!: (response: Response) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
|
||||
const user = userEvent.setup();
|
||||
const view = render(<SessionInfoPopover client={client} sessionKey="websocket:chat-1" token="tok" title="Release work" />);
|
||||
await user.click(screen.getByRole("button", { name: "Session details" }));
|
||||
expect(screen.getByRole("status", { name: "Loading automations..." })).toHaveAttribute("aria-busy", "true");
|
||||
await act(async () => finish(automationsResponse([automationJob()])));
|
||||
expect(await screen.findByRole("button", { name: /Morning check/ })).toBeVisible();
|
||||
await user.keyboard("{Escape}");
|
||||
let fail!: (error: Error) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((_, reject) => { fail = reject; }));
|
||||
await user.click(screen.getByRole("button", { name: "Session details" }));
|
||||
expect(screen.getByRole("button", { name: /Morning check/ })).toBeVisible();
|
||||
expect(screen.queryByRole("status", { name: "Loading automations..." })).not.toBeInTheDocument();
|
||||
await act(async () => fail(new Error("Refresh failed")));
|
||||
expect(screen.getByRole("button", { name: /Morning check/ })).toBeVisible();
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));
|
||||
view.rerender(<SessionInfoPopover client={client} sessionKey="websocket:chat-2" token="tok" title="Other project" />);
|
||||
expect(screen.queryByRole("button", { name: /Morning check/ })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("status", { name: "Loading automations..." })).toBeVisible();
|
||||
await act(async () => finish(automationsResponse([])));
|
||||
expect(await screen.findByText("No automations in this session yet.")).toBeVisible();
|
||||
});
|
||||
|
||||
it("manages a session task through the shared detail dialog", async () => {
|
||||
const boundJob = { ...automationJob(), origin: {
|
||||
session_key: "websocket:chat-1", channel: "websocket", chat_id: "chat-1",
|
||||
|
||||
@@ -164,6 +164,32 @@ describe("Settings system domains", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
["skills", "Loading skills…"],
|
||||
["apps", "Loading apps…"],
|
||||
["channels", "Loading channels…"],
|
||||
["automations", "Loading automations..."],
|
||||
] as const)("keeps the %s loading surface mounted when the settings snapshot arrives", async (initialSection, label) => {
|
||||
let resolveSettings!: (value: Response) => void;
|
||||
const pendingSettings = new Promise<Response>((resolve) => { resolveSettings = resolve; });
|
||||
vi.stubGlobal("fetch", vi.fn((input: RequestInfo | URL) => String(input) === "/api/settings"
|
||||
? pendingSettings : new Promise<Response>(() => {})));
|
||||
renderSettingsView({ initialSection, initialSettings: null, skillsLoading: true, showSidebar: false });
|
||||
const skeleton = screen.getByRole("status", { name: label });
|
||||
expect(skeleton).toHaveAttribute("aria-busy", "true");
|
||||
await act(async () => { resolveSettings(jsonResponse(settingsPayload())); });
|
||||
expect(screen.getByRole("status", { name: label })).toBe(skeleton);
|
||||
});
|
||||
|
||||
it("shows available skills while the unrelated settings snapshot is still pending", () => {
|
||||
vi.stubGlobal("fetch", vi.fn(() => new Promise<Response>(() => {})));
|
||||
renderSettingsView({ initialSection: "skills", initialSettings: null, showSidebar: false, skills: [{
|
||||
name: "project-review", description: "Review a project.", source: "builtin", available: true, enabled: true,
|
||||
}] });
|
||||
expect(screen.getByRole("button", { name: "Open details for project-review" })).toBeVisible();
|
||||
expect(screen.getByRole("textbox", { name: "Search installed skills" })).toBeVisible();
|
||||
});
|
||||
|
||||
it("keeps the regular settings page at its existing width", () => {
|
||||
renderSettingsView({ initialSection: "models", initialSettings: settingsPayload() });
|
||||
|
||||
@@ -258,6 +284,32 @@ describe("Settings system domains", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("loads only the skill detail body and preserves it while checking dependencies again", async () => {
|
||||
const skill = { name: "pr-review", description: "Review pull requests", source: "builtin", available: false, enabled: true };
|
||||
let finish!: (response: Response) => void;
|
||||
vi.stubGlobal("fetch", vi.fn(() => new Promise<Response>((resolve) => { finish = resolve; })));
|
||||
render(<ClientProvider client={{} as never} token="tok"><SkillsCatalogSettings skills={[skill]} /></ClientProvider>);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Open details for pr-review" }));
|
||||
const detail = screen.getByRole("dialog");
|
||||
expect(within(detail).getByText("Review pull requests")).toBeVisible();
|
||||
expect(within(detail).getByRole("status", { name: "Loading skill details..." })).toHaveAttribute("aria-busy", "true");
|
||||
await act(async () => finish(jsonResponse({ ...skill, raw_markdown: "Review repository changes.", requirements: {
|
||||
bins: ["gh"], env: [], missing_bins: ["gh"], missing_env: [],
|
||||
} })));
|
||||
const toggle = within(detail).getByRole("switch");
|
||||
expect(within(detail).getByText("Skill instructions")).toBeVisible();
|
||||
let fail!: (error: Error) => void;
|
||||
vi.mocked(fetch).mockImplementationOnce(() => new Promise((_, reject) => { fail = reject; }));
|
||||
fireEvent.click(within(detail).getByRole("button", { name: "Check again" }));
|
||||
expect(within(detail).getByText("Skill instructions")).toBeVisible();
|
||||
expect(toggle).toBeDisabled();
|
||||
expect(within(detail).queryByRole("status", { name: "Loading skill details..." })).not.toBeInTheDocument();
|
||||
await act(async () => fail(new Error("Read failed")));
|
||||
expect(within(detail).getByRole("alert")).toHaveTextContent("Could not load skill details.");
|
||||
expect(within(detail).getByText("Skill instructions")).toBeVisible();
|
||||
expect(toggle).toBeEnabled();
|
||||
});
|
||||
|
||||
it("keeps skill group labels natural without changing grouping or filtering", () => {
|
||||
render(<ClientProvider client={{} as never} token="tok">
|
||||
<SkillsCatalogSettings skills={[
|
||||
|
||||
@@ -140,7 +140,9 @@ export function renderSettingsView(
|
||||
| "image"
|
||||
| "browser"
|
||||
| "runtime";
|
||||
initialSettings?: SettingsPayload;
|
||||
initialSettings?: SettingsPayload | null;
|
||||
skills?: React.ComponentProps<typeof SettingsView>["skills"];
|
||||
skillsLoading?: boolean;
|
||||
showSidebar?: boolean;
|
||||
mainNavigationExpanded?: boolean;
|
||||
onBackToChat?: () => void;
|
||||
@@ -163,6 +165,8 @@ export function renderSettingsView(
|
||||
theme="light"
|
||||
initialSection={options.initialSection ?? "apps"}
|
||||
initialSettings={options.initialSettings}
|
||||
skills={options.skills}
|
||||
skillsLoading={options.skillsLoading}
|
||||
showSidebar={options.showSidebar}
|
||||
mainNavigationExpanded={options.mainNavigationExpanded}
|
||||
onToggleTheme={() => {}}
|
||||
|
||||
@@ -74,6 +74,20 @@ function wrap(
|
||||
}
|
||||
|
||||
describe("useSessions", () => {
|
||||
it("distinguishes initial loading from revalidating a successfully loaded empty list", async () => {
|
||||
let finish!: (rows: Awaited<ReturnType<typeof api.listSessions>>) => void;
|
||||
vi.mocked(api.listSessions).mockImplementation(() => new Promise((resolve) => { finish = resolve; }));
|
||||
const { result } = renderHook(() => useSessions(), { wrapper: wrap(fakeClient()) });
|
||||
expect(result.current.initialLoading).toBe(true);
|
||||
await act(async () => finish([]));
|
||||
expect(result.current.initialLoading).toBe(false);
|
||||
let refresh!: Promise<void>;
|
||||
act(() => { refresh = result.current.refresh(); });
|
||||
expect(result.current.loading).toBe(true);
|
||||
expect(result.current.initialLoading).toBe(false);
|
||||
await act(async () => { finish([]); await refresh; });
|
||||
});
|
||||
|
||||
it("shows tab-cached sessions while revalidating and removes server-deleted rows", async () => {
|
||||
activateReloadCache("ws://localhost:8765/");
|
||||
writeReloadCache("sessions", [{
|
||||
@@ -86,6 +100,7 @@ describe("useSessions", () => {
|
||||
try {
|
||||
expect(result.current.sessions[0]?.key).toBe("websocket:cached");
|
||||
expect(result.current.loading).toBe(true);
|
||||
expect(result.current.initialLoading).toBe(false);
|
||||
await act(async () => finish([]));
|
||||
expect(result.current.sessions).toEqual([]);
|
||||
expect(result.current.loading).toBe(false);
|
||||
|
||||
Reference in new issue
Block a user