Skip to content

Your lightweight open-source personal agent.

fix(webui): check for updates only after opening About (#6397)

chengyongru6ace6068d78f
diff --git a/AGENTS.md b/AGENTS.md
index d85d4aafb..c03a774a6 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -19,5 +19,6 @@ The Python gateway owns agent execution, sessions, tools, memory, and security p
- Analyze the required behavior, state ownership, and root cause before extending existing code. Refactor when the structure causes the problem; a smaller diff does not justify another fallback.
- Do not add defensive tests for hypothetical internal states or unsupported combinations. Each new test needs a reachable path and a meaningful contract to protect.
+- Do not add tests merely to prove that nonexistent behavior, removed code, or obsolete symbols are absent. Negative assertions must exercise a concrete, reachable risk and protect an observable behavioral contract; prefer testing supported actions and their results.
- Do not run `ruff format`; mechanical formatting obscures git blame and creates unrelated diffs. This constraint takes precedence over the optional touched-file formatting in `CONTRIBUTING.md`.
- Do not manually wrap prose in Markdown files. Keep each paragraph on one source line; use line breaks only for Markdown structure.
diff --git a/docs/webui.md b/docs/webui.md
index b012a570d..68cef0584 100644
--- a/docs/webui.md
+++ b/docs/webui.md
@@ -81,6 +81,10 @@ Share WebUI access only with people you trust to administer the same agent. To g
| Automations | Review, search, run, pause, edit, and delete scheduled and local-trigger agent turns |
| Settings | Adjust models, providers, image generation, voice, web tools, runtime, and safety options |
+## Check for updates
+
+Open **Settings → About** to check for updates automatically. Startup, reconnecting, and normal chatting do not trigger background version checks. Use **Check again** or **Retry** to check manually; changing the update channel also refreshes its status. Checking does not install updates or restart nanobot.
+
## Topic Workspace
The sidebar is the topic switcher. Each topic keeps its own history, title, workspace selection, and linked automations. Use a new topic when you want a separate context; use fork when you want to continue from an existing point without changing the original thread.
diff --git a/webui/src/App.tsx b/webui/src/App.tsx
index 82757b044..1bfd55e65 100644
--- a/webui/src/App.tsx
+++ b/webui/src/App.tsx
@@ -1146,7 +1146,6 @@ export default function App() {
modelName={state.modelName}
ingressLimits={state.ingressLimits}
webuiCapabilities={state.webuiCapabilities}
- checkUpdatesOnConnect={state.runtimeSurface !== "native" && state.webuiCapabilities.includes("webui.core.v1")}
allowUpdateFlow={state.runtimeSurface !== "native"}
>
<BrowserNotifications client={state.client} />
diff --git a/webui/src/providers/ClientProvider.tsx b/webui/src/providers/ClientProvider.tsx
index 18a11923d..5615a61c9 100644
--- a/webui/src/providers/ClientProvider.tsx
+++ b/webui/src/providers/ClientProvider.tsx
@@ -29,7 +29,6 @@ export function ClientProvider({
modelName = null,
ingressLimits = null,
webuiCapabilities = [],
- checkUpdatesOnConnect = false,
allowUpdateFlow = true,
children,
}: {
@@ -38,7 +37,6 @@ export function ClientProvider({
modelName?: string | null;
ingressLimits?: WebUIIngressLimits | null;
webuiCapabilities?: string[];
- checkUpdatesOnConnect?: boolean;
allowUpdateFlow?: boolean;
children: ReactNode;
}) {
@@ -52,7 +50,7 @@ export function ClientProvider({
return (
<ClientContext.Provider value={value}>
- <VersionCheckProvider token={token} client={client} autoCheck={checkUpdatesOnConnect}
+ <VersionCheckProvider token={token} client={client}
channels={allowUpdateFlow && webuiCapabilities.includes("webui.update-channels.v1")}>
<UpdateFlowProvider client={client} token={token} enabled={allowUpdateFlow && webuiCapabilities.includes("webui.update-flow.v1")}
canSettleHandoff={webuiCapabilities.includes("webui.update-jobs.settle-handoff.v1")}>
diff --git a/webui/src/providers/VersionCheckProvider.tsx b/webui/src/providers/VersionCheckProvider.tsx
index 73d8817cb..1b4220240 100644
--- a/webui/src/providers/VersionCheckProvider.tsx
+++ b/webui/src/providers/VersionCheckProvider.tsx
@@ -1,4 +1,4 @@
-import { createContext, useContext, useEffect, useMemo, useSyncExternalStore, type ReactNode } from "react";
+import { createContext, useContext, useMemo, useSyncExternalStore, type ReactNode } from "react";
import { checkVersion, changeUpdateChannel, type ReleaseStatus, type UpdateChannel, type UpdateMethod, type WebUIMutationTransport } from "@/lib/api";
@@ -96,9 +96,8 @@ function createVersionCheck(token: string, channels: boolean, client?: WebUIMuta
};
}
-export function VersionCheckProvider({ token, autoCheck = false, channels = false, client, children }: {
+export function VersionCheckProvider({ token, channels = false, client, children }: {
token: string;
- autoCheck?: boolean;
channels?: boolean;
client?: WebUIMutationTransport;
children: ReactNode;
@@ -106,11 +105,6 @@ export function VersionCheckProvider({ token, autoCheck = false, channels = fals
const store = useMemo(() => createVersionCheck(token, channels, client), [token, channels, client]);
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot);
- useEffect(() => {
- // One quiet check on connection, not a timer or an installation request.
- if (autoCheck && token) void store.check();
- }, [autoCheck, store, token]);
-
return <VersionCheckContext.Provider value={{ ...snapshot, check: store.check, dismiss: store.dismiss, changeChannel: store.changeChannel }}>
{children}
</VersionCheckContext.Provider>;
diff --git a/webui/src/tests/update-channels.test.tsx b/webui/src/tests/update-channels.test.tsx
index 5cb02839e..cb18857f2 100644
--- a/webui/src/tests/update-channels.test.tsx
+++ b/webui/src/tests/update-channels.test.tsx
@@ -22,7 +22,7 @@ function Controls() {
</>;
}
function view(client: NanobotClient, token = "channel-a", native = false) {
- return <ClientProvider client={client} token={token} checkUpdatesOnConnect allowUpdateFlow={!native}
+ return <ClientProvider client={client} token={token} allowUpdateFlow={!native}
webuiCapabilities={["webui.update-channels.v1"]}>
<AboutSettings settings={settingsPayload()} /><Controls />
</ClientProvider>;
diff --git a/webui/src/tests/update-flow.test.tsx b/webui/src/tests/update-flow.test.tsx
index 4561d1aae..62c3ac132 100644
--- a/webui/src/tests/update-flow.test.tsx
+++ b/webui/src/tests/update-flow.test.tsx
@@ -564,7 +564,7 @@ describe("Real update consent and recovery", () => {
vi.mocked(api.readUpdateJob).mockResolvedValue({ job: {
...job("restart_failed", "confirmed"), mutation_started: true, running_version: "0.3.6",
} });
- render(<ClientProvider client={client} token="gateway-a" checkUpdatesOnConnect webuiCapabilities={["webui.update-flow.v1"]}>
+ render(<ClientProvider client={client} token="gateway-a" webuiCapabilities={["webui.update-flow.v1"]}>
<AboutSettings settings={settingsPayload()} />
</ClientProvider>);
fireEvent.click(await screen.findByRole("button", { name: "Close" }));
diff --git a/webui/src/tests/update-notice.test.tsx b/webui/src/tests/update-notice.test.tsx
index ffed18c86..9e0e75fbb 100644
--- a/webui/src/tests/update-notice.test.tsx
+++ b/webui/src/tests/update-notice.test.tsx
@@ -40,16 +40,17 @@ function Surface() {
</>;
}
-const view = (token = "host-a") => <ClientProvider client={client} token={token} checkUpdatesOnConnect><Surface /></ClientProvider>;
+const view = (token = "host-a") => <ClientProvider client={client} token={token}><Surface /></ClientProvider>;
describe("Sidebar update entry", () => {
it("keeps About update actions available after dismissing the sidebar notice", async () => {
const fetcher = vi.fn(async () => jsonResponse(available()));
vi.stubGlobal("fetch", fetcher);
const { rerender } = render(view("dismiss-sidebar"));
+ fireEvent.click(screen.getByText("Refresh version"));
fireEvent.click(await screen.findByRole("button", { name: "Update available v0.3.6" }));
fireEvent.click(screen.getByRole("button", { name: "Dismiss update notice" }));
- rerender(<ClientProvider client={client} token="dismiss-sidebar" checkUpdatesOnConnect>
+ rerender(<ClientProvider client={client} token="dismiss-sidebar">
<Surface />
<AboutSettings settings={settingsPayload()} onRequestUpdate={vi.fn()} />
</ClientProvider>);
@@ -63,14 +64,17 @@ describe("Sidebar update entry", () => {
let resolve!: (response: Response) => void;
const fetcher = vi.fn().mockImplementation(() => new Promise<Response>(done => { resolve = done; }));
vi.stubGlobal("fetch", fetcher);
- const surface = (about: boolean) => <ClientProvider client={client} token="about-entry" checkUpdatesOnConnect>
+ const surface = (about: boolean) => <ClientProvider client={client} token="about-entry">
{about && <AboutSettings settings={settingsPayload()} />}
</ClientProvider>;
const mounted = render(surface(false));
- expect(fetcher).toHaveBeenCalledOnce();
+ expect(fetcher).not.toHaveBeenCalled();
mounted.rerender(surface(true));
expect(screen.getByRole("status")).toHaveTextContent("Checking...");
expect(fetcher).toHaveBeenCalledOnce();
+ mounted.rerender(surface(false));
+ mounted.rerender(surface(true));
+ expect(fetcher).toHaveBeenCalledOnce();
await act(async () => resolve(jsonResponse({ updateAvailable: null })));
expect(screen.getByText("You're up to date")).toBeVisible();
@@ -102,7 +106,7 @@ describe("Sidebar update entry", () => {
it("uses the same direct confirmation in About when an update action is available", async () => {
vi.stubGlobal("fetch", vi.fn(async () => jsonResponse(available())));
const requestUpdate = vi.fn();
- render(<ClientProvider client={client} token="about-update" checkUpdatesOnConnect>
+ render(<ClientProvider client={client} token="about-update">
<AboutSettings settings={{ ...settingsPayload(), version: { current: "0.3.5" } }} onRequestUpdate={requestUpdate} />
</ClientProvider>);
const button = await screen.findByRole("button", { name: /^Update$/ });
@@ -117,6 +121,7 @@ describe("Sidebar update entry", () => {
vi.stubGlobal("fetch", fetcher);
render(view());
fireEvent.change(screen.getByLabelText("Draft"), { target: { value: "Keep writing" } });
+ fireEvent.click(screen.getByText("Refresh version"));
fireEvent.click(await screen.findByRole("button", { name: "Update available v0.3.6" }));
expect(screen.getByRole("dialog", { name: "Update available v0.3.6" })).toBeVisible();
expect(screen.queryByRole("link", { name: "Installation guide" })).toBeNull();
@@ -138,6 +143,7 @@ describe("Sidebar update entry", () => {
vi.stubGlobal("fetch", fetcher);
render(view());
fireEvent.click(screen.getByText("Refresh version"));
+ fireEvent.click(screen.getByText("Refresh version"));
expect(fetcher).toHaveBeenCalledTimes(1);
await act(async () => resolve(jsonResponse(available())));
fireEvent.click(screen.getByRole("button", { name: "Update available v0.3.6" }));
@@ -157,7 +163,10 @@ describe("Sidebar update entry", () => {
vi.stubGlobal("fetch", fetcher);
const { rerender } = render(view());
fireEvent.change(screen.getByLabelText("Draft"), { target: { value: "Keep this draft" } });
+ fireEvent.click(screen.getByText("Refresh version"));
rerender(view("host-b"));
+ expect(fetcher).toHaveBeenCalledTimes(1);
+ fireEvent.click(screen.getByText("Refresh version"));
await waitFor(() => expect(fetcher).toHaveBeenCalledTimes(2));
await act(async () => resolveOld(jsonResponse(available())));
expect(screen.queryByRole("button", { name: /Update available/ })).toBeNull();
@@ -168,6 +177,7 @@ describe("Sidebar update entry", () => {
const fetcher = vi.fn().mockImplementation(() => failure ? Promise.reject(failure) : Promise.resolve(jsonResponse({ updateAvailable: null })));
vi.stubGlobal("fetch", fetcher);
render(view());
+ fireEvent.click(screen.getByText("Refresh version"));
await waitFor(() => expect(fetcher).toHaveBeenCalledTimes(1));
expect(screen.queryByRole("button", { name: /Update available/ })).toBeNull();
expect(screen.queryByRole("alert")).toBeNull();