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:
Xubin Renandchengyongru authored and GitHub committed 2026-10-21 19:16:56 +08:00
1 parent 76da55994b
commit fbb61a373f
216 files changed
+27948 -1084

No files matched your search

@@ -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,