AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
import { useEffect, useMemo, useRef, useState } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { getClientDisplaySizeParts } from "@edgeever/shared";
import type { DeploymentMetadata } from "@edgeever/shared/deployment-metadata";
import { Activity, CircleCheck, CircleX, Cloud, Copy, ExternalLink, Info, LoaderCircle, MonitorSmartphone, RefreshCw, RotateCcw } from "lucide-react";
import { useTranslation } from "react-i18next";
import { ClipboardCopyNotice } from "@/components/ClipboardCopyNotice";
import { Button } from "@/components/ui/button";
import { useDeployedUpdateNotice } from "@/hooks/useDeployedUpdateNotice";
import { detectWebClientKind } from "@/lib/client-environment";
import { api, getConfiguredDesktopApiBaseUrl, type InstanceHealth } from "@/lib/api";
import { copyHtmlToClipboard } from "@/lib/clipboard";
import { resolveSystemInfoDeploymentMetadata } from "@/lib/deployment-metadata";
import { resolveDeploymentPlatform } from "@/lib/instance-runtime";
import {
getClientRuntimeDiagnostics,
getClientSyncDiagnostics,
readBrowserClientDisplaySize,
type ClientRuntimeDiagnostics,
type ClientSyncDiagnostics,
} from "@/lib/system-diagnostics";
import { formatSystemInfoClipboard } from "@/lib/system-info-clipboard";
import { cn } from "@/lib/utils";
import { DesktopUpdateProgress } from "@/components/DesktopUpdateProgress";
import { getReleaseTagForVersion, isClientAheadOfInstance } from "@/lib/version-check";
export type SystemInfoItem = {
label: string;
value: string;
mono?: boolean;
colSpan?: "full" | "two" | "double-sm";
status?: "connected" | "connecting" | "failed" | "warning" | "error" | "default";
localOnly?: boolean;
breakAll?: boolean;
};
type InstanceSystemDiagnostics = Pick<InstanceHealth, "build" | "buildCreatedAt" | "buildProvenance" | "containerImageSource" | "deployment" | "deploymentVersionCreatedAt" | "migration" | "objectStorageProvider" | "storage"> & {
runtime?: string | null;
};
export type SystemInfoDiagnostics = {
clientRuntime?: ClientRuntimeDiagnostics | null;
instance?: Partial<InstanceSystemDiagnostics> | null;
instanceUrl?: string | null;
instanceVersion?: string | null;
};
type SystemInfoGroup = {
id: "cloud" | "client" | "connection";
title: string;
description: string;
items: SystemInfoItem[];
};
type NavigatorWithStandalone = Navigator & { standalone?: boolean };
const detectBrowser = (userAgent: string) => {
if (/Edg\//.test(userAgent) || /EdgA\//.test(userAgent) || /EdgiOS\//.test(userAgent)) return "Microsoft Edge";
if ((/Chrome\//.test(userAgent) || /CriOS\//.test(userAgent)) && !/Chromium\//.test(userAgent)) return "Chrome";
if (/Firefox\//.test(userAgent)) return "Firefox";
if (/Safari\//.test(userAgent) && !/Chrome\//.test(userAgent)) return "Safari";
return null;
};
const detectOperatingSystem = (userAgent: string, platform: string) => {
const source = `${userAgent} ${platform}`;
if (/Windows/i.test(source)) return "Windows";
if (/Android/i.test(source)) return "Android";
if (/(iPhone|iPad|iPod)/i.test(source)) return "iOS";
if (/Mac/i.test(source)) return "macOS";
if (/Linux/i.test(source)) return "Linux";
return null;
};
const getDeploymentDescription = (
t: (key: string) => string,
deployment: DeploymentMetadata,
) => {
const trigger = t(`systemInfo.deploymentTriggers.${deployment.trigger}`);
const method = t(`systemInfo.deploymentMethods.${deployment.method}`);
return `${trigger} · ${method}`;
};
const formatInstanceTimestamp = (value: string | null | undefined, language: string) =>
value && Number.isFinite(Date.parse(value))
? new Intl.DateTimeFormat(language, { dateStyle: "medium", timeStyle: "short" }).format(new Date(value))
: null;
const getContainerImageSourceTranslationKey = (source: string | null | undefined) => {
if (source === "official-ghcr" || source === "official-cn-mirror" || source === "custom") return source;
return "unknown";
};
const getColSpanClass = (colSpan?: SystemInfoItem["colSpan"]) => {
if (colSpan === "full") return "sm:col-span-2 lg:col-span-3";
if (colSpan === "two") return "sm:col-span-2 lg:col-span-2";
if (colSpan === "double-sm") return "sm:col-span-2 lg:col-span-1";
return "col-span-1";
};
const formatLastSuccessfulSync = (
t: (key: string) => string,
language: string,
sync: ClientSyncDiagnostics | undefined,
) => {
if (!sync) return t("systemInfo.unknown");
if (sync.lastSyncedAt) {
const lastSyncedDate = new Date(sync.lastSyncedAt);
if (Number.isFinite(lastSyncedDate.getTime())) {
return new Intl.DateTimeFormat(language, { dateStyle: "medium", timeStyle: "short" }).format(lastSyncedDate);
}
}
const outstanding = sync.pending + sync.syncing + sync.error + sync.conflict;
return outstanding > 0 ? t("systemInfo.neverSynced") : t("systemInfo.nothingToSync");
};
const getWebSystemInfoGroups = (
t: (key: string, options?: Record<string, string>) => string,
language: string,
diagnostics: SystemInfoDiagnostics = {},
): SystemInfoGroup[] => {
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || t("systemInfo.unknown");
const displaySize = (() => {
const metrics = readBrowserClientDisplaySize();
const parts = metrics ? getClientDisplaySizeParts(metrics) : null;
return parts ? t("systemInfo.screenResolutionValue", parts) : null;
})();
const userAgent = navigator.userAgent;
const clientKind = detectWebClientKind({
desktopBridgeAvailable: window.edgeeverDesktop?.isAvailable === true,
displayModeStandalone:
window.matchMedia("(display-mode: standalone)").matches ||
window.matchMedia("(display-mode: fullscreen)").matches,
navigatorStandalone: (navigator as NavigatorWithStandalone).standalone === true,
});
const deployment = resolveSystemInfoDeploymentMetadata(
diagnostics.instance?.deployment,
{
trigger: __EDGEEVER_DEPLOYMENT_TRIGGER__,
method: __EDGEEVER_DEPLOYMENT_METHOD__,
},
clientKind !== "desktopApp",
);
const instanceUrl = clientKind === "desktopApp"
? (diagnostics.instanceUrl ?? getConfiguredDesktopApiBaseUrl()).trim()
: "";
return [
{
id: "cloud",
title: t("systemInfo.cloudSection"),
description: t("systemInfo.cloudSectionDescription"),
items: [
...(instanceUrl
? [{
label: t("systemInfo.instanceUrl"),
value: instanceUrl,
colSpan: "full" as const,
localOnly: true,
}]
: []),
{
label: t("systemInfo.instanceVersion"),
value: diagnostics.instanceVersion
? `v${diagnostics.instanceVersion.replace(/^v/, "")}`
: clientKind === "desktopApp"
? t("systemInfo.unknown")
: `v${__EDGEEVER_APP_VERSION__}`,
mono: true,
},
{ label: t("systemInfo.instanceBuild"), value: diagnostics.instance?.build ?? t("systemInfo.unknown"), mono: true },
{
label: t("systemInfo.deploymentVersionTime"),
value: formatInstanceTimestamp(diagnostics.instance?.deploymentVersionCreatedAt, language) ?? t("systemInfo.unknown"),
},
{ label: t("systemInfo.databaseMigration"), value: diagnostics.instance?.migration ?? t("systemInfo.unknown"), mono: true },
{
label: t("systemInfo.databaseBackend"),
value: diagnostics.instance?.storage?.database
? t(`systemInfo.databaseBackends.${diagnostics.instance.storage.database}`)
: t("systemInfo.unknown"),
},
{
label: t("systemInfo.newUploadObjectStorage"),
value: diagnostics.instance?.objectStorageProvider === "s3"
? t("systemInfo.objectStorageBackends.external_s3")
: diagnostics.instance?.objectStorageProvider === "builtin" && diagnostics.instance.storage?.resources
? t(`systemInfo.objectStorageBackends.builtin_${diagnostics.instance.storage.resources}`)
: t("systemInfo.unknown"),
},
...(diagnostics.instance?.objectStorageProvider === "s3"
? [{
label: t("systemInfo.existingAttachments"),
value: t("systemInfo.existingAttachmentsOriginalStorage"),
}]
: []),
{
label: t("systemInfo.deploymentPlatform"),
value: t(`systemInfo.deploymentPlatforms.${resolveDeploymentPlatform(diagnostics.instance?.runtime)}`),
},
...(diagnostics.instance?.runtime === "self-hosted-bun"
? [
{
label: t("systemInfo.containerImageSource"),
value: t(`systemInfo.containerImageSources.${getContainerImageSourceTranslationKey(diagnostics.instance.containerImageSource)}`),
},
{
label: t("systemInfo.imageBuiltAt"),
value: formatInstanceTimestamp(diagnostics.instance.buildCreatedAt, language) ?? t("systemInfo.unknown"),
},
{
label: t("systemInfo.imageBuildSource"),
value: getDeploymentDescription(t, resolveSystemInfoDeploymentMetadata(diagnostics.instance.buildProvenance, {}, false)),
},
]
: []),
{ label: t("systemInfo.deployment"), value: getDeploymentDescription(t, deployment), colSpan: "full" },
],
},
{
id: "client",
title: t("systemInfo.clientSection"),
description: t("systemInfo.clientSectionDescription"),
items: [
{
label: t("systemInfo.clientVersion"),
value: `v${diagnostics.clientRuntime?.appVersion ?? __EDGEEVER_APP_VERSION__}`,
mono: true,
},
{
label: t("systemInfo.releaseTime"),
value: __EDGEEVER_RELEASED_AT__
? new Intl.DateTimeFormat(language, { dateStyle: "medium", timeStyle: "short" }).format(new Date(__EDGEEVER_RELEASED_AT__))
: t("systemInfo.unknown"),
},
{ label: t("systemInfo.build"), value: __EDGEEVER_BUILD_LABEL__, mono: true },
{ label: t("systemInfo.client"), value: t(`systemInfo.clients.${clientKind}`) },
{
label: t("systemInfo.os"),
value: diagnostics.clientRuntime?.operatingSystem
?? detectOperatingSystem(userAgent, navigator.platform)
?? t("systemInfo.unknown"),
},
{
label: t("systemInfo.deviceModel"),
value: diagnostics.clientRuntime?.deviceModel ?? t("systemInfo.unknown"),
},
{
label: t("systemInfo.architecture"),
value: diagnostics.clientRuntime?.architecture ?? t("systemInfo.unknown"),
mono: true,
},
{
label: t("systemInfo.runtimeEngine"),
value: diagnostics.clientRuntime?.engine
?? (clientKind === "desktopApp" ? t("systemInfo.unknown") : detectBrowser(userAgent) ?? t("systemInfo.unknown")),
},
{ label: t("systemInfo.language"), value: navigator.language || language, mono: true },
{
label: t("systemInfo.screenResolution"),
value: displaySize ?? t("systemInfo.unknown"),
mono: true,
colSpan: "full",
},
{ label: t("systemInfo.timeZone"), value: timeZone, mono: true, colSpan: "double-sm" },
],
},
];
};
export const getWebSystemInfoItems = (
t: (key: string, options?: Record<string, string>) => string,
language: string,
diagnostics: SystemInfoDiagnostics = {},
): SystemInfoItem[] => getWebSystemInfoGroups(t, language, diagnostics)
.flatMap((group) => group.items);
export const getShareableWebSystemInfoItems = (
t: (key: string, options?: Record<string, string>) => string,
language: string,
diagnostics: SystemInfoDiagnostics = {},
) => getWebSystemInfoItems(t, language, diagnostics)
.filter((item) => !item.localOnly)
.map(({ label, value }) => ({ label, value }));
export const SystemInfoPanel = ({ active = true }: { active?: boolean }) => {
const { t, i18n } = useTranslation();
const [copyState, setCopyState] = useState<"idle" | "copied" | "error">("idle");
const copyResetTimeoutRef = useRef<number | null>(null);
const [desktopUpdateChecked, setDesktopUpdateChecked] = useState(false);
const [viewportRevision, setViewportRevision] = useState(0);
const queryClient = useQueryClient();
const { markSeen, release } = useDeployedUpdateNotice();
const desktopBridge = window.edgeeverDesktop;
const desktopAvailable = desktopBridge?.isAvailable === true;
const instanceUrl = desktopAvailable ? getConfiguredDesktopApiBaseUrl() : window.location.origin;
const healthQuery = useQuery({
queryKey: ["instance-health", instanceUrl],
queryFn: async () => {
const startedAt = performance.now();
const health = await api.getInstanceHealth();
return { health, latencyMs: Math.max(0, Math.round(performance.now() - startedAt)) };
},
enabled: active && Boolean(instanceUrl),
staleTime: 60 * 1000,
retry: 1,
});
const clientRuntimeQuery = useQuery({
queryKey: ["system-info-client-runtime"],
queryFn: getClientRuntimeDiagnostics,
enabled: active,
staleTime: Number.POSITIVE_INFINITY,
retry: 1,
});
const syncDiagnosticsQuery = useQuery<ClientSyncDiagnostics>({
queryKey: ["system-info-sync-diagnostics", instanceUrl],
queryFn: getClientSyncDiagnostics,
enabled: active && Boolean(instanceUrl),
refetchInterval: active ? 10_000 : false,
retry: 1,
});
const desktopUpdateStatusQuery = useQuery({
queryKey: ["desktop-update-status"],
queryFn: () => desktopBridge!.updateStatus(),
enabled: active && desktopAvailable,
refetchInterval: (query) => query.state.data?.state === "available" ? 1_000 : false,
retry: 1,
});
useEffect(() => {
if (active) markSeen();
}, [active, markSeen]);
useEffect(() => {
if (!active) return;
const onResize = () => setViewportRevision((value) => value + 1);
window.addEventListener("resize", onResize);
return () => window.removeEventListener("resize", onResize);
}, [active]);
useEffect(() => () => {
if (copyResetTimeoutRef.current !== null) window.clearTimeout(copyResetTimeoutRef.current);
}, []);
const [updateDiagnosticCopyState, setUpdateDiagnosticCopyState] = useState<"idle" | "copied" | "error">("idle");
useEffect(() => {
if (!active || !desktopAvailable || !desktopBridge?.onUpdateStatus) return;
return desktopBridge.onUpdateStatus((status) => {
queryClient.setQueryData(["desktop-update-status"], status);
});
}, [active, desktopAvailable, desktopBridge, queryClient]);
const desktopUpdateCheckMutation = useMutation({
mutationFn: () => desktopBridge!.checkUpdate(),
onSuccess: (status) => {
queryClient.setQueryData(["desktop-update-status"], status);
setDesktopUpdateChecked(!status.error);
},
});
const desktopUpdateInstallMutation = useMutation({
mutationFn: () => desktopBridge!.installUpdate(),
});
const infoGroups = useMemo(() => {
const groups = getWebSystemInfoGroups(t, i18n.language, {
clientRuntime: clientRuntimeQuery.data,
instance: healthQuery.data?.health,
instanceUrl: desktopAvailable ? instanceUrl : null,
instanceVersion: release?.version,
});
const formattedLastSync = formatLastSuccessfulSync(t, i18n.language, syncDiagnosticsQuery.data);
const pendingCount = syncDiagnosticsQuery.data
? syncDiagnosticsQuery.data.pending + syncDiagnosticsQuery.data.syncing
: null;
const failedCount = syncDiagnosticsQuery.data
? syncDiagnosticsQuery.data.error + syncDiagnosticsQuery.data.conflict
: null;
groups.push({
id: "connection",
title: t("systemInfo.connectionSection"),
description: t("systemInfo.connectionSectionDescription"),
items: [
{
label: t("systemInfo.instanceConnection"),
value: healthQuery.isError
? t("systemInfo.connectionFailed")
: healthQuery.isSuccess
? t("systemInfo.connectionConnected")
: t("systemInfo.connectionChecking"),
colSpan: "two",
status: healthQuery.isError ? "failed" : healthQuery.isSuccess ? "connected" : "connecting",
},
{
label: t("systemInfo.requestLatency"),
value: healthQuery.data ? `${healthQuery.data.latencyMs} ms` : t("systemInfo.unknown"),
mono: true,
},
{ label: t("systemInfo.lastSuccessfulSync"), value: formattedLastSync },
{
label: t("systemInfo.pendingSync"),
value: pendingCount !== null ? String(pendingCount) : t("systemInfo.unknown"),
mono: true,
status: (pendingCount ?? 0) > 0 ? "warning" : "default",
},
{
label: t("systemInfo.failedSync"),
value: failedCount !== null ? String(failedCount) : t("systemInfo.unknown"),
mono: true,
status: (failedCount ?? 0) > 0 ? "error" : "default",
},
],
});
return groups;
}, [
clientRuntimeQuery.data,
desktopAvailable,
healthQuery.data,
healthQuery.isError,
healthQuery.isSuccess,
i18n.language,
instanceUrl,
release?.version,
syncDiagnosticsQuery.data,
t,
viewportRevision,
]);
const releaseTag = release ? getReleaseTagForVersion(release.version) : null;
const releaseUrl = releaseTag
? `https://github.com/tianma-if/edgeever/releases/tag/${encodeURIComponent(releaseTag)}`
: "https://github.com/tianma-if/edgeever/releases/latest";
const handleCopy = async () => {
const clipboard = formatSystemInfoClipboard({
title: t("systemInfo.title"),
fieldLabel: t("systemInfo.copyFieldLabel"),
valueLabel: t("systemInfo.copyValueLabel"),
groups: infoGroups,
});
let copied = false;
try {
await copyHtmlToClipboard(clipboard.html, clipboard.plainText);
copied = true;
} catch {
copied = false;
}
setCopyState(copied ? "copied" : "error");
if (copyResetTimeoutRef.current !== null) window.clearTimeout(copyResetTimeoutRef.current);
copyResetTimeoutRef.current = window.setTimeout(() => {
setCopyState("idle");
copyResetTimeoutRef.current = null;
}, copied ? 2200 : 3000);
};
const clientAheadOfInstance = isClientAheadOfInstance(
clientRuntimeQuery.data?.appVersion ?? __EDGEEVER_APP_VERSION__,
release?.version,
);
const clientAheadHint = t(
`systemInfo.clientAheadOfInstanceByPlatform.${resolveDeploymentPlatform(healthQuery.data?.health?.runtime)}`,
);
const desktopUpdateState = desktopUpdateStatusQuery.data?.state ?? "idle";
const desktopAutoUpdateSupported = clientRuntimeQuery.data?.autoUpdateSupported !== false;
const desktopUpdateDownloadLabel = t(desktopUpdateStatusQuery.data?.progress?.percent === 100
? "systemInfo.desktopUpdateVerifying" : "systemInfo.desktopUpdateDownloading");
const desktopUpdateBusy = desktopUpdateCheckMutation.isPending || desktopUpdateInstallMutation.isPending;
const desktopUpdateDiagnostic = desktopUpdateStatusQuery.data?.error;
const updateDiagnosticText = desktopUpdateDiagnostic
? JSON.stringify({ ...desktopUpdateDiagnostic, localTime: new Date(desktopUpdateDiagnostic.at).toLocaleString(i18n.language) }, null, 2)
: null;
const handleCopyUpdateDiagnostic = async () => {
if (!updateDiagnosticText) return;
try {
const copied = await desktopBridge!.copyText(updateDiagnosticText);
setUpdateDiagnosticCopyState(copied ? "copied" : "error");
} catch {
setUpdateDiagnosticCopyState("error");
}
};
const desktopUpdateStatus = desktopUpdateDiagnostic || desktopUpdateInstallMutation.isError || desktopUpdateCheckMutation.isError || desktopUpdateStatusQuery.isError
? t("systemInfo.desktopUpdateFailed")
: desktopUpdateInstallMutation.isPending
? t("systemInfo.desktopUpdateInstalling")
: desktopUpdateCheckMutation.isPending
? t("systemInfo.desktopUpdateChecking")
: desktopUpdateState === "available"
? desktopUpdateDownloadLabel
: desktopUpdateState === "downloaded"
? t("systemInfo.desktopUpdateReady")
: desktopUpdateChecked
? t("systemInfo.desktopUpdateCurrent")
: null;
const handleDesktopUpdate = () => {
if (desktopUpdateState === "downloaded") desktopUpdateInstallMutation.mutate();
else {
setUpdateDiagnosticCopyState("idle");
desktopUpdateCheckMutation.mutate();
}
};
return (
<div className="grid gap-3.5">
<div className="flex items-center justify-end">
<Button
size="sm"
variant="outline"
className={cn(
"h-7 gap-1.5 bg-card px-2.5 text-xs text-slate-700 shadow-xs hover:bg-slate-50",
copyState === "copied" && "border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-50",
copyState === "error" && "border-rose-200 bg-rose-50 text-rose-700 hover:bg-rose-50",
)}
type="button"
onClick={() => void handleCopy()}
>
{copyState === "copied"
? <CircleCheck className="h-3.5 w-3.5" />
: copyState === "error"
? <CircleX className="h-3.5 w-3.5" />
: <Copy className="h-3.5 w-3.5 text-slate-500" />}
<span className={copyState === "idle" ? "" : "font-medium"}>
{copyState === "copied"
? t("common.copied")
: copyState === "error"
? t("systemInfo.copyFailed")
: t("systemInfo.copy")}
</span>
</Button>
</div>
{infoGroups.map((group) => {
const isCloud = group.id === "cloud";
const isClient = group.id === "client";
const headingId = `system-info-${group.id}-heading`;
return (
<section key={group.id} className="grid gap-2" aria-labelledby={headingId}>
<div className="flex flex-wrap items-center justify-between gap-2 px-0.5">
<div className="flex min-w-0 items-center gap-2">
<div className="flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-200 bg-slate-100 text-slate-700">
{isCloud
? <Cloud className="h-3.5 w-3.5" />
: isClient
? <MonitorSmartphone className="h-3.5 w-3.5" />
: <Activity className="h-3.5 w-3.5" />}
</div>
<div className="min-w-0">
<h3 id={headingId} className="text-xs font-semibold text-slate-800">{group.title}</h3>
</div>
</div>
{isClient && desktopAvailable && desktopAutoUpdateSupported ? (
<Button
size="sm"
variant="outline"
className="h-7 bg-card px-2.5 text-xs shadow-xs hover:bg-slate-50"
type="button"
disabled={desktopUpdateBusy || desktopUpdateState === "available"}
onClick={handleDesktopUpdate}
>
{desktopUpdateBusy || desktopUpdateState === "available"
? <LoaderCircle className="h-3.5 w-3.5 animate-spin" />
: desktopUpdateState === "downloaded"
? <RotateCcw className="h-3.5 w-3.5" />
: <RefreshCw className="h-3.5 w-3.5" />}
{desktopUpdateState === "downloaded"
? t("systemInfo.desktopUpdateRestart")
: desktopUpdateState === "available"
? desktopUpdateDownloadLabel
: desktopUpdateCheckMutation.isPending
? t("systemInfo.desktopUpdateChecking")
: t("systemInfo.desktopCheckForUpdates")}
</Button>
) : isClient && desktopAvailable ? (
<Button
asChild
size="sm"
variant="outline"
className="h-7 bg-card px-2.5 text-xs shadow-xs hover:bg-slate-50"
>
<a href="https://github.com/tianma-if/edgeever/releases/latest" target="_blank" rel="noreferrer">
<ExternalLink className="h-3.5 w-3.5" />
{t("systemInfo.desktopDownloadLatest")}
</a>
</Button>
) : null}
</div>
{isCloud && active && clientAheadOfInstance ? (
<p className="flex items-start gap-1.5 px-0.5 text-xs leading-4 text-slate-500" role="status">
<Info className="mt-0.5 h-3 w-3 shrink-0 text-slate-400" />
<span>{clientAheadHint}</span>
</p>
) : isCloud && active && release ? (
<div className="flex flex-wrap items-center gap-2 rounded-lg border border-slate-200 bg-slate-50 px-3 py-1.5 text-slate-800" role="status">
<CircleCheck className="h-3.5 w-3.5 shrink-0 text-slate-700" />
<div className="min-w-0 flex-1 text-xs font-medium text-slate-950">
{t("systemInfo.deployedUpdateTitle", { version: releaseTag?.replace(/^v/, "") ?? release.version })}
</div>
<a className="inline-flex shrink-0 items-center gap-1 text-xs font-semibold text-slate-800 underline underline-offset-2 hover:text-slate-950" href={releaseUrl} target="_blank" rel="noreferrer">
{t("systemInfo.viewReleaseNotes")} <ExternalLink className="h-3 w-3" />
</a>
</div>
) : null}
{isClient && desktopAvailable && desktopAutoUpdateSupported && desktopUpdateStatus && desktopUpdateState !== "available" ? (
<p
className={cn(
"text-right text-xs",
desktopUpdateDiagnostic || desktopUpdateInstallMutation.isError || desktopUpdateCheckMutation.isError || desktopUpdateStatusQuery.isError
? "text-red-600"
: "text-slate-500",
)}
role="status"
aria-live="polite"
>
{desktopUpdateStatus}
</p>
) : null}
{isClient && desktopAvailable && desktopUpdateState === "available" && !desktopUpdateDiagnostic ? (
<DesktopUpdateProgress progress={desktopUpdateStatusQuery.data?.progress} />
) : null}
{isClient && desktopAvailable && desktopUpdateDiagnostic && updateDiagnosticText ? (
<div className="grid gap-2 rounded-lg border border-red-200 bg-red-50/50 p-3 text-xs" role="alert">
<p className="break-words font-medium text-red-700">{desktopUpdateDiagnostic.code && !desktopUpdateDiagnostic.message.includes(desktopUpdateDiagnostic.code) ? `${desktopUpdateDiagnostic.code}: ` : ""}{desktopUpdateDiagnostic.message}</p>
<details>
<summary className="cursor-pointer">{t("systemInfo.desktopUpdateDiagnosticDetails")}</summary>
<p className="my-2 text-slate-600">{t("systemInfo.desktopUpdateDiagnosticHint")}</p>
<pre className="max-h-56 select-text overflow-auto whitespace-pre-wrap break-all text-slate-700">{updateDiagnosticText}</pre>
</details>
<div className="flex flex-wrap items-center gap-2">
<Button size="sm" variant="outline" className="h-7 text-xs" onClick={() => void handleCopyUpdateDiagnostic()}>
<Copy className="h-3.5 w-3.5" />
{updateDiagnosticCopyState === "copied" ? t("systemInfo.desktopUpdateDiagnosticCopied") : t("systemInfo.desktopCopyUpdateDiagnostic")}
</Button>
{updateDiagnosticCopyState === "error" ? <span role="status">{t("systemInfo.copyFailed")}</span> : null}
<a className="underline underline-offset-2" href="https://github.com/tianma-if/edgeever/releases/latest" target="_blank" rel="noreferrer">
{t("systemInfo.desktopUpdateManualDownload")}
</a>
</div>
</div>
) : null}
<div className="rounded-lg border border-slate-200/80 bg-card p-3 sm:p-3.5">
<dl className="grid grid-cols-2 gap-x-4 gap-y-2.5 sm:grid-cols-3 sm:gap-x-5">
{group.items.map((item) => (
<div
key={item.label}
className={cn("min-w-0", getColSpanClass(item.colSpan))}
>
<dt className="truncate text-xs font-normal text-slate-400">{item.label}</dt>
<dd className="mt-0.5 flex min-w-0 items-center gap-1.5">
{item.status === "connected" ? (
<span className="inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-slate-950" />
) : item.status === "connecting" ? (
<span className="inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-amber-500 animate-pulse" />
) : item.status === "failed" ? (
<span className="inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-rose-500 shadow-[0_0_4px_rgba(244,63,94,0.5)]" />
) : null}
<span
className={cn(
"break-words text-xs leading-5",
item.mono ? "font-mono font-medium" : "font-sans font-medium",
item.breakAll && "break-all",
item.status === "failed" || item.status === "error"
? "font-semibold text-rose-600"
: item.status === "warning"
? "font-semibold text-amber-600"
: "text-slate-800",
)}
>
{item.value}
</span>
</dd>
</div>
))}
</dl>
</div>
</section>
);
})}
{copyState !== "idle" ? (
<ClipboardCopyNotice status={copyState}>
{t(copyState === "copied" ? "systemInfo.copySucceeded" : "systemInfo.copyFailed")}
</ClipboardCopyNotice>
) : null}
</div>
);
};