feat(webui): improve setup flows across chat channels (NAN-112) (#5356)
* feat(webui): improve channel setup flows * fix(webui): refine channel setup interactions (NAN-112) * fix(webui): keep email setup sections channel-owned * fix(webui): remove concrete channel details from shared components * refactor(webui): remove unused channel setup resources * fix(webui): finish channel-owned setup boundaries * fix(webui): update channel switches optimistically * test(channels): remove obsolete absence assertions * fix(webui): flatten channel instance settings disclosure * fix(webui): complete channel setup and connection flows * fix(whatsapp): wait for session database release * fix(webui): preserve scrolling channel controls * fix(webui): stage channel connection checks * fix(channels): align verification actions * fix(email): expose connection checks * fix(webui): align channel field actions * fix(email): verify account credentials * fix(wecom): bypass system proxy for websocket * fix(channels): stabilize async connection cleanup * fix(webui): autosave channel credentials * fix(email): make provider presets non-destructive * test(weixin): isolate persisted QR credentials
This commit is contained in:
1 parent
3cc3012b3a
commit
e8a29a0087
291 files changed
+12194
-3979
No files matched your search
@@ -3,21 +3,17 @@ import type { TFunction } from "i18next";
|
||||
type ChannelFieldMessages = {
|
||||
label: string;
|
||||
placeholder?: string;
|
||||
help?: string;
|
||||
choices?: Record<string, string>;
|
||||
};
|
||||
|
||||
export type ChannelMessages = {
|
||||
displayName?: string;
|
||||
description: string;
|
||||
requirements: string;
|
||||
setup: {
|
||||
primaryAction?: string;
|
||||
docsLabel?: string;
|
||||
officialLabel?: string;
|
||||
summary?: string;
|
||||
tryIt?: string;
|
||||
steps: string[];
|
||||
presetLabel?: string;
|
||||
sections?: Record<string, string>;
|
||||
fields?: Record<string, ChannelFieldMessages>;
|
||||
actions?: Record<string, string>;
|
||||
presets?: Record<string, string>;
|
||||
|
||||
@@ -6,14 +6,24 @@ import type {
|
||||
NanobotFeaturesPayload,
|
||||
} from "@/lib/types";
|
||||
|
||||
export type ChannelFeatureActionOptions = {
|
||||
confirmed?: boolean;
|
||||
installOnly?: boolean;
|
||||
};
|
||||
|
||||
export type ChannelFeatureAction = (
|
||||
action: "enable" | "disable",
|
||||
name: string,
|
||||
options?: ChannelFeatureActionOptions,
|
||||
) => void;
|
||||
|
||||
export type ChannelPluginPanelProps = {
|
||||
connectRequestId?: number;
|
||||
token: string;
|
||||
feature: NanobotFeatureInfo;
|
||||
actionKey: string | null;
|
||||
chatAppsDocsUrl?: string;
|
||||
showBrandLogos: boolean;
|
||||
onAction: (action: "enable" | "disable", name: string) => void;
|
||||
onAction: ChannelFeatureAction;
|
||||
onFeaturesUpdate: (payload: NanobotFeaturesPayload) => void;
|
||||
};
|
||||
|
||||
|
||||
@@ -680,12 +680,16 @@ export function SettingsPage({
|
||||
/>
|
||||
|
||||
<NanobotFeatureInstallDialog
|
||||
feature={nanobotFeatureConfirm}
|
||||
installing={nanobotFeatureAction === `enable:${nanobotFeatureConfirm?.name ?? ""}`}
|
||||
feature={nanobotFeatureConfirm?.feature ?? null}
|
||||
installOnly={nanobotFeatureConfirm?.installOnly ?? false}
|
||||
installing={nanobotFeatureAction === `${nanobotFeatureConfirm?.installOnly ? "install" : "enable"}:${nanobotFeatureConfirm?.feature.name ?? ""}`}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setNanobotFeatureConfirm(null);
|
||||
}}
|
||||
onConfirm={(feature) => handleNanobotFeatureAction("enable", feature.name, true)}
|
||||
onConfirm={(feature) => handleNanobotFeatureAction("enable", feature.name, {
|
||||
confirmed: true,
|
||||
installOnly: nanobotFeatureConfirm?.installOnly,
|
||||
})}
|
||||
/>
|
||||
|
||||
<AutomationDeleteDialog
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import { CircleHelp, ExternalLink } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { channelSetup } from "@/components/settings/channels/ChannelIdentity";
|
||||
import { docsUrlWithBase } from "@/components/settings/channels/catalog";
|
||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Tooltip, TooltipProvider, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
|
||||
import type { NanobotFeatureInfo } from "@/lib/types";
|
||||
|
||||
export function ChannelHelpMenu({ feature, chatAppsDocsUrl }: {
|
||||
feature: NanobotFeatureInfo;
|
||||
chatAppsDocsUrl?: string;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const setup = channelSetup(feature, i18n.resolvedLanguage ?? i18n.language);
|
||||
const links = [
|
||||
{ url: setup.officialUrl, label: setup.officialLabel },
|
||||
{ url: docsUrlWithBase(setup.docsUrl, chatAppsDocsUrl), label: setup.docsLabel },
|
||||
].filter((link) => link.url);
|
||||
if (!links.length) return null;
|
||||
const label = t("settings.channels.help", { defaultValue: "Help" });
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<DropdownMenu>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button type="button" aria-label={label}
|
||||
className="grid h-8 w-8 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring">
|
||||
<CircleHelp className="h-4 w-4" aria-hidden />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{label}</TooltipContent>
|
||||
</Tooltip>
|
||||
<DropdownMenuContent align="end">
|
||||
{links.map((link) => (
|
||||
<DropdownMenuItem key={link.url} asChild>
|
||||
<a href={link.url} target="_blank" rel="noreferrer">
|
||||
{link.label ?? label}
|
||||
<ExternalLink className="ml-2 h-3.5 w-3.5 text-muted-foreground" aria-hidden />
|
||||
</a>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMemo, type ReactNode } from "react";
|
||||
import type { useTranslation } from "react-i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import {
|
||||
channelFieldMessageKey,
|
||||
@@ -12,14 +12,17 @@ import {
|
||||
} from "@/channel-plugins/registry";
|
||||
import type {
|
||||
ChannelConfigField,
|
||||
ChannelFieldPresentation,
|
||||
ChannelSetupPresentation,
|
||||
} from "@/components/settings/channels/catalog";
|
||||
import { channelValidationMessage } from "@/components/settings/channels/validationMessages";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { normalizeLocale } from "@/i18n/config";
|
||||
import { logoFallbackUrls } from "@/lib/provider-brand";
|
||||
import type { ChannelRuntimeStatus, NanobotFeatureInfo } from "@/lib/types";
|
||||
|
||||
export type ChannelFilter = "all" | "on" | "off";
|
||||
export const CHANNEL_SETUP_PANEL_CLASS_NAME =
|
||||
"min-h-full rounded-panel bg-settings-surface p-6";
|
||||
|
||||
export function channelSetup(
|
||||
feature: NanobotFeatureInfo,
|
||||
@@ -35,25 +38,23 @@ export function channelSetup(
|
||||
key,
|
||||
label: copy?.label ?? fieldLabel(key.split(".").at(-1) ?? key),
|
||||
placeholder: copy?.placeholder,
|
||||
help: copy?.help,
|
||||
};
|
||||
};
|
||||
const localizePresentedField = (
|
||||
field: ChannelFieldPresentation,
|
||||
): ChannelConfigField => ({
|
||||
...localizeField(field.key),
|
||||
section: field.section,
|
||||
});
|
||||
const presentation: ChannelSetupPresentation = {
|
||||
...definition,
|
||||
primaryActionLabel: setupMessages?.primaryAction,
|
||||
docsLabel: setupMessages?.docsLabel,
|
||||
officialLabel: setupMessages?.officialLabel,
|
||||
summary:
|
||||
setupMessages?.summary
|
||||
?? "Enable turns on this channel in nanobot, but this integration still needs platform-specific setup before it can receive messages.",
|
||||
tryIt: setupMessages?.tryIt,
|
||||
steps: setupMessages?.steps ?? [
|
||||
`Open ~/.nanobot/config.json and find channels.${feature.name}.`,
|
||||
"Add the credentials required by that platform, using the channel documentation as the source of truth.",
|
||||
"Restart nanobot, then send a small test message from that platform.",
|
||||
],
|
||||
fields: definition?.fields?.map((field) => localizeField(field.key)),
|
||||
manualFields: definition?.manualFields?.map((field) => localizeField(field.key)),
|
||||
presetLabel: setupMessages?.presetLabel,
|
||||
sectionLabels: setupMessages?.sections,
|
||||
fields: definition?.fields?.map(localizePresentedField),
|
||||
manualFields: definition?.manualFields?.map(localizePresentedField),
|
||||
actions: definition?.actions?.map((action) => ({
|
||||
...action,
|
||||
label: setupMessages?.actions?.[action.id] ?? fieldLabel(action.id),
|
||||
@@ -83,9 +84,11 @@ export function channelSetup(
|
||||
...copy,
|
||||
key: field.key,
|
||||
label: copy.label,
|
||||
section: copy.section ?? (field.required ? "credentials" : "advanced"),
|
||||
secret: field.kind === "secret",
|
||||
optional: !field.required,
|
||||
inputType: field.kind === "int" ? "number" : undefined,
|
||||
kind: field.kind,
|
||||
inputType: channelFieldInputType(field.field, field.kind),
|
||||
defaultValue: field.default_value,
|
||||
options:
|
||||
field.kind === "enum" || field.kind === "bool"
|
||||
@@ -106,11 +109,24 @@ export function channelSetup(
|
||||
officialLabel:
|
||||
presentation.officialLabel
|
||||
?? (contract.official_url ? "Open official setup" : undefined),
|
||||
requirements: contract.requirements,
|
||||
fields: fields.length ? fields : undefined,
|
||||
manualFields: manual.length ? manual : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function channelFieldInputType(
|
||||
field: string,
|
||||
kind: string,
|
||||
): ChannelConfigField["inputType"] {
|
||||
if (kind === "int" || kind === "float") return "number";
|
||||
const normalized = field.toLowerCase();
|
||||
if (normalized.includes("url")) return "url";
|
||||
if (normalized.includes("email") || normalized.includes("address")) return "email";
|
||||
if (normalized.includes("phone")) return "tel";
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function fieldLabel(value: string): string {
|
||||
const spaced = value
|
||||
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
||||
@@ -126,21 +142,14 @@ export function ChannelLogo({
|
||||
feature: NanobotFeatureInfo;
|
||||
showBrandLogos: boolean;
|
||||
}) {
|
||||
const presentation = channelUiPresentation(feature.name, feature.webui);
|
||||
const presentation = channelUiPresentation(feature.name, feature.webui)
|
||||
?? channelUiPresentation(feature.name);
|
||||
const initials = presentation?.initials ?? feature.display_name.slice(0, 2).toUpperCase();
|
||||
const color = presentation?.color ?? "#6B7280";
|
||||
const Icon = presentation?.icon;
|
||||
const logoUrls = useMemo(() => logoFallbackUrls(presentation?.logoUrl), [presentation?.logoUrl]);
|
||||
const { logoUrl, onLogoError, onLogoLoad } = useLogoFallback(logoUrls);
|
||||
|
||||
if (feature.name === "websocket") {
|
||||
return (
|
||||
<span className="grid h-10 w-10 shrink-0 place-items-center rounded-control bg-background">
|
||||
<img src="/brand/nanobot_mark.svg" alt="" className="h-6 w-6 object-contain" draggable={false} />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
if (showBrandLogos && logoUrl) {
|
||||
return (
|
||||
<span
|
||||
@@ -194,24 +203,6 @@ export function localizedChannelDisplayName(
|
||||
return channelTranslator(t, channelUiOwner(feature.name))("displayName", fallback);
|
||||
}
|
||||
|
||||
export function channelDescription(feature: NanobotFeatureInfo, t: ReturnType<typeof useTranslation>["t"]): string {
|
||||
const fallback =
|
||||
`Use nanobot from ${channelDisplayName(feature)}.`;
|
||||
return channelTranslator(t, channelUiOwner(feature.name))("description", fallback);
|
||||
}
|
||||
|
||||
export function channelRequirements(feature: NanobotFeatureInfo, t: ReturnType<typeof useTranslation>["t"]): string {
|
||||
const fallback =
|
||||
"Channel credentials and gateway settings";
|
||||
return channelTranslator(t, channelUiOwner(feature.name))("requirements", fallback);
|
||||
}
|
||||
|
||||
export function channelMatchesFilter(feature: NanobotFeatureInfo, filter: ChannelFilter): boolean {
|
||||
if (filter === "on") return channelIsRunning(feature);
|
||||
if (filter === "off") return !channelIsRunning(feature);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function channelIsRunning(feature: NanobotFeatureInfo): boolean {
|
||||
return feature.runtime_status === "running";
|
||||
}
|
||||
@@ -232,27 +223,11 @@ export function channelStatusLabel(
|
||||
}
|
||||
if (channelIsRunning(feature)) return tx("settings.values.on", "On");
|
||||
if (feature.enabled) return tx("settings.channels.runtimeStopped", "Not running");
|
||||
if (feature.configured === false) return tx("settings.channels.needsConfig", "Needs setup");
|
||||
if (feature.configured === true) return tx("settings.nanobotFeatures.ready", "Ready");
|
||||
return tx("settings.values.off", "Off");
|
||||
}
|
||||
|
||||
export function channelSearchText(
|
||||
feature: NanobotFeatureInfo,
|
||||
t?: ReturnType<typeof useTranslation>["t"],
|
||||
): string {
|
||||
return [
|
||||
t ? localizedChannelDisplayName(feature, t) : undefined,
|
||||
channelDisplayName(feature),
|
||||
feature.display_name,
|
||||
feature.name,
|
||||
feature.status,
|
||||
t ? channelDescription(feature, t) : undefined,
|
||||
t ? channelRequirements(feature, t) : undefined,
|
||||
]
|
||||
.join(" ")
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
export function ChannelStatusBadge({
|
||||
children,
|
||||
status,
|
||||
@@ -281,10 +256,11 @@ export function ChannelRuntimeError({
|
||||
message?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
if (!message) return null;
|
||||
return (
|
||||
<div className={`${className} rounded-control border border-destructive/20 bg-destructive/5 px-3 py-2 text-[12px] leading-5 text-destructive`}>
|
||||
{message}
|
||||
{channelValidationMessage(message, t)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -13,17 +13,12 @@ import {
|
||||
defaultChannelFieldValues,
|
||||
} from "@/components/settings/channels/CredentialForm";
|
||||
import {
|
||||
CHANNEL_SETUP_PANEL_CLASS_NAME,
|
||||
ChannelLogo,
|
||||
ChannelRuntimeError,
|
||||
ChannelStatusBadge,
|
||||
channelSetup,
|
||||
channelStatusLabel,
|
||||
localizedChannelDisplayName,
|
||||
} from "@/components/settings/channels/ChannelIdentity";
|
||||
import {
|
||||
ChannelGuideLink,
|
||||
ChannelSetupSteps,
|
||||
} from "@/components/settings/channels/ChannelSetupParts";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import {
|
||||
@@ -41,7 +36,6 @@ import { cn } from "@/lib/utils";
|
||||
import { useClient } from "@/providers/ClientProvider";
|
||||
|
||||
export type ChannelInstancesPanelCustomization = {
|
||||
countLabel?: (runningCount: number) => string;
|
||||
toggleAriaLabel?: (instance: NanobotChannelInstanceInfo) => string;
|
||||
configuredLabel?: string;
|
||||
needsSetupLabel?: string;
|
||||
@@ -53,14 +47,12 @@ export type ChannelInstancesPanelCustomization = {
|
||||
export function ChannelInstancesPanel({
|
||||
feature,
|
||||
showBrandLogos,
|
||||
chatAppsDocsUrl,
|
||||
instances: providedInstances,
|
||||
onFeaturesUpdate,
|
||||
customization = {},
|
||||
}: {
|
||||
feature: NanobotFeatureInfo;
|
||||
showBrandLogos: boolean;
|
||||
chatAppsDocsUrl?: string;
|
||||
instances?: NanobotChannelInstanceInfo[];
|
||||
onFeaturesUpdate: (payload: NanobotFeaturesPayload) => void;
|
||||
customization?: ChannelInstancesPanelCustomization;
|
||||
@@ -70,8 +62,9 @@ export function ChannelInstancesPanel({
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
const displayName = localizedChannelDisplayName(feature, t);
|
||||
const instances = providedInstances ?? feature.instances ?? [];
|
||||
const [selectedId, setSelectedId] = useState<string | null>(null);
|
||||
const [busyInstanceId, setBusyInstanceId] = useState<string | null>(null);
|
||||
const [editor, setEditor] = useState<{ id: string; expanded: boolean } | null>(null);
|
||||
const selectedId = editor?.id;
|
||||
const [pendingToggle, setPendingToggle] = useState<{ id: string; checked: boolean } | null>(null);
|
||||
const [notice, setNotice] = useState<string | null>(null);
|
||||
const selected = selectedId ? instances.find((instance) => instance.id === selectedId) : undefined;
|
||||
const setup = useMemo(
|
||||
@@ -87,9 +80,9 @@ export function ChannelInstancesPanel({
|
||||
);
|
||||
const [visibleSecrets, setVisibleSecrets] = useState<Record<string, boolean>>({});
|
||||
const [savingFields, setSavingFields] = useState(false);
|
||||
const configuredCount = instances.filter((instance) => instance.configured).length;
|
||||
const runningCount = instances.filter((instance) => instance.runtime_status === "running").length;
|
||||
const selectedValuesKey = JSON.stringify(selected?.config_values ?? {});
|
||||
const selectedValuesKey = JSON.stringify(
|
||||
defaultChannelFieldValues(instanceFields, selected?.config_values),
|
||||
);
|
||||
const selectedConfiguredFields = useMemo(
|
||||
() => new Set(selected?.configured_fields ?? []),
|
||||
[selected?.configured_fields],
|
||||
@@ -97,17 +90,18 @@ export function ChannelInstancesPanel({
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedId && !instances.some((instance) => instance.id === selectedId)) {
|
||||
setSelectedId(null);
|
||||
setEditor(null);
|
||||
}
|
||||
}, [instances, selectedId]);
|
||||
|
||||
useEffect(() => {
|
||||
setFieldValues(defaultChannelFieldValues(instanceFields, selected?.config_values));
|
||||
setVisibleSecrets({});
|
||||
}, [instanceFields, selected?.id, selectedValuesKey]);
|
||||
}, [selected?.id, selectedValuesKey]);
|
||||
|
||||
const toggleInstance = async (instance: NanobotChannelInstanceInfo, checked: boolean) => {
|
||||
setBusyInstanceId(instance.id);
|
||||
if (pendingToggle || savingFields) return;
|
||||
setPendingToggle({ id: instance.id, checked });
|
||||
setNotice(null);
|
||||
try {
|
||||
const payload = checked
|
||||
@@ -117,12 +111,12 @@ export function ChannelInstancesPanel({
|
||||
} catch (err) {
|
||||
setNotice((err as Error).message);
|
||||
} finally {
|
||||
setBusyInstanceId(null);
|
||||
setPendingToggle(null);
|
||||
}
|
||||
};
|
||||
|
||||
const saveSelectedInstanceSettings = async () => {
|
||||
if (!selected) return;
|
||||
if (!selected || pendingToggle || savingFields) return;
|
||||
setSavingFields(true);
|
||||
setNotice(null);
|
||||
try {
|
||||
@@ -144,35 +138,24 @@ export function ChannelInstancesPanel({
|
||||
};
|
||||
|
||||
return (
|
||||
<aside className="min-h-full rounded-panel bg-settings-surface p-5">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<ChannelLogo feature={feature} showBrandLogos={showBrandLogos} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="truncate text-[18px] font-semibold leading-6 text-foreground">
|
||||
{displayName}
|
||||
</h3>
|
||||
<p className="mt-1 text-[13px] leading-5 text-muted-foreground">
|
||||
{customization.countLabel?.(runningCount)
|
||||
?? t("settings.channels.configuredInstances", {
|
||||
count: configuredCount,
|
||||
defaultValue: `${configuredCount} instances configured`,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<ChannelStatusBadge status={feature.runtime_status}>
|
||||
{channelStatusLabel(feature, tx)}
|
||||
</ChannelStatusBadge>
|
||||
</div>
|
||||
<aside className={CHANNEL_SETUP_PANEL_CLASS_NAME}>
|
||||
<div className="pe-20">
|
||||
<ChannelLogo feature={feature} showBrandLogos={showBrandLogos} />
|
||||
<h3 className="sr-only">{displayName}</h3>
|
||||
</div>
|
||||
|
||||
<ChannelRuntimeError message={feature.runtime_error} />
|
||||
|
||||
<div className="mt-5 space-y-3">
|
||||
{instances.map((instance) => {
|
||||
const expanded = selected?.id === instance.id;
|
||||
const expanded = selected?.id === instance.id && editor?.expanded === true;
|
||||
const toggling = pendingToggle?.id === instance.id;
|
||||
const checked = toggling ? pendingToggle.checked : instanceToggleChecked(instance);
|
||||
const instanceSummary = customization.renderInstanceSummary
|
||||
? customization.renderInstanceSummary(instance)
|
||||
: instance.id;
|
||||
const instanceAction = customization.renderInstanceAction?.(instance);
|
||||
const hasInstanceOverview = Boolean(instanceSummary || instanceAction);
|
||||
return (
|
||||
<article
|
||||
key={instance.id}
|
||||
@@ -180,18 +163,11 @@ export function ChannelInstancesPanel({
|
||||
"overflow-hidden rounded-floating transition-colors",
|
||||
expanded
|
||||
? "bg-background"
|
||||
: "bg-background/70 settings-hover",
|
||||
: "bg-background/70",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-3 px-3 py-3">
|
||||
<button
|
||||
type="button"
|
||||
className="flex min-w-0 flex-1 items-center gap-3 text-left"
|
||||
onClick={() =>
|
||||
setSelectedId((current) => (current === instance.id ? null : instance.id))
|
||||
}
|
||||
aria-expanded={expanded}
|
||||
>
|
||||
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-3">
|
||||
<div className="flex min-w-0 flex-[1_1_12rem] items-center gap-3">
|
||||
<ChannelInstanceAvatar
|
||||
feature={feature}
|
||||
instance={instance}
|
||||
@@ -200,22 +176,43 @@ export function ChannelInstancesPanel({
|
||||
<span className="min-w-0 flex-1 truncate text-[13px] font-semibold text-foreground">
|
||||
{channelInstanceDisplayName(instance)}
|
||||
</span>
|
||||
<ChevronDown
|
||||
className={cn(
|
||||
"h-4 w-4 shrink-0 text-muted-foreground transition-transform",
|
||||
expanded && "rotate-180",
|
||||
)}
|
||||
aria-hidden
|
||||
<ChannelInstanceStatusBadge
|
||||
instance={instance}
|
||||
configuredLabel={customization.configuredLabel}
|
||||
needsSetupLabel={customization.needsSetupLabel}
|
||||
/>
|
||||
</button>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
{busyInstanceId === instance.id ? (
|
||||
</div>
|
||||
<div className="ms-auto flex shrink-0 items-center gap-3">
|
||||
{instanceFields.length ? (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex min-h-8 items-center gap-1.5 rounded px-1 text-[12px] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-offset-2"
|
||||
onClick={() =>
|
||||
setEditor((current) => ({
|
||||
id: instance.id,
|
||||
expanded: current?.id !== instance.id || !current.expanded,
|
||||
}))
|
||||
}
|
||||
aria-expanded={expanded}
|
||||
>
|
||||
{tx("settings.channels.advanced", "Advanced")}
|
||||
<ChevronDown
|
||||
className={cn(
|
||||
"h-3.5 w-3.5 transition-transform motion-reduce:transition-none",
|
||||
expanded && "rotate-180",
|
||||
)}
|
||||
aria-hidden
|
||||
/>
|
||||
</button>
|
||||
) : null}
|
||||
{toggling ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin text-muted-foreground" aria-hidden />
|
||||
) : null}
|
||||
<ToggleButton
|
||||
checked={instanceToggleChecked(instance)}
|
||||
checked={checked}
|
||||
disabled={
|
||||
busyInstanceId === instance.id
|
||||
Boolean(pendingToggle)
|
||||
|| savingFields
|
||||
|| !instance.configured
|
||||
}
|
||||
ariaLabel={customization.toggleAriaLabel?.(instance)
|
||||
@@ -223,51 +220,28 @@ export function ChannelInstancesPanel({
|
||||
name: channelInstanceDisplayName(instance),
|
||||
defaultValue: "{{name}} instance",
|
||||
})}
|
||||
label={instanceToggleChecked(instance) ? tx("settings.values.on", "On") : tx("settings.values.off", "Off")}
|
||||
label={checked ? tx("settings.values.on", "On") : tx("settings.values.off", "Off")}
|
||||
onChange={(checked) => void toggleInstance(instance, checked)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{expanded ? (
|
||||
<div className="space-y-5 px-4 pb-4">
|
||||
<section className="pt-4">
|
||||
<div className="mb-3 flex items-start justify-between gap-3">
|
||||
{hasInstanceOverview || (expanded && instanceFields.length > 0) ? (
|
||||
<div className="space-y-3 px-4 pb-4 pt-1">
|
||||
{hasInstanceOverview ? <section className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
||||
{instanceSummary ? (
|
||||
<p className="min-w-0 flex-1 truncate font-mono text-[11.5px] leading-6 text-muted-foreground">
|
||||
{customization.renderInstanceSummary?.(instance) ?? instance.id}
|
||||
{instanceSummary}
|
||||
</p>
|
||||
<ChannelInstanceStatusBadge
|
||||
instance={instance}
|
||||
configuredLabel={customization.configuredLabel}
|
||||
needsSetupLabel={customization.needsSetupLabel}
|
||||
/>
|
||||
</div>
|
||||
{customization.renderInstanceAction?.(instance)}
|
||||
</section>
|
||||
<ChannelSetupSteps
|
||||
steps={setup.steps}
|
||||
action={
|
||||
<ChannelGuideLink
|
||||
feature={feature}
|
||||
setup={setup}
|
||||
chatAppsDocsUrl={chatAppsDocsUrl}
|
||||
compact
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{instanceFields.length ? (
|
||||
<details className="group text-[12px] leading-5 text-muted-foreground">
|
||||
<summary className="cursor-pointer list-none text-[12px] font-semibold text-foreground">
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
{tx("settings.channels.advanced", "Advanced")}
|
||||
<ChevronDown
|
||||
className="h-3.5 w-3.5 transition-transform group-open:rotate-180"
|
||||
aria-hidden
|
||||
/>
|
||||
</span>
|
||||
</summary>
|
||||
) : <span className="flex-1" />}
|
||||
{instanceAction}
|
||||
</section> : null}
|
||||
{expanded && instanceFields.length > 0 ? (
|
||||
<div className={cn(
|
||||
"text-[12px] leading-5 text-muted-foreground",
|
||||
hasInstanceOverview && "border-t border-border/50 pt-3",
|
||||
)}>
|
||||
<form
|
||||
className="mt-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void saveSelectedInstanceSettings();
|
||||
@@ -292,7 +266,7 @@ export function ChannelInstancesPanel({
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
className="h-8 rounded-full bg-muted/70 px-3 text-[12px] font-semibold settings-hover"
|
||||
disabled={savingFields}
|
||||
disabled={savingFields || Boolean(pendingToggle)}
|
||||
>
|
||||
{savingFields ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
@@ -301,7 +275,7 @@ export function ChannelInstancesPanel({
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { channelValidationMessage } from "./validationMessages";
|
||||
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import QRCode from "qrcode";
|
||||
import { Check, Loader2, Network, RotateCcw } from "lucide-react";
|
||||
import { Check, Loader2, RotateCcw } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -28,13 +29,6 @@ export type ChannelQrConnectLabels = {
|
||||
connect: string;
|
||||
};
|
||||
|
||||
export type ChannelConnectStartOptions = {
|
||||
domain?: string;
|
||||
instanceId?: string;
|
||||
mode?: "replace" | "create";
|
||||
force?: boolean;
|
||||
};
|
||||
|
||||
export type ChannelQrConnectPendingContext = {
|
||||
connect: ChannelConnectPayload;
|
||||
busy: boolean;
|
||||
@@ -45,10 +39,12 @@ export type ChannelQrConnectPendingContext = {
|
||||
|
||||
export function ChannelQrConnectFlow({
|
||||
channelName,
|
||||
startOptions = {},
|
||||
startParams = {},
|
||||
idleLabel,
|
||||
connectRequestId,
|
||||
forceOnRepeat = false,
|
||||
autoStart = false,
|
||||
minimalPending = false,
|
||||
labels,
|
||||
onFeaturesUpdate,
|
||||
pausePolling,
|
||||
@@ -58,10 +54,12 @@ export function ChannelQrConnectFlow({
|
||||
}: {
|
||||
token: string;
|
||||
channelName: string;
|
||||
startOptions?: ChannelConnectStartOptions;
|
||||
startParams?: Readonly<Record<string, string | boolean>>;
|
||||
idleLabel?: string;
|
||||
connectRequestId?: number;
|
||||
forceOnRepeat?: boolean;
|
||||
autoStart?: boolean;
|
||||
minimalPending?: boolean;
|
||||
labels: ChannelQrConnectLabels;
|
||||
onFeaturesUpdate: (payload: NanobotFeaturesPayload) => void;
|
||||
pausePolling?: (payload: ChannelConnectPayload) => boolean;
|
||||
@@ -77,19 +75,16 @@ export function ChannelQrConnectFlow({
|
||||
const [qrDataUrl, setQrDataUrl] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [handledRequestId, setHandledRequestId] = useState(0);
|
||||
const handledRequestId = useRef(0);
|
||||
const autoStarted = useRef(false);
|
||||
const pollInFlight = useRef(false);
|
||||
const startDomain = startOptions.domain;
|
||||
const startInstanceId = startOptions.instanceId;
|
||||
const startMode = startOptions.mode;
|
||||
const startForce = startOptions.force;
|
||||
|
||||
const pending = connect?.status === "pending";
|
||||
const succeeded = connect?.status === "succeeded";
|
||||
const canStart = !pending && !busy;
|
||||
const pollingPaused = Boolean(connect && pausePolling?.(connect));
|
||||
const displayMessage = connect
|
||||
? resolveMessage?.(connect) ?? connect.message
|
||||
? resolveMessage?.(connect) ?? (connect.message ? channelValidationMessage(connect.message, t) : undefined)
|
||||
: undefined;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -176,10 +171,8 @@ export function ChannelQrConnectFlow({
|
||||
setError(null);
|
||||
try {
|
||||
const payload = await startChannelConnect(client, channelName, {
|
||||
domain: startDomain,
|
||||
instanceId: startInstanceId,
|
||||
mode: startMode,
|
||||
force: force || startForce,
|
||||
...startParams,
|
||||
...(force ? { force: true } : {}),
|
||||
});
|
||||
setConnect(payload);
|
||||
} catch (err) {
|
||||
@@ -187,13 +180,15 @@ export function ChannelQrConnectFlow({
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}, [channelName, client, startDomain, startForce, startInstanceId, startMode]);
|
||||
}, [channelName, client, startParams]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!connectRequestId || connectRequestId === handledRequestId) return;
|
||||
setHandledRequestId(connectRequestId);
|
||||
const requested = Boolean(connectRequestId && connectRequestId !== handledRequestId.current);
|
||||
if (!requested && !(autoStart && !autoStarted.current)) return;
|
||||
handledRequestId.current = connectRequestId ?? 0;
|
||||
autoStarted.current = true;
|
||||
void start();
|
||||
}, [connectRequestId, handledRequestId, start]);
|
||||
}, [autoStart, connectRequestId, start]);
|
||||
|
||||
const cancel = async () => {
|
||||
if (!connect?.session_id) {
|
||||
@@ -250,7 +245,28 @@ export function ChannelQrConnectFlow({
|
||||
|
||||
return (
|
||||
<div className="mt-3 space-y-3">
|
||||
{pending ? (
|
||||
{autoStart && busy && !connect ? (
|
||||
<div role="status" className="grid min-h-[228px] place-items-center">
|
||||
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" aria-hidden />
|
||||
<span className="sr-only">{labels.connecting}</span>
|
||||
</div>
|
||||
) : null}
|
||||
{pending && minimalPending ? (
|
||||
<div className="flex min-h-[228px] flex-col items-center justify-center gap-4 py-4">
|
||||
<div className="grid h-[196px] w-[196px] place-items-center rounded-control bg-background shadow-[inset_0_0_0_1px_oklch(0_0_0/0.1)] dark:shadow-[inset_0_0_0_1px_oklch(1_0_0/0.1)]">
|
||||
{qrDataUrl ? (
|
||||
<img
|
||||
src={qrDataUrl}
|
||||
alt={labels.qrAlt}
|
||||
className="h-[184px] w-[184px]"
|
||||
/>
|
||||
) : (
|
||||
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" aria-hidden />
|
||||
)}
|
||||
</div>
|
||||
{renderPending?.({ connect, busy, poll: submitPoll })}
|
||||
</div>
|
||||
) : pending ? (
|
||||
<div className="grid gap-4 rounded-control border border-border/70 p-4 sm:grid-cols-[auto_minmax(0,1fr)]">
|
||||
<div className="grid h-[196px] w-[196px] place-items-center rounded-control border border-border/60 bg-background">
|
||||
{qrDataUrl ? (
|
||||
@@ -268,12 +284,12 @@ export function ChannelQrConnectFlow({
|
||||
{labels.scanTitle}
|
||||
</div>
|
||||
<p className="mt-1 text-[12.5px] leading-5 text-muted-foreground">
|
||||
{labels.scanDescription}
|
||||
{qrDataUrl ? labels.scanDescription : null}
|
||||
</p>
|
||||
{renderPending?.({ connect, busy, poll: submitPoll }) ?? (
|
||||
<div className="mt-3 flex items-center gap-2 text-[12px] text-muted-foreground">
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
{labels.waiting}
|
||||
{qrDataUrl ? labels.waiting : labels.connecting}
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-4 flex flex-wrap justify-end gap-2">
|
||||
@@ -311,7 +327,7 @@ export function ChannelQrConnectFlow({
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="flex flex-wrap justify-end gap-2">
|
||||
{!pending && !(autoStart && busy && !connect) ? <div className="flex flex-wrap justify-end gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
@@ -324,16 +340,14 @@ export function ChannelQrConnectFlow({
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
) : succeeded ? (
|
||||
<RotateCcw className="mr-1.5 h-3.5 w-3.5" aria-hidden />
|
||||
) : (
|
||||
<Network className="mr-1.5 h-3.5 w-3.5" aria-hidden />
|
||||
)}
|
||||
) : null}
|
||||
{pending
|
||||
? labels.connecting
|
||||
: succeeded
|
||||
? labels.scanAgain
|
||||
: idleLabel ?? labels.connect}
|
||||
</Button>
|
||||
</div>
|
||||
</div> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +1,11 @@
|
||||
import { useMemo, useState, type ReactNode } from "react";
|
||||
import { channelValidationMessage } from "./validationMessages";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Clipboard, ExternalLink, Loader2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { channelUiPresentation } from "@/channel-plugins/registry";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
docsUrlWithBase,
|
||||
type ChannelProviderPreset,
|
||||
type ChannelSetupPresentation,
|
||||
} from "@/components/settings/channels/catalog";
|
||||
@@ -16,154 +16,13 @@ import {
|
||||
channelValidationStatusIcon,
|
||||
channelValidationStatusLabel,
|
||||
} from "@/components/settings/channels/CredentialForm";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { copyTextToClipboard } from "@/lib/clipboard";
|
||||
import { logoFallbackUrls } from "@/lib/provider-brand";
|
||||
import type {
|
||||
ChannelValidationPayload,
|
||||
NanobotFeatureInfo,
|
||||
} from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function ChannelGuideLink({
|
||||
feature,
|
||||
setup,
|
||||
chatAppsDocsUrl,
|
||||
compact = false,
|
||||
}: {
|
||||
feature: NanobotFeatureInfo;
|
||||
setup: ChannelSetupPresentation;
|
||||
chatAppsDocsUrl?: string;
|
||||
compact?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
const presentation = channelUiPresentation(feature.name, feature.webui);
|
||||
const logoUrls = useMemo(
|
||||
() => logoFallbackUrls(setup.docsLogoUrl ?? presentation?.logoUrl),
|
||||
[presentation?.logoUrl, setup.docsLogoUrl],
|
||||
);
|
||||
const { logoUrl, onLogoError, onLogoLoad } = useLogoFallback(logoUrls);
|
||||
const Icon = presentation?.icon;
|
||||
const initials = presentation?.initials ?? feature.display_name.slice(0, 2).toUpperCase();
|
||||
const color = presentation?.color ?? "#6B7280";
|
||||
const docsUrl = docsUrlWithBase(setup.docsUrl, chatAppsDocsUrl);
|
||||
|
||||
if (!docsUrl) return null;
|
||||
|
||||
return (
|
||||
<a
|
||||
href={docsUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className={cn(
|
||||
"inline-flex max-w-full items-center gap-2 bg-background/80 font-semibold text-foreground transition-colors settings-hover",
|
||||
compact
|
||||
? "shrink-0 rounded-full py-1 pl-1 pr-2.5 text-[11.5px]"
|
||||
: "mt-3 rounded-control py-1.5 pl-1.5 pr-3 text-[12px]",
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"grid shrink-0 place-items-center overflow-hidden bg-muted/70 font-bold",
|
||||
compact ? "h-5 w-5 rounded-full text-[9px]" : "h-6 w-6 rounded-compact text-[10px]",
|
||||
)}
|
||||
style={{ color }}
|
||||
aria-hidden
|
||||
>
|
||||
{logoUrl ? (
|
||||
<img
|
||||
src={logoUrl}
|
||||
alt=""
|
||||
decoding="async"
|
||||
loading="lazy"
|
||||
className={cn("object-contain", compact ? "h-3.5 w-3.5" : "h-4 w-4")}
|
||||
onLoad={onLogoLoad}
|
||||
onError={onLogoError}
|
||||
/>
|
||||
) : Icon ? (
|
||||
<Icon className={compact ? "h-3 w-3" : "h-3.5 w-3.5"} strokeWidth={2.25} />
|
||||
) : (
|
||||
initials
|
||||
)}
|
||||
</span>
|
||||
<span className="truncate">
|
||||
{setup.docsLabel ?? tx("settings.channels.officialGuide", "Official guide")}
|
||||
</span>
|
||||
<ExternalLink className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChannelSetupLinks({
|
||||
feature,
|
||||
setup,
|
||||
chatAppsDocsUrl,
|
||||
}: {
|
||||
feature: NanobotFeatureInfo;
|
||||
setup: ChannelSetupPresentation;
|
||||
chatAppsDocsUrl?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="mt-3 flex flex-wrap items-center gap-2">
|
||||
<ChannelOfficialLink feature={feature} setup={setup} />
|
||||
<ChannelGuideLink feature={feature} setup={setup} chatAppsDocsUrl={chatAppsDocsUrl} compact />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ChannelOfficialLink({
|
||||
feature,
|
||||
setup,
|
||||
}: {
|
||||
feature: NanobotFeatureInfo;
|
||||
setup: ChannelSetupPresentation;
|
||||
}) {
|
||||
const presentation = channelUiPresentation(feature.name, feature.webui);
|
||||
const logoUrls = useMemo(
|
||||
() => logoFallbackUrls(setup.docsLogoUrl ?? presentation?.logoUrl),
|
||||
[presentation?.logoUrl, setup.docsLogoUrl],
|
||||
);
|
||||
const { logoUrl, onLogoError, onLogoLoad } = useLogoFallback(logoUrls);
|
||||
const Icon = presentation?.icon;
|
||||
const initials = presentation?.initials ?? feature.display_name.slice(0, 2).toUpperCase();
|
||||
const color = presentation?.color ?? "#6B7280";
|
||||
const label = setup.officialLabel;
|
||||
if (!setup.officialUrl || !label) return null;
|
||||
return (
|
||||
<a
|
||||
href={setup.officialUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex max-w-full shrink-0 items-center gap-2 rounded-full bg-background/80 py-1 pl-1 pr-2.5 text-[11.5px] font-semibold text-foreground transition-colors settings-hover"
|
||||
>
|
||||
<span
|
||||
className="grid h-5 w-5 shrink-0 place-items-center overflow-hidden rounded-full bg-muted/70"
|
||||
style={{ color }}
|
||||
aria-hidden
|
||||
>
|
||||
{logoUrl ? (
|
||||
<img
|
||||
src={logoUrl}
|
||||
alt=""
|
||||
decoding="async"
|
||||
loading="lazy"
|
||||
className="h-3.5 w-3.5 object-contain"
|
||||
onLoad={onLogoLoad}
|
||||
onError={onLogoError}
|
||||
/>
|
||||
) : Icon ? (
|
||||
<Icon className="h-3 w-3" strokeWidth={2.25} />
|
||||
) : (
|
||||
<span className="text-[8px] font-bold">{initials}</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="truncate">{label}</span>
|
||||
<ExternalLink className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-hidden />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChannelSetupActions({
|
||||
feature,
|
||||
setup,
|
||||
@@ -216,48 +75,48 @@ export function ChannelSetupActions({
|
||||
export function ChannelProviderPresets({
|
||||
presets,
|
||||
onApply,
|
||||
label,
|
||||
disabled = false,
|
||||
}: {
|
||||
presets: ChannelProviderPreset[];
|
||||
onApply: (preset: ChannelProviderPreset) => void;
|
||||
label?: string;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [selected, setSelected] = useState("");
|
||||
if (!presets.length) return null;
|
||||
return (
|
||||
<div className="mt-3">
|
||||
<div className="mb-1 text-[11px] font-medium text-foreground/85">
|
||||
{t("settings.channels.providerPreset", { defaultValue: "Provider" })}
|
||||
</div>
|
||||
<div
|
||||
role="radiogroup"
|
||||
aria-label={t("settings.channels.providerPreset", { defaultValue: "Provider" })}
|
||||
className="grid rounded-control bg-muted p-0.5 text-[12px] font-medium text-muted-foreground"
|
||||
style={{ gridTemplateColumns: `repeat(${presets.length}, minmax(0, 1fr))` }}
|
||||
>
|
||||
<fieldset>
|
||||
<legend className="mb-1 text-[11px] font-medium text-foreground/85">
|
||||
{label ?? t("settings.channels.providerPreset", { defaultValue: "Provider" })}
|
||||
</legend>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{presets.map((preset) => (
|
||||
<button
|
||||
<Button
|
||||
key={preset.id}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={selected === preset.id}
|
||||
onClick={() => {
|
||||
setSelected(preset.id);
|
||||
onApply(preset);
|
||||
}}
|
||||
className={cn(
|
||||
"min-h-8 rounded-compact px-2 py-1.5 transition-colors hover:text-foreground",
|
||||
selected === preset.id && "bg-background text-foreground",
|
||||
)}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
disabled={disabled}
|
||||
className="h-8 rounded-full px-3 text-[12px] font-medium"
|
||||
onClick={() => onApply(preset)}
|
||||
>
|
||||
{preset.label}
|
||||
</button>
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChannelValidationBadge({
|
||||
function visibleValidationChecks(validation: ChannelValidationPayload | null) {
|
||||
return (validation?.checks ?? []).filter(
|
||||
(check) => check.id !== "manual_review"
|
||||
&& !(check.id.startsWith("field:") && check.status === "pass"),
|
||||
).slice(0, 6);
|
||||
}
|
||||
|
||||
export function ChannelValidationProgress({
|
||||
validation,
|
||||
validating,
|
||||
feature,
|
||||
@@ -267,118 +126,108 @@ export function ChannelValidationBadge({
|
||||
feature: NanobotFeatureInfo;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const checks = useMemo(() => visibleValidationChecks(validation), [validation]);
|
||||
const [reveal, setReveal] = useState<{
|
||||
validation: ChannelValidationPayload | null;
|
||||
settledCheckCount: number;
|
||||
}>({ validation: null, settledCheckCount: 0 });
|
||||
const settledCheckCount = reveal.validation === validation ? reveal.settledCheckCount : 0;
|
||||
|
||||
useEffect(() => {
|
||||
if (validating || !validation) {
|
||||
setReveal({ validation: null, settledCheckCount: 0 });
|
||||
return;
|
||||
}
|
||||
setReveal({ validation, settledCheckCount: 0 });
|
||||
const timers = checks.map((_, index) => window.setTimeout(
|
||||
() => setReveal((current) => (
|
||||
current.validation === validation
|
||||
? { validation, settledCheckCount: index + 1 }
|
||||
: current
|
||||
)),
|
||||
(index + 1) * 260,
|
||||
));
|
||||
return () => timers.forEach((timer) => window.clearTimeout(timer));
|
||||
}, [checks, validating, validation]);
|
||||
|
||||
if (!validating && !validation) return null;
|
||||
|
||||
const finished = Boolean(validation) && !validating && settledCheckCount >= checks.length;
|
||||
const shownChecks = finished ? checks : checks.slice(0, settledCheckCount + 1);
|
||||
const status = validation?.status ?? (feature.configured ? "configured" : "needs_setup");
|
||||
const label = validating
|
||||
? t("settings.channels.checking", { defaultValue: "Checking..." })
|
||||
: channelValidationStatusLabel(status, t);
|
||||
const presentation = channelUiPresentation(feature.name, feature.webui);
|
||||
const identity = validation?.identity?.name
|
||||
? validation.identity.workspace
|
||||
? `${validation.identity.name} · ${validation.identity.workspace}`
|
||||
: validation.identity.name
|
||||
: presentation?.displayName ?? feature.display_name;
|
||||
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11.5px] font-medium",
|
||||
channelValidationStatusClass(status),
|
||||
)}
|
||||
<div
|
||||
role="status"
|
||||
aria-live="polite"
|
||||
aria-atomic="true"
|
||||
className="rounded-control border border-border/60 bg-muted/25 px-3 py-3"
|
||||
>
|
||||
{validating ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
) : (
|
||||
channelValidationStatusIcon(status)
|
||||
)}
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChannelValidationDetails({ validation }: { validation: ChannelValidationPayload | null }) {
|
||||
const message = validation?.message;
|
||||
if (!validation?.identity?.name && !message) return null;
|
||||
return (
|
||||
<div className="mt-2 truncate text-[11.5px] text-muted-foreground">
|
||||
{validation?.identity?.name
|
||||
? validation.identity.workspace
|
||||
? `${validation.identity.name} · ${validation.identity.workspace}`
|
||||
: validation.identity.name
|
||||
: message}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChannelValidationChecks({ validation }: { validation: ChannelValidationPayload }) {
|
||||
const { t } = useTranslation();
|
||||
if (!validation.checks.length) return null;
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-2 text-[12px] font-semibold text-foreground">
|
||||
{t("settings.channels.connectionChecks")}
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{validation.checks.slice(0, 6).map((check) => (
|
||||
<div key={check.id} className="flex gap-2 text-[12px] leading-5">
|
||||
<span className={cn("mt-0.5", channelValidationCheckIconClass(check.status))}>
|
||||
{channelValidationCheckIcon(check.status)}
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="font-medium text-foreground/85">{check.label}</div>
|
||||
{check.message ? (
|
||||
<div className="text-muted-foreground">{check.message}</div>
|
||||
) : null}
|
||||
{check.action_url ? (
|
||||
<a
|
||||
href={check.action_url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-1 text-foreground underline decoration-border underline-offset-4"
|
||||
>
|
||||
{t("settings.channels.open")}
|
||||
<ExternalLink className="h-3 w-3" aria-hidden />
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="space-y-2.5">
|
||||
{validating ? (
|
||||
<div className="flex items-center gap-2 px-2.5 text-[12px] font-medium text-foreground/85">
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin text-muted-foreground" aria-hidden />
|
||||
{t("settings.channels.checking", { defaultValue: "Checking..." })}
|
||||
</div>
|
||||
))}
|
||||
) : null}
|
||||
{!validating ? shownChecks.map((check, index) => {
|
||||
const pending = !finished && index === settledCheckCount;
|
||||
return (
|
||||
<div
|
||||
key={check.id}
|
||||
className="flex animate-in gap-2 px-2.5 fade-in-0 slide-in-from-top-1 text-[12px] leading-5 duration-200 motion-reduce:animate-none"
|
||||
>
|
||||
<span className={cn(
|
||||
"mt-0.5",
|
||||
pending ? "text-muted-foreground" : channelValidationCheckIconClass(check.status),
|
||||
)}>
|
||||
{pending
|
||||
? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
: channelValidationCheckIcon(check.status)}
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex min-w-0 items-center gap-x-2 font-medium text-foreground/85">
|
||||
<span className="min-w-0 truncate">{channelValidationMessage(check.label, t)}</span>
|
||||
{!pending && check.action_url ? (
|
||||
<a
|
||||
href={check.action_url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-foreground underline decoration-border underline-offset-4"
|
||||
>
|
||||
{t("settings.channels.open")}
|
||||
<ExternalLink className="h-3 w-3" aria-hidden />
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
{!pending && check.status !== "pass" && check.message ? (
|
||||
<div className="text-muted-foreground">
|
||||
{channelValidationMessage(check.message, t)}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}) : null}
|
||||
{finished ? (
|
||||
<div
|
||||
className={cn(
|
||||
"flex animate-in items-center gap-2 rounded-control px-2.5 py-2 text-[12px] font-medium fade-in-0 duration-200 motion-reduce:animate-none",
|
||||
channelValidationStatusClass(status),
|
||||
)}
|
||||
>
|
||||
{channelValidationStatusIcon(status)}
|
||||
<span className="min-w-0 truncate font-semibold">{identity}</span>
|
||||
<span className="lowercase">{channelValidationStatusLabel(status, t)}</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChannelSetupSteps({
|
||||
steps,
|
||||
action,
|
||||
tryIt,
|
||||
}: {
|
||||
steps: string[];
|
||||
action?: ReactNode;
|
||||
tryIt?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
return (
|
||||
<div className="text-[12.5px] leading-5 text-muted-foreground">
|
||||
<div className="mb-2 flex items-center justify-between gap-3">
|
||||
<div className="text-[12px] font-semibold text-foreground">
|
||||
{tx("settings.channels.setupSteps", "Next steps")}
|
||||
</div>
|
||||
{action}
|
||||
</div>
|
||||
<ol className="space-y-1.5">
|
||||
{steps.map((step, index) => (
|
||||
<li key={step} className="flex gap-2">
|
||||
<span className="mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground">
|
||||
{index + 1}
|
||||
</span>
|
||||
<span>{step}</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
{tryIt ? (
|
||||
<div className="mt-3 rounded-control bg-background/75 px-3 py-2 text-[12px] text-muted-foreground">
|
||||
<span className="font-medium text-foreground">
|
||||
{tx("settings.channels.tryIt", "Try it")}
|
||||
</span>
|
||||
<span className="ml-2">
|
||||
{tryIt}
|
||||
</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { Check, CircleAlert, Eye, EyeOff, X } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import type { ChannelConfigField } from "@/components/settings/channels/catalog";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
@@ -10,6 +11,10 @@ function channelFieldValue(field: ChannelConfigField, values: Record<string, str
|
||||
return values[field.key] ?? field.defaultValue ?? field.options?.[0]?.value ?? "";
|
||||
}
|
||||
|
||||
export function channelFieldInputId(key: string): string {
|
||||
return `channel-field-${key.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
||||
}
|
||||
|
||||
export function defaultChannelFieldValues(
|
||||
fields: ChannelConfigField[],
|
||||
configValues: Record<string, string> | undefined = undefined,
|
||||
@@ -39,9 +44,14 @@ export function channelValuesForSubmit(
|
||||
fields: ChannelConfigField[],
|
||||
values: Record<string, string>,
|
||||
touchedFields: Set<string>,
|
||||
): Record<string, string> {
|
||||
const payload: Record<string, string> = {};
|
||||
clearedSecrets: Set<string> = new Set(),
|
||||
): Record<string, string | null> {
|
||||
const payload: Record<string, string | null> = {};
|
||||
for (const field of fields) {
|
||||
if (field.secret && clearedSecrets.has(field.key)) {
|
||||
payload[field.key] = null;
|
||||
continue;
|
||||
}
|
||||
const touched = touchedFields.has(field.key);
|
||||
const value = channelFieldValue(field, values);
|
||||
if (field.secret && !value.trim()) continue;
|
||||
@@ -58,7 +68,7 @@ export function channelValidationStatusLabel(
|
||||
): string {
|
||||
const labels: Record<string, string> = {
|
||||
connected: "Connected",
|
||||
configured: "Configured manually",
|
||||
configured: "Not verified",
|
||||
needs_setup: "Needs setup",
|
||||
invalid: "Invalid",
|
||||
unsupported: "Manual setup",
|
||||
@@ -82,7 +92,7 @@ export function channelValidationStatusClass(status: string): string {
|
||||
}
|
||||
|
||||
export function channelValidationStatusIcon(status: string): ReactNode {
|
||||
if (status === "connected" || status === "configured") {
|
||||
if (status === "connected") {
|
||||
return <Check className="h-3.5 w-3.5" aria-hidden />;
|
||||
}
|
||||
if (status === "invalid") {
|
||||
@@ -111,34 +121,53 @@ export function CredentialForm({
|
||||
configuredFields,
|
||||
visibleSecrets,
|
||||
onChange,
|
||||
onFieldBlur,
|
||||
onToggleSecret,
|
||||
errors = {},
|
||||
clearedSecrets = new Set(),
|
||||
onClearSecret,
|
||||
compact = false,
|
||||
showSecretActions = false,
|
||||
disabled = false,
|
||||
}: {
|
||||
fields: ChannelConfigField[];
|
||||
values: Record<string, string>;
|
||||
configuredFields?: Set<string>;
|
||||
visibleSecrets: Record<string, boolean>;
|
||||
onChange: (key: string, value: string) => void;
|
||||
onFieldBlur?: (key: string) => void;
|
||||
onToggleSecret: (key: string) => void;
|
||||
errors?: Record<string, string>;
|
||||
clearedSecrets?: Set<string>;
|
||||
onClearSecret?: (key: string, clear: boolean) => void;
|
||||
compact?: boolean;
|
||||
showSecretActions?: boolean;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
return (
|
||||
<div className={cn(compact ? "space-y-2.5" : "mt-3 space-y-2.5")}>
|
||||
<div className={cn("grid", compact ? "gap-y-4" : "mt-3 gap-y-2.5")}>
|
||||
{fields.map((field) => {
|
||||
const inputId = channelFieldInputId(field.key);
|
||||
const error = errors[field.key];
|
||||
const errorId = error ? `${inputId}-error` : undefined;
|
||||
const describedBy = errorId;
|
||||
const visible = Boolean(visibleSecrets[field.key]);
|
||||
const value = values[field.key] ?? "";
|
||||
const savedSecret = Boolean(field.secret && configuredFields?.has(field.key) && !value.trim());
|
||||
const clearSecret = clearedSecrets.has(field.key);
|
||||
const savedSecret = Boolean(
|
||||
field.secret && configuredFields?.has(field.key) && !value.trim() && !clearSecret,
|
||||
);
|
||||
const showSecretToggle = Boolean(field.secret && value.trim());
|
||||
const inputType = field.secret && !visible ? "password" : field.inputType ?? "text";
|
||||
const selectedOption = channelFieldValue(field, values);
|
||||
const header = (
|
||||
<span className="flex items-center justify-between gap-2 text-[11px] font-medium text-foreground/85">
|
||||
<span>{field.label}</span>
|
||||
{savedSecret ? (
|
||||
<span className="font-normal text-muted-foreground">
|
||||
{tx("settings.channels.savedSecret", "Saved")}
|
||||
{clearSecret ? (
|
||||
<span className="font-normal text-destructive">
|
||||
{tx("settings.channels.secretWillBeRemoved", "Will be removed")}
|
||||
</span>
|
||||
) : field.optional && !compact ? (
|
||||
<span className="font-normal text-muted-foreground">
|
||||
@@ -147,48 +176,94 @@ export function CredentialForm({
|
||||
) : null}
|
||||
</span>
|
||||
);
|
||||
const help = field.help ? (
|
||||
<span className="mt-1 block text-[11px] leading-4 text-muted-foreground">
|
||||
{field.help}
|
||||
const errorMessage = error ? (
|
||||
<span id={errorId} className="mt-1 block text-[11px] leading-4 text-destructive">
|
||||
{error}
|
||||
</span>
|
||||
) : null;
|
||||
if (field.options?.length) {
|
||||
return (
|
||||
<div key={field.key} className="block">
|
||||
{header}
|
||||
<fieldset
|
||||
key={field.key}
|
||||
id={`${inputId}-group`}
|
||||
aria-labelledby={`${inputId}-label`}
|
||||
aria-invalid={Boolean(error)}
|
||||
aria-describedby={describedBy}
|
||||
className="block"
|
||||
>
|
||||
<div className="grid grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)] items-start gap-x-4">
|
||||
<span id={`${inputId}-label`} className="flex min-h-12 items-center sm:min-h-10">{header}</span>
|
||||
<div className="min-w-0">
|
||||
<span
|
||||
role="radiogroup"
|
||||
aria-label={field.label}
|
||||
className="mt-1 grid rounded-control bg-muted p-0.5 text-[12px] font-medium text-muted-foreground"
|
||||
className="grid rounded-control bg-muted p-0.5 text-[12px] font-medium text-muted-foreground"
|
||||
style={{ gridTemplateColumns: `repeat(${field.options.length}, minmax(0, 1fr))` }}
|
||||
>
|
||||
{field.options.map((option) => (
|
||||
<button
|
||||
key={option.value}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={selectedOption === option.value}
|
||||
onClick={() => onChange(field.key, option.value)}
|
||||
className={cn(
|
||||
"min-h-8 rounded-compact px-2 py-1.5 transition-colors hover:text-foreground",
|
||||
selectedOption === option.value
|
||||
&& "bg-background text-foreground ring-1 ring-inset ring-border/45",
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
{field.options.map((option, index) => (
|
||||
<label key={option.value} className="relative block">
|
||||
<input
|
||||
id={index === 0 ? inputId : `${inputId}-${index}`}
|
||||
type="radio"
|
||||
name={inputId}
|
||||
value={option.value}
|
||||
checked={selectedOption === option.value}
|
||||
disabled={disabled}
|
||||
aria-invalid={Boolean(error)}
|
||||
aria-describedby={describedBy}
|
||||
onChange={() => onChange(field.key, option.value)}
|
||||
onBlur={() => onFieldBlur?.(field.key)}
|
||||
className="peer sr-only"
|
||||
/>
|
||||
<span className="grid min-h-11 cursor-pointer place-items-center rounded-compact px-2 py-1.5 transition-colors hover:text-foreground peer-checked:bg-background peer-checked:text-foreground peer-checked:ring-1 peer-checked:ring-inset peer-checked:ring-border/45 peer-focus-visible:ring-2 peer-focus-visible:ring-ring sm:min-h-9">
|
||||
{option.label}
|
||||
</span>
|
||||
</label>
|
||||
))}
|
||||
</span>
|
||||
{help}
|
||||
{errorMessage}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
if (field.kind === "json") {
|
||||
return (
|
||||
<div key={field.key} className="grid grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)] items-start gap-x-4">
|
||||
<label htmlFor={inputId} className="flex min-h-10 min-w-0 items-center self-start sm:min-h-9">
|
||||
{header}
|
||||
</label>
|
||||
<div className="min-w-0">
|
||||
<Textarea
|
||||
id={inputId}
|
||||
aria-label={field.label}
|
||||
aria-invalid={Boolean(error)}
|
||||
aria-describedby={describedBy}
|
||||
placeholder={field.placeholder}
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
onChange={(event) => onChange(field.key, event.target.value)}
|
||||
onBlur={() => onFieldBlur?.(field.key)}
|
||||
rows={4}
|
||||
spellCheck={false}
|
||||
className={cn(
|
||||
"resize-y border-border/40 bg-background font-mono text-[12px]",
|
||||
error && "border-destructive focus-visible:ring-destructive/30",
|
||||
)}
|
||||
/>
|
||||
{errorMessage}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<label key={field.key} className="block">
|
||||
{header}
|
||||
<span className="relative mt-1 block">
|
||||
<div key={field.key} className="grid grid-cols-[minmax(0,0.8fr)_minmax(0,1.2fr)] items-start gap-x-4">
|
||||
<label htmlFor={inputId} className="flex min-h-10 min-w-0 items-center self-start sm:min-h-9">{header}</label>
|
||||
<div className="min-w-0">
|
||||
<span className="relative block">
|
||||
<Input
|
||||
id={inputId}
|
||||
aria-label={field.label}
|
||||
aria-invalid={Boolean(error)}
|
||||
aria-describedby={describedBy}
|
||||
type={inputType}
|
||||
autoComplete={field.secret ? "off" : undefined}
|
||||
inputMode={field.inputType === "number" ? "numeric" : undefined}
|
||||
@@ -198,9 +273,12 @@ export function CredentialForm({
|
||||
: field.placeholder
|
||||
}
|
||||
value={values[field.key] ?? ""}
|
||||
disabled={disabled}
|
||||
onChange={(event) => onChange(field.key, event.target.value)}
|
||||
onBlur={() => onFieldBlur?.(field.key)}
|
||||
className={cn(
|
||||
"h-9 rounded-full border-border/60 bg-muted/35 text-[13px]",
|
||||
"h-10 rounded-full border-border/40 bg-background text-base sm:h-9 sm:text-[13px]",
|
||||
error && "border-destructive focus-visible:ring-destructive/30",
|
||||
showSecretToggle && "pr-9",
|
||||
)}
|
||||
/>
|
||||
@@ -213,7 +291,8 @@ export function CredentialForm({
|
||||
: tx("settings.channels.showSecret", "Show secret")
|
||||
}
|
||||
onClick={() => onToggleSecret(field.key)}
|
||||
className="absolute right-2 top-1/2 grid h-6 w-6 -translate-y-1/2 place-items-center rounded-full text-muted-foreground settings-hover hover:text-foreground"
|
||||
disabled={disabled}
|
||||
className="absolute right-0 top-1/2 grid h-10 w-10 -translate-y-1/2 place-items-center rounded-full text-muted-foreground hover:bg-background hover:text-foreground sm:right-1 sm:h-8 sm:w-8"
|
||||
>
|
||||
{visible ? (
|
||||
<EyeOff className="h-3.5 w-3.5" aria-hidden />
|
||||
@@ -223,8 +302,21 @@ export function CredentialForm({
|
||||
</button>
|
||||
) : null}
|
||||
</span>
|
||||
{help}
|
||||
</label>
|
||||
{errorMessage}
|
||||
{showSecretActions && field.secret && configuredFields?.has(field.key) && !value.trim() && onClearSecret ? (
|
||||
<button
|
||||
type="button"
|
||||
className="mt-1 min-h-8 text-[11px] font-medium text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
|
||||
onClick={() => onClearSecret(field.key, !clearSecret)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{clearSecret
|
||||
? tx("settings.channels.keepSavedSecret", "Keep saved credential")
|
||||
: tx("settings.channels.removeSavedSecret", "Remove saved credential")}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
import type { ComponentType } from "react";
|
||||
|
||||
export type ChannelPresentation = {
|
||||
displayName: string;
|
||||
initials: string;
|
||||
color: string;
|
||||
icon?: LucideIcon;
|
||||
icon?: ComponentType<{ className?: string; strokeWidth?: string | number }>;
|
||||
logoUrl?: string;
|
||||
setup?: ChannelCatalogSetupPresentation;
|
||||
};
|
||||
@@ -15,14 +15,13 @@ export type ChannelSetupPresentation = {
|
||||
command?: string;
|
||||
docsUrl?: string;
|
||||
docsLabel?: string;
|
||||
docsLogoUrl?: string;
|
||||
officialUrl?: string;
|
||||
officialLabel?: string;
|
||||
summary?: string;
|
||||
tryIt?: string;
|
||||
steps: string[];
|
||||
presetLabel?: string;
|
||||
sectionLabels?: Record<string, string>;
|
||||
fields?: ChannelConfigField[];
|
||||
manualFields?: ChannelConfigField[];
|
||||
requirements?: ChannelSetupRequirement[];
|
||||
actions?: ChannelSetupAction[];
|
||||
presets?: ChannelProviderPreset[];
|
||||
};
|
||||
@@ -31,15 +30,28 @@ type ChannelCatalogSetupPresentation = {
|
||||
mode?: "webui" | "credentials" | "connect";
|
||||
command?: string;
|
||||
docsUrl?: string;
|
||||
docsLogoUrl?: string;
|
||||
fields?: ChannelFieldPresentation[];
|
||||
manualFields?: ChannelFieldPresentation[];
|
||||
actions?: ChannelSetupActionDefinition[];
|
||||
presets?: ChannelProviderPresetDefinition[];
|
||||
};
|
||||
|
||||
type ChannelFieldPresentation = {
|
||||
export type ChannelFieldPresentation = {
|
||||
key: string;
|
||||
section?: string;
|
||||
};
|
||||
|
||||
export type ChannelFieldSection =
|
||||
| "account"
|
||||
| "credentials"
|
||||
| "connection"
|
||||
| "access"
|
||||
| "behavior"
|
||||
| "security"
|
||||
| "advanced";
|
||||
|
||||
export type ChannelSetupRequirement = {
|
||||
alternatives: string[][];
|
||||
};
|
||||
|
||||
type ChannelSetupActionDefinition = Omit<ChannelSetupAction, "label">;
|
||||
@@ -66,8 +78,9 @@ export type ChannelConfigField = {
|
||||
placeholder?: string;
|
||||
secret?: boolean;
|
||||
optional?: boolean;
|
||||
help?: string;
|
||||
inputType?: "text" | "number";
|
||||
inputType?: "text" | "number" | "url" | "email" | "tel";
|
||||
kind?: "string" | "secret" | "int" | "bool" | "list" | "enum" | string;
|
||||
section?: string;
|
||||
defaultValue?: string;
|
||||
options?: ChannelConfigOption[];
|
||||
};
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { TFunction } from "i18next";
|
||||
|
||||
const messages: Record<string, string> = {
|
||||
"Connection verified.": "connected",
|
||||
"Configuration is present, but full verification was not possible.": "unverified",
|
||||
"Required setup is missing.": "missing",
|
||||
"Configuration was checked and looks invalid.": "invalid",
|
||||
"This channel is not supported by the WebUI setup checker.": "unsupported",
|
||||
"Configured.": "present",
|
||||
"Required.": "required",
|
||||
"This channel can be checked from saved fields, but not fully verified in-browser.": "manual",
|
||||
};
|
||||
|
||||
export function channelValidationMessage(message: string, t: TFunction): string {
|
||||
const key = messages[message];
|
||||
return key ? t(`settings.channels.validationMessages.${key}`, { defaultValue: message }) : message;
|
||||
}
|
||||
@@ -48,11 +48,13 @@ export function CapabilityInstallNotice({
|
||||
|
||||
export function NanobotFeatureInstallDialog({
|
||||
feature,
|
||||
installOnly = false,
|
||||
installing,
|
||||
onOpenChange,
|
||||
onConfirm,
|
||||
}: {
|
||||
feature: NanobotFeatureInfo | null;
|
||||
installOnly?: boolean;
|
||||
installing: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
onConfirm: (feature: NanobotFeatureInfo) => void | Promise<void>;
|
||||
@@ -72,11 +74,17 @@ export function NanobotFeatureInstallDialog({
|
||||
{tx("settings.nanobotFeatures.installConfirmTitle", "Install support for {{name}}?", { name })}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="mt-3 max-w-[20rem] text-center text-[14px] leading-6 text-muted-foreground">
|
||||
{tx(
|
||||
"settings.nanobotFeatures.installConfirmDescription",
|
||||
"nanobot will add what {{name}} needs, then turn it on. Continue?",
|
||||
{ name },
|
||||
)}
|
||||
{installOnly
|
||||
? tx(
|
||||
"settings.nanobotFeatures.installOnlyConfirmDescription",
|
||||
"nanobot will install what {{name}} needs. You can connect it after installation.",
|
||||
{ name },
|
||||
)
|
||||
: tx(
|
||||
"settings.nanobotFeatures.installConfirmDescription",
|
||||
"nanobot will add what {{name}} needs, then turn it on. Continue?",
|
||||
{ name },
|
||||
)}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter className="mt-7 !grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
@@ -96,7 +104,9 @@ export function NanobotFeatureInstallDialog({
|
||||
className="h-11 w-full min-w-0 !whitespace-normal px-5 text-center text-[15px] font-semibold"
|
||||
>
|
||||
{installing ? <Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden /> : null}
|
||||
{tx("settings.nanobotFeatures.installConfirmAction", "Install and enable")}
|
||||
{installOnly
|
||||
? tx("settings.nanobotFeatures.installOnlyConfirmAction", "Install support")
|
||||
: tx("settings.nanobotFeatures.installConfirmAction", "Install and enable")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
@@ -117,6 +127,8 @@ export function DismissibleStatusMessage({
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
return (
|
||||
<div
|
||||
role={isError ? "alert" : "status"}
|
||||
aria-atomic="true"
|
||||
className={cn(
|
||||
"flex items-center justify-between gap-3 rounded-control border py-2.5 pl-4 pr-2 text-[13px]",
|
||||
isError
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import type { FormEvent, ReactNode } from "react";
|
||||
import type { TFunction } from "i18next";
|
||||
import {
|
||||
ArrowUpDown,
|
||||
Check,
|
||||
@@ -17,7 +18,8 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { channelUiPresentation } from "@/channel-plugins/registry";
|
||||
import { channelTranslator } from "@/channel-plugins/i18n";
|
||||
import { channelUiOwner, channelUiPresentation } from "@/channel-plugins/registry";
|
||||
import { SETTINGS_SEARCH_INPUT_CLASS } from "@/components/settings/shared/SettingsControls";
|
||||
import { AppsActionButton } from "@/components/settings/system/AppsSettings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -302,7 +304,7 @@ function AutomationListItem({
|
||||
const tx = (key: string, fallback: string, values?: Record<string, unknown>) =>
|
||||
t(key, { defaultValue: fallback, ...(values ?? {}) });
|
||||
const status = automationStatus(job, tx);
|
||||
const origin = automationOriginLabel(job, tx);
|
||||
const origin = automationOriginLabel(job, t);
|
||||
const nextRun = formatAutomationNext(job, tx);
|
||||
const summary = automationSummary(job, tx);
|
||||
|
||||
@@ -381,7 +383,7 @@ function AutomationDetailPanel({
|
||||
const tx = (key: string, fallback: string, values?: Record<string, unknown>) =>
|
||||
t(key, { defaultValue: fallback, ...(values ?? {}) });
|
||||
const status = automationStatus(job, tx);
|
||||
const origin = automationOriginLabel(job, tx);
|
||||
const origin = automationOriginLabel(job, t);
|
||||
const originHref = job.origin?.channel === "websocket" && job.origin.session_key
|
||||
? `#/chat/${encodeURIComponent(job.origin.session_key)}`
|
||||
: null;
|
||||
@@ -1358,23 +1360,27 @@ function automationStatus(
|
||||
|
||||
function automationOriginLabel(
|
||||
job: SessionAutomationJob,
|
||||
tx: (key: string, fallback: string, values?: Record<string, unknown>) => string,
|
||||
t: TFunction,
|
||||
): string {
|
||||
if (job.protected) return tx("settings.automations.origin.system", "System");
|
||||
if (job.protected) return t("settings.automations.origin.system", { defaultValue: "System" });
|
||||
const origin = job.origin;
|
||||
if (!origin) return tx("settings.automations.origin.unknown", "No linked chat");
|
||||
if (origin.channel !== "websocket") return automationChannelLabel(origin.channel, tx);
|
||||
return origin.title || origin.preview || origin.session_key || automationChannelLabel(origin.channel, tx);
|
||||
if (!origin) return t("settings.automations.origin.unknown", { defaultValue: "No linked chat" });
|
||||
if (origin.channel !== "websocket") return automationChannelLabel(origin.channel, t);
|
||||
return origin.title || origin.preview || origin.session_key || automationChannelLabel(origin.channel, t);
|
||||
}
|
||||
|
||||
function automationChannelLabel(
|
||||
channel: string,
|
||||
tx: (key: string, fallback: string, values?: Record<string, unknown>) => string,
|
||||
t: TFunction,
|
||||
): string {
|
||||
const key = channel.trim().toLowerCase();
|
||||
const displayName = automationChannelDisplayName(key);
|
||||
const presentation = channelUiPresentation(key);
|
||||
if (presentation) {
|
||||
return channelTranslator(t, channelUiOwner(key))("displayName", presentation.displayName);
|
||||
}
|
||||
const displayName = HOST_AUTOMATION_CHANNEL_LABELS[key];
|
||||
return displayName
|
||||
? tx(`settings.automations.channels.${key}`, displayName)
|
||||
? t(`settings.automations.channels.${key}`, { defaultValue: displayName })
|
||||
: channel;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useCallback, useLayoutEffect, useRef, useState } from "react";
|
||||
import { Loader2, Search, X } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SegmentedControl } from "@/components/ui/segmented-control";
|
||||
import { SETTINGS_SEARCH_INPUT_CLASS } from "@/components/settings/shared/SettingsControls";
|
||||
import type { ChannelFeatureAction } from "@/channel-plugins/types";
|
||||
import { localizedChannelDisplayName } from "@/components/settings/channels/ChannelIdentity";
|
||||
import { ChannelHelpMenu } from "@/components/settings/channels/ChannelHelpMenu";
|
||||
import { ChannelCatalogRow, ChannelSetupPanel } from "@/components/settings/channels/ChannelSetupPanel";
|
||||
import { DismissibleStatusMessage, RestartRequiredNotice, SettingsGroup } from "@/components/settings/shared/SettingsControls";
|
||||
import type { NanobotFeaturesPayload } from "@/lib/types";
|
||||
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Dialog, DialogClose, DialogContent, DialogTitle } from "@/components/ui/dialog";
|
||||
|
||||
type ChannelFilter = "all" | "enabled";
|
||||
|
||||
export function ChannelsSettings({
|
||||
token, nanobotFeatures, loading, actionKey, chatAppsDocsUrl, showBrandLogos,
|
||||
@@ -21,7 +28,7 @@ export function ChannelsSettings({
|
||||
showBrandLogos: boolean;
|
||||
error: string | null;
|
||||
requiresRestartPending: boolean;
|
||||
onAction: (action: "enable" | "disable", name: string) => void;
|
||||
onAction: ChannelFeatureAction;
|
||||
onFeaturesUpdate: (payload: NanobotFeaturesPayload) => void;
|
||||
onDismissStatus: () => void;
|
||||
onRestart?: () => void;
|
||||
@@ -29,19 +36,83 @@ export function ChannelsSettings({
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [selectedChannelName, setSelectedChannelName] = useState<string | null>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const [filter, setFilter] = useState<ChannelFilter>("enabled");
|
||||
const [connectRequestId, setConnectRequestId] = useState(0);
|
||||
const filterInitializedRef = useRef(false);
|
||||
const triggerRef = useRef<HTMLElement | null>(null);
|
||||
const dialogRef = useRef<HTMLDivElement | null>(null);
|
||||
const beforeCloseRef = useRef<(() => Promise<boolean>) | null>(null);
|
||||
const closePendingRef = useRef(false);
|
||||
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 hasEnabledChannels = channels.some((feature) => feature.enabled);
|
||||
const restartRequired = requiresRestartPending || Boolean(nanobotFeatures?.requires_restart);
|
||||
useLayoutEffect(() => {
|
||||
if (!nanobotFeatures || filterInitializedRef.current) return;
|
||||
filterInitializedRef.current = true;
|
||||
setFilter(hasEnabledChannels ? "enabled" : "all");
|
||||
}, [hasEnabledChannels, nanobotFeatures]);
|
||||
const visibleChannels = channels.filter((feature) =>
|
||||
(filter === "all" || feature.enabled)
|
||||
&& `${feature.name} ${localizedChannelDisplayName(feature, t)}`.toLocaleLowerCase()
|
||||
.includes(query.trim().toLocaleLowerCase()));
|
||||
const channelGroups = filter === "enabled"
|
||||
? [{ key: "enabled", label: null, channels: visibleChannels }]
|
||||
: [
|
||||
{
|
||||
key: "builtin",
|
||||
label: t("settings.channels.noInstallNeeded"),
|
||||
channels: visibleChannels.filter((feature) => !feature.requires_dependencies),
|
||||
},
|
||||
{
|
||||
key: "dependencies",
|
||||
label: t("settings.channels.installNeeded"),
|
||||
channels: visibleChannels.filter((feature) => feature.requires_dependencies),
|
||||
},
|
||||
].filter((group) => group.channels.length);
|
||||
const selectedChannel = channels.find((feature) => feature.name === selectedChannelName);
|
||||
const requestChannelClose = useCallback(() => {
|
||||
if (closePendingRef.current) return;
|
||||
const beforeClose = beforeCloseRef.current;
|
||||
if (!beforeClose) {
|
||||
setSelectedChannelName(null);
|
||||
return;
|
||||
}
|
||||
closePendingRef.current = true;
|
||||
void beforeClose().then((canClose) => {
|
||||
if (canClose) setSelectedChannelName(null);
|
||||
}).finally(() => {
|
||||
closePendingRef.current = false;
|
||||
});
|
||||
}, []);
|
||||
const setBeforeChannelClose = useCallback(
|
||||
(handler: (() => Promise<boolean>) | null) => { beforeCloseRef.current = handler; },
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="settings-stack">
|
||||
{error ? <DismissibleStatusMessage message={error} isError onDismiss={onDismissStatus} /> : null}
|
||||
{requiresRestartPending ? (
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
<div className="relative min-w-0 flex-1">
|
||||
<Search className="pointer-events-none absolute start-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
|
||||
<Input type="search" value={query} onChange={(event) => setQuery(event.target.value)}
|
||||
aria-label={t("settings.channels.search")}
|
||||
placeholder={t("settings.channels.search")}
|
||||
className={`h-12 ps-11 text-[15px] ${SETTINGS_SEARCH_INPUT_CLASS}`} />
|
||||
</div>
|
||||
<SegmentedControl value={filter} onChange={(value) => {
|
||||
filterInitializedRef.current = true;
|
||||
setFilter(value);
|
||||
}} options={[
|
||||
{ value: "all", label: t("settings.channels.filterAll") },
|
||||
{ value: "enabled", label: t("settings.channels.filterEnabled") },
|
||||
]} />
|
||||
</div>
|
||||
{error && !selectedChannel ? <DismissibleStatusMessage message={error} isError onDismiss={onDismissStatus} /> : null}
|
||||
{restartRequired ? (
|
||||
<RestartRequiredNotice message={t("settings.channels.restartRequired")}
|
||||
onRestart={onRestart} isRestarting={isRestarting} />
|
||||
) : null}
|
||||
@@ -50,34 +121,62 @@ export function ChannelsSettings({
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
|
||||
{t("settings.channels.loading")}
|
||||
</div>
|
||||
) : channels.length ? (
|
||||
<SettingsGroup>
|
||||
{channels.map((feature) => (
|
||||
) : visibleChannels.length ? (
|
||||
channelGroups.map((group) => (
|
||||
<section
|
||||
key={group.key}
|
||||
aria-labelledby={group.label ? `channel-group-${group.key}` : undefined}
|
||||
aria-label={group.label ? undefined : t("settings.channels.filterEnabled")}
|
||||
className={group.label ? "space-y-2" : undefined}
|
||||
>
|
||||
{group.label ? (
|
||||
<h2 id={`channel-group-${group.key}`} className="px-4 text-[12px] font-medium text-muted-foreground">{group.label}</h2>
|
||||
) : null}
|
||||
<SettingsGroup>
|
||||
<div className="grid grid-cols-1 gap-x-4 gap-y-1 min-[640px]:grid-cols-2">
|
||||
{group.channels.map((feature) => (
|
||||
<ChannelCatalogRow key={feature.name} feature={feature} showBrandLogos={showBrandLogos}
|
||||
actionKey={actionKey} onAction={onAction}
|
||||
actionKey={actionKey} actionsDisabled={restartRequired || Boolean(isRestarting)} onAction={onAction}
|
||||
onSelect={(connect = false) => {
|
||||
triggerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
beforeCloseRef.current = null;
|
||||
setConnectRequestId(connect ? 1 : 0);
|
||||
setSelectedChannelName(feature.name);
|
||||
}} />
|
||||
))}
|
||||
</SettingsGroup>
|
||||
</div>
|
||||
</SettingsGroup>
|
||||
</section>
|
||||
))
|
||||
) : (
|
||||
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
|
||||
{t("settings.channels.empty")}
|
||||
{t(channels.length ? "settings.channels.noResults" : "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"
|
||||
<Dialog open={Boolean(selectedChannel)} onOpenChange={(open) => { if (!open) requestChannelClose(); }}>
|
||||
<DialogContent ref={dialogRef} showCloseButton={false} aria-describedby={undefined} className="max-h-[85dvh] w-[min(calc(100vw-2rem),40rem)] max-w-none overflow-hidden p-0 outline-none"
|
||||
onOpenAutoFocus={(event) => {
|
||||
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}
|
||||
<div className="max-h-[85dvh] min-h-0 overflow-y-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
||||
<div className="relative">
|
||||
<div className="absolute end-6 top-6 z-10 flex h-10 items-center gap-1">
|
||||
{selectedChannel ? <ChannelHelpMenu feature={selectedChannel} chatAppsDocsUrl={chatAppsDocsUrl} /> : null}
|
||||
<DialogClose className="grid h-8 w-8 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring">
|
||||
<X className="h-4 w-4" aria-hidden />
|
||||
<span className="sr-only">{t("common.close")}</span>
|
||||
</DialogClose>
|
||||
</div>
|
||||
{error ? <DismissibleStatusMessage message={error} isError onDismiss={onDismissStatus} /> : null}
|
||||
{selectedChannel ? <ChannelSetupPanel token={token} feature={selectedChannel} actionKey={actionKey}
|
||||
showBrandLogos={showBrandLogos}
|
||||
onAction={onAction} onFeaturesUpdate={onFeaturesUpdate} connectRequestId={connectRequestId}
|
||||
onBeforeCloseChange={setBeforeChannelClose} /> : null}
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
@@ -98,6 +98,7 @@ export function createSystemSettingsActions({
|
||||
mcpOAuthFlowRef,
|
||||
mcpOAuthNavigatedUrlRef,
|
||||
mcpOAuthPopupRef,
|
||||
nanobotFeatureActionRef,
|
||||
nanobotFeatures,
|
||||
setApiService,
|
||||
setApiServiceAction,
|
||||
@@ -130,12 +131,26 @@ export function createSystemSettingsActions({
|
||||
setNanobotFeaturesError,
|
||||
} = state;
|
||||
|
||||
const beginNanobotFeatureAction = (key: string) => {
|
||||
if (nanobotFeatureActionRef.current) return false;
|
||||
nanobotFeatureActionRef.current = key;
|
||||
setNanobotFeatureAction(key);
|
||||
return true;
|
||||
};
|
||||
|
||||
const endNanobotFeatureAction = (key: string) => {
|
||||
if (nanobotFeatureActionRef.current !== key) return;
|
||||
nanobotFeatureActionRef.current = null;
|
||||
setNanobotFeatureAction(null);
|
||||
};
|
||||
|
||||
const installCapabilities = async (names: string[]): Promise<boolean> => {
|
||||
const missing = names.filter(
|
||||
(name) => !featureCatalog.find((feature) => feature.name === name)?.installed,
|
||||
);
|
||||
if (!missing.length) return true;
|
||||
setNanobotFeatureAction(`enable:${names.join("+")}`);
|
||||
const key = `enable:${names.join("+")}`;
|
||||
if (!beginNanobotFeatureAction(key)) return false;
|
||||
setNanobotFeaturesError(null);
|
||||
try {
|
||||
let latest = nanobotFeatures;
|
||||
@@ -151,7 +166,7 @@ export function createSystemSettingsActions({
|
||||
setNanobotFeaturesError((err as Error).message);
|
||||
return false;
|
||||
} finally {
|
||||
setNanobotFeatureAction(null);
|
||||
endNanobotFeatureAction(key);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -204,30 +219,42 @@ export function createSystemSettingsActions({
|
||||
const handleNanobotFeatureAction = async (
|
||||
action: "enable" | "disable",
|
||||
name: string,
|
||||
confirmed = false,
|
||||
options: { confirmed?: boolean; installOnly?: boolean } = {},
|
||||
) => {
|
||||
const feature = featureCatalog.find((item) => item.name === name);
|
||||
if (action === "enable" && !confirmed && feature && !feature.installed && feature.install_supported) {
|
||||
if (
|
||||
action === "enable"
|
||||
&& !options.confirmed
|
||||
&& feature
|
||||
&& !feature.installed
|
||||
&& feature.install_supported
|
||||
) {
|
||||
setNanobotFeaturesError(null);
|
||||
setNanobotFeatureConfirm(feature);
|
||||
setNanobotFeatureConfirm({ feature, installOnly: Boolean(options.installOnly) });
|
||||
return;
|
||||
}
|
||||
const key = `${action}:${name}`;
|
||||
setNanobotFeatureAction(key);
|
||||
const key = `${action === "enable" && options.installOnly ? "install" : action}:${name}`;
|
||||
if (!beginNanobotFeatureAction(key)) return;
|
||||
setNanobotFeatureConfirm(null);
|
||||
setNanobotFeaturesError(null);
|
||||
try {
|
||||
const payload = action === "enable"
|
||||
? await enableNanobotFeature(client, name)
|
||||
? await enableNanobotFeature(client, name, { installOnly: options.installOnly })
|
||||
: await disableNanobotFeature(client, name);
|
||||
setNanobotFeatures(payload);
|
||||
if (payload.requires_restart) {
|
||||
setPendingRestartSections((prev) => ({ ...prev, runtime: true }));
|
||||
}
|
||||
} catch (err) {
|
||||
setNanobotFeaturesError((err as Error).message);
|
||||
console.error("nanobot feature action failed", {
|
||||
action,
|
||||
name,
|
||||
installOnly: Boolean(options.installOnly),
|
||||
error: err,
|
||||
});
|
||||
setNanobotFeaturesError(err instanceof Error ? err.message : String(err));
|
||||
} finally {
|
||||
setNanobotFeatureAction(null);
|
||||
endNanobotFeatureAction(key);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@ import type {
|
||||
SessionAutomationJob,
|
||||
} from "@/lib/types";
|
||||
|
||||
export type NanobotFeatureInstallRequest = {
|
||||
feature: NanobotFeatureInfo;
|
||||
installOnly: boolean;
|
||||
};
|
||||
|
||||
export function useSystemSettingsState() {
|
||||
const [cliApps, setCliApps] = useState<CliAppsPayload | null>(null);
|
||||
const [nanobotFeatures, setNanobotFeatures] = useState<NanobotFeaturesPayload | null>(null);
|
||||
@@ -31,7 +36,9 @@ export function useSystemSettingsState() {
|
||||
const [automationsLoading, setAutomationsLoading] = useState(false);
|
||||
const [cliAppsAction, setCliAppsAction] = useState<string | null>(null);
|
||||
const [nanobotFeatureAction, setNanobotFeatureAction] = useState<string | null>(null);
|
||||
const [nanobotFeatureConfirm, setNanobotFeatureConfirm] = useState<NanobotFeatureInfo | null>(null);
|
||||
const nanobotFeatureActionRef = useRef<string | null>(null);
|
||||
const [nanobotFeatureConfirm, setNanobotFeatureConfirm] =
|
||||
useState<NanobotFeatureInstallRequest | null>(null);
|
||||
const [mcpPresetAction, setMcpPresetAction] = useState<string | null>(null);
|
||||
const [mcpOAuthFlow, setMcpOAuthFlow] = useState<McpOAuthFlowPayload | null>(null);
|
||||
const mcpOAuthFlowRef = useRef<McpOAuthFlowPayload | null>(null);
|
||||
@@ -105,6 +112,7 @@ export function useSystemSettingsState() {
|
||||
mcpPresets,
|
||||
mcpPresetsLoading,
|
||||
nanobotFeatureAction,
|
||||
nanobotFeatureActionRef,
|
||||
nanobotFeatureConfirm,
|
||||
nanobotFeatures,
|
||||
nanobotFeaturesError,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { FloatingPortalContext } from "@/components/ui/floating-portal";
|
||||
|
||||
const Dialog = DialogPrimitive.Root;
|
||||
const DialogTrigger = DialogPrimitive.Trigger;
|
||||
const DialogClose = DialogPrimitive.Close;
|
||||
const DialogPortal = DialogPrimitive.Portal;
|
||||
export const DialogLayoutContext = React.createContext<HTMLElement | null>(null);
|
||||
|
||||
@@ -95,7 +96,7 @@ const DialogContent = React.forwardRef<
|
||||
{children}
|
||||
</FloatingPortalContext.Provider>
|
||||
{showCloseButton ? (
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
||||
<DialogPrimitive.Close className="absolute right-2.5 top-2.5 grid h-7 w-7 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground active:bg-muted/80 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">{t("common.close")}</span>
|
||||
</DialogPrimitive.Close>
|
||||
@@ -165,6 +166,7 @@ DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
||||
export {
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "nanobot web UI — chat with your nanobot workspace."
|
||||
},
|
||||
"pairing": {
|
||||
"title": "Pair a chat user",
|
||||
"description": "Enter the pairing code shown in the chat.",
|
||||
"title": "Pair your chat account",
|
||||
"description": "Enter the pairing code you received in chat.",
|
||||
"code": "Pairing code",
|
||||
"matched": "Matched {{channel}}. Connecting...",
|
||||
"expiresInline": "Code expires {{expires}}.",
|
||||
@@ -983,7 +983,6 @@
|
||||
"requires": "Requires: {{requirements}}",
|
||||
"setUp": "Set up",
|
||||
"setupGuide": "Setup guide",
|
||||
"setupSummary": "Enable only turns on nanobot support. Add the platform credentials, then restart nanobot.",
|
||||
"configKeys": "Config keys",
|
||||
"enable": "Enable channel",
|
||||
"disable": "Disable channel",
|
||||
@@ -997,7 +996,8 @@
|
||||
"open": "Open",
|
||||
"checkedAndEnabled": "Checked and enabled.",
|
||||
"checking": "Checking...",
|
||||
"checkOnly": "Check only",
|
||||
"help": "Help",
|
||||
"checkOnly": "Check",
|
||||
"commandCopied": "Command copied.",
|
||||
"commandCopyFailed": "Could not copy command.",
|
||||
"configuredInstances": "{{count}} instances configured",
|
||||
@@ -1015,7 +1015,6 @@
|
||||
"runtimeStarting": "Starting",
|
||||
"runtimeStopped": "Not running",
|
||||
"managedByWebui": "Managed by WebUI",
|
||||
"officialGuide": "Official guide",
|
||||
"optional": "Optional",
|
||||
"providerPreset": "Provider",
|
||||
"requiredSetup": "Required setup",
|
||||
@@ -1024,21 +1023,51 @@
|
||||
"savedSettings": "Settings saved.",
|
||||
"saveSettings": "Save settings",
|
||||
"selectChannel": "View {{name}} settings",
|
||||
"setupSteps": "Next steps",
|
||||
"showSecret": "Show secret",
|
||||
"toggleChannel": "{{name}} channel",
|
||||
"toggleInstance": "{{name}} instance",
|
||||
"tryIt": "Try it",
|
||||
"validationFailed": "Check the required setup before enabling.",
|
||||
"completeSetupToEnable": "Complete the required setup below, then nanobot can enable this channel.",
|
||||
"chooseCredentialMethod": "Choose one credential method",
|
||||
"or": "or",
|
||||
"fieldRequired": "Required to complete setup.",
|
||||
"secretWillBeRemoved": "Will be removed",
|
||||
"keepSavedSecret": "Keep saved credential",
|
||||
"removeSavedSecret": "Remove saved credential",
|
||||
"sections": {
|
||||
"account": "Account",
|
||||
"credentials": "Credentials",
|
||||
"connection": "Connection",
|
||||
"access": "Access",
|
||||
"behavior": "Behavior",
|
||||
"security": "Security"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "Connected",
|
||||
"configured": "Configured manually",
|
||||
"configured": "Not verified",
|
||||
"needs_setup": "Needs setup",
|
||||
"invalid": "Invalid",
|
||||
"invalid": "Connection failed",
|
||||
"unsupported": "Manual setup"
|
||||
},
|
||||
"configuredInstances_one": "{{count}} instance configured",
|
||||
"configuredInstances_other": "{{count}} instances configured"
|
||||
"configuredInstances_other": "{{count}} instances configured",
|
||||
"validationMessages": {
|
||||
"connected": "Connection verified.",
|
||||
"unverified": "Connection not verified.",
|
||||
"missing": "Complete the required fields.",
|
||||
"invalid": "Connection check failed.",
|
||||
"unsupported": "Connection testing is not supported for this channel yet.",
|
||||
"present": "Filled in",
|
||||
"required": "Required",
|
||||
"manual": "Connection testing is not supported for this channel yet."
|
||||
},
|
||||
"search": "Search channels",
|
||||
"filterEnabled": "Enabled",
|
||||
"noResults": "No matching channels",
|
||||
"install": "Install",
|
||||
"installChannel": "Install {{name}}",
|
||||
"noInstallNeeded": "No installation needed",
|
||||
"installNeeded": "Requires dependencies"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "Enabled",
|
||||
@@ -1049,7 +1078,9 @@
|
||||
"installSupport": "Install support",
|
||||
"installConfirmTitle": "Install support for {{name}}?",
|
||||
"installConfirmDescription": "nanobot will add what {{name}} needs, then turn it on. Continue?",
|
||||
"installOnlyConfirmDescription": "nanobot will install what {{name}} needs. You can connect it after installation.",
|
||||
"installConfirmAction": "Install and enable",
|
||||
"installOnlyConfirmAction": "Install support",
|
||||
"websocketRequired": "Required for WebUI",
|
||||
"channelDisabled": "Channel is disabled",
|
||||
"notEnabled": "Not enabled"
|
||||
@@ -1114,20 +1145,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "Email",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "At {{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "Interfaz web de nanobot: conversa con tu espacio de trabajo de nanobot."
|
||||
},
|
||||
"pairing": {
|
||||
"title": "Vincular a un usuario del chat",
|
||||
"description": "Introduce el código de vinculación que aparece en el chat.",
|
||||
"title": "Vincular tu cuenta de chat",
|
||||
"description": "Introduce el código de vinculación que recibiste en el chat.",
|
||||
"code": "Código de vinculación",
|
||||
"matched": "Coincidencia: {{channel}}. Conectando...",
|
||||
"expiresInline": "El código caduca {{expires}}.",
|
||||
@@ -778,13 +778,13 @@
|
||||
"searchPlaceholder": "Buscar canales",
|
||||
"backToChannels": "Todos los canales",
|
||||
"catalog": "Canales",
|
||||
"help": "Ayuda",
|
||||
"loading": "Cargando canales...",
|
||||
"empty": "Ningún canal coincide con este filtro.",
|
||||
"restartRequired": "Reinicia nanobot para aplicar el soporte de canales actualizado.",
|
||||
"requires": "Requiere: {{requirements}}",
|
||||
"setUp": "Configurar",
|
||||
"setupGuide": "Guía de configuración",
|
||||
"setupSummary": "Activa el canal, añade las credenciales de la plataforma y reinicia nanobot.",
|
||||
"configKeys": "Claves de configuración",
|
||||
"enable": "Activar canal",
|
||||
"disable": "Desactivar canal",
|
||||
@@ -818,7 +818,6 @@
|
||||
"runtimeStarting": "Iniciando",
|
||||
"runtimeStopped": "No está en ejecución",
|
||||
"managedByWebui": "Gestionado por WebUI",
|
||||
"officialGuide": "Guía oficial",
|
||||
"optional": "Opcional",
|
||||
"providerPreset": "Proveedor",
|
||||
"requiredSetup": "Configuración requerida",
|
||||
@@ -827,19 +826,49 @@
|
||||
"savedSettings": "Configuración guardada.",
|
||||
"saveSettings": "Guardar configuración",
|
||||
"selectChannel": "Ver la configuración de {{name}}",
|
||||
"setupSteps": "Siguientes pasos",
|
||||
"showSecret": "Mostrar secreto",
|
||||
"toggleChannel": "Activar {{name}}",
|
||||
"toggleInstance": "Activar la instancia {{name}}",
|
||||
"tryIt": "Pruébalo",
|
||||
"validationFailed": "Comprueba la configuración requerida antes de activar.",
|
||||
"completeSetupToEnable": "Completa la configuración requerida para activar este canal.",
|
||||
"chooseCredentialMethod": "Elige un método de credenciales",
|
||||
"or": "o",
|
||||
"fieldRequired": "Obligatorio para completar la configuración.",
|
||||
"secretWillBeRemoved": "Se eliminará",
|
||||
"keepSavedSecret": "Conservar credencial guardada",
|
||||
"removeSavedSecret": "Eliminar credencial guardada",
|
||||
"sections": {
|
||||
"account": "Cuenta",
|
||||
"credentials": "Credenciales",
|
||||
"connection": "Conexión",
|
||||
"access": "Acceso",
|
||||
"behavior": "Comportamiento",
|
||||
"security": "Seguridad"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "Conectado",
|
||||
"configured": "Configurado manualmente",
|
||||
"needs_setup": "Requiere configuración",
|
||||
"invalid": "No válido",
|
||||
"invalid": "Error de conexión",
|
||||
"unsupported": "Configuración manual"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "Conexión verificada.",
|
||||
"unverified": "Conexión sin verificar.",
|
||||
"missing": "Completa los campos obligatorios.",
|
||||
"invalid": "Falló la comprobación de la conexión.",
|
||||
"unsupported": "Este canal todavía no permite comprobar la conexión.",
|
||||
"present": "Completado",
|
||||
"required": "Obligatorio",
|
||||
"manual": "Este canal todavía no permite comprobar la conexión."
|
||||
},
|
||||
"search": "Buscar canales",
|
||||
"filterEnabled": "Activados",
|
||||
"noResults": "No hay canales coincidentes",
|
||||
"install": "Instalar",
|
||||
"installChannel": "Instalar {{name}}",
|
||||
"noInstallNeeded": "No requiere instalación",
|
||||
"installNeeded": "Requiere dependencias"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "Activado",
|
||||
@@ -850,7 +879,9 @@
|
||||
"installSupport": "Instalar dependencias",
|
||||
"installConfirmTitle": "¿Instalar las dependencias de {{name}}?",
|
||||
"installConfirmDescription": "nanobot instalará las dependencias necesarias y activará {{name}}.",
|
||||
"installOnlyConfirmDescription": "nanobot instalará lo que {{name}} necesita. Podrás conectarlo después de la instalación.",
|
||||
"installConfirmAction": "Instalar y activar",
|
||||
"installOnlyConfirmAction": "Instalar soporte",
|
||||
"websocketRequired": "Requerido para WebUI",
|
||||
"channelDisabled": "El canal está desactivado",
|
||||
"notEnabled": "No activado"
|
||||
@@ -915,20 +946,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "Email",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "A las {{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "Interface web nanobot — discutez avec votre espace de travail nanobot."
|
||||
},
|
||||
"pairing": {
|
||||
"title": "Associer un utilisateur du chat",
|
||||
"description": "Saisissez le code d’association affiché dans le chat.",
|
||||
"title": "Associer votre compte de messagerie",
|
||||
"description": "Saisissez le code d’association reçu dans la messagerie.",
|
||||
"code": "Code d’association",
|
||||
"matched": "Correspondance {{channel}}. Connexion...",
|
||||
"expiresInline": "Le code expire {{expires}}.",
|
||||
@@ -777,13 +777,13 @@
|
||||
"searchPlaceholder": "Rechercher des canaux",
|
||||
"backToChannels": "Tous les canaux",
|
||||
"catalog": "Canaux",
|
||||
"help": "Aide",
|
||||
"loading": "Chargement des canaux...",
|
||||
"empty": "Aucun canal ne correspond à ce filtre.",
|
||||
"restartRequired": "Redémarrez nanobot pour appliquer le support de canal mis à jour.",
|
||||
"requires": "Requiert : {{requirements}}",
|
||||
"setUp": "Configurer",
|
||||
"setupGuide": "Guide de configuration",
|
||||
"setupSummary": "Activez le canal, renseignez les identifiants de la plateforme, puis redémarrez nanobot.",
|
||||
"configKeys": "Clés de configuration",
|
||||
"enable": "Activer le canal",
|
||||
"disable": "Désactiver le canal",
|
||||
@@ -817,7 +817,6 @@
|
||||
"runtimeStarting": "Démarrage",
|
||||
"runtimeStopped": "À l'arrêt",
|
||||
"managedByWebui": "Géré par la WebUI",
|
||||
"officialGuide": "Guide officiel",
|
||||
"optional": "Facultatif",
|
||||
"providerPreset": "Fournisseur",
|
||||
"requiredSetup": "Configuration requise",
|
||||
@@ -826,19 +825,49 @@
|
||||
"savedSettings": "Paramètres enregistrés.",
|
||||
"saveSettings": "Enregistrer les paramètres",
|
||||
"selectChannel": "Afficher les paramètres de {{name}}",
|
||||
"setupSteps": "Étapes suivantes",
|
||||
"showSecret": "Afficher le secret",
|
||||
"toggleChannel": "Activer {{name}}",
|
||||
"toggleInstance": "Activer l’instance {{name}}",
|
||||
"tryIt": "Essayer",
|
||||
"validationFailed": "Vérifiez la configuration requise avant l'activation.",
|
||||
"completeSetupToEnable": "Terminez la configuration requise ci-dessous pour activer ce canal.",
|
||||
"chooseCredentialMethod": "Choisissez une méthode d'authentification",
|
||||
"or": "ou",
|
||||
"fieldRequired": "Requis pour terminer la configuration.",
|
||||
"secretWillBeRemoved": "Sera supprimé",
|
||||
"keepSavedSecret": "Conserver l'identifiant enregistré",
|
||||
"removeSavedSecret": "Supprimer l'identifiant enregistré",
|
||||
"sections": {
|
||||
"account": "Compte",
|
||||
"credentials": "Identifiants",
|
||||
"connection": "Connexion",
|
||||
"access": "Accès",
|
||||
"behavior": "Comportement",
|
||||
"security": "Sécurité"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "Connecté",
|
||||
"configured": "Configuré manuellement",
|
||||
"needs_setup": "Configuration requise",
|
||||
"invalid": "Non valide",
|
||||
"invalid": "Échec de la connexion",
|
||||
"unsupported": "Configuration manuelle"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "Connexion vérifiée.",
|
||||
"unverified": "Connexion non vérifiée.",
|
||||
"missing": "Renseignez les champs obligatoires.",
|
||||
"invalid": "Échec de la vérification de la connexion.",
|
||||
"unsupported": "La vérification de la connexion n’est pas encore disponible pour ce canal.",
|
||||
"present": "Renseigné",
|
||||
"required": "Obligatoire",
|
||||
"manual": "La vérification de la connexion n’est pas encore disponible pour ce canal."
|
||||
},
|
||||
"search": "Rechercher des canaux",
|
||||
"filterEnabled": "Activés",
|
||||
"noResults": "Aucun canal correspondant",
|
||||
"install": "Installer",
|
||||
"installChannel": "Installer {{name}}",
|
||||
"noInstallNeeded": "Aucune installation requise",
|
||||
"installNeeded": "Dépendances requises"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "Activé",
|
||||
@@ -849,7 +878,9 @@
|
||||
"installSupport": "Installer les dépendances",
|
||||
"installConfirmTitle": "Installer les dépendances de {{name}} ?",
|
||||
"installConfirmDescription": "nanobot installera les dépendances nécessaires, puis activera {{name}}.",
|
||||
"installOnlyConfirmDescription": "nanobot installera les composants requis par {{name}}. Vous pourrez vous connecter après l’installation.",
|
||||
"installConfirmAction": "Installer et activer",
|
||||
"installOnlyConfirmAction": "Installer le support",
|
||||
"websocketRequired": "Requis pour la WebUI",
|
||||
"channelDisabled": "Canal désactivé",
|
||||
"notEnabled": "Non activé"
|
||||
@@ -914,20 +945,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "Email",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "À {{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "UI web nanobot — ngobrol dengan ruang kerja nanobot Anda."
|
||||
},
|
||||
"pairing": {
|
||||
"title": "Hubungkan pengguna chat",
|
||||
"description": "Masukkan kode pairing yang ditampilkan di chat.",
|
||||
"title": "Pasangkan akun chat Anda",
|
||||
"description": "Masukkan kode pemasangan yang Anda terima di chat.",
|
||||
"code": "Kode pairing",
|
||||
"matched": "Cocok dengan {{channel}}. Menghubungkan...",
|
||||
"expiresInline": "Kode kedaluwarsa {{expires}}.",
|
||||
@@ -777,13 +777,13 @@
|
||||
"searchPlaceholder": "Cari kanal",
|
||||
"backToChannels": "Semua kanal",
|
||||
"catalog": "Kanal",
|
||||
"help": "Bantuan",
|
||||
"loading": "Memuat kanal...",
|
||||
"empty": "Tidak ada kanal yang cocok dengan filter ini.",
|
||||
"restartRequired": "Mulai ulang nanobot untuk menerapkan dukungan kanal yang diperbarui.",
|
||||
"requires": "Memerlukan: {{requirements}}",
|
||||
"setUp": "Siapkan",
|
||||
"setupGuide": "Panduan penyiapan",
|
||||
"setupSummary": "Aktifkan kanal, tambahkan kredensial platform, lalu mulai ulang nanobot.",
|
||||
"configKeys": "Kunci konfigurasi",
|
||||
"enable": "Aktifkan kanal",
|
||||
"disable": "Nonaktifkan kanal",
|
||||
@@ -817,7 +817,6 @@
|
||||
"runtimeStarting": "Memulai",
|
||||
"runtimeStopped": "Tidak berjalan",
|
||||
"managedByWebui": "Dikelola oleh WebUI",
|
||||
"officialGuide": "Panduan resmi",
|
||||
"optional": "Opsional",
|
||||
"providerPreset": "Penyedia",
|
||||
"requiredSetup": "Penyiapan wajib",
|
||||
@@ -826,19 +825,49 @@
|
||||
"savedSettings": "Pengaturan disimpan.",
|
||||
"saveSettings": "Simpan pengaturan",
|
||||
"selectChannel": "Lihat pengaturan {{name}}",
|
||||
"setupSteps": "Langkah berikutnya",
|
||||
"showSecret": "Tampilkan kredensial",
|
||||
"toggleChannel": "Aktifkan {{name}}",
|
||||
"toggleInstance": "Aktifkan instans {{name}}",
|
||||
"tryIt": "Coba",
|
||||
"validationFailed": "Periksa penyiapan wajib sebelum mengaktifkan.",
|
||||
"completeSetupToEnable": "Selesaikan penyiapan wajib di bawah untuk mengaktifkan kanal ini.",
|
||||
"chooseCredentialMethod": "Pilih satu metode kredensial",
|
||||
"or": "atau",
|
||||
"fieldRequired": "Wajib untuk menyelesaikan penyiapan.",
|
||||
"secretWillBeRemoved": "Akan dihapus",
|
||||
"keepSavedSecret": "Pertahankan kredensial tersimpan",
|
||||
"removeSavedSecret": "Hapus kredensial tersimpan",
|
||||
"sections": {
|
||||
"account": "Akun",
|
||||
"credentials": "Kredensial",
|
||||
"connection": "Koneksi",
|
||||
"access": "Akses",
|
||||
"behavior": "Perilaku",
|
||||
"security": "Keamanan"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "Terhubung",
|
||||
"configured": "Dikonfigurasi manual",
|
||||
"needs_setup": "Perlu penyiapan",
|
||||
"invalid": "Tidak valid",
|
||||
"invalid": "Koneksi gagal",
|
||||
"unsupported": "Penyiapan manual"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "Koneksi terverifikasi.",
|
||||
"unverified": "Koneksi belum terverifikasi.",
|
||||
"missing": "Lengkapi kolom wajib.",
|
||||
"invalid": "Pemeriksaan koneksi gagal.",
|
||||
"unsupported": "Kanal ini belum mendukung pemeriksaan koneksi.",
|
||||
"present": "Terisi",
|
||||
"required": "Wajib",
|
||||
"manual": "Kanal ini belum mendukung pemeriksaan koneksi."
|
||||
},
|
||||
"search": "Cari kanal",
|
||||
"filterEnabled": "Aktif",
|
||||
"noResults": "Tidak ada kanal yang cocok",
|
||||
"install": "Pasang",
|
||||
"installChannel": "Pasang {{name}}",
|
||||
"noInstallNeeded": "Tidak perlu dipasang",
|
||||
"installNeeded": "Memerlukan dependensi"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "Aktif",
|
||||
@@ -849,7 +878,9 @@
|
||||
"installSupport": "Pasang paket yang diperlukan",
|
||||
"installConfirmTitle": "Pasang paket yang diperlukan {{name}}?",
|
||||
"installConfirmDescription": "nanobot akan memasang paket yang diperlukan, lalu mengaktifkan {{name}}.",
|
||||
"installOnlyConfirmDescription": "nanobot akan menginstal dukungan yang dibutuhkan {{name}}. Anda dapat menghubungkannya setelah instalasi.",
|
||||
"installConfirmAction": "Instal dan aktifkan",
|
||||
"installOnlyConfirmAction": "Instal dukungan",
|
||||
"websocketRequired": "Wajib untuk WebUI",
|
||||
"channelDisabled": "Kanal dinonaktifkan",
|
||||
"notEnabled": "Belum aktif"
|
||||
@@ -914,20 +945,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "Email",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "Pada {{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "nanobot Web UI — nanobot ワークスペースと会話します。"
|
||||
},
|
||||
"pairing": {
|
||||
"title": "チャットユーザーをペアリング",
|
||||
"description": "チャットに表示されたペアリングコードを入力してください。",
|
||||
"title": "チャットアカウントをペアリング",
|
||||
"description": "チャットで受け取ったペアリングコードを入力してください。",
|
||||
"code": "ペアリングコード",
|
||||
"matched": "{{channel}} と一致しました。接続中…",
|
||||
"expiresInline": "コードの有効期限: {{expires}}。",
|
||||
@@ -777,13 +777,13 @@
|
||||
"searchPlaceholder": "チャンネルを検索",
|
||||
"backToChannels": "すべてのチャンネル",
|
||||
"catalog": "チャンネル",
|
||||
"help": "ヘルプ",
|
||||
"loading": "チャンネルを読み込み中...",
|
||||
"empty": "一致するチャンネルはありません。",
|
||||
"restartRequired": "更新したチャンネルサポートを反映するには nanobot を再起動してください。",
|
||||
"requires": "必要: {{requirements}}",
|
||||
"setUp": "設定",
|
||||
"setupGuide": "設定ガイド",
|
||||
"setupSummary": "チャンネルを有効にしてプラットフォームの認証情報を設定し、nanobot を再起動してください。",
|
||||
"configKeys": "設定キー",
|
||||
"enable": "チャンネルを有効化",
|
||||
"disable": "チャンネルを無効化",
|
||||
@@ -817,7 +817,6 @@
|
||||
"runtimeStarting": "起動中",
|
||||
"runtimeStopped": "未実行",
|
||||
"managedByWebui": "WebUI で管理",
|
||||
"officialGuide": "公式ガイド",
|
||||
"optional": "任意",
|
||||
"providerPreset": "プロバイダー",
|
||||
"requiredSetup": "必要な設定",
|
||||
@@ -826,19 +825,49 @@
|
||||
"savedSettings": "設定を保存しました。",
|
||||
"saveSettings": "設定を保存",
|
||||
"selectChannel": "{{name}} の設定を表示",
|
||||
"setupSteps": "次の手順",
|
||||
"showSecret": "シークレットを表示",
|
||||
"toggleChannel": "{{name}} を有効にする",
|
||||
"toggleInstance": "インスタンス {{name}} を有効にする",
|
||||
"tryIt": "試してみる",
|
||||
"validationFailed": "有効化する前に必要な設定を確認してください。",
|
||||
"completeSetupToEnable": "以下の必須設定を完了すると、このチャンネルを有効にできます。",
|
||||
"chooseCredentialMethod": "認証方法を1つ選択",
|
||||
"or": "または",
|
||||
"fieldRequired": "設定を完了するために必要です。",
|
||||
"secretWillBeRemoved": "削除されます",
|
||||
"keepSavedSecret": "保存済みの認証情報を保持",
|
||||
"removeSavedSecret": "保存済みの認証情報を削除",
|
||||
"sections": {
|
||||
"account": "アカウント",
|
||||
"credentials": "認証情報",
|
||||
"connection": "接続",
|
||||
"access": "アクセス",
|
||||
"behavior": "動作",
|
||||
"security": "セキュリティ"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "接続済み",
|
||||
"configured": "手動設定済み",
|
||||
"needs_setup": "設定が必要",
|
||||
"invalid": "無効",
|
||||
"invalid": "接続失敗",
|
||||
"unsupported": "手動設定"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "接続を確認しました。",
|
||||
"unverified": "接続は未確認です。",
|
||||
"missing": "必須項目を入力してください。",
|
||||
"invalid": "接続確認に失敗しました。",
|
||||
"unsupported": "このチャンネルでは、まだ接続を確認できません。",
|
||||
"present": "入力済み",
|
||||
"required": "必須",
|
||||
"manual": "このチャンネルでは、まだ接続を確認できません。"
|
||||
},
|
||||
"search": "チャンネルを検索",
|
||||
"filterEnabled": "有効",
|
||||
"noResults": "一致するチャンネルはありません",
|
||||
"install": "インストール",
|
||||
"installChannel": "{{name}} をインストール",
|
||||
"noInstallNeeded": "インストール不要",
|
||||
"installNeeded": "依存関係が必要"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "有効",
|
||||
@@ -849,7 +878,9 @@
|
||||
"installSupport": "必要なパッケージをインストール",
|
||||
"installConfirmTitle": "{{name}} に必要なパッケージをインストールしますか?",
|
||||
"installConfirmDescription": "nanobot が必要なパッケージをインストールし、{{name}} を有効にします。",
|
||||
"installOnlyConfirmDescription": "nanobot が {{name}} に必要なサポートをインストールします。インストール後に接続できます。",
|
||||
"installConfirmAction": "インストールして有効化",
|
||||
"installOnlyConfirmAction": "サポートをインストール",
|
||||
"websocketRequired": "WebUI に必須",
|
||||
"channelDisabled": "チャンネルは無効",
|
||||
"notEnabled": "無効"
|
||||
@@ -914,20 +945,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "Email",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "{{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "nanobot 웹 UI — nanobot 작업공간과 대화하세요."
|
||||
},
|
||||
"pairing": {
|
||||
"title": "채팅 사용자 연결",
|
||||
"description": "채팅에 표시된 연결 코드를 입력하세요.",
|
||||
"title": "내 채팅 계정 페어링",
|
||||
"description": "채팅에서 받은 페어링 코드를 입력하세요.",
|
||||
"code": "연결 코드",
|
||||
"matched": "{{channel}} 일치. 연결 중...",
|
||||
"expiresInline": "코드 만료: {{expires}}.",
|
||||
@@ -777,13 +777,13 @@
|
||||
"searchPlaceholder": "채널 검색",
|
||||
"backToChannels": "모든 채널",
|
||||
"catalog": "채널",
|
||||
"help": "도움말",
|
||||
"loading": "채널을 불러오는 중...",
|
||||
"empty": "일치하는 채널이 없습니다.",
|
||||
"restartRequired": "업데이트된 채널 지원을 적용하려면 nanobot을 다시 시작하세요.",
|
||||
"requires": "필요: {{requirements}}",
|
||||
"setUp": "설정",
|
||||
"setupGuide": "설정 가이드",
|
||||
"setupSummary": "채널을 활성화하고 플랫폼 인증 정보를 입력한 후 nanobot을 다시 시작하세요.",
|
||||
"configKeys": "설정 키",
|
||||
"enable": "채널 활성화",
|
||||
"disable": "채널 비활성화",
|
||||
@@ -817,7 +817,6 @@
|
||||
"runtimeStarting": "시작 중",
|
||||
"runtimeStopped": "실행 중 아님",
|
||||
"managedByWebui": "WebUI에서 관리",
|
||||
"officialGuide": "공식 가이드",
|
||||
"optional": "선택 사항",
|
||||
"providerPreset": "제공업체",
|
||||
"requiredSetup": "필수 설정",
|
||||
@@ -826,19 +825,49 @@
|
||||
"savedSettings": "설정을 저장했습니다.",
|
||||
"saveSettings": "설정 저장",
|
||||
"selectChannel": "{{name}} 설정 보기",
|
||||
"setupSteps": "다음 단계",
|
||||
"showSecret": "비밀 값 표시",
|
||||
"toggleChannel": "{{name}} 활성화",
|
||||
"toggleInstance": "{{name}} 인스턴스 활성화",
|
||||
"tryIt": "사용해 보기",
|
||||
"validationFailed": "활성화하기 전에 필수 설정을 확인하세요.",
|
||||
"completeSetupToEnable": "아래 필수 설정을 완료하면 이 채널을 활성화할 수 있습니다.",
|
||||
"chooseCredentialMethod": "인증 방식 하나 선택",
|
||||
"or": "또는",
|
||||
"fieldRequired": "설정을 완료하려면 필요합니다.",
|
||||
"secretWillBeRemoved": "삭제 예정",
|
||||
"keepSavedSecret": "저장된 인증 정보 유지",
|
||||
"removeSavedSecret": "저장된 인증 정보 삭제",
|
||||
"sections": {
|
||||
"account": "계정",
|
||||
"credentials": "인증 정보",
|
||||
"connection": "연결",
|
||||
"access": "접근",
|
||||
"behavior": "동작",
|
||||
"security": "보안"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "연결됨",
|
||||
"configured": "수동 설정됨",
|
||||
"needs_setup": "설정 필요",
|
||||
"invalid": "잘못됨",
|
||||
"invalid": "연결 실패",
|
||||
"unsupported": "수동 설정"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "연결을 확인했습니다.",
|
||||
"unverified": "연결이 확인되지 않았습니다.",
|
||||
"missing": "필수 항목을 입력하세요.",
|
||||
"invalid": "연결 확인에 실패했습니다.",
|
||||
"unsupported": "이 채널은 아직 연결 확인을 지원하지 않습니다.",
|
||||
"present": "입력됨",
|
||||
"required": "필수",
|
||||
"manual": "이 채널은 아직 연결 확인을 지원하지 않습니다."
|
||||
},
|
||||
"search": "채널 검색",
|
||||
"filterEnabled": "활성화됨",
|
||||
"noResults": "일치하는 채널 없음",
|
||||
"install": "설치",
|
||||
"installChannel": "{{name}} 설치",
|
||||
"noInstallNeeded": "설치 필요 없음",
|
||||
"installNeeded": "종속 항목 필요"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "활성화됨",
|
||||
@@ -849,7 +878,9 @@
|
||||
"installSupport": "지원 패키지 설치",
|
||||
"installConfirmTitle": "{{name}}에 필요한 패키지를 설치할까요?",
|
||||
"installConfirmDescription": "nanobot이 필요한 패키지를 설치한 뒤 {{name}} 기능을 활성화합니다.",
|
||||
"installOnlyConfirmDescription": "nanobot이 {{name}}에 필요한 지원 패키지를 설치합니다. 설치 후 연결할 수 있습니다.",
|
||||
"installConfirmAction": "설치하고 활성화",
|
||||
"installOnlyConfirmAction": "지원 패키지 설치",
|
||||
"websocketRequired": "WebUI 필수",
|
||||
"channelDisabled": "채널이 비활성화됨",
|
||||
"notEnabled": "비활성화됨"
|
||||
@@ -914,20 +945,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "Email",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "{{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "Interface web do nanobot — converse com o seu espaço de trabalho do nanobot."
|
||||
},
|
||||
"pairing": {
|
||||
"title": "Vincular usuário do chat",
|
||||
"description": "Digite o código de vinculação exibido no chat.",
|
||||
"title": "Parear sua conta de chat",
|
||||
"description": "Digite o código de pareamento recebido no chat.",
|
||||
"code": "Código de vinculação",
|
||||
"matched": "Correspondência com {{channel}}. Conectando...",
|
||||
"expiresInline": "O código expira {{expires}}.",
|
||||
@@ -791,13 +791,13 @@
|
||||
"searchPlaceholder": "Buscar canais",
|
||||
"backToChannels": "Todos os canais",
|
||||
"catalog": "Canais",
|
||||
"help": "Ajuda",
|
||||
"loading": "Carregando canais...",
|
||||
"empty": "Nenhum canal corresponde a este filtro.",
|
||||
"restartRequired": "Reinicie o nanobot para aplicar o suporte de canais atualizado.",
|
||||
"requires": "Requer: {{requirements}}",
|
||||
"setUp": "Configurar",
|
||||
"setupGuide": "Guia de configuração",
|
||||
"setupSummary": "Ative o canal, adicione as credenciais da plataforma e reinicie o nanobot.",
|
||||
"configKeys": "Chaves de configuração",
|
||||
"enable": "Habilitar canal",
|
||||
"disable": "Desabilitar canal",
|
||||
@@ -831,7 +831,6 @@
|
||||
"runtimeStarting": "Iniciando",
|
||||
"runtimeStopped": "Não está em execução",
|
||||
"managedByWebui": "Gerenciado pela WebUI",
|
||||
"officialGuide": "Guia oficial",
|
||||
"optional": "Opcional",
|
||||
"providerPreset": "Provedor",
|
||||
"requiredSetup": "Configuração obrigatória",
|
||||
@@ -840,19 +839,49 @@
|
||||
"savedSettings": "Configurações salvas.",
|
||||
"saveSettings": "Salvar configurações",
|
||||
"selectChannel": "Ver configurações de {{name}}",
|
||||
"setupSteps": "Próximas etapas",
|
||||
"showSecret": "Mostrar segredo",
|
||||
"toggleChannel": "Ativar {{name}}",
|
||||
"toggleInstance": "Ativar a instância {{name}}",
|
||||
"tryIt": "Experimente",
|
||||
"validationFailed": "Verifique a configuração obrigatória antes de ativar.",
|
||||
"completeSetupToEnable": "Conclua a configuração obrigatória abaixo para ativar este canal.",
|
||||
"chooseCredentialMethod": "Escolha um método de credencial",
|
||||
"or": "ou",
|
||||
"fieldRequired": "Obrigatório para concluir a configuração.",
|
||||
"secretWillBeRemoved": "Será removida",
|
||||
"keepSavedSecret": "Manter credencial salva",
|
||||
"removeSavedSecret": "Remover credencial salva",
|
||||
"sections": {
|
||||
"account": "Conta",
|
||||
"credentials": "Credenciais",
|
||||
"connection": "Conexão",
|
||||
"access": "Acesso",
|
||||
"behavior": "Comportamento",
|
||||
"security": "Segurança"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "Conectado",
|
||||
"configured": "Configurado manualmente",
|
||||
"needs_setup": "Requer configuração",
|
||||
"invalid": "Inválido",
|
||||
"invalid": "Falha na conexão",
|
||||
"unsupported": "Configuração manual"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "Conexão verificada.",
|
||||
"unverified": "Conexão não verificada.",
|
||||
"missing": "Preencha os campos obrigatórios.",
|
||||
"invalid": "Falha ao verificar a conexão.",
|
||||
"unsupported": "Este canal ainda não permite verificar a conexão.",
|
||||
"present": "Preenchido",
|
||||
"required": "Obrigatório",
|
||||
"manual": "Este canal ainda não permite verificar a conexão."
|
||||
},
|
||||
"search": "Buscar canais",
|
||||
"filterEnabled": "Ativados",
|
||||
"noResults": "Nenhum canal correspondente",
|
||||
"install": "Instalar",
|
||||
"installChannel": "Instalar {{name}}",
|
||||
"noInstallNeeded": "Não requer instalação",
|
||||
"installNeeded": "Requer dependências"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "Habilitado",
|
||||
@@ -863,7 +892,9 @@
|
||||
"installSupport": "Instalar dependências",
|
||||
"installConfirmTitle": "Instalar as dependências de {{name}}?",
|
||||
"installConfirmDescription": "O nanobot instalará as dependências necessárias e ativará {{name}}.",
|
||||
"installOnlyConfirmDescription": "O nanobot instalará o que {{name}} precisa. Você poderá conectá-lo após a instalação.",
|
||||
"installConfirmAction": "Instalar e habilitar",
|
||||
"installOnlyConfirmAction": "Instalar suporte",
|
||||
"websocketRequired": "Necessário para a WebUI",
|
||||
"channelDisabled": "Canal desabilitado",
|
||||
"notEnabled": "Não habilitado"
|
||||
@@ -928,20 +959,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "E-mail",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "Às {{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "Giao diện web nanobot — trò chuyện với không gian làm việc nanobot của bạn."
|
||||
},
|
||||
"pairing": {
|
||||
"title": "Liên kết người dùng chat",
|
||||
"description": "Nhập mã liên kết hiển thị trong cuộc trò chuyện.",
|
||||
"title": "Ghép nối tài khoản trò chuyện của bạn",
|
||||
"description": "Nhập mã ghép nối bạn nhận được trong cuộc trò chuyện.",
|
||||
"code": "Mã liên kết",
|
||||
"matched": "Đã khớp với {{channel}}. Đang kết nối...",
|
||||
"expiresInline": "Mã hết hạn {{expires}}.",
|
||||
@@ -777,13 +777,13 @@
|
||||
"searchPlaceholder": "Tìm kênh",
|
||||
"backToChannels": "Tất cả kênh",
|
||||
"catalog": "Kênh",
|
||||
"help": "Trợ giúp",
|
||||
"loading": "Đang tải kênh...",
|
||||
"empty": "Không có kênh nào phù hợp.",
|
||||
"restartRequired": "Khởi động lại nanobot để áp dụng hỗ trợ kênh đã cập nhật.",
|
||||
"requires": "Yêu cầu: {{requirements}}",
|
||||
"setUp": "Thiết lập",
|
||||
"setupGuide": "Hướng dẫn thiết lập",
|
||||
"setupSummary": "Bật kênh, thêm thông tin xác thực của nền tảng rồi khởi động lại nanobot.",
|
||||
"configKeys": "Khóa cấu hình",
|
||||
"enable": "Bật kênh",
|
||||
"disable": "Tắt kênh",
|
||||
@@ -817,7 +817,6 @@
|
||||
"runtimeStarting": "Đang khởi động",
|
||||
"runtimeStopped": "Không chạy",
|
||||
"managedByWebui": "Do WebUI quản lý",
|
||||
"officialGuide": "Hướng dẫn chính thức",
|
||||
"optional": "Tùy chọn",
|
||||
"providerPreset": "Nhà cung cấp",
|
||||
"requiredSetup": "Thiết lập bắt buộc",
|
||||
@@ -826,19 +825,49 @@
|
||||
"savedSettings": "Đã lưu cài đặt.",
|
||||
"saveSettings": "Lưu cài đặt",
|
||||
"selectChannel": "Xem cài đặt {{name}}",
|
||||
"setupSteps": "Các bước tiếp theo",
|
||||
"showSecret": "Hiện khóa bí mật",
|
||||
"toggleChannel": "Bật {{name}}",
|
||||
"toggleInstance": "Bật cấu hình {{name}}",
|
||||
"tryIt": "Dùng thử",
|
||||
"validationFailed": "Hãy kiểm tra thiết lập bắt buộc trước khi bật.",
|
||||
"completeSetupToEnable": "Hoàn tất thiết lập bắt buộc bên dưới để bật kênh này.",
|
||||
"chooseCredentialMethod": "Chọn một phương thức xác thực",
|
||||
"or": "hoặc",
|
||||
"fieldRequired": "Bắt buộc để hoàn tất thiết lập.",
|
||||
"secretWillBeRemoved": "Sẽ bị xóa",
|
||||
"keepSavedSecret": "Giữ thông tin xác thực đã lưu",
|
||||
"removeSavedSecret": "Xóa thông tin xác thực đã lưu",
|
||||
"sections": {
|
||||
"account": "Tài khoản",
|
||||
"credentials": "Thông tin xác thực",
|
||||
"connection": "Kết nối",
|
||||
"access": "Quyền truy cập",
|
||||
"behavior": "Hành vi",
|
||||
"security": "Bảo mật"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "Đã kết nối",
|
||||
"configured": "Đã cấu hình thủ công",
|
||||
"needs_setup": "Cần thiết lập",
|
||||
"invalid": "Không hợp lệ",
|
||||
"invalid": "Kết nối thất bại",
|
||||
"unsupported": "Thiết lập thủ công"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "Đã xác minh kết nối.",
|
||||
"unverified": "Chưa xác minh kết nối.",
|
||||
"missing": "Hãy điền các trường bắt buộc.",
|
||||
"invalid": "Không thể xác minh kết nối.",
|
||||
"unsupported": "Kênh này chưa hỗ trợ kiểm tra kết nối.",
|
||||
"present": "Đã điền",
|
||||
"required": "Bắt buộc",
|
||||
"manual": "Kênh này chưa hỗ trợ kiểm tra kết nối."
|
||||
},
|
||||
"search": "Tìm kênh",
|
||||
"filterEnabled": "Đã bật",
|
||||
"noResults": "Không có kênh phù hợp",
|
||||
"install": "Cài đặt",
|
||||
"installChannel": "Cài đặt {{name}}",
|
||||
"noInstallNeeded": "Không cần cài đặt",
|
||||
"installNeeded": "Cần phần phụ thuộc"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "Đã bật",
|
||||
@@ -849,7 +878,9 @@
|
||||
"installSupport": "Cài gói hỗ trợ",
|
||||
"installConfirmTitle": "Cài các gói cần thiết cho {{name}}?",
|
||||
"installConfirmDescription": "nanobot sẽ cài các gói cần thiết rồi bật {{name}}.",
|
||||
"installOnlyConfirmDescription": "nanobot sẽ cài đặt gói hỗ trợ mà {{name}} cần. Bạn có thể kết nối sau khi cài đặt.",
|
||||
"installConfirmAction": "Cài và bật",
|
||||
"installOnlyConfirmAction": "Cài gói hỗ trợ",
|
||||
"websocketRequired": "Bắt buộc cho WebUI",
|
||||
"channelDisabled": "Kênh đang tắt",
|
||||
"notEnabled": "Chưa bật"
|
||||
@@ -914,20 +945,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "DingTalk",
|
||||
"discord": "Discord",
|
||||
"email": "Email",
|
||||
"feishu": "Feishu",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "WeChat",
|
||||
"wecom": "WeCom",
|
||||
"weixin": "WeChat",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "Vào {{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "nanobot Web UI —— 与你的 nanobot 工作区对话。"
|
||||
},
|
||||
"pairing": {
|
||||
"title": "配对聊天用户",
|
||||
"description": "输入聊天中显示的配对码。",
|
||||
"title": "配对你的聊天账号",
|
||||
"description": "输入你在聊天平台中收到的配对码。",
|
||||
"code": "配对码",
|
||||
"matched": "已匹配 {{channel}},正在连接…",
|
||||
"expiresInline": "配对码将于 {{expires}} 过期。",
|
||||
@@ -983,7 +983,6 @@
|
||||
"requires": "需要:{{requirements}}",
|
||||
"setUp": "设置",
|
||||
"setupGuide": "配置指南",
|
||||
"setupSummary": "启用后,请填写此平台的连接信息,然后重启 nanobot。",
|
||||
"configKeys": "配置字段",
|
||||
"enable": "启用",
|
||||
"disable": "停用",
|
||||
@@ -997,7 +996,8 @@
|
||||
"open": "打开",
|
||||
"checkedAndEnabled": "已检查并启用。",
|
||||
"checking": "正在检查...",
|
||||
"checkOnly": "仅检查",
|
||||
"help": "帮助",
|
||||
"checkOnly": "检测",
|
||||
"commandCopied": "命令已复制。",
|
||||
"commandCopyFailed": "无法复制命令。",
|
||||
"configuredInstances_one": "已配置 {{count}} 个实例",
|
||||
@@ -1017,7 +1017,6 @@
|
||||
"runtimeStarting": "正在启动",
|
||||
"runtimeStopped": "未运行",
|
||||
"managedByWebui": "由 WebUI 管理",
|
||||
"officialGuide": "官方指南",
|
||||
"optional": "可选",
|
||||
"providerPreset": "提供商",
|
||||
"requiredSetup": "必需配置",
|
||||
@@ -1026,19 +1025,49 @@
|
||||
"savedSettings": "设置已保存。",
|
||||
"saveSettings": "保存设置",
|
||||
"selectChannel": "查看 {{name}} 设置",
|
||||
"setupSteps": "后续步骤",
|
||||
"showSecret": "显示密钥",
|
||||
"toggleChannel": "启用 {{name}}",
|
||||
"toggleInstance": "启用 {{name}}",
|
||||
"tryIt": "试一试",
|
||||
"validationFailed": "启用前请检查必需配置。",
|
||||
"completeSetupToEnable": "请先完成下方必需配置,然后即可启用此渠道。",
|
||||
"chooseCredentialMethod": "选择一种凭据方式",
|
||||
"or": "或",
|
||||
"fieldRequired": "完成配置需要此字段。",
|
||||
"secretWillBeRemoved": "将被删除",
|
||||
"keepSavedSecret": "保留已保存的凭据",
|
||||
"removeSavedSecret": "删除已保存的凭据",
|
||||
"sections": {
|
||||
"account": "账户",
|
||||
"credentials": "凭据",
|
||||
"connection": "连接",
|
||||
"access": "访问权限",
|
||||
"behavior": "行为",
|
||||
"security": "安全"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "已连接",
|
||||
"configured": "手动配置",
|
||||
"configured": "未验证",
|
||||
"needs_setup": "需要配置",
|
||||
"invalid": "配置无效",
|
||||
"invalid": "连接失败",
|
||||
"unsupported": "手动配置"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "连接正常",
|
||||
"unverified": "尚未验证连接是否可用",
|
||||
"missing": "请填写必填项",
|
||||
"invalid": "检测失败",
|
||||
"unsupported": "此渠道暂不支持连接检测",
|
||||
"present": "已填写",
|
||||
"required": "必填",
|
||||
"manual": "此渠道暂不支持连接检测"
|
||||
},
|
||||
"search": "搜索聊天平台",
|
||||
"filterEnabled": "已启用",
|
||||
"noResults": "没有匹配的渠道",
|
||||
"install": "安装",
|
||||
"installChannel": "安装 {{name}}",
|
||||
"noInstallNeeded": "无需安装",
|
||||
"installNeeded": "需要额外依赖"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "已启用",
|
||||
@@ -1049,7 +1078,9 @@
|
||||
"installSupport": "安装支持包",
|
||||
"installConfirmTitle": "安装 {{name}} 所需的软件包?",
|
||||
"installConfirmDescription": "安装所需软件包后,将启用 {{name}}。",
|
||||
"installOnlyConfirmDescription": "将安装 {{name}} 所需的支持包。安装完成后即可连接。",
|
||||
"installConfirmAction": "安装并启用",
|
||||
"installOnlyConfirmAction": "安装支持包",
|
||||
"websocketRequired": "WebUI 必需",
|
||||
"channelDisabled": "此平台已停用",
|
||||
"notEnabled": "未启用"
|
||||
@@ -1114,20 +1145,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "钉钉",
|
||||
"discord": "Discord",
|
||||
"email": "邮件",
|
||||
"feishu": "飞书",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "微信",
|
||||
"wecom": "企业微信",
|
||||
"weixin": "微信",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "在 {{time}}",
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
"description": "nanobot Web UI —— 與你的 nanobot 工作區對話。"
|
||||
},
|
||||
"pairing": {
|
||||
"title": "配對聊天使用者",
|
||||
"description": "輸入聊天中顯示的配對碼。",
|
||||
"title": "配對你的聊天帳號",
|
||||
"description": "輸入你在聊天平台收到的配對碼。",
|
||||
"code": "配對碼",
|
||||
"matched": "已符合 {{channel}},正在連線…",
|
||||
"expiresInline": "配對碼將於 {{expires}} 到期。",
|
||||
@@ -783,7 +783,6 @@
|
||||
"requires": "需要:{{requirements}}",
|
||||
"setUp": "設定",
|
||||
"setupGuide": "設定指南",
|
||||
"setupSummary": "啟用此通訊管道只會開啟 nanobot 的支援功能。請新增平台憑證,然後重新啟動 nanobot。",
|
||||
"configKeys": "設定欄位",
|
||||
"enable": "啟用通訊管道",
|
||||
"disable": "停用通訊管道",
|
||||
@@ -797,7 +796,8 @@
|
||||
"open": "開啟",
|
||||
"checkedAndEnabled": "已檢查並啟用。",
|
||||
"checking": "正在檢查...",
|
||||
"checkOnly": "僅檢查",
|
||||
"help": "說明",
|
||||
"checkOnly": "檢測",
|
||||
"commandCopied": "指令已複製。",
|
||||
"commandCopyFailed": "無法複製指令。",
|
||||
"configuredInstances_one": "已設定 {{count}} 個執行個體",
|
||||
@@ -817,7 +817,6 @@
|
||||
"runtimeStarting": "正在啟動",
|
||||
"runtimeStopped": "未執行",
|
||||
"managedByWebui": "由 WebUI 管理",
|
||||
"officialGuide": "官方指南",
|
||||
"optional": "選填",
|
||||
"providerPreset": "服務供應商",
|
||||
"requiredSetup": "必要設定",
|
||||
@@ -826,19 +825,49 @@
|
||||
"savedSettings": "設定已儲存。",
|
||||
"saveSettings": "儲存設定",
|
||||
"selectChannel": "檢視 {{name}} 設定",
|
||||
"setupSteps": "後續步驟",
|
||||
"showSecret": "顯示金鑰",
|
||||
"toggleChannel": "啟用 {{name}}",
|
||||
"toggleInstance": "{{name}} 執行個體",
|
||||
"tryIt": "試試看",
|
||||
"validationFailed": "啟用前請檢查必要設定。",
|
||||
"completeSetupToEnable": "請先完成下方必要設定,然後即可啟用此頻道。",
|
||||
"chooseCredentialMethod": "選擇一種憑證方式",
|
||||
"or": "或",
|
||||
"fieldRequired": "完成設定需要此欄位。",
|
||||
"secretWillBeRemoved": "將被移除",
|
||||
"keepSavedSecret": "保留已儲存的憑證",
|
||||
"removeSavedSecret": "移除已儲存的憑證",
|
||||
"sections": {
|
||||
"account": "帳戶",
|
||||
"credentials": "憑證",
|
||||
"connection": "連線",
|
||||
"access": "存取權限",
|
||||
"behavior": "行為",
|
||||
"security": "安全性"
|
||||
},
|
||||
"validation": {
|
||||
"connected": "已連線",
|
||||
"configured": "手動設定",
|
||||
"configured": "未驗證",
|
||||
"needs_setup": "需要設定",
|
||||
"invalid": "無效",
|
||||
"invalid": "連線失敗",
|
||||
"unsupported": "手動設定"
|
||||
}
|
||||
},
|
||||
"validationMessages": {
|
||||
"connected": "連線正常",
|
||||
"unverified": "尚未驗證連線是否可用",
|
||||
"missing": "請填寫必填欄位",
|
||||
"invalid": "檢測失敗",
|
||||
"unsupported": "此渠道暫不支援連線檢測",
|
||||
"present": "已填寫",
|
||||
"required": "必填",
|
||||
"manual": "此渠道暫不支援連線檢測"
|
||||
},
|
||||
"search": "搜尋聊天平台",
|
||||
"filterEnabled": "已啟用",
|
||||
"noResults": "沒有符合的渠道",
|
||||
"install": "安裝",
|
||||
"installChannel": "安裝 {{name}}",
|
||||
"noInstallNeeded": "無需安裝",
|
||||
"installNeeded": "需要額外依賴"
|
||||
},
|
||||
"nanobotFeatures": {
|
||||
"enabled": "已啟用",
|
||||
@@ -849,7 +878,9 @@
|
||||
"installSupport": "安裝支援套件",
|
||||
"installConfirmTitle": "安裝 {{name}} 的支援套件?",
|
||||
"installConfirmDescription": "nanobot 將安裝 {{name}} 所需的元件並啟用支援。要繼續嗎?",
|
||||
"installOnlyConfirmDescription": "將安裝 {{name}} 所需的支援套件。安裝完成後即可連線。",
|
||||
"installConfirmAction": "安裝並啟用",
|
||||
"installOnlyConfirmAction": "安裝支援套件",
|
||||
"websocketRequired": "WebUI 需要此功能",
|
||||
"channelDisabled": "通訊管道已停用",
|
||||
"notEnabled": "未啟用"
|
||||
@@ -914,20 +945,7 @@
|
||||
},
|
||||
"channels": {
|
||||
"api": "API",
|
||||
"cli": "CLI",
|
||||
"dingtalk": "釘釘",
|
||||
"discord": "Discord",
|
||||
"email": "電子郵件",
|
||||
"feishu": "飛書",
|
||||
"matrix": "Matrix",
|
||||
"msteams": "Microsoft Teams",
|
||||
"qq": "QQ",
|
||||
"slack": "Slack",
|
||||
"telegram": "Telegram",
|
||||
"wechat": "微信",
|
||||
"wecom": "企業微信",
|
||||
"weixin": "微信",
|
||||
"whatsapp": "WhatsApp"
|
||||
"cli": "CLI"
|
||||
},
|
||||
"schedule": {
|
||||
"at": "於 {{time}}",
|
||||
@@ -1187,7 +1205,7 @@
|
||||
"compaction": {
|
||||
"cancelled": "上下文壓縮已取消",
|
||||
"empty": "無需壓縮上下文",
|
||||
"started": "正在壓縮上下文",
|
||||
"started": "正在壓縮上下文…",
|
||||
"failed": "上下文壓縮失敗",
|
||||
"succeeded": "上下文已壓縮"
|
||||
},
|
||||
|
||||
+10
-14
@@ -566,12 +566,16 @@ export async function stopApiService(
|
||||
export async function enableNanobotFeature(
|
||||
transport: WebUIMutationTransport,
|
||||
name: string,
|
||||
options: { instanceId?: string } = {},
|
||||
options: { instanceId?: string; installOnly?: boolean } = {},
|
||||
): Promise<NanobotFeaturesPayload> {
|
||||
return mutation<NanobotFeaturesPayload>(
|
||||
transport,
|
||||
"settings.feature.enable",
|
||||
{ name, ...(options.instanceId ? { instance_id: options.instanceId } : {}) },
|
||||
{
|
||||
name,
|
||||
...(options.instanceId ? { instance_id: options.instanceId } : {}),
|
||||
...(options.installOnly ? { install_only: true } : {}),
|
||||
},
|
||||
PACKAGE_MUTATION_TIMEOUT_MS,
|
||||
);
|
||||
}
|
||||
@@ -611,22 +615,14 @@ export async function runPairingAction(
|
||||
export async function startChannelConnect(
|
||||
transport: WebUIMutationTransport,
|
||||
channel: string,
|
||||
options: {
|
||||
domain?: string;
|
||||
instanceId?: string;
|
||||
mode?: "replace" | "create";
|
||||
force?: boolean;
|
||||
} = {},
|
||||
params: Readonly<Record<string, string | boolean>> = {},
|
||||
): Promise<ChannelConnectPayload> {
|
||||
return mutation<ChannelConnectPayload>(
|
||||
transport,
|
||||
"settings.channel.connect.start",
|
||||
{
|
||||
...params,
|
||||
channel,
|
||||
...(options.domain ? { domain: options.domain } : {}),
|
||||
...(options.instanceId ? { instance_id: options.instanceId } : {}),
|
||||
...(options.mode ? { mode: options.mode } : {}),
|
||||
...(options.force ? { force: true } : {}),
|
||||
},
|
||||
PACKAGE_MUTATION_TIMEOUT_MS,
|
||||
);
|
||||
@@ -664,7 +660,7 @@ export async function cancelChannelConnect(
|
||||
export async function configureChannel(
|
||||
transport: WebUIMutationTransport,
|
||||
name: string,
|
||||
values: Record<string, string>,
|
||||
values: Record<string, string | null>,
|
||||
options: { enable?: boolean; instanceId?: string } = {},
|
||||
): Promise<ChannelConfigurePayload> {
|
||||
return mutation<ChannelConfigurePayload>(
|
||||
@@ -683,7 +679,7 @@ export async function configureChannel(
|
||||
export async function validateChannel(
|
||||
transport: WebUIMutationTransport,
|
||||
name: string,
|
||||
values: Record<string, string> = {},
|
||||
values: Record<string, string | null> = {},
|
||||
options: { instanceId?: string } = {},
|
||||
): Promise<ChannelValidationPayload> {
|
||||
return mutation<ChannelValidationPayload>(
|
||||
|
||||
@@ -984,8 +984,9 @@ export interface NanobotFeatureInfo {
|
||||
configured_fields?: string[];
|
||||
setup?: ChannelSetupContract;
|
||||
instances?: NanobotChannelInstanceInfo[];
|
||||
installed: boolean;
|
||||
ready: boolean;
|
||||
installed: boolean;
|
||||
requires_dependencies?: boolean;
|
||||
ready: boolean;
|
||||
status: "enabled" | "missing_dependency" | "not_enabled" | string;
|
||||
install_supported: boolean;
|
||||
requires_restart: boolean;
|
||||
@@ -1002,7 +1003,13 @@ export interface ChannelSetupContractField {
|
||||
|
||||
export interface ChannelSetupContract {
|
||||
fields: ChannelSetupContractField[];
|
||||
requirements?: ChannelSetupContractRequirement[];
|
||||
official_url?: string;
|
||||
verifies_connection?: boolean;
|
||||
}
|
||||
|
||||
export interface ChannelSetupContractRequirement {
|
||||
alternatives: string[][];
|
||||
}
|
||||
|
||||
export interface NanobotChannelInstanceInfo {
|
||||
@@ -1194,11 +1201,8 @@ export interface ChannelConnectPayload {
|
||||
status: ChannelConnectStatus;
|
||||
message?: string;
|
||||
qr_url?: string;
|
||||
domain?: string;
|
||||
interval_ms?: number;
|
||||
expires_at_ms?: number;
|
||||
app_id?: string;
|
||||
account?: string;
|
||||
nanobot_features?: NanobotFeaturesPayload;
|
||||
}
|
||||
|
||||
|
||||
@@ -259,6 +259,20 @@ describe("webui API helpers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("forwards channel-owned connect parameters without overriding the channel", async () => {
|
||||
await startChannelConnect(mutationTransport, "plugin-chat", {
|
||||
region: "eu",
|
||||
interactive: false,
|
||||
channel: "another-channel",
|
||||
});
|
||||
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.channel.connect.start",
|
||||
{ channel: "plugin-chat", region: "eu", interactive: false },
|
||||
150_000,
|
||||
);
|
||||
});
|
||||
|
||||
it("serializes workspace automation actions", async () => {
|
||||
await runAutomationAction(mutationTransport, "disable", "job 1/2");
|
||||
|
||||
@@ -810,6 +824,13 @@ describe("webui API helpers", () => {
|
||||
150_000,
|
||||
);
|
||||
|
||||
await enableNanobotFeature(mutationTransport, "whatsapp", { installOnly: true });
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.feature.enable",
|
||||
{ name: "whatsapp", install_only: true },
|
||||
150_000,
|
||||
);
|
||||
|
||||
await disableNanobotFeature(mutationTransport, "matrix");
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.feature.disable",
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import { fireEvent, render, screen, within } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import {
|
||||
CredentialForm,
|
||||
channelValuesForSubmit,
|
||||
} from "@/components/settings/channels/CredentialForm";
|
||||
import type { ChannelConfigField } from "@/components/settings/channels/catalog";
|
||||
|
||||
const fields: ChannelConfigField[] = [
|
||||
{
|
||||
key: "channels.matrix.password",
|
||||
label: "Password",
|
||||
secret: true,
|
||||
},
|
||||
{
|
||||
key: "channels.matrix.groupPolicy",
|
||||
label: "Group behavior",
|
||||
options: [
|
||||
{ value: "mention", label: "Mention only" },
|
||||
{ value: "open", label: "All messages" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
describe("CredentialForm", () => {
|
||||
it("uses native radio semantics for option fields", () => {
|
||||
const onChange = vi.fn();
|
||||
render(
|
||||
<CredentialForm
|
||||
fields={[fields[1]!]}
|
||||
values={{ "channels.matrix.groupPolicy": "mention" }}
|
||||
visibleSecrets={{}}
|
||||
onChange={onChange}
|
||||
onToggleSecret={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
const group = screen.getByRole("group", { name: "Group behavior" });
|
||||
expect(within(group).getByRole("radio", { name: "Mention only" })).toBeChecked();
|
||||
fireEvent.click(within(group).getByRole("radio", { name: "All messages" }));
|
||||
expect(onChange).toHaveBeenCalledWith("channels.matrix.groupPolicy", "open");
|
||||
});
|
||||
|
||||
it("associates option errors and exposes a stable focus target", () => {
|
||||
render(
|
||||
<CredentialForm
|
||||
fields={[fields[1]!]}
|
||||
values={{ "channels.matrix.groupPolicy": "mention" }}
|
||||
visibleSecrets={{}}
|
||||
onChange={vi.fn()}
|
||||
onToggleSecret={vi.fn()}
|
||||
errors={{ "channels.matrix.groupPolicy": "Required to complete setup." }}
|
||||
/>,
|
||||
);
|
||||
|
||||
const group = screen.getByRole("group", { name: "Group behavior" });
|
||||
const firstRadio = within(group).getByRole("radio", { name: "Mention only" });
|
||||
const secondRadio = within(group).getByRole("radio", { name: "All messages" });
|
||||
|
||||
expect(group).toHaveAttribute("id", "channel-field-channels-matrix-groupPolicy-group");
|
||||
expect(group).toHaveAttribute("aria-invalid", "true");
|
||||
expect(group).toHaveAccessibleDescription(
|
||||
"Required to complete setup.",
|
||||
);
|
||||
expect(firstRadio).toHaveAttribute("id", "channel-field-channels-matrix-groupPolicy");
|
||||
expect(secondRadio).toHaveAttribute("id", "channel-field-channels-matrix-groupPolicy-1");
|
||||
expect(firstRadio).toHaveAttribute("aria-invalid", "true");
|
||||
expect(firstRadio).toHaveAccessibleDescription(
|
||||
"Required to complete setup.",
|
||||
);
|
||||
|
||||
document.getElementById("channel-field-channels-matrix-groupPolicy")?.focus();
|
||||
expect(firstRadio).toHaveFocus();
|
||||
});
|
||||
|
||||
it("associates field errors and saved-secret removal actions", () => {
|
||||
const onClearSecret = vi.fn();
|
||||
render(
|
||||
<CredentialForm
|
||||
fields={[fields[0]!]}
|
||||
values={{}}
|
||||
configuredFields={new Set(["channels.matrix.password"])}
|
||||
visibleSecrets={{}}
|
||||
onChange={vi.fn()}
|
||||
onToggleSecret={vi.fn()}
|
||||
errors={{ "channels.matrix.password": "Required to complete setup." }}
|
||||
onClearSecret={onClearSecret}
|
||||
showSecretActions
|
||||
/>,
|
||||
);
|
||||
|
||||
const password = screen.getByLabelText("Password");
|
||||
expect(password).toHaveAttribute("aria-invalid", "true");
|
||||
expect(password).toHaveAccessibleDescription("Required to complete setup.");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Remove saved credential" }));
|
||||
expect(onClearSecret).toHaveBeenCalledWith("channels.matrix.password", true);
|
||||
});
|
||||
|
||||
it("uses null only for an explicitly cleared secret", () => {
|
||||
expect(
|
||||
channelValuesForSubmit(
|
||||
fields,
|
||||
{ "channels.matrix.password": "" },
|
||||
new Set(),
|
||||
new Set(["channels.matrix.password"]),
|
||||
),
|
||||
).toEqual({ "channels.matrix.password": null });
|
||||
expect(channelValuesForSubmit(fields, {}, new Set())).toEqual({});
|
||||
});
|
||||
});
|
||||
@@ -120,13 +120,26 @@ describe("channelSetup", () => {
|
||||
webui: "webui/index.ts",
|
||||
}), "zh-CN");
|
||||
|
||||
expect(setup.summary).toBe("钉钉需要 Stream 模式的应用凭据。");
|
||||
expect(setup.steps[0]).toBe("创建或选择一个已启用 Stream 模式的钉钉应用。");
|
||||
expect(setup.docsLabel).toBe("打开钉钉配置指南");
|
||||
expect(setup.officialLabel).toBe("打开钉钉开发者后台");
|
||||
expect(setup.fields).toContainEqual(expect.objectContaining({
|
||||
key: "channels.dingtalk.allowFrom",
|
||||
label: "允许的用户",
|
||||
}));
|
||||
});
|
||||
|
||||
it("loads custom setup section labels from the channel-owned locale", () => {
|
||||
const setup = channelSetup(feature({
|
||||
name: "email",
|
||||
display_name: "Email",
|
||||
webui: "webui/index.ts",
|
||||
}));
|
||||
|
||||
expect(setup.sectionLabels).toEqual({
|
||||
receiving: "Receiving mail",
|
||||
sending: "Sending mail",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("channel runtime state", () => {
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { channelFieldMessageKey } from "@/channel-plugins/i18n";
|
||||
@@ -15,6 +12,7 @@ const expectedChannels = [
|
||||
"feishu",
|
||||
"matrix",
|
||||
"mattermost",
|
||||
"mochat",
|
||||
"msteams",
|
||||
"napcat",
|
||||
"qq",
|
||||
@@ -96,22 +94,6 @@ describe("channel locale registry", () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps i18n initialization independent from channel React modules", () => {
|
||||
const localeRegistry = readFileSync(
|
||||
resolve(process.cwd(), "src/channel-plugins/locale-registry.ts"),
|
||||
"utf8",
|
||||
);
|
||||
const i18nEntry = readFileSync(resolve(process.cwd(), "src/i18n/index.ts"), "utf8");
|
||||
|
||||
expect(localeRegistry).toContain("webui/locales/*.json");
|
||||
expect(localeRegistry).not.toContain("eager: true");
|
||||
expect(localeRegistry).not.toMatch(/channel-plugins\/registry|\.tsx|\breact\b/i);
|
||||
expect(i18nEntry).toContain("channel-plugins/locale-registry");
|
||||
expect(i18nEntry).toContain("import.meta.glob");
|
||||
expect(i18nEntry).not.toMatch(/import\s+\w+Common\s+from/);
|
||||
expect(i18nEntry).not.toContain("channel-plugins/registry");
|
||||
});
|
||||
});
|
||||
|
||||
describe("channel locale registry concurrency", () => {
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { ChannelQrConnectFlow } from "@/components/settings/channels/ChannelQrConnectFlow";
|
||||
import { FeishuConnectFlow } from "../../../nanobot/channels/feishu/webui/FeishuConnectFlow";
|
||||
|
||||
const { requestMutation } = vi.hoisted(() => ({ requestMutation: vi.fn() }));
|
||||
|
||||
vi.mock("@/providers/ClientProvider", () => {
|
||||
const client = { requestMutation };
|
||||
return { useClient: () => ({ client }) };
|
||||
});
|
||||
|
||||
const labels = {
|
||||
qrAlt: "Connection QR code",
|
||||
scanTitle: "Scan to connect",
|
||||
scanDescription: "Scan with your app",
|
||||
waiting: "Waiting",
|
||||
connected: "Connected",
|
||||
stopped: "Stopped",
|
||||
connecting: "Connecting",
|
||||
scanAgain: "Scan again",
|
||||
connect: "Connect",
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
requestMutation.mockReset().mockResolvedValue({
|
||||
session_id: "link-1",
|
||||
status: "succeeded",
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe("channel QR connect parameters", () => {
|
||||
it("forwards current channel parameters without restarting on rerender and preserves forced retries", async () => {
|
||||
const props = {
|
||||
token: "tok",
|
||||
channelName: "plugin-chat",
|
||||
autoStart: true,
|
||||
forceOnRepeat: true,
|
||||
labels,
|
||||
onFeaturesUpdate: vi.fn(),
|
||||
};
|
||||
const view = render(<ChannelQrConnectFlow {...props} startParams={{ region: "eu" }} />);
|
||||
await waitFor(() => expect(requestMutation).toHaveBeenCalledTimes(1));
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.channel.connect.start",
|
||||
{ channel: "plugin-chat", region: "eu" },
|
||||
150_000,
|
||||
);
|
||||
await screen.findByText("Connected");
|
||||
|
||||
view.rerender(<ChannelQrConnectFlow {...props} startParams={{ region: "us" }} />);
|
||||
expect(requestMutation).toHaveBeenCalledTimes(1);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Scan again" }));
|
||||
await waitFor(() => expect(requestMutation).toHaveBeenCalledTimes(2));
|
||||
expect(requestMutation).toHaveBeenLastCalledWith(
|
||||
"settings.channel.connect.start",
|
||||
{ channel: "plugin-chat", region: "us", force: true },
|
||||
150_000,
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves the Feishu-owned registration domain and instance creation mode", async () => {
|
||||
render(
|
||||
<FeishuConnectFlow
|
||||
token="tok"
|
||||
instanceId="support"
|
||||
mode="create"
|
||||
connectRequestId={1}
|
||||
onFeaturesUpdate={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
await waitFor(() => expect(requestMutation).toHaveBeenCalledWith(
|
||||
"settings.channel.connect.start",
|
||||
{ channel: "feishu", domain: "feishu", instance_id: "support", mode: "create" },
|
||||
150_000,
|
||||
));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,189 @@
|
||||
import { act, fireEvent, screen, waitFor, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { NanobotFeatureInfo, NanobotFeaturesPayload } from "@/lib/types";
|
||||
import {
|
||||
installSettingsViewTestHooks,
|
||||
jsonResponse,
|
||||
renderSettingsView,
|
||||
requestMutationMock,
|
||||
settingsPayload,
|
||||
} from "@/tests/settings-test-utils";
|
||||
|
||||
function deferred<T>() {
|
||||
let resolve!: (value: T) => void;
|
||||
let reject!: (error: Error) => void;
|
||||
const promise = new Promise<T>((res, rej) => { resolve = res; reject = rej; });
|
||||
return { promise, resolve, reject };
|
||||
}
|
||||
|
||||
function feature(enabled: boolean, instances = false): NanobotFeatureInfo {
|
||||
return {
|
||||
name: "test-chat",
|
||||
display_name: "Test Chat",
|
||||
type: "channel",
|
||||
installed: true,
|
||||
configured: true,
|
||||
enabled,
|
||||
running: enabled,
|
||||
runtime_status: enabled ? "running" : "stopped",
|
||||
ready: true,
|
||||
status: enabled ? "enabled" : "not_enabled",
|
||||
install_supported: true,
|
||||
requires_restart: false,
|
||||
setup: { fields: [], requirements: [] },
|
||||
...(instances ? { instances: [{
|
||||
id: "first",
|
||||
name: "First",
|
||||
configured: true,
|
||||
enabled,
|
||||
runtime_status: enabled ? "running" : "stopped",
|
||||
config_values: {},
|
||||
configured_fields: [],
|
||||
}, {
|
||||
id: "second",
|
||||
name: "Second",
|
||||
configured: true,
|
||||
enabled: false,
|
||||
runtime_status: "stopped",
|
||||
config_values: {},
|
||||
configured_fields: [],
|
||||
}] } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function payload(channel: NanobotFeatureInfo): NanobotFeaturesPayload {
|
||||
return { features: [channel], enabled_count: Number(channel.enabled) };
|
||||
}
|
||||
|
||||
function renderChannel(channel: NanobotFeatureInfo) {
|
||||
vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
if (url === "/api/settings") return jsonResponse(settingsPayload());
|
||||
if (url === "/api/settings/nanobot-features") return jsonResponse(payload(channel));
|
||||
return { ok: false, status: 404, json: async () => ({}) } as Response;
|
||||
}));
|
||||
renderSettingsView({ initialSection: "channels" });
|
||||
}
|
||||
|
||||
describe("optimistic channel switches", () => {
|
||||
installSettingsViewTestHooks();
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
for (const surface of ["catalog", "setup", "instance"] as const) {
|
||||
it.each([
|
||||
[false, true],
|
||||
[true, true],
|
||||
[false, false],
|
||||
[true, false],
|
||||
])(`${surface}: updates immediately from %s and settles with success=%s`, async (initial, succeeds) => {
|
||||
const mutation = deferred<unknown>();
|
||||
const validation = deferred<unknown>();
|
||||
requestMutationMock.mockImplementation((action: string) =>
|
||||
action === "settings.channel.validate" ? validation.promise : mutation.promise);
|
||||
vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
renderChannel(feature(initial, surface === "instance"));
|
||||
|
||||
const catalogSwitch = await screen.findByRole("switch", { name: "Test Chat channel" });
|
||||
if (surface !== "catalog") {
|
||||
fireEvent.click(screen.getByRole("button", { name: "View Test Chat settings" }));
|
||||
}
|
||||
const toggle = surface === "catalog"
|
||||
? catalogSwitch
|
||||
: surface === "instance"
|
||||
? await screen.findByRole("switch", { name: "First instance" })
|
||||
: within(await screen.findByRole("dialog")).getByRole("switch");
|
||||
|
||||
if (!initial && succeeds) {
|
||||
toggle.focus();
|
||||
await userEvent.setup().keyboard("[Space]");
|
||||
} else {
|
||||
fireEvent.click(toggle);
|
||||
}
|
||||
expect(toggle).toHaveAttribute("aria-checked", String(!initial));
|
||||
expect(toggle).toBeDisabled();
|
||||
fireEvent.click(toggle);
|
||||
expect(requestMutationMock).toHaveBeenCalledTimes(1);
|
||||
if (surface === "instance") {
|
||||
const other = screen.getByRole("switch", { name: "Second instance" });
|
||||
expect(other).toHaveAttribute("aria-checked", "false");
|
||||
expect(other).toBeDisabled();
|
||||
fireEvent.click(other);
|
||||
expect(requestMutationMock).toHaveBeenCalledTimes(1);
|
||||
}
|
||||
|
||||
await act(async () => { fireEvent(window, new Event("focus")); });
|
||||
expect(toggle).toHaveAttribute("aria-checked", String(!initial));
|
||||
expect(toggle).toBeDisabled();
|
||||
|
||||
if (surface === "setup" && !initial) {
|
||||
await act(async () => validation.resolve({
|
||||
name: "test-chat", status: "connected", can_enable: true,
|
||||
checks: [], missing_fields: [], requires_restart: false,
|
||||
}));
|
||||
expect(requestMutationMock).toHaveBeenCalledTimes(2);
|
||||
expect(toggle).toHaveAttribute("aria-checked", "true");
|
||||
expect(toggle).toBeDisabled();
|
||||
}
|
||||
const result = payload(feature(!initial, surface === "instance"));
|
||||
await act(async () => {
|
||||
if (succeeds) {
|
||||
mutation.resolve(surface === "setup" && !initial ? { nanobot_features: result } : result);
|
||||
} else {
|
||||
mutation.reject(new Error("Channel update failed"));
|
||||
}
|
||||
});
|
||||
if (surface === "catalog" && initial && succeeds) {
|
||||
await waitFor(() => expect(toggle).not.toBeInTheDocument());
|
||||
} else {
|
||||
await waitFor(() => expect(toggle).toBeEnabled());
|
||||
expect(toggle).toHaveAttribute("aria-checked", String(succeeds ? !initial : initial));
|
||||
}
|
||||
if (!succeeds) expect(screen.getByText("Channel update failed")).toBeVisible();
|
||||
if (surface === "instance") {
|
||||
expect(screen.getByRole("switch", { name: "Second instance" })).toBeEnabled();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it("rolls back when server validation rejects activation without saving", async () => {
|
||||
const validation = deferred<unknown>();
|
||||
requestMutationMock.mockReturnValue(validation.promise);
|
||||
renderChannel(feature(false));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "View Test Chat settings" }));
|
||||
const toggle = within(await screen.findByRole("dialog")).getByRole("switch");
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toHaveAttribute("aria-checked", "true");
|
||||
|
||||
await act(async () => validation.resolve({
|
||||
name: "test-chat", status: "invalid", can_enable: false, message: "Credentials rejected",
|
||||
checks: [], missing_fields: [], requires_restart: false,
|
||||
}));
|
||||
expect(toggle).toHaveAttribute("aria-checked", "false");
|
||||
expect(toggle).toBeEnabled();
|
||||
expect(screen.getByText("Credentials rejected")).toBeVisible();
|
||||
expect(requestMutationMock).toHaveBeenCalledTimes(1);
|
||||
expect(requestMutationMock.mock.calls[0][0]).toBe("settings.channel.validate");
|
||||
});
|
||||
|
||||
it("does not show installation-only requests as optimistic activation", async () => {
|
||||
const installation = deferred<unknown>();
|
||||
requestMutationMock.mockReturnValue(installation.promise);
|
||||
const channel = { ...feature(false), installed: false, requires_dependencies: true };
|
||||
renderChannel(channel);
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Install Test Chat" }));
|
||||
expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.feature.enable", { name: "test-chat", install_only: true }, 150_000,
|
||||
);
|
||||
|
||||
channel.installed = true;
|
||||
await act(async () => { fireEvent(window, new Event("focus")); });
|
||||
const toggle = await screen.findByRole("switch", { name: "Test Chat channel" });
|
||||
expect(toggle).toHaveAttribute("aria-checked", "false");
|
||||
expect(toggle).toBeDisabled();
|
||||
await act(async () => installation.resolve(payload(channel)));
|
||||
expect(toggle).toHaveAttribute("aria-checked", "false");
|
||||
expect(toggle).toBeEnabled();
|
||||
});
|
||||
});
|
||||
@@ -33,44 +33,6 @@ describe("channel UI contributions", () => {
|
||||
expect(channelUiOwner("wechat")).toBe("weixin");
|
||||
});
|
||||
|
||||
it("uses the DingTalk Open Platform brand mark", () => {
|
||||
expect(channelUiPresentation("dingtalk")?.logoUrl).toBe(
|
||||
"https://img.alicdn.com/imgextra/i3/O1CN01WMvMRG1ks3Ixc9x1v_!!6000000004738-55-tps-32-32.svg",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps the core setup panel independent of concrete channel plugins", () => {
|
||||
const source = readFileSync(
|
||||
resolve(process.cwd(), "src/components/settings/channels/ChannelSetupPanel.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
expect(source).not.toMatch(/feature\.name\s*===\s*["'](?:feishu|weixin)["']/);
|
||||
expect(source).not.toMatch(/channel-plugins\/(?:feishu|weixin)/);
|
||||
expect(source).not.toMatch(/(?:Feishu|Weixin)(?:AssistantsPanel|ConnectFlow)/);
|
||||
});
|
||||
|
||||
it("discovers UI contributions only from channel-owned packages", () => {
|
||||
const source = readFileSync(
|
||||
resolve(process.cwd(), "src/channel-plugins/registry.ts"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
expect(source).toContain("../../../nanobot/channels/*/webui/index.{ts,tsx}");
|
||||
expect(source).not.toContain("webui/**/*.{ts,tsx}");
|
||||
expect(source).not.toContain('"./*/index.tsx"');
|
||||
});
|
||||
|
||||
it("derives channel identity from the package directory", () => {
|
||||
for (const channel of ["feishu", "weixin"]) {
|
||||
const source = readFileSync(
|
||||
resolve(process.cwd(), `../nanobot/channels/${channel}/webui/index.tsx`),
|
||||
"utf8",
|
||||
);
|
||||
expect(source).not.toMatch(/\bchannel\s*:/);
|
||||
}
|
||||
});
|
||||
|
||||
it("includes channel-owned UI in Tailwind's production scan", () => {
|
||||
const source = readFileSync(resolve(process.cwd(), "tailwind.config.js"), "utf8");
|
||||
|
||||
|
||||
@@ -228,7 +228,6 @@ const LOCALIZED_CHANNEL_SHELL_KEYS = [
|
||||
"settings.channels.instanceConfigured",
|
||||
"settings.channels.instanceNeedsSetup",
|
||||
"settings.channels.managedByWebui",
|
||||
"settings.channels.officialGuide",
|
||||
"settings.channels.optional",
|
||||
"settings.channels.providerPreset",
|
||||
"settings.channels.requiredSetup",
|
||||
@@ -237,11 +236,9 @@ const LOCALIZED_CHANNEL_SHELL_KEYS = [
|
||||
"settings.channels.savedSettings",
|
||||
"settings.channels.saveSettings",
|
||||
"settings.channels.selectChannel",
|
||||
"settings.channels.setupSteps",
|
||||
"settings.channels.showSecret",
|
||||
"settings.channels.toggleChannel",
|
||||
"settings.channels.toggleInstance",
|
||||
"settings.channels.tryIt",
|
||||
"settings.channels.validation.connected",
|
||||
"settings.channels.validation.configured",
|
||||
"settings.channels.validation.invalid",
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { act, cleanup, render, screen } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AutomationsSettings } from "@/components/settings/system/AutomationsSettings";
|
||||
import i18n from "@/i18n";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
function renderAutomations(channel: string) {
|
||||
return render(
|
||||
<AutomationsSettings
|
||||
payload={{ jobs: [{
|
||||
id: "task-1",
|
||||
name: "Scheduled task",
|
||||
enabled: true,
|
||||
schedule: { kind: "every", every_ms: 60_000 },
|
||||
payload: { message: "Summarize updates" },
|
||||
state: {},
|
||||
origin: { channel },
|
||||
}] }}
|
||||
loading={false}
|
||||
query=""
|
||||
filter="all"
|
||||
sort="name"
|
||||
actionKey={null}
|
||||
error={null}
|
||||
onQueryChange={vi.fn()}
|
||||
onFilterChange={vi.fn()}
|
||||
onSortChange={vi.fn()}
|
||||
onAction={vi.fn()}
|
||||
onRequestEdit={vi.fn()}
|
||||
onRequestDelete={vi.fn()}
|
||||
onBackToChat={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
describe("automation channel identity", () => {
|
||||
it("uses channel-owned names in the list and details when the language changes", async () => {
|
||||
renderAutomations("email");
|
||||
expect(screen.getAllByText("Email")).toHaveLength(2);
|
||||
|
||||
for (const [locale, name] of [
|
||||
["zh-CN", "电子邮件"],
|
||||
["ja", "メール"],
|
||||
["es", "Correo electrónico"],
|
||||
]) {
|
||||
await act(() => i18n.changeLanguage(locale));
|
||||
expect(screen.getAllByText(name)).toHaveLength(2);
|
||||
expect(screen.queryByText("Email")).not.toBeInTheDocument();
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves aliases through the owning channel namespace", async () => {
|
||||
await i18n.changeLanguage("zh-CN");
|
||||
renderAutomations("wechat");
|
||||
expect(screen.getAllByText("微信")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["api", "API"],
|
||||
["cli", "CLI"],
|
||||
["extension-chat", "extension-chat"],
|
||||
])("preserves the label for %s", (channel, label) => {
|
||||
renderAutomations(channel);
|
||||
expect(screen.getAllByText(label)).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -162,7 +162,7 @@ describe("Settings system domains", () => {
|
||||
expect(screen.getByTestId("settings-section-transition")).not.toHaveClass("settings-feature-page");
|
||||
});
|
||||
|
||||
it("does not show the Settings kicker on the standalone Automations surface", async () => {
|
||||
it("opens a chat from the standalone automations empty state", async () => {
|
||||
const onBackToChat = vi.fn();
|
||||
vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
@@ -389,7 +389,7 @@ describe("Settings system domains", () => {
|
||||
expect(screen.getByRole("button", { name: "MCP" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows nanobot optional features and enables one", async () => {
|
||||
it("installs optional channel support before enabling and disabling it", async () => {
|
||||
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
if (url === "/api/settings") return jsonResponse(settingsPayload());
|
||||
@@ -403,6 +403,7 @@ describe("Settings system domains", () => {
|
||||
webui: "webui/index.ts",
|
||||
type: "channel",
|
||||
enabled: false,
|
||||
configured: true,
|
||||
installed: false,
|
||||
ready: false,
|
||||
status: "missing_dependency",
|
||||
@@ -415,25 +416,31 @@ describe("Settings system domains", () => {
|
||||
return { ok: false, status: 404, json: async () => ({}) } as Response;
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
requestMutationMock.mockImplementation(async (action: string) => {
|
||||
requestMutationMock.mockImplementation(async (action: string, values: Record<string, unknown>) => {
|
||||
if (action === "settings.feature.enable") {
|
||||
const enabled = values.install_only !== true;
|
||||
return {
|
||||
features: [{
|
||||
name: "matrix",
|
||||
display_name: "Matrix",
|
||||
webui: "webui/index.ts",
|
||||
type: "channel",
|
||||
enabled: true,
|
||||
running: true,
|
||||
runtime_status: "running",
|
||||
enabled,
|
||||
running: enabled,
|
||||
runtime_status: enabled ? "running" : "stopped",
|
||||
configured: true,
|
||||
installed: true,
|
||||
ready: true,
|
||||
status: "enabled",
|
||||
status: enabled ? "enabled" : "not_enabled",
|
||||
install_supported: true,
|
||||
requires_restart: true,
|
||||
}],
|
||||
enabled_count: 1,
|
||||
last_action: { ok: true, message: "Enabled channel 'matrix'", enabled: true },
|
||||
enabled_count: enabled ? 1 : 0,
|
||||
last_action: {
|
||||
ok: true,
|
||||
message: enabled ? "Enabled channel 'matrix'" : "Installed support for channel 'matrix'",
|
||||
enabled,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (action === "settings.feature.disable") {
|
||||
@@ -463,13 +470,23 @@ describe("Settings system domains", () => {
|
||||
const matrixRow = await screen.findByRole("button", { name: "View Matrix settings" });
|
||||
expect(matrixRow).toHaveAttribute("aria-haspopup", "dialog");
|
||||
fireEvent.click(matrixRow);
|
||||
expect(screen.getByRole("heading", { name: "Matrix", exact: true })).toBeVisible();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Close", exact: true }));
|
||||
fireEvent.click(screen.getByRole("switch", { name: "Matrix channel" }));
|
||||
expect(screen.getByRole("dialog", { name: "Install support for Matrix?" })).toBeInTheDocument();
|
||||
expect(screen.getByText("nanobot will add what Matrix needs, then turn it on. Continue?")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("switch", { name: "Matrix channel" })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Install Matrix" })).toHaveFocus();
|
||||
expect(requestMutationMock).not.toHaveBeenCalled();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Install and enable" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Install Matrix" }));
|
||||
|
||||
await waitFor(() =>
|
||||
expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.feature.enable",
|
||||
{ name: "matrix", install_only: true },
|
||||
150_000,
|
||||
),
|
||||
);
|
||||
const matrixToggle = await screen.findByRole("switch", { name: "Matrix channel" });
|
||||
expect(matrixToggle).toHaveAttribute("aria-checked", "false");
|
||||
expect(requestMutationMock).toHaveBeenCalledTimes(1);
|
||||
fireEvent.click(matrixToggle);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
|
||||
Reference in new issue
Block a user