feat(webui): expand and organize settings with autosave (#5704)
* feat(webui): expand settings with autosave and live configuration * feat(memory): add long-term memory and idle compaction switches * refactor(webui): clarify settings hierarchy and align compact controls * refactor(webui): keep only memory consolidation in memory settings * refactor(webui): defer runtime changes until explicit restart * refactor(webui): remove default workspace setting * fix(webui): align model lists and remove preset counters * fix(i18n): use natural Chinese labels for chat platforms * fix(i18n): shorten chat settings navigation label * fix(webui): match settings navigation icons to text size * refactor(webui): remove redundant settings sidebar heading * refactor(webui): use icon-only back navigation in settings * fix(webui): remove back arrow hover hint * refactor(webui): remove redundant overview details * refactor(webui): hide secondary descriptions in settings rows * style(webui): replace settings dividers with rounded highlights * refactor(webui): remove redundant model list subtitles and badges * fix(i18n): restore chat translation namespace boundaries * fix(i18n): complete settings translations for all locales * fix(webui): reveal settings only for enabled capabilities * fix(webui): consolidate capabilities and isolate settings feedback * fix(webui): clear restart notices when settings are reverted * fix(webui): anchor restart controls in settings sidebar * fix(webui): shorten sidebar restart label * fix(webui): align settings spacing and control sizes * refactor(webui): unify settings dialogs and interaction feedback * fix(webui): keep settings option groups on one line without scrolling * refactor(webui): align settings spacing and sidebar icon proportions * style(webui): match main sidebar typography to settings * style(webui): use monospace for sidebar session handles * refactor(webui): remove heartbeat configuration from automations * feat(webui): expose configuration actions beside capability toggles * style(webui): remove ellipsis from configuration actions * refactor(webui): remove redundant app configuration controls * feat(webui): add compact sidebar navigation and shortcut hints * fix(webui): synchronize npm dependency lockfile * test(webui): align input radius expectation with pill styling * feat(webui): show daily token usage and cache breakdown * feat(webui): add model usage details and cache hit rates * feat(webui): chart daily token usage by model * refactor(webui): simplify usage details and model labels * fix(webui): hide usage dialog date range * refactor(webui): consolidate model usage into chart legends * fix(webui): enforce restart choices and correct settings test route * fix(webui): polish settings localization and controls * fix(webui): avoid repeated usage legend labels * fix(webui): skip empty usage columns in keyboard navigation * test(webui): assert settings behavior positively * feat(webui): refine sidebar navigation and add drag resizing * style(webui): soften sidebar scroll edges * style(webui): harmonize sidebar typography and text colors * feat(webui): move channels to the main sidebar * style(webui): remove dotted underlines from settings hints * fix(webui): unify tooltip hover delay * fix(webui): support Seatbelt sandbox settings * fix(webui): remove unused appearance density preference * fix(webui): align settings input values consistently * style(webui): group compact settings controls before inputs * feat(webui): edit multiline settings in compact dialogs * feat(webui): add continuous settings scrolling with gentle snapping * Revert "feat(webui): add continuous settings scrolling with gentle snapping" This reverts commit f0978c261a53c844185eeab4d0c3190fbd196fe6.
This commit is contained in:
1 parent
20f115bf46
commit
8ea683679d
244 files changed
+6929
-3900
No files matched your search
@@ -48,6 +48,7 @@ import {
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { SettingsTextEditor } from "@/components/settings/shared/SettingsTextEditor";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { isGenericRepositoryLogoUrl, logoFallbackUrls } from "@/lib/provider-brand";
|
||||
import type {
|
||||
@@ -245,7 +246,7 @@ export function AppsCatalogSettings({
|
||||
)
|
||||
: "";
|
||||
return (
|
||||
<div className="space-y-7">
|
||||
<div className="settings-stack">
|
||||
<div role="status" className="sr-only">{oauthStatusAnnouncement}</div>
|
||||
<section className="space-y-4">
|
||||
<div className="flex flex-col gap-3 lg:flex-row lg:items-center">
|
||||
@@ -303,7 +304,7 @@ export function AppsCatalogSettings({
|
||||
{loading ? (
|
||||
<div className="flex h-36 items-center justify-center text-sm text-muted-foreground">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
||||
{tx("settings.apps.loading", "Loading Apps...")}
|
||||
{tx("settings.apps.loading", "Loading apps…")}
|
||||
</div>
|
||||
) : items.length ? (
|
||||
<div className="grid grid-cols-1 gap-x-10 gap-y-1 py-3 xl:grid-cols-2">
|
||||
@@ -412,7 +413,7 @@ function CliAppsCatalogRow({
|
||||
const description = app.description || app.requires || app.entry_point || app.name;
|
||||
|
||||
return (
|
||||
<article className="apps-catalog-row group flex min-w-0 items-center gap-3 rounded-control px-3 py-3 transition-colors hover:bg-muted/45">
|
||||
<article className="apps-catalog-row group flex min-w-0 items-center gap-3 rounded-control px-3 py-3 transition-colors settings-hover">
|
||||
<CliAppLogo app={app} showBrandLogos={showBrandLogos} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex min-w-0 items-baseline gap-2">
|
||||
@@ -583,7 +584,7 @@ function McpAppsCatalogRow({
|
||||
};
|
||||
|
||||
return (
|
||||
<article className="min-w-0 rounded-control transition-colors hover:bg-muted/45">
|
||||
<article className="min-w-0 rounded-control transition-colors settings-hover">
|
||||
<div className="group flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 px-3 py-3">
|
||||
<McpPresetLogo preset={preset} showBrandLogos={showBrandLogos} />
|
||||
<div className="min-w-[8rem] flex-[1_1_8rem]">
|
||||
@@ -918,9 +919,9 @@ export const AppsActionButton = forwardRef<HTMLButtonElement, AppsActionButtonPr
|
||||
visibleLabel
|
||||
? "h-8 w-auto gap-1.5 px-3 text-[12px] font-semibold"
|
||||
: "h-9 w-9",
|
||||
tone === "installed" && "bg-transparent hover:bg-muted/70 hover:text-foreground",
|
||||
tone === "installed" && "bg-transparent settings-hover hover:text-foreground",
|
||||
tone === "danger" && "bg-transparent hover:bg-destructive/10 hover:text-destructive",
|
||||
tone === "default" && "bg-muted/70 hover:bg-muted hover:text-foreground",
|
||||
tone === "default" && "bg-muted/70 settings-hover hover:text-foreground",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
@@ -1146,16 +1147,12 @@ function McpCustomServerPanel({
|
||||
htmlFor={headersInputId}
|
||||
className="mb-1 block text-[11.5px] font-medium text-muted-foreground"
|
||||
>
|
||||
{tx("settings.mcp.headers", "Headers JSON")}
|
||||
{tx("settings.mcp.headers", "Headers (JSON)")}
|
||||
</label>
|
||||
<Textarea
|
||||
id={headersInputId}
|
||||
aria-describedby={headersHelpId}
|
||||
value={form.headers}
|
||||
onChange={(event) => update("headers", event.target.value)}
|
||||
placeholder={'{"Authorization":"Bearer ..."}'}
|
||||
className="min-h-[68px] resize-y bg-background/80 font-mono text-[12px]"
|
||||
/>
|
||||
<SettingsTextEditor id={headersInputId} title={tx("settings.mcp.headers", "Headers (JSON)")}
|
||||
value={form.headers} onSave={(value) => update("headers", value)}
|
||||
placeholder={'{"Authorization":"Bearer ..."}'}
|
||||
/>
|
||||
<p
|
||||
id={headersHelpId}
|
||||
className="mt-1 text-[11.5px] leading-5 text-muted-foreground"
|
||||
@@ -1180,7 +1177,7 @@ function McpCustomServerPanel({
|
||||
aria-hidden
|
||||
/>
|
||||
{advancedOpen
|
||||
? tx("settings.mcp.hideAdvanced", "Hide advanced")
|
||||
? tx("settings.mcp.hideAdvanced", "Hide advanced options")
|
||||
: tx("settings.mcp.advancedOptions", "Advanced options")}
|
||||
</Button>
|
||||
|
||||
@@ -1196,30 +1193,26 @@ function McpCustomServerPanel({
|
||||
{!remote ? (
|
||||
<label className="min-w-0">
|
||||
<span className="mb-1 block text-[11.5px] font-medium text-muted-foreground">
|
||||
{tx("settings.mcp.args", "Args JSON")}
|
||||
{tx("settings.mcp.args", "Arguments (JSON)")}
|
||||
</span>
|
||||
<Textarea
|
||||
value={form.args}
|
||||
onChange={(event) => update("args", event.target.value)}
|
||||
placeholder={'["-y", "docs-mcp"]'}
|
||||
className="min-h-[68px] resize-y bg-background/80 font-mono text-[12px]"
|
||||
/>
|
||||
<SettingsTextEditor title={tx("settings.mcp.args", "Arguments (JSON)")}
|
||||
value={form.args} onSave={(value) => update("args", value)}
|
||||
placeholder={'["-y", "docs-mcp"]'}
|
||||
/>
|
||||
</label>
|
||||
) : null}
|
||||
<label className="min-w-0">
|
||||
<span className="mb-1 block text-[11.5px] font-medium text-muted-foreground">
|
||||
{tx("settings.mcp.env", "Env JSON")}
|
||||
{tx("settings.mcp.env", "Environment variables (JSON)")}
|
||||
</span>
|
||||
<Textarea
|
||||
value={form.env}
|
||||
onChange={(event) => update("env", event.target.value)}
|
||||
<SettingsTextEditor title={tx("settings.mcp.env", "Environment variables (JSON)")}
|
||||
value={form.env} onSave={(value) => update("env", value)}
|
||||
placeholder={'{"API_KEY":"..."}'}
|
||||
className="min-h-[68px] resize-y bg-background/80 font-mono text-[12px]"
|
||||
/>
|
||||
</label>
|
||||
<label className="min-w-0">
|
||||
<span className="mb-1 block text-[11.5px] font-medium text-muted-foreground">
|
||||
{tx("settings.mcp.timeout", "Tool timeout")}
|
||||
{tx("settings.mcp.timeout", "Tool timeout (seconds)")}
|
||||
</span>
|
||||
<Input
|
||||
value={form.toolTimeout}
|
||||
@@ -1240,7 +1233,7 @@ function McpCustomServerPanel({
|
||||
className="h-9 w-full rounded-full px-4 text-[12.5px] font-semibold sm:w-auto"
|
||||
>
|
||||
{customBusy ? <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" aria-hidden /> : <Check className="mr-1.5 h-3.5 w-3.5" aria-hidden />}
|
||||
{tx("settings.mcp.saveCustom", "Save MCP")}
|
||||
{tx("settings.mcp.saveCustom", "Save MCP server")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1253,11 +1246,9 @@ function McpCustomServerPanel({
|
||||
<span className="mb-1.5 block text-[11.5px] font-medium text-muted-foreground">
|
||||
{tx("settings.mcp.configImport", "Import mcp.json")}
|
||||
</span>
|
||||
<Textarea
|
||||
value={configImport}
|
||||
onChange={(event) => onConfigImportChange(event.target.value)}
|
||||
<SettingsTextEditor title={tx("settings.mcp.configImport", "Import mcp.json")}
|
||||
value={configImport} onSave={onConfigImportChange}
|
||||
placeholder={'{"mcpServers":{"docs":{"command":"npx","args":["-y","docs-mcp"]}}}'}
|
||||
className="min-h-[84px] resize-y bg-background/80 font-mono text-[12px]"
|
||||
/>
|
||||
</label>
|
||||
<Button
|
||||
@@ -1295,7 +1286,7 @@ function mcpOAuthStatusText(
|
||||
}
|
||||
return popupBlocked
|
||||
? tx("settings.mcp.openSignInToContinue", "Open the sign-in page to continue.")
|
||||
: tx("settings.mcp.finishSignInInBrowser", "Finish signing in in the browser window.");
|
||||
: tx("settings.mcp.finishSignInInBrowser", "Complete sign-in in the browser window.");
|
||||
case "connecting":
|
||||
return tx("settings.mcp.finishingConnection", "Finishing connection...");
|
||||
case "authorized":
|
||||
@@ -1433,7 +1424,7 @@ function CliAppReadyPanel({
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={copyPrompt}
|
||||
className="h-8 rounded-full px-3 text-[12px] font-medium text-muted-foreground hover:bg-muted/65 hover:text-foreground"
|
||||
className="h-8 rounded-full px-3 text-[12px] font-medium text-muted-foreground settings-hover hover:text-foreground"
|
||||
>
|
||||
{copied ? <Check className="mr-1.5 h-3.5 w-3.5" aria-hidden /> : null}
|
||||
{copied
|
||||
|
||||
@@ -166,7 +166,7 @@ export function AutomationsSettings({
|
||||
"Search task, message, linked chat, or schedule",
|
||||
)}
|
||||
className={cn(
|
||||
"h-9 w-full rounded-control pl-9 text-[13px]",
|
||||
"h-9 w-full rounded-full pl-9 text-[13px]",
|
||||
SETTINGS_SEARCH_INPUT_CLASS,
|
||||
)}
|
||||
/>
|
||||
@@ -175,7 +175,7 @@ export function AutomationsSettings({
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex h-9 min-w-[8.5rem] items-center justify-center gap-1.5 whitespace-nowrap rounded-control border border-border/45 bg-settings-surface px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground sm:w-auto"
|
||||
className="inline-flex h-9 min-w-[8.5rem] items-center justify-center gap-1.5 whitespace-nowrap rounded-control border border-border/45 bg-settings-surface px-3 text-[12px] font-medium text-muted-foreground transition-colors settings-hover hover:text-foreground sm:w-auto"
|
||||
>
|
||||
<ArrowUpDown className="h-3.5 w-3.5" aria-hidden />
|
||||
<span>{sortLabel[sort]}</span>
|
||||
@@ -316,7 +316,7 @@ function AutomationListItem({
|
||||
"group grid w-full grid-cols-[minmax(0,1fr)_auto] gap-3 rounded-floating px-3 py-3.5 text-left transition-colors",
|
||||
selected
|
||||
? "bg-background/80 text-foreground"
|
||||
: "text-muted-foreground hover:bg-background/55 hover:text-foreground",
|
||||
: "text-muted-foreground settings-hover hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
<span className="min-w-0">
|
||||
@@ -1070,27 +1070,27 @@ function automationEditDraftError(
|
||||
job: SessionAutomationJob | null,
|
||||
tx: (key: string, fallback: string, values?: Record<string, unknown>) => string,
|
||||
): string | null {
|
||||
if (!draft.name.trim()) return tx("settings.automations.validation.nameRequired", "Name is required.");
|
||||
if (!draft.name.trim()) return tx("settings.automations.validation.nameRequired", "Enter a task name.");
|
||||
if (isLocalTriggerAutomation(job)) return null;
|
||||
if (!draft.message.trim()) {
|
||||
return tx("settings.automations.validation.messageRequired", "Message is required.");
|
||||
return tx("settings.automations.validation.messageRequired", "Enter a task message.");
|
||||
}
|
||||
if (draft.scheduleKind === "every") {
|
||||
const value = Number(draft.everyValue);
|
||||
if (!Number.isInteger(value) || value <= 0) {
|
||||
return tx("settings.automations.validation.intervalRequired", "Interval must be a positive number.");
|
||||
return tx("settings.automations.validation.intervalRequired", "Enter a positive whole number for the interval.");
|
||||
}
|
||||
}
|
||||
if (draft.scheduleKind === "cron" && !draft.cronExpr.trim()) {
|
||||
return tx("settings.automations.validation.cronRequired", "Cron expression is required.");
|
||||
return tx("settings.automations.validation.cronRequired", "Enter a Cron expression.");
|
||||
}
|
||||
if (draft.scheduleKind === "at") {
|
||||
const atMs = new Date(draft.atLocal).getTime();
|
||||
if (!Number.isFinite(atMs)) {
|
||||
return tx("settings.automations.validation.timeRequired", "Run time is required.");
|
||||
return tx("settings.automations.validation.timeRequired", "Choose a run time.");
|
||||
}
|
||||
if (atMs <= Date.now() && automationScheduleChanged(draft, job)) {
|
||||
return tx("settings.automations.validation.futureRequired", "Run time must be in the future.");
|
||||
return tx("settings.automations.validation.futureRequired", "Choose a time in the future.");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,52 +1,26 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { ChevronLeft, Loader2, Search } from "lucide-react";
|
||||
import { useRef, useState } from "react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import {
|
||||
channelIsRunning,
|
||||
channelMatchesFilter,
|
||||
channelSearchText,
|
||||
localizedChannelDisplayName,
|
||||
type ChannelFilter,
|
||||
} from "@/components/settings/channels/ChannelIdentity";
|
||||
import { localizedChannelDisplayName } from "@/components/settings/channels/ChannelIdentity";
|
||||
import { ChannelCatalogRow, ChannelSetupPanel } from "@/components/settings/channels/ChannelSetupPanel";
|
||||
import {
|
||||
DismissibleStatusMessage,
|
||||
RestartRequiredNotice,
|
||||
SETTINGS_SEARCH_INPUT_CLASS,
|
||||
} from "@/components/settings/shared/SettingsControls";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { useMediaQuery } from "@/hooks/useMediaQuery";
|
||||
import { DismissibleStatusMessage, RestartRequiredNotice, SettingsGroup } from "@/components/settings/shared/SettingsControls";
|
||||
import type { NanobotFeaturesPayload } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
|
||||
|
||||
export function ChannelsSettings({
|
||||
token,
|
||||
nanobotFeatures,
|
||||
loading,
|
||||
query,
|
||||
actionKey,
|
||||
chatAppsDocsUrl,
|
||||
showBrandLogos,
|
||||
error,
|
||||
requiresRestartPending,
|
||||
onQueryChange,
|
||||
onAction,
|
||||
onFeaturesUpdate,
|
||||
onDismissStatus,
|
||||
onRestart,
|
||||
isRestarting,
|
||||
token, nanobotFeatures, loading, actionKey, chatAppsDocsUrl, showBrandLogos,
|
||||
error, requiresRestartPending, onAction, onFeaturesUpdate, onDismissStatus,
|
||||
onRestart, isRestarting,
|
||||
}: {
|
||||
token: string;
|
||||
nanobotFeatures: NanobotFeaturesPayload | null;
|
||||
loading: boolean;
|
||||
query: string;
|
||||
actionKey: string | null;
|
||||
chatAppsDocsUrl?: string;
|
||||
showBrandLogos: boolean;
|
||||
error: string | null;
|
||||
requiresRestartPending: boolean;
|
||||
onQueryChange: (value: string) => void;
|
||||
onAction: (action: "enable" | "disable", name: string) => void;
|
||||
onFeaturesUpdate: (payload: NanobotFeaturesPayload) => void;
|
||||
onDismissStatus: () => void;
|
||||
@@ -54,204 +28,58 @@ export function ChannelsSettings({
|
||||
isRestarting?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
const [filter, setFilter] = useState<ChannelFilter>("all");
|
||||
const splitLayout = useMediaQuery("(min-width: 1280px)");
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const compactDetailTopRef = useRef<HTMLButtonElement>(null);
|
||||
const [compactDetailOpen, setCompactDetailOpen] = useState(false);
|
||||
const allChannels = (nanobotFeatures?.features ?? [])
|
||||
.filter((feature) => feature.type === "channel")
|
||||
.filter((feature) => feature.settings_visible !== false)
|
||||
.filter((feature) => !normalizedQuery || channelSearchText(feature, t).includes(normalizedQuery))
|
||||
.sort((left, right) => {
|
||||
const rank = Number(!left.ready) - Number(!right.ready);
|
||||
return rank || localizedChannelDisplayName(left, t).localeCompare(
|
||||
localizedChannelDisplayName(right, t),
|
||||
);
|
||||
});
|
||||
const channels = allChannels.filter((feature) => channelMatchesFilter(feature, filter));
|
||||
const [selectedChannelName, setSelectedChannelName] = useState<string | null>(null);
|
||||
const selectedChannel =
|
||||
channels.find((feature) => feature.name === selectedChannelName) ?? channels[0] ?? null;
|
||||
const enabledCount = allChannels.filter(channelIsRunning).length;
|
||||
const offCount = Math.max(0, allChannels.length - enabledCount);
|
||||
const filterOptions: Array<{ value: ChannelFilter; label: string; count: number }> = [
|
||||
{ value: "all", label: tx("settings.channels.filterAll", "All"), count: allChannels.length },
|
||||
{ value: "on", label: tx("settings.channels.filterOn", "On"), count: enabledCount },
|
||||
{ value: "off", label: tx("settings.channels.filterOff", "Off"), count: offCount },
|
||||
];
|
||||
const statusMessage = error;
|
||||
const statusIsError = true;
|
||||
|
||||
useEffect(() => {
|
||||
if (!channels.length) {
|
||||
if (selectedChannelName !== null) setSelectedChannelName(null);
|
||||
setCompactDetailOpen(false);
|
||||
return;
|
||||
}
|
||||
if (!selectedChannelName || !channels.some((feature) => feature.name === selectedChannelName)) {
|
||||
setSelectedChannelName(channels[0].name);
|
||||
setCompactDetailOpen(false);
|
||||
}
|
||||
}, [channels, selectedChannelName]);
|
||||
|
||||
useEffect(() => {
|
||||
if (splitLayout) return;
|
||||
const resetScroll = () => {
|
||||
let node = containerRef.current?.parentElement ?? null;
|
||||
while (node) {
|
||||
node.scrollTop = 0;
|
||||
node = node.parentElement;
|
||||
}
|
||||
if (compactDetailOpen) {
|
||||
compactDetailTopRef.current?.scrollIntoView?.({ block: "start" });
|
||||
}
|
||||
};
|
||||
resetScroll();
|
||||
const frame = window.requestAnimationFrame(resetScroll);
|
||||
return () => window.cancelAnimationFrame(frame);
|
||||
}, [compactDetailOpen, selectedChannelName, splitLayout]);
|
||||
|
||||
const openChannel = (name: string) => {
|
||||
setSelectedChannelName(name);
|
||||
if (!splitLayout) setCompactDetailOpen(true);
|
||||
};
|
||||
|
||||
const setupPanel = selectedChannel ? (
|
||||
<ChannelSetupPanel
|
||||
token={token}
|
||||
feature={selectedChannel}
|
||||
actionKey={actionKey}
|
||||
chatAppsDocsUrl={chatAppsDocsUrl}
|
||||
showBrandLogos={showBrandLogos}
|
||||
onAction={onAction}
|
||||
onFeaturesUpdate={onFeaturesUpdate}
|
||||
/>
|
||||
) : null;
|
||||
const showingCompactDetail = !splitLayout && compactDetailOpen && selectedChannel !== null;
|
||||
const [connectRequestId, setConnectRequestId] = useState(0);
|
||||
const triggerRef = useRef<HTMLElement | null>(null);
|
||||
const dialogRef = useRef<HTMLDivElement | null>(null);
|
||||
const channels = (nanobotFeatures?.features ?? [])
|
||||
.filter((feature) => feature.type === "channel" && feature.settings_visible !== false)
|
||||
.sort((left, right) => Number(!left.ready) - Number(!right.ready)
|
||||
|| localizedChannelDisplayName(left, t).localeCompare(localizedChannelDisplayName(right, t)));
|
||||
const selectedChannel = channels.find((feature) => feature.name === selectedChannelName);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="flex min-h-full flex-1 flex-col xl:min-h-0 xl:overflow-hidden"
|
||||
>
|
||||
{!showingCompactDetail ? (
|
||||
<section className="shrink-0 space-y-4">
|
||||
<div className="flex flex-col gap-3 lg:flex-row lg:items-center">
|
||||
<div className="relative min-w-0 flex-1">
|
||||
<Search className="pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||
<Input
|
||||
value={query}
|
||||
onChange={(event) => onQueryChange(event.target.value)}
|
||||
placeholder={tx("settings.channels.searchPlaceholder", "Search channels")}
|
||||
className={cn(
|
||||
"h-12 rounded-control pl-11 text-[15px]",
|
||||
SETTINGS_SEARCH_INPUT_CLASS,
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-wrap gap-1.5 rounded-control bg-muted/55 p-1">
|
||||
{filterOptions.map((option) => (
|
||||
<button
|
||||
key={option.value}
|
||||
type="button"
|
||||
onClick={() => setFilter(option.value)}
|
||||
className={cn(
|
||||
"rounded-control px-3 py-1.5 text-[12px] font-medium transition-colors",
|
||||
filter === option.value
|
||||
? "bg-background text-foreground"
|
||||
: "text-muted-foreground hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
<span className="ml-1 text-[11px] text-muted-foreground">{option.count}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{statusMessage ? (
|
||||
<div className="mt-3 shrink-0">
|
||||
<DismissibleStatusMessage
|
||||
message={statusMessage}
|
||||
isError={statusIsError}
|
||||
onDismiss={onDismissStatus}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="settings-stack">
|
||||
{error ? <DismissibleStatusMessage message={error} isError onDismiss={onDismissStatus} /> : null}
|
||||
{requiresRestartPending ? (
|
||||
<div className="mt-3 shrink-0">
|
||||
<RestartRequiredNotice
|
||||
message={tx("settings.channels.restartRequired", "Restart nanobot to apply updated channel support.")}
|
||||
onRestart={onRestart}
|
||||
isRestarting={isRestarting}
|
||||
/>
|
||||
</div>
|
||||
<RestartRequiredNotice message={t("settings.channels.restartRequired")}
|
||||
onRestart={onRestart} isRestarting={isRestarting} />
|
||||
) : null}
|
||||
|
||||
<section
|
||||
className={cn(
|
||||
"flex flex-1 flex-col",
|
||||
showingCompactDetail ? "mt-1" : "mt-5",
|
||||
splitLayout && "min-h-0 overflow-hidden",
|
||||
)}
|
||||
>
|
||||
{loading && !nanobotFeatures ? (
|
||||
<div className="flex h-36 items-center justify-center text-sm text-muted-foreground">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
||||
{tx("settings.channels.loading", "Loading Channels...")}
|
||||
</div>
|
||||
) : channels.length ? splitLayout ? (
|
||||
<div className="grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)_minmax(400px,460px)] gap-6 overflow-hidden">
|
||||
<div className="min-h-0 space-y-1 overflow-y-auto overscroll-contain pr-1">
|
||||
{channels.map((feature) => (
|
||||
<ChannelCatalogRow
|
||||
key={feature.name}
|
||||
feature={feature}
|
||||
selected={selectedChannel?.name === feature.name}
|
||||
showBrandLogos={showBrandLogos}
|
||||
onSelect={() => openChannel(feature.name)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="min-h-0 overflow-y-auto overscroll-contain pr-1">{setupPanel}</div>
|
||||
</div>
|
||||
) : showingCompactDetail ? (
|
||||
<div className="pb-6">
|
||||
<button
|
||||
ref={compactDetailTopRef}
|
||||
type="button"
|
||||
onClick={() => setCompactDetailOpen(false)}
|
||||
className="mb-4 inline-flex h-9 items-center gap-1.5 rounded-full px-2.5 text-[13px] font-medium text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground"
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" aria-hidden />
|
||||
{tx("settings.channels.backToChannels", "All channels")}
|
||||
</button>
|
||||
{setupPanel}
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-1 pb-6">
|
||||
{channels.map((feature) => (
|
||||
<ChannelCatalogRow
|
||||
key={feature.name}
|
||||
feature={feature}
|
||||
selected={false}
|
||||
showBrandLogos={showBrandLogos}
|
||||
onSelect={() => openChannel(feature.name)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="min-h-0 flex-1 px-3 py-12 text-center text-sm text-muted-foreground">
|
||||
{tx("settings.channels.empty", "No channels match this filter.")}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
{loading && !nanobotFeatures ? (
|
||||
<div className="flex h-36 items-center justify-center text-sm text-muted-foreground">
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
||||
{t("settings.channels.loading")}
|
||||
</div>
|
||||
) : channels.length ? (
|
||||
<SettingsGroup>
|
||||
{channels.map((feature) => (
|
||||
<ChannelCatalogRow key={feature.name} feature={feature} showBrandLogos={showBrandLogos}
|
||||
actionKey={actionKey} onAction={onAction}
|
||||
onSelect={(connect = false) => {
|
||||
triggerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
setConnectRequestId(connect ? 1 : 0);
|
||||
setSelectedChannelName(feature.name);
|
||||
}} />
|
||||
))}
|
||||
</SettingsGroup>
|
||||
) : (
|
||||
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
|
||||
{t("settings.channels.empty")}
|
||||
</div>
|
||||
)}
|
||||
<Dialog open={Boolean(selectedChannel)} onOpenChange={(open) => { if (!open) setSelectedChannelName(null); }}>
|
||||
<DialogContent ref={dialogRef} aria-describedby={undefined} className="max-h-[85dvh] w-[min(calc(100vw-2rem),40rem)] max-w-none overflow-y-auto p-0 outline-none"
|
||||
onOpenAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
dialogRef.current?.focus({ preventScroll: true });
|
||||
}}
|
||||
onCloseAutoFocus={(event) => { event.preventDefault(); triggerRef.current?.focus(); }}>
|
||||
<DialogTitle className="sr-only">{t("settings.nav.channels")}</DialogTitle>
|
||||
{selectedChannel ? <ChannelSetupPanel token={token} feature={selectedChannel} actionKey={actionKey}
|
||||
chatAppsDocsUrl={chatAppsDocsUrl} showBrandLogos={showBrandLogos}
|
||||
onAction={onAction} onFeaturesUpdate={onFeaturesUpdate} connectRequestId={connectRequestId} /> : null}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -449,7 +449,7 @@ function ToolsPanel({
|
||||
return (
|
||||
<label
|
||||
key={toolName}
|
||||
className="flex min-h-11 cursor-pointer items-center gap-3 border-b border-border/45 px-3.5 py-2.5 transition-colors last:border-b-0 hover:bg-muted/35 has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-inset has-[:focus-visible]:ring-ring"
|
||||
className="flex min-h-11 cursor-pointer items-center gap-3 border-b border-border/45 px-3.5 py-2.5 transition-colors last:border-b-0 settings-hover has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-inset has-[:focus-visible]:ring-ring"
|
||||
>
|
||||
<span className="relative h-5 w-5 shrink-0">
|
||||
<input
|
||||
@@ -598,7 +598,7 @@ function ConnectionPanel({
|
||||
{field.label}
|
||||
{field.configured ? (
|
||||
<span className="font-normal text-emerald-600 dark:text-emerald-300">
|
||||
· {tx("settings.mcp.configured", "configured")}
|
||||
· {tx("settings.mcp.configured", "Configured")}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
@@ -607,7 +607,7 @@ function ConnectionPanel({
|
||||
type={field.secret ? "password" : "text"}
|
||||
value={values[field.name] ?? ""}
|
||||
onChange={(event) => onFieldChange(preset.name, field.name, event.target.value)}
|
||||
placeholder={field.configured ? tx("settings.mcp.keepExisting", "Leave blank to keep existing") : field.placeholder}
|
||||
placeholder={field.configured ? tx("settings.mcp.keepExisting", "Leave blank to keep the current value") : field.placeholder}
|
||||
className="h-10 rounded-full bg-muted/35 text-[12.5px]"
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { ToggleButton } from "@/components/settings/ToggleButton";
|
||||
import { SettingsGroup, SettingsRow, SettingsSectionTitle, RestartRequiredNotice, RestartSettingsFooter } from "@/components/settings/shared/SettingsControls";
|
||||
import { ProviderPicker } from "@/components/settings/shared/ModelControls";
|
||||
import { TimezonePicker } from "@/components/settings/shared/TimezonePicker";
|
||||
import { SettingsTextEditor } from "@/components/settings/shared/SettingsTextEditor";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS, type RuntimeConfigField, type RuntimeConfigPage } from "@/components/settings/system/runtime-config-fields";
|
||||
import { updateRuntimeConfigSettings } from "@/lib/api";
|
||||
import type { NanobotClient } from "@/lib/nanobot-client";
|
||||
import type { RuntimeConfigValue, SettingsPayload } from "@/lib/types";
|
||||
import type { ApplySettingsPayload } from "@/components/settings/contracts";
|
||||
|
||||
type Draft = string | boolean;
|
||||
|
||||
function displayValue(value: RuntimeConfigValue | undefined): Draft {
|
||||
if (typeof value === "boolean") return value;
|
||||
if (Array.isArray(value)) return value.join("\n");
|
||||
return value == null ? "" : String(value);
|
||||
}
|
||||
|
||||
export function useRuntimeConfigSettings(
|
||||
settings: SettingsPayload | null,
|
||||
client: NanobotClient,
|
||||
applyPayload: ApplySettingsPayload,
|
||||
) {
|
||||
const { t } = useTranslation();
|
||||
const [drafts, setDrafts] = useState<Record<string, Draft>>({});
|
||||
const [saving, setSaving] = useState<string | null>(null);
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
const [invalidField, setInvalidField] = useState<string | null>(null);
|
||||
const delay = useRef(600);
|
||||
const saveLatest = useRef<(group: string) => Promise<void>>(async () => {});
|
||||
const pendingGroups = useRef<string[]>([]);
|
||||
const queuedSaves = useRef<string[]>([]);
|
||||
const [saved, setSaved] = useState<Record<string, boolean>>({});
|
||||
useEffect(() => {
|
||||
if (invalidField && saving === null) document.getElementById(`runtime-${invalidField}`)?.focus();
|
||||
}, [invalidField, saving]);
|
||||
const value = (path: string): Draft => drafts[path] ?? displayValue(settings?.runtime_config?.[path]);
|
||||
const visible = (field: RuntimeConfigField) => !field.when || (Array.isArray(field.when.value)
|
||||
? field.when.value.includes(String(value(field.when.path)))
|
||||
: value(field.when.path) === field.when.value);
|
||||
const dirty = (field: RuntimeConfigField) =>
|
||||
drafts[field.path] !== undefined && drafts[field.path] !== displayValue(settings?.runtime_config?.[field.path]);
|
||||
const discard = (group: string) => {
|
||||
setDrafts((prev) => Object.fromEntries(Object.entries(prev).filter(([path]) =>
|
||||
!RUNTIME_CONFIG_FIELDS.some((field) => field.group === group && field.path === path),
|
||||
)));
|
||||
setErrors((prev) => ({ ...prev, [group]: "" }));
|
||||
setInvalidField(null);
|
||||
};
|
||||
const change = (field: RuntimeConfigField, next: Draft) => {
|
||||
delay.current = ["boolean", "toggle", "select", "preset"].includes(field.kind) ? 0 : 600;
|
||||
setDrafts((prev) => ({ ...prev, [field.path]: next }));
|
||||
setSaved((prev) => ({ ...prev, [field.group]: false }));
|
||||
setErrors((prev) => ({ ...prev, [field.group]: "" }));
|
||||
setInvalidField(null);
|
||||
};
|
||||
const save = async (group: string) => {
|
||||
if (!settings?.runtime_config) return;
|
||||
if (saving) {
|
||||
if (!queuedSaves.current.includes(group)) queuedSaves.current.push(group);
|
||||
return;
|
||||
}
|
||||
const changed = RUNTIME_CONFIG_FIELDS.filter((field) => field.group === group && visible(field) && dirty(field));
|
||||
if (!changed.length) return;
|
||||
const values: Record<string, RuntimeConfigValue> = {};
|
||||
for (const field of changed) {
|
||||
const raw = value(field.path);
|
||||
if (field.kind === "number") {
|
||||
const parsed = Number(raw);
|
||||
if (String(raw).trim() === "" || !Number.isFinite(parsed)
|
||||
|| (field.path !== "api.timeout" && !Number.isInteger(parsed))
|
||||
|| (field.min !== undefined && parsed < field.min)
|
||||
|| (field.max !== undefined && parsed > field.max)) {
|
||||
setErrors((prev) => ({ ...prev, [group]: t("settings.runtimeConfig.numberError") }));
|
||||
setInvalidField(field.path);
|
||||
return;
|
||||
}
|
||||
values[field.path] = parsed;
|
||||
} else if (field.kind === "list") {
|
||||
values[field.path] = String(raw).split("\n").map((line) => line.trim()).filter(Boolean);
|
||||
} else if (field.kind === "nullable" || field.kind === "preset") {
|
||||
values[field.path] = String(raw).trim() || null;
|
||||
} else {
|
||||
values[field.path] = raw;
|
||||
}
|
||||
}
|
||||
setSaving(group);
|
||||
setErrors((prev) => ({ ...prev, [group]: "" }));
|
||||
try {
|
||||
const payload = await updateRuntimeConfigSettings(client, values);
|
||||
applyPayload(payload, { preserveAgentForm: true, preserveCapabilityForms: true });
|
||||
discard(group);
|
||||
setSaved((prev) => ({ ...prev, [group]: true }));
|
||||
} catch (error) {
|
||||
const message = (error as Error).message;
|
||||
setErrors((prev) => ({ ...prev, [group]: message }));
|
||||
setInvalidField(changed.find((field) => message.startsWith(field.path))?.path ?? null);
|
||||
} finally {
|
||||
setSaving(null);
|
||||
}
|
||||
};
|
||||
saveLatest.current = save;
|
||||
pendingGroups.current = [...new Set(RUNTIME_CONFIG_FIELDS.filter((field) =>
|
||||
visible(field) && dirty(field) && !errors[field.group]
|
||||
&& !RUNTIME_CONFIG_FIELDS.some((other) => other.group === field.group && other.manual && dirty(other)),
|
||||
).map((field) => field.group))];
|
||||
useEffect(() => {
|
||||
if (saving) return;
|
||||
const timer = window.setTimeout(() => {
|
||||
const group = queuedSaves.current.shift() ?? pendingGroups.current[0];
|
||||
if (group) void saveLatest.current(group);
|
||||
}, delay.current);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [drafts, saving]);
|
||||
const saveList = async (field: RuntimeConfigField, next: string) => {
|
||||
const payload = await updateRuntimeConfigSettings(client, {
|
||||
[field.path]: next.split("\n").map((line) => line.trim()).filter(Boolean),
|
||||
});
|
||||
applyPayload(payload, { preserveAgentForm: true, preserveCapabilityForms: true });
|
||||
setSaved((prev) => ({ ...prev, [field.group]: true }));
|
||||
};
|
||||
return { value, visible, dirty, discard, change, save, saveList, saving, errors, invalidField, saved };
|
||||
}
|
||||
|
||||
export type RuntimeConfigController = ReturnType<typeof useRuntimeConfigSettings>;
|
||||
|
||||
export function RuntimeConfigSettings({
|
||||
page, settings, state, onRestart, isRestarting, remoteBrowserAccess, children,
|
||||
}: {
|
||||
page: RuntimeConfigPage;
|
||||
settings: SettingsPayload;
|
||||
state: RuntimeConfigController;
|
||||
onRestart?: () => void;
|
||||
isRestarting: boolean;
|
||||
remoteBrowserAccess: boolean;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tr = (key: string) => t(`settings.runtimeConfig.${key}`);
|
||||
if (!settings.runtime_config) return <div className="settings-stack">
|
||||
<p className="settings-editor text-[13px] leading-5 text-muted-foreground">{tr("unavailable")}</p>
|
||||
{children}
|
||||
</div>;
|
||||
const groups = RUNTIME_CONFIG_GROUPS.filter((group) => group.page === page);
|
||||
const restartPending = settings.restart_required_sections?.includes("runtime")
|
||||
|| (settings.requires_restart && Object.values(state.saved).some(Boolean));
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
{restartPending && onRestart ? <RestartRequiredNotice message={t("settings.status.savedRestartApply")}
|
||||
onRestart={onRestart} isRestarting={isRestarting} /> : null}
|
||||
{groups.map((group) => {
|
||||
if (group.enabledBy && state.value(group.enabledBy) === false) return null;
|
||||
if (group.id === "chat") return <div key={group.id}>{children}</div>;
|
||||
const fields = RUNTIME_CONFIG_FIELDS.filter((field) => field.group === group.id);
|
||||
const dirty = fields.filter(state.visible).some(state.dirty);
|
||||
const title = tr(`groups.${group.id}.title`);
|
||||
const errorId = `runtime-error-${group.id}`;
|
||||
const section = (
|
||||
<section key={group.id} aria-label={title}>
|
||||
<SettingsSectionTitle>{title}</SettingsSectionTitle>
|
||||
<form noValidate onSubmit={(event) => { event.preventDefault(); void state.save(group.id); }}>
|
||||
<fieldset disabled={state.saving === group.id || isRestarting} className="min-w-0">
|
||||
<legend className="sr-only">{title}</legend>
|
||||
<button type="submit" hidden />
|
||||
<SettingsGroup>
|
||||
{fields.filter(state.visible).map((field) => {
|
||||
const id = `runtime-${field.path}`;
|
||||
const key = field.path.replaceAll(".", "_");
|
||||
const text = tr(`fields.${key}.label`);
|
||||
const help = tr(`fields.${key}.help`);
|
||||
const current = state.value(field.path);
|
||||
const disabled = (field.path === "agents.defaults.timezone" && state.value("agents.defaults.timezone_mode") === "auto")
|
||||
|| (field.path === "tools.webui_allow_remote_package_install" && remoteBrowserAccess);
|
||||
const common = {
|
||||
id, disabled, "aria-label": text, "aria-describedby": `${id}-help${state.invalidField === field.path ? ` ${errorId}` : ""}`,
|
||||
"aria-invalid": state.invalidField === field.path || undefined,
|
||||
};
|
||||
const options = field.kind === "preset"
|
||||
? ["", ...new Set(["default", ...settings.model_presets.map((preset) => preset.name)])]
|
||||
: [...field.options ?? []];
|
||||
// Keep a configured preset visible if it is no longer available.
|
||||
if (field.kind === "preset" && current && !options.includes(String(current))) options.push(String(current));
|
||||
return (
|
||||
<SettingsRow key={field.path} title={text} description={help}>
|
||||
<span id={`${id}-help`} className="sr-only">{help}</span>
|
||||
{field.kind === "boolean" || field.kind === "toggle" ? (
|
||||
<ToggleButton {...common} checked={field.kind === "toggle" ? current === field.options?.[1] : current === true} label={text}
|
||||
onChange={(next) => state.change(field, field.kind === "toggle" ? field.options![next ? 1 : 0] : next)} />
|
||||
) : (
|
||||
<div className="w-full">
|
||||
{field.path === "agents.defaults.timezone" ? (
|
||||
<TimezonePicker {...common} value={String(current)} onChange={(next) => state.change(field, next)} />
|
||||
) : field.kind === "list" ? (
|
||||
<SettingsTextEditor id={id} title={text} description={help} value={String(current)}
|
||||
disabled={disabled || state.saving !== null || isRestarting}
|
||||
onSave={(next) => state.saveList(field, next)} />
|
||||
) : field.kind === "select" || field.kind === "preset" ? (
|
||||
<ProviderPicker triggerProps={{ ...common, disabled: disabled || state.saving === group.id || isRestarting }}
|
||||
value={String(current) || "__none__"} emptyLabel={tr("none")}
|
||||
providers={options.map((option) => ({ name: option || "__none__", label:
|
||||
!option ? tr(field.kind === "preset" ? "activeModel" : "none")
|
||||
: ["auto", "manual", "standard", "persistent"].includes(option) ? tr(option) : option,
|
||||
}))}
|
||||
onChange={(next) => state.change(field, next === "__none__" ? "" : next)} />
|
||||
) : (
|
||||
<Input {...common} type={field.kind === "number" ? "number" : "text"}
|
||||
min={field.min} max={field.max} step={field.path === "api.timeout" ? "any" : 1}
|
||||
value={String(current)} className="h-9 rounded-full text-[13px]" autoComplete="off"
|
||||
onChange={(event) => state.change(field, event.target.value)} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</SettingsRow>
|
||||
);
|
||||
})}
|
||||
<RestartSettingsFooter autoSave={!fields.some((field) => field.manual && state.dirty(field))} dirty={dirty} saving={state.saving === group.id}
|
||||
error={Boolean(state.errors[group.id])}
|
||||
disabled={state.saving === group.id || isRestarting}
|
||||
pendingRestart={false}
|
||||
message={state.saved[group.id] && !dirty ? tr("saved") : undefined}
|
||||
onSave={() => void state.save(group.id)} onReset={() => state.discard(group.id)}
|
||||
onRestart={onRestart} isRestarting={isRestarting} />
|
||||
</SettingsGroup>
|
||||
</fieldset>
|
||||
{state.errors[group.id] ? <p id={errorId} role="alert" className="mt-2 break-words px-1 text-[12px] text-destructive">{state.errors[group.id]}</p> : null}
|
||||
</form>
|
||||
</section>
|
||||
);
|
||||
return section;
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -91,11 +91,11 @@ export function RuntimeSettings({
|
||||
const [apiKeyVisible, setApiKeyVisible] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!apiService) return;
|
||||
setApiHost(apiService.host);
|
||||
setApiPort(apiService.port);
|
||||
setApiHost(settings.api?.host ?? apiService.host);
|
||||
setApiPort(settings.api?.port ?? apiService.port);
|
||||
setApiKey("");
|
||||
setApiKeyVisible(false);
|
||||
}, [apiService]);
|
||||
}, [apiService, settings.api?.host, settings.api?.port]);
|
||||
const apiNetworkAccess = !isLoopbackHost(apiHost);
|
||||
const apiMissingNetworkKey = apiNetworkAccess && !apiKey.trim() && !apiDefaults.api_key_hint;
|
||||
const engineState = isRestarting
|
||||
@@ -114,7 +114,7 @@ export function RuntimeSettings({
|
||||
target,
|
||||
message: tx(
|
||||
"settings.status.hostApiUnavailable",
|
||||
"Host actions are only available inside the native app.",
|
||||
"These actions are only available in the desktop app.",
|
||||
),
|
||||
});
|
||||
return;
|
||||
@@ -131,7 +131,7 @@ export function RuntimeSettings({
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="space-y-7">
|
||||
<div className="settings-stack">
|
||||
{isNativeHost ? (
|
||||
<section>
|
||||
<SettingsSectionTitle>{tx("settings.sections.nativeHost", "Native host")}</SettingsSectionTitle>
|
||||
@@ -238,7 +238,7 @@ export function RuntimeSettings({
|
||||
: {
|
||||
host: apiHost,
|
||||
port: apiPort,
|
||||
timeout: apiDefaults.timeout,
|
||||
timeout: settings.api?.timeout ?? apiDefaults.timeout,
|
||||
apiKey: apiKey.trim() || undefined,
|
||||
},
|
||||
)
|
||||
@@ -284,8 +284,7 @@ export function RuntimeSettings({
|
||||
<SettingsRow title={tx("settings.api.port", "Port")}>
|
||||
<NumberInput value={apiPort} min={1} max={65535} onChange={setApiPort} />
|
||||
</SettingsRow>
|
||||
{apiNetworkAccess ? (
|
||||
<SettingsRow
|
||||
<SettingsRow
|
||||
title={tx("settings.api.apiKey", "API key")}
|
||||
description={
|
||||
apiMissingNetworkKey
|
||||
@@ -293,7 +292,7 @@ export function RuntimeSettings({
|
||||
: tx("settings.api.apiKeyHelp", "Clients send this as a Bearer token.")
|
||||
}
|
||||
>
|
||||
<div className="relative w-[280px] max-w-full">
|
||||
<div className="relative w-full">
|
||||
<Input
|
||||
type={apiKeyVisible ? "text" : "password"}
|
||||
value={apiKey}
|
||||
@@ -312,8 +311,7 @@ export function RuntimeSettings({
|
||||
{apiKeyVisible ? <EyeOff className="h-3.5 w-3.5" /> : <Eye className="h-3.5 w-3.5" />}
|
||||
</Button>
|
||||
</div>
|
||||
</SettingsRow>
|
||||
) : null}
|
||||
</SettingsRow>
|
||||
</>
|
||||
) : null}
|
||||
</SettingsGroup>
|
||||
@@ -353,7 +351,7 @@ export function RuntimeSettings({
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
) : null}
|
||||
{capabilityAction === "enable:langfuse"
|
||||
? tx("settings.capabilities.installing", "Installing support...")
|
||||
? tx("settings.capabilities.installing", "Installing required packages…")
|
||||
: tx("settings.observability.enable", "Enable tracing support")}
|
||||
</Button>
|
||||
)}
|
||||
@@ -372,14 +370,18 @@ export function RuntimeSettings({
|
||||
/>
|
||||
) : null}
|
||||
<ReadOnlyRow title={t("settings.rows.configPath")} value={settings.runtime.config_path} />
|
||||
<ReadOnlyRow title={tx("settings.rows.workspacePath", "Default workspace")} value={settings.runtime.workspace_path} />
|
||||
<ReadOnlyRow title={tx("settings.rows.timezone", "Timezone")} value={form.timezone} />
|
||||
{!settings.runtime_config ? (
|
||||
<ReadOnlyRow title={tx("settings.rows.workspacePath", "Default workspace")} value={settings.runtime.workspace_path} />
|
||||
) : null}
|
||||
{!settings.runtime_config ? (
|
||||
<ReadOnlyRow title={tx("settings.rows.timezone", "Timezone")} value={form.timezone} />
|
||||
) : null}
|
||||
{onRestart ? (
|
||||
<SettingsRow
|
||||
title={t("settings.rows.restart")}
|
||||
description={
|
||||
requiresRestartPending
|
||||
? tx("settings.status.savedRestartApply", "Saved. Restart when ready.")
|
||||
? tx("settings.status.savedRestartApply", "Saved. Restart to apply changes.")
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
export interface RuntimeConfigField {
|
||||
group: string;
|
||||
path: string;
|
||||
kind: "toggle" | "text" | "nullable" | "number" | "boolean" | "select" | "list" | "preset";
|
||||
options?: string[];
|
||||
when?: { path: string; value: string | boolean | string[] };
|
||||
manual?: boolean;
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
|
||||
export type RuntimeConfigPage = "memory" | "runtime" | "advanced" | "browser" | "image";
|
||||
|
||||
export const RUNTIME_CONFIG_GROUPS: { id: string; page: RuntimeConfigPage; enabledBy?: string }[] = [
|
||||
{ id: "identity", page: "runtime" },
|
||||
{ id: "memory", page: "memory" },
|
||||
{ id: "chat", page: "advanced" },
|
||||
{ id: "execution", page: "advanced" },
|
||||
{ id: "sessions", page: "runtime" },
|
||||
{ id: "tools", page: "runtime" },
|
||||
{ id: "web", page: "browser" },
|
||||
{ id: "shell", page: "advanced", enabledBy: "tools.exec.enable" },
|
||||
{ id: "network", page: "advanced", enabledBy: "tools.web.enable" },
|
||||
{ id: "safety", page: "advanced" },
|
||||
{ id: "cli", page: "advanced", enabledBy: "tools.cli_apps.enable" },
|
||||
{ id: "gateway", page: "advanced" },
|
||||
{ id: "api", page: "advanced" },
|
||||
{ id: "storage", page: "image" },
|
||||
];
|
||||
|
||||
export const RUNTIME_CONFIG_FIELDS: RuntimeConfigField[] = [
|
||||
{ group: "identity", path: "agents.defaults.timezone_mode", kind: "toggle", options: ["manual", "auto"] },
|
||||
{ group: "identity", path: "agents.defaults.timezone", kind: "text", when: { path: "agents.defaults.timezone_mode", value: "manual" } },
|
||||
{ group: "memory", path: "agents.defaults.dream.enabled", kind: "boolean" },
|
||||
{ group: "execution", path: "agents.defaults.provider_retry_mode", kind: "toggle", options: ["standard", "persistent"] },
|
||||
{ group: "execution", path: "agents.defaults.max_tool_iterations", kind: "number", min: 1 },
|
||||
{ group: "execution", path: "agents.defaults.max_concurrent_subagents", kind: "number", min: 1 },
|
||||
{ group: "execution", path: "agents.defaults.max_tool_result_chars", kind: "number", min: 1 },
|
||||
{ group: "execution", path: "agents.defaults.tool_hint_max_length", kind: "number", min: 20, max: 500 },
|
||||
{ group: "execution", path: "tools.max_session_messages_per_minute", kind: "number", min: 1 },
|
||||
{ group: "sessions", path: "agents.defaults.unified_session", kind: "boolean" },
|
||||
{ group: "tools", path: "tools.exec.enable", kind: "boolean" },
|
||||
{ group: "tools", path: "tools.file.enable", kind: "boolean" },
|
||||
{ group: "web", path: "tools.web.enable", kind: "boolean" },
|
||||
{ group: "tools", path: "tools.my.enable", kind: "boolean" },
|
||||
{ group: "tools", path: "tools.my.allow_set", kind: "boolean", when: { path: "tools.my.enable", value: true } },
|
||||
{ group: "shell", path: "tools.exec.timeout", kind: "number", min: 0 },
|
||||
{ group: "shell", path: "tools.exec.path_prepend", kind: "text" },
|
||||
{ group: "shell", path: "tools.exec.path_append", kind: "text" },
|
||||
{ group: "shell", path: "tools.exec.sandbox", kind: "select", options: ["", "bwrap", "seatbelt"] },
|
||||
{ group: "shell", path: "tools.exec.sandbox_ro_binds", kind: "list", when: { path: "tools.exec.sandbox", value: ["bwrap", "seatbelt"] } },
|
||||
{ group: "shell", path: "tools.exec.sandbox_rw_binds", kind: "list", when: { path: "tools.exec.sandbox", value: ["bwrap", "seatbelt"] } },
|
||||
{ group: "shell", path: "tools.exec.allowed_env_keys", kind: "list" },
|
||||
{ group: "shell", path: "tools.exec.allow_patterns", kind: "list" },
|
||||
{ group: "shell", path: "tools.exec.deny_patterns", kind: "list" },
|
||||
{ group: "network", path: "tools.web.proxy", kind: "nullable" },
|
||||
{ group: "network", path: "tools.web.user_agent", kind: "nullable" },
|
||||
{ group: "safety", path: "tools.restrict_to_workspace", kind: "boolean" },
|
||||
{ group: "safety", path: "tools.webui_allow_remote_package_install", kind: "boolean" },
|
||||
{ group: "safety", path: "tools.ssrf_whitelist", kind: "list" },
|
||||
{ group: "cli", path: "tools.cli_apps.install_timeout", kind: "number", min: 1, max: 3600 },
|
||||
{ group: "cli", path: "tools.cli_apps.run_timeout", kind: "number", min: 1, max: 600 },
|
||||
{ group: "cli", path: "tools.cli_apps.catalog_ttl_seconds", kind: "number", min: 60, max: 86400 },
|
||||
{ group: "gateway", path: "gateway.host", kind: "text", manual: true },
|
||||
{ group: "gateway", path: "gateway.port", kind: "number", min: 1, max: 65535, manual: true },
|
||||
{ group: "gateway", path: "gateway.restart_mode", kind: "select", options: ["auto", "exec", "spawn", "exit"] },
|
||||
{ group: "api", path: "api.host", kind: "text", manual: true },
|
||||
{ group: "api", path: "api.timeout", kind: "number", min: 1, max: 3600 },
|
||||
{ group: "storage", path: "tools.image_generation.save_dir", kind: "text" },
|
||||
];
|
||||
@@ -85,7 +85,7 @@ export function useSystemSettingsEffects({
|
||||
useEffect(() => {
|
||||
if (
|
||||
!pageVisible
|
||||
|| !["channels", "models", "browser", "runtime"].includes(activeSection)
|
||||
|| !["channels", "models", "browser", "image", "voice", "memory", "capabilities", "runtime"].includes(activeSection)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ export function useSystemSettingsState() {
|
||||
const [apiServiceAction, setApiServiceAction] = useState<"start" | "stop" | null>(null);
|
||||
const [apiServiceError, setApiServiceError] = useState<string | null>(null);
|
||||
const [appsQuery, setAppsQuery] = useState("");
|
||||
const [channelsQuery, setChannelsQuery] = useState("");
|
||||
const [automationsQuery, setAutomationsQuery] = useState("");
|
||||
const [automationsFilter, setAutomationsFilter] = useState<AutomationFilter>("all");
|
||||
const [automationsSort, setAutomationsSort] = useState<AutomationSort>("next");
|
||||
@@ -83,7 +82,6 @@ export function useSystemSettingsState() {
|
||||
automationsLoading,
|
||||
automationsQuery,
|
||||
automationsSort,
|
||||
channelsQuery,
|
||||
cliApps,
|
||||
cliAppsAction,
|
||||
cliAppsError,
|
||||
@@ -126,7 +124,6 @@ export function useSystemSettingsState() {
|
||||
setAutomationsLoading,
|
||||
setAutomationsQuery,
|
||||
setAutomationsSort,
|
||||
setChannelsQuery,
|
||||
setCliApps,
|
||||
setCliAppsAction,
|
||||
setCliAppsError,
|
||||
|
||||
Reference in new issue
Block a user