feat(update): integrate managed installs and recoverable in-app updates (#6168)
Add owner-aware Stable and Preview updates with explicit consent, verified release plans, protected process handoff and bounded service recovery. Keep configuration and conversations separate from program rollback. Include the compact About controls, Windows long-path support, native package recovery checks and optional macOS Dock lifecycle integration. Preserve documented guidance for installations owned by other managers. This code integration does not publish packages, enable signing or advance the public update channel. Co-authored-by: chengyongru <61816729+chengyongru@users.noreply.github.com>
This commit is contained in:
1 parent
76da55994b
commit
fbb61a373f
216 files changed
+27948
-1084
No files matched your search
@@ -24,6 +24,7 @@ import {
|
||||
type SidebarPaneGroup,
|
||||
} from "@/components/ChatList";
|
||||
import { HostSwitcher } from "@/components/remote/HostSwitcher";
|
||||
import { UpdateNotice } from "@/components/UpdateNotice";
|
||||
import {
|
||||
SIDEBAR_SELECTION_ACTION_ITEM_CLASS,
|
||||
SidebarSelectionHighlight,
|
||||
@@ -35,6 +36,7 @@ import type {
|
||||
SidebarViewState,
|
||||
} from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { UpdateMethod } from "@/lib/api";
|
||||
import { sidebarShortcutAria, sidebarShortcutLabel } from "@/lib/sidebar-shortcuts";
|
||||
|
||||
interface SidebarProps {
|
||||
@@ -66,6 +68,8 @@ interface SidebarProps {
|
||||
onRequestRenameProject: (projectKey: string, label: string) => void;
|
||||
onNewChatInProject: (projectPath: string, projectName: string) => void;
|
||||
onOpenSettings: () => void;
|
||||
onOpenUpdates?: () => void;
|
||||
availableUpdate?: { version: string; onDismiss: () => void; onRequestUpdate?: () => void; installationMethod?: UpdateMethod | null };
|
||||
onOpenApps: () => void;
|
||||
onOpenSkills: () => void;
|
||||
onOpenAutomations: () => void;
|
||||
@@ -313,6 +317,11 @@ export function Sidebar(props: SidebarProps) {
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{props.onOpenUpdates && props.availableUpdate && (
|
||||
<UpdateNotice version={props.availableUpdate.version} collapsed={collapsed}
|
||||
onOpen={props.onOpenUpdates} onDismiss={props.availableUpdate.onDismiss}
|
||||
onRequestUpdate={props.availableUpdate.onRequestUpdate} installationMethod={props.availableUpdate.installationMethod} />
|
||||
)}
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center justify-between gap-1 bg-sidebar/55 px-2.5 py-3 text-xs",
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Disclosure } from "@/components/ui/disclosure";
|
||||
import { fetchSettings, type UpdateGuide as Guide } from "@/lib/api";
|
||||
import { copyTextToClipboard } from "@/lib/clipboard";
|
||||
|
||||
function Command({ command, label, collapsed = false }: { command: string; label: string; collapsed?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const [copy, setCopy] = useState<"idle" | "pending" | "copied" | "failed">("idle");
|
||||
const content = <div className="space-y-1.5">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="text-xs font-medium">{label}</span>
|
||||
<Button size="sm" variant="ghost" disabled={copy === "pending"} aria-busy={copy === "pending"} className="h-7 px-2 text-xs" onClick={async () => {
|
||||
setCopy("pending");
|
||||
setCopy(await copyTextToClipboard(command) ? "copied" : "failed");
|
||||
}}>{t(copy === "copied" ? "remote.pair.copied" : "remote.pair.copy")}</Button>
|
||||
</div>
|
||||
<Textarea aria-label={label} readOnly value={command} rows={Math.min(5, command.split("\n").length + 1)}
|
||||
onFocus={event => event.currentTarget.select()} className="resize-none font-mono text-xs leading-5" />
|
||||
<p role="status" className="text-xs text-muted-foreground">{copy === "failed" ? t("remote.pair.copyFailed") : copy === "copied" ? t("remote.pair.copied") : ""}</p>
|
||||
</div>;
|
||||
return collapsed ? <Disclosure summaryClassName="flex min-h-9 items-center gap-2 rounded-control text-xs text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
summary={<><ChevronDown aria-hidden className="h-3.5 w-3.5 shrink-0 transition-transform group-data-[state=open]/disclosure:rotate-180 motion-reduce:transition-none" />{label}</>}>
|
||||
{content}
|
||||
</Disclosure> : content;
|
||||
}
|
||||
|
||||
/** Display and copy only. The package manager/deployment remains the owner. */
|
||||
export function UpdateGuide({ guide, token, targetVersion }: { guide: Guide; token: string; targetVersion: string }) {
|
||||
const { t } = useTranslation();
|
||||
const active = useRef(true);
|
||||
const [checking, setChecking] = useState(false);
|
||||
const [result, setResult] = useState("");
|
||||
useEffect(() => { active.current = true; return () => { active.current = false; }; }, []);
|
||||
const check = async () => {
|
||||
if (checking) return;
|
||||
setChecking(true);
|
||||
setResult("");
|
||||
const feedback = new Promise(resolve => setTimeout(resolve, 600));
|
||||
try {
|
||||
const settings = await fetchSettings(token).finally(() => feedback);
|
||||
const version = settings.version?.current;
|
||||
if (!version) throw new Error("No running version");
|
||||
if (active.current) setResult(t(version === targetVersion ? "updates.guide.verified" : "updates.guide.observed", { version, target: targetVersion }));
|
||||
} catch {
|
||||
if (active.current) setResult(t("updates.guide.checkFailed"));
|
||||
} finally { if (active.current) setChecking(false); }
|
||||
};
|
||||
return <div className="mt-4 space-y-4 text-sm leading-6">
|
||||
<div className="rounded-control bg-muted/50 p-3">
|
||||
<p className="break-words font-medium">{t("updates.guide.host", { host: guide.host })}</p>
|
||||
<p className="mt-1 text-xs leading-5 text-muted-foreground">{t(guide.method === "container" ? "updates.guide.containerHost" : "updates.guide.where")}</p>
|
||||
<p className="mt-2 break-all font-mono text-xs text-muted-foreground">{guide.environment}</p>
|
||||
</div>
|
||||
<ol className="list-decimal space-y-4 ps-5 marker:text-muted-foreground">
|
||||
<li className="ps-1"><p className="font-medium">{t("updates.guide.beforeTitle")}</p>
|
||||
<p className="text-muted-foreground">{t("updates.guide.before")}</p></li>
|
||||
<li className="space-y-2 ps-1"><p className="font-medium">{t("updates.guide.installTitle", { shell: guide.shell === "powershell" ? "PowerShell" : "sh / bash / zsh" })}</p>
|
||||
<p className="text-muted-foreground">{t(`updates.guide.reasons.${guide.reason}`)}</p>
|
||||
{guide.inspect_command && <Command command={guide.inspect_command} label={t("updates.guide.inspectCommand")} collapsed />}
|
||||
{guide.update_command && <Command command={guide.update_command} label={t("updates.guide.updateCommand")} />}
|
||||
</li>
|
||||
<li className="space-y-2 ps-1"><p className="font-medium">{t("updates.guide.verifyTitle")}</p>
|
||||
<p className="text-muted-foreground">{t("updates.guide.verify", { version: targetVersion })}</p>
|
||||
{guide.verify_command && <Command command={guide.verify_command} label={t("updates.guide.versionCommand")} collapsed />}
|
||||
<Button size="sm" variant="outline" aria-disabled={checking} aria-busy={checking}
|
||||
className={checking ? "opacity-50" : undefined} onClick={() => void check()}>
|
||||
{t(checking ? "settings.about.checking" : "updates.guide.check")}
|
||||
</Button>
|
||||
<p role="status" className="text-xs text-muted-foreground">{result}</p>
|
||||
</li>
|
||||
</ol>
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Download } from "lucide-react";
|
||||
import { useId, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { UpdateMethod } from "@/lib/api";
|
||||
|
||||
export function UpdateNotice({ version, collapsed = false, onOpen, onDismiss, onRequestUpdate, installationMethod }: {
|
||||
version: string;
|
||||
collapsed?: boolean;
|
||||
onOpen: () => void;
|
||||
onDismiss: () => void;
|
||||
/** Opens the host's update confirmation, never installs from the entry itself. */
|
||||
onRequestUpdate?: () => void;
|
||||
installationMethod?: UpdateMethod | null;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const titleId = useId();
|
||||
const methodLabel = installationMethod && installationMethod !== "managed"
|
||||
? t("updates.guide.entry", { method: t(`updates.guide.methods.${installationMethod}`) }) : null;
|
||||
const label = [t("settings.about.updateAvailable", { version }), methodLabel].filter(Boolean).join(" · ");
|
||||
const button = <Button type="button" variant="ghost" aria-label={label} onClick={onRequestUpdate}
|
||||
className={cn(
|
||||
"touch-target h-8 min-w-0 gap-2 rounded-control text-blue-600 shadow-none hover:bg-blue-500/[0.08] data-[state=open]:bg-blue-500/[0.08] focus-visible:ring-blue-500 dark:text-blue-400 dark:hover:bg-blue-400/10 dark:data-[state=open]:bg-blue-400/10",
|
||||
collapsed ? "w-8 p-0" : "w-full justify-start px-2 text-[13px] font-medium",
|
||||
)}>
|
||||
<Download className="h-4 w-4 shrink-0" strokeWidth={1.75} aria-hidden />
|
||||
{!collapsed && <span className="truncate">{methodLabel ?? t("settings.about.updateNotice")}</span>}
|
||||
</Button>;
|
||||
|
||||
return <div className={cn("flex shrink-0 items-center", collapsed ? "w-14 justify-center pb-1" : "px-2.5")}>
|
||||
{onRequestUpdate ? <TooltipProvider><Tooltip>
|
||||
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
||||
<TooltipContent side="right">{label}</TooltipContent>
|
||||
</Tooltip></TooltipProvider> : <Popover open={open} onOpenChange={setOpen}>
|
||||
{collapsed ? <TooltipProvider><Tooltip>
|
||||
<TooltipTrigger asChild><PopoverTrigger asChild>{button}</PopoverTrigger></TooltipTrigger>
|
||||
{!open && <TooltipContent side="right">{label}</TooltipContent>}
|
||||
</Tooltip></TooltipProvider> : <PopoverTrigger asChild>{button}</PopoverTrigger>}
|
||||
<PopoverContent side="top" align="start" sideOffset={8} collisionPadding={12}
|
||||
aria-labelledby={titleId} className="w-64 max-w-[calc(100vw-1.5rem)] p-3.5">
|
||||
<h2 id={titleId} className="text-[13px] font-medium">{label}</h2>
|
||||
<div className="mt-3 flex flex-wrap items-center justify-end gap-1.5">
|
||||
<Button type="button" variant="ghost" size="sm" className="touch-target h-8 px-2.5 text-xs text-muted-foreground"
|
||||
onClick={() => { setOpen(false); onDismiss(); }}>{t("settings.about.dismissUpdate")}</Button>
|
||||
<Button type="button" size="sm" variant="accent"
|
||||
className="touch-target h-8 px-2.5 text-xs"
|
||||
onClick={() => { setOpen(false); onOpen(); }}>{t("settings.about.viewUpdateDetails")}</Button>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>}
|
||||
</div>;
|
||||
}
|
||||
@@ -4,6 +4,22 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import { SettingsGroup } from "@/components/settings/shared/SettingsControls";
|
||||
|
||||
export function AboutSettingsLayout({ versionCheck, links, starLink }: {
|
||||
versionCheck: ReactNode;
|
||||
links: ReactNode;
|
||||
starLink: ReactNode;
|
||||
}) {
|
||||
return <div className="flex flex-1 flex-col gap-5">
|
||||
<div className="flex flex-col items-center gap-3 py-6 text-center">
|
||||
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16 select-none" draggable={false} />
|
||||
<h1><img src="/brand/nanobot_wordmark.svg" alt="nanobot" width={800} height={164} className="h-auto w-40 select-none dark:brightness-150" draggable={false} /></h1>
|
||||
</div>
|
||||
{versionCheck}
|
||||
{links}
|
||||
<div className="mt-auto pt-8 text-center">{starLink}</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
export function AboutSettingsView({ reportIssueUrl, versionCheck, starLink }: {
|
||||
reportIssueUrl: string;
|
||||
versionCheck: ReactNode;
|
||||
@@ -16,12 +32,7 @@ export function AboutSettingsView({ reportIssueUrl, versionCheck, starLink }: {
|
||||
{ key: "reportIssue", icon: MessageCircle, href: reportIssueUrl },
|
||||
];
|
||||
return (
|
||||
<div className="flex flex-1 flex-col gap-5">
|
||||
<div className="flex flex-col items-center gap-4 py-6 text-center">
|
||||
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16 select-none" draggable={false} />
|
||||
<h1><img src="/brand/nanobot_wordmark.svg" alt="nanobot" className="h-auto w-40 select-none dark:brightness-150" draggable={false} /></h1>
|
||||
{versionCheck}
|
||||
</div>
|
||||
<AboutSettingsLayout versionCheck={versionCheck} starLink={starLink} links={
|
||||
<SettingsGroup>
|
||||
{links.map(({ key, icon: Icon, href }) => (
|
||||
<a key={key} href={href} target="_blank" rel="noopener noreferrer"
|
||||
@@ -32,9 +43,6 @@ export function AboutSettingsView({ reportIssueUrl, versionCheck, starLink }: {
|
||||
</a>
|
||||
))}
|
||||
</SettingsGroup>
|
||||
<div className="mt-auto pt-8 text-center">
|
||||
{starLink}
|
||||
</div>
|
||||
</div>
|
||||
} />
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
ImageGenerationIcon,
|
||||
VoiceIcon,
|
||||
} from "@/components/icons/product-icons";
|
||||
import { useContext, useState, type Dispatch, type SetStateAction } from "react";
|
||||
import { useContext, useEffect, type Dispatch, type SetStateAction } from "react";
|
||||
import {
|
||||
ChevronRight,
|
||||
type LucideIcon,
|
||||
@@ -15,7 +15,7 @@ import { HostNavigationContext } from "@/components/remote/HostSwitcher";
|
||||
import { StarLink } from "@/components/StarPrompt";
|
||||
import { AboutSettingsView } from "./AboutSettingsView";
|
||||
import { AppearanceSettingsView } from "./AppearanceSettingsView";
|
||||
import { VersionCheckRowView, type VersionCheckState, type VersionInfoProps } from "./VersionCheckRowView";
|
||||
import { VersionCheckRowView, type VersionInfoProps } from "./VersionCheckRowView";
|
||||
import { DEFAULT_TRANSCRIPTION_SETTINGS } from "@/components/settings/capabilities/TranscriptionSettings";
|
||||
import type { SettingsSectionKey } from "@/components/settings/contracts";
|
||||
import { settingsProviderConfigured } from "@/components/settings/shared/ModelControls";
|
||||
@@ -25,14 +25,14 @@ import {
|
||||
} from "@/components/settings/shared/SettingsControls";
|
||||
import { TokenUsageCard } from "@/components/settings/TokenUsageCard";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { checkVersion } from "@/lib/api";
|
||||
import type {
|
||||
LocalPreferences,
|
||||
} from "@/lib/local-preferences";
|
||||
import { providerBrand, providerDisplayLabel } from "@/lib/provider-brand";
|
||||
import type { SettingsPayload } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useClient } from "@/providers/ClientProvider";
|
||||
import { useUpdateFlow } from "@/providers/UpdateFlowProvider";
|
||||
import { useVersionCheck } from "@/providers/VersionCheckProvider";
|
||||
|
||||
export function OverviewSettings({
|
||||
settings,
|
||||
@@ -127,8 +127,10 @@ export function OverviewSettings({
|
||||
);
|
||||
}
|
||||
|
||||
export function AboutSettings({ settings }: { settings: SettingsPayload }) {
|
||||
export function AboutSettings({ settings, onRequestUpdate: requestUpdate }: { settings: SettingsPayload; onRequestUpdate?: () => void }) {
|
||||
const hostPicker = useContext(HostNavigationContext);
|
||||
const flow = useUpdateFlow();
|
||||
const onRequestUpdate = requestUpdate ?? flow.open;
|
||||
const currentVersion = settings.version?.current;
|
||||
const currentCommit = settings.version?.commit;
|
||||
const environment = settings.environment;
|
||||
@@ -152,38 +154,22 @@ export function AboutSettings({ settings }: { settings: SettingsPayload }) {
|
||||
reportIssueUrl.searchParams.set("connection", hostPicker?.kind === "embedded"
|
||||
? "Remote host" : hostPicker ? "Local host" : "Direct WebUI");
|
||||
return <AboutSettingsView reportIssueUrl={reportIssueUrl.href}
|
||||
versionCheck={<VersionCheckRow currentVersion={currentVersion} currentCommit={currentCommit} />}
|
||||
versionCheck={<VersionCheckRow currentVersion={currentVersion} currentCommit={currentCommit}
|
||||
onRequestUpdate={onRequestUpdate} hasPendingUpdate={flow.pending} />}
|
||||
starLink={<StarLink />} />;
|
||||
}
|
||||
|
||||
function VersionCheckRow({ currentVersion, currentCommit }: VersionInfoProps) {
|
||||
const { token } = useClient();
|
||||
const [checking, setChecking] = useState(false);
|
||||
const [result, setResult] = useState<VersionCheckState>(null);
|
||||
|
||||
const handleCheck = async () => {
|
||||
setChecking(true);
|
||||
setResult(null);
|
||||
try {
|
||||
const res = await checkVersion(token);
|
||||
if (res.updateAvailable) {
|
||||
setResult({
|
||||
type: "update",
|
||||
latestVersion: res.updateAvailable.latestVersion,
|
||||
pypiUrl: res.updateAvailable.pypiUrl,
|
||||
});
|
||||
} else {
|
||||
setResult({ type: "up-to-date" });
|
||||
}
|
||||
} catch (err) {
|
||||
setResult({ type: "error", message: (err as Error).message });
|
||||
} finally {
|
||||
setChecking(false);
|
||||
}
|
||||
};
|
||||
function VersionCheckRow({ currentVersion, currentCommit, onRequestUpdate, hasPendingUpdate }: VersionInfoProps) {
|
||||
const { checking, result, check, releaseStatus, canChangeChannel,
|
||||
changingChannel, channelError, changeChannel, installationMethod } = useVersionCheck();
|
||||
useEffect(() => { void check(); }, [check]);
|
||||
|
||||
return <VersionCheckRowView currentVersion={currentVersion} currentCommit={currentCommit}
|
||||
checking={checking} result={result} onCheck={() => void handleCheck()} />;
|
||||
checking={checking} result={result} onCheck={() => void check()}
|
||||
onRequestUpdate={onRequestUpdate} hasPendingUpdate={hasPendingUpdate}
|
||||
installationMethod={installationMethod}
|
||||
releaseStatus={releaseStatus} canChangeChannel={canChangeChannel} changingChannel={changingChannel}
|
||||
channelError={channelError} onChangeChannel={changeChannel} />;
|
||||
}
|
||||
|
||||
export function AppearanceSettings({ theme, onToggleTheme, localPrefs, onChangeLocalPrefs }: {
|
||||
|
||||
@@ -1,32 +1,49 @@
|
||||
import { ArrowUpCircle, Check, ExternalLink, Loader2 } from "lucide-react";
|
||||
import { useId } from "react";
|
||||
import { Check, ExternalLink, Loader2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SettingsGroup, SettingsRow } from "@/components/settings/shared/SettingsControls";
|
||||
import { ToggleButton } from "@/components/ui/toggle-button";
|
||||
import type { ReleaseStatus, UpdateChannel, UpdateMethod } from "@/lib/api";
|
||||
import type { VersionResult } from "@/providers/VersionCheckProvider";
|
||||
|
||||
export type VersionInfoProps = { currentVersion?: string; currentCommit?: string | null };
|
||||
export type VersionCheckState =
|
||||
| { type: "up-to-date" }
|
||||
| { type: "update"; latestVersion: string; pypiUrl?: string }
|
||||
| { type: "error"; message: string }
|
||||
| null;
|
||||
export type VersionInfoProps = {
|
||||
currentVersion?: string;
|
||||
currentCommit?: string | null;
|
||||
onRequestUpdate?: () => void;
|
||||
hasPendingUpdate?: boolean;
|
||||
installationMethod?: UpdateMethod | null;
|
||||
};
|
||||
export type VersionCheckState = VersionResult;
|
||||
|
||||
export function VersionCheckRowView({ currentVersion, currentCommit, checking, result, onCheck }: VersionInfoProps & {
|
||||
export function VersionCheckRowView({
|
||||
currentVersion, currentCommit, checking, result, onCheck,
|
||||
onRequestUpdate, hasPendingUpdate, installationMethod,
|
||||
releaseStatus, canChangeChannel, changingChannel, channelError, onChangeChannel,
|
||||
}: VersionInfoProps & {
|
||||
checking: boolean;
|
||||
result: VersionCheckState;
|
||||
onCheck: () => void;
|
||||
releaseStatus?: ReleaseStatus | null;
|
||||
canChangeChannel?: boolean;
|
||||
changingChannel?: boolean;
|
||||
channelError?: string;
|
||||
onChangeChannel?: (channel: UpdateChannel) => Promise<void>;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
const previewHelp = useId();
|
||||
const previewToggle = useId();
|
||||
const available = result?.type === "update" ? result : null;
|
||||
const actionClass = "h-auto min-h-9 max-w-full whitespace-normal break-words text-start";
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<div className="min-w-0">
|
||||
<div className="sr-only">
|
||||
{tx("settings.about.version", "Version")}
|
||||
</div>
|
||||
<div className="mt-0.5 text-[12px] leading-5 text-muted-foreground">
|
||||
{currentVersion ? `v${currentVersion}` : "nanobot"}
|
||||
{currentCommit && (
|
||||
<>
|
||||
<SettingsGroup>
|
||||
<SettingsRow title={<>
|
||||
<span>{t("settings.about.version")}</span>
|
||||
<div className="mt-1 flex flex-wrap items-baseline gap-x-2 text-[13px] font-normal leading-5 tabular-nums text-muted-foreground">
|
||||
<span className="min-w-0 break-all">
|
||||
{currentVersion ? `v${currentVersion}` : "nanobot"}
|
||||
{currentCommit && <>
|
||||
<span aria-hidden> (</span>
|
||||
<a href={`https://github.com/HKUDS/nanobot/commit/${currentCommit}`}
|
||||
target="_blank" rel="noopener noreferrer" title={currentCommit}
|
||||
@@ -34,57 +51,73 @@ export function VersionCheckRowView({ currentVersion, currentCommit, checking, r
|
||||
{currentCommit.slice(0, 7)}
|
||||
</a>
|
||||
<span aria-hidden>)</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-col items-center gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={onCheck}
|
||||
disabled={checking}
|
||||
className="rounded-full"
|
||||
>
|
||||
{checking ? (
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" aria-hidden />
|
||||
) : (
|
||||
<ArrowUpCircle className="mr-1.5 h-3.5 w-3.5" aria-hidden />
|
||||
)}
|
||||
{checking
|
||||
? tx("settings.about.checking", "Checking...")
|
||||
: tx("settings.about.checkForUpdates", "Check for updates")}
|
||||
</Button>
|
||||
{result?.type === "up-to-date" ? (
|
||||
<span className="inline-flex items-center gap-1.5 text-[12px] text-emerald-600 dark:text-emerald-300">
|
||||
<Check className="h-3 w-3" aria-hidden />
|
||||
{tx("settings.about.upToDate", "You're up to date")}
|
||||
</>}
|
||||
</span>
|
||||
) : null}
|
||||
{result?.type === "update" ? (
|
||||
<span className="inline-flex items-center gap-1.5 text-[12px] text-blue-600 dark:text-blue-300">
|
||||
<ArrowUpCircle className="h-3 w-3" aria-hidden />
|
||||
{t("settings.about.updateAvailable", {
|
||||
defaultValue: "Update available v{{version}}",
|
||||
version: result.latestVersion,
|
||||
})}
|
||||
{result.pypiUrl ? (
|
||||
<a
|
||||
href={result.pypiUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-0.5 underline-offset-2 hover:underline"
|
||||
>
|
||||
PyPI
|
||||
<ExternalLink className="h-2.5 w-2.5" aria-hidden />
|
||||
{available && !checking && <span className="min-w-0 break-all" role="status">
|
||||
<span aria-hidden>→ </span><span className="sr-only">{t("settings.about.updateNotice")} </span>
|
||||
<span>v{available.latestVersion}</span>
|
||||
</span>}
|
||||
</div>
|
||||
{!checking && available && releaseStatus?.state === "withdrawn" &&
|
||||
<p role="alert" className="mt-1 text-[13px] font-normal leading-5 text-destructive">{t("updates.channel.withdrawn")}</p>}
|
||||
{available && !checking && !onRequestUpdate &&
|
||||
<p className="mt-1 text-[13px] font-normal leading-5 text-muted-foreground">{t("settings.about.updateInstructions")}</p>}
|
||||
</>}>
|
||||
<div className="settings-version-actions flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1">
|
||||
{(checking || (result && !available)) && <span role="status" aria-atomic="true" className={`min-w-0 text-[13px] leading-5 [overflow-wrap:anywhere] ${result?.type === "error" && !checking ? "text-destructive" : "text-muted-foreground"}`}>
|
||||
{checking ? <span className="inline-flex items-center gap-1.5">
|
||||
<Loader2 className="h-3.5 w-3.5 shrink-0 animate-spin motion-reduce:animate-none" aria-hidden />
|
||||
{t("settings.about.checking")}
|
||||
</span> : result?.type === "up-to-date" ? <span className="inline-flex items-center gap-1.5">
|
||||
<Check className="h-3 w-3 shrink-0" aria-hidden />{t("settings.about.upToDate")}
|
||||
</span> : result?.type === "release-status" ? t(`updates.channel.${result.state}`)
|
||||
: result?.type === "error" ? result.message : null}
|
||||
</span>}
|
||||
{hasPendingUpdate && onRequestUpdate ? (
|
||||
<Button size="sm" variant="outline" className={actionClass} onClick={onRequestUpdate}>
|
||||
{t("settings.about.viewUpdateDetails")}
|
||||
</Button>
|
||||
) : checking ? null : available ? <>
|
||||
{onRequestUpdate ? <Button size="sm" variant="outline" className={actionClass} onClick={onRequestUpdate} disabled={changingChannel}>
|
||||
{installationMethod && installationMethod !== "managed"
|
||||
? t("updates.guide.entry", { method: t(`updates.guide.methods.${installationMethod}`) })
|
||||
: t("settings.about.updateNow")}
|
||||
</Button> : <Button size="sm" variant="outline" className={actionClass} asChild>
|
||||
<a href="https://github.com/HKUDS/nanobot#-install" target="_blank" rel="noopener noreferrer">
|
||||
{t("settings.about.installationGuide")}<ExternalLink className="ms-1.5 h-3 w-3 shrink-0" aria-hidden />
|
||||
</a>
|
||||
</Button>}
|
||||
{available.releaseUrl || available.pypiUrl ? (
|
||||
<a href={available.releaseUrl || available.pypiUrl} target="_blank" rel="noopener noreferrer"
|
||||
className="inline-flex min-h-9 items-center gap-1 rounded-control text-[13px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
|
||||
{available.releaseUrl ? t("updates.channel.releaseNotes") : "PyPI"}
|
||||
<ExternalLink className="h-3 w-3 shrink-0" aria-hidden />
|
||||
</a>
|
||||
) : null}
|
||||
</> : <Button size="sm" variant="ghost" className={`${actionClass} px-2 text-muted-foreground`} onClick={onCheck} disabled={changingChannel}>
|
||||
{result?.type === "error" ? t("common.retry") : result ? t("updates.checkAgain") : t("settings.about.checkForUpdates")}
|
||||
</Button>}
|
||||
</div>
|
||||
</SettingsRow>
|
||||
{releaseStatus && onChangeChannel && <div className="border-t border-border/50">
|
||||
<SettingsRow title={<>
|
||||
<label htmlFor={previewToggle}>{t("updates.channel.receivePreview")}</label>
|
||||
<p id={previewHelp} className="mt-1 text-[13px] font-normal leading-5 text-muted-foreground">
|
||||
{t("updates.channel.hint")}
|
||||
{!canChangeChannel && <span className="mt-2 block">{t("updates.blocked.permission")}</span>}
|
||||
</p>
|
||||
</>}>
|
||||
<ToggleButton id={previewToggle} checked={releaseStatus.channel === "preview"}
|
||||
onChange={enabled => { void onChangeChannel(enabled ? "preview" : "stable"); }}
|
||||
disabled={!canChangeChannel || changingChannel || checking}
|
||||
label={t("updates.channel.receivePreview")} aria-describedby={previewHelp} />
|
||||
</SettingsRow>
|
||||
<p role="status" className={`settings-list-inset text-[13px] leading-5 ${channelError ? "text-destructive" : "text-muted-foreground"}`}>
|
||||
<span className={changingChannel || channelError ? "block pb-3" : undefined}>
|
||||
{changingChannel ? t("updates.channel.saving") : channelError}
|
||||
</span>
|
||||
) : null}
|
||||
{result?.type === "error" ? (
|
||||
<span className="text-[12px] text-destructive">{result.message}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
</div>}
|
||||
</SettingsGroup>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,8 @@ import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts";
|
||||
import { SettingsGroup } from "@/components/settings/shared/SettingsControls";
|
||||
import { AboutSettingsLayout } from "@/components/settings/overview/AboutSettingsView";
|
||||
import { SettingsGroup, SettingsRow } from "@/components/settings/shared/SettingsControls";
|
||||
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
|
||||
import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS, type RuntimeConfigPage } from "@/components/settings/system/runtime-config-fields";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -94,14 +95,14 @@ export function SettingsSectionSkeleton({ section, showRestart = false }: { sect
|
||||
content = <RuntimeGroups page="advanced" />;
|
||||
break;
|
||||
case "about":
|
||||
content = <>
|
||||
<div className="flex flex-col items-center gap-4 py-6">
|
||||
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16" />
|
||||
<img src="/brand/nanobot_wordmark.svg" alt="" className="h-auto w-40 dark:brightness-150" />
|
||||
<div className="flex flex-col items-center gap-4"><div className="mt-0.5 flex h-5 items-center"><div className={cn(block, "h-3 w-20")} /></div><div className={cn(block, "h-9 w-36 rounded-full")} /></div>
|
||||
</div>
|
||||
content = <AboutSettingsLayout starLink={null} versionCheck={
|
||||
<SettingsGroup><SettingsRow title={<>
|
||||
<div className="flex h-5 items-center"><div className={cn(block, "h-3.5 w-20")} /></div>
|
||||
<div className="mt-1 flex h-5 items-center"><div className={cn(block, "h-3 w-24")} /></div>
|
||||
</>}><div className={cn(block, "settings-version-actions h-9 w-36 rounded-control")} /></SettingsRow></SettingsGroup>
|
||||
} links={
|
||||
<SettingsGroup>{[0, 1, 2].map((index) => <div key={index} className="settings-list-row flex items-center gap-3"><div className={cn(block, "h-4 w-4")} /><div className={cn(block, "h-3.5 w-28")} /></div>)}</SettingsGroup>
|
||||
</>;
|
||||
} />;
|
||||
break;
|
||||
}
|
||||
return <SkeletonStatus label={t("settings.status.loading")} className="settings-stack">{content}</SkeletonStatus>;
|
||||
|
||||
@@ -156,6 +156,11 @@ export function useSettingsController({
|
||||
|
||||
const runtimeConfigState = useRuntimeConfigSettings(settings, client, applyPayload);
|
||||
|
||||
const markUpdateInstalled = useCallback(() => {
|
||||
setPendingRestartSections((current) => ({ ...current, runtime: true }));
|
||||
setSettings((current) => current ? { ...current, requires_restart: true } : current);
|
||||
}, []);
|
||||
|
||||
const closeProviderOAuthFlow = useCallback((cancelPending = true) => {
|
||||
const flow = providerOAuthFlowRef.current;
|
||||
providerOAuthFlowRef.current = null;
|
||||
@@ -456,6 +461,7 @@ export function useSettingsController({
|
||||
systemState,
|
||||
systemActions,
|
||||
activeSection,
|
||||
markUpdateInstalled,
|
||||
runtimeConfigState,
|
||||
closeProviderOAuthFlow,
|
||||
error,
|
||||
|
||||
@@ -10,6 +10,7 @@ const buttonVariants = cva(
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
||||
accent: "bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-400 dark:text-slate-950 dark:hover:bg-blue-300",
|
||||
destructive:
|
||||
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
||||
outline:
|
||||
|
||||
Reference in new issue
Block a user