From 6ace6068d78fe34c2e38329a032764f5918c0969 Mon Sep 17 00:00:00 2001
From: chengyongru <61816729+chengyongru@users.noreply.github.com>
Date: Thu, 22 Oct 2026 21:04:21 +0800
Subject: [PATCH] fix(webui): check for updates only after opening About
(#6397)
* fix(webui): check for updates only after opening About
* docs(agent): require meaningful behavioral test assertions
---
AGENTS.md | 1 +
docs/webui.md | 4 ++++
webui/src/App.tsx | 1 -
webui/src/providers/ClientProvider.tsx | 4 +---
webui/src/providers/VersionCheckProvider.tsx | 10 ++--------
webui/src/tests/update-channels.test.tsx | 2 +-
webui/src/tests/update-flow.test.tsx | 2 +-
webui/src/tests/update-notice.test.tsx | 20 +++++++++++++++-----
8 files changed, 25 insertions(+), 19 deletions(-)
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"}
>
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 (
-
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
{children}
;
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
;
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(
+ render(
);
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") => ;
+const view = (token = "host-a") => ;
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(
+ rerender(
);
@@ -63,14 +64,17 @@ describe("Sidebar update entry", () => {
let resolve!: (response: Response) => void;
const fetcher = vi.fn().mockImplementation(() => new Promise(done => { resolve = done; }));
vi.stubGlobal("fetch", fetcher);
- const surface = (about: boolean) =>
+ const surface = (about: boolean) =>
{about && }
;
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(
+ render(
);
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();