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
@@ -15,16 +15,74 @@ import { jsonResponse, settingsPayload, renderSettingsView, installSettingsViewT
|
||||
describe("Settings overview and appearance", () => {
|
||||
installSettingsViewTestHooks();
|
||||
|
||||
it.each([{ capabilities: [] }, { capabilities: ["webui.core.v1", "webui.self-update.v1"] }])(
|
||||
"checks on About entry without calling the legacy updater (%j)",
|
||||
async ({ capabilities }) => {
|
||||
const fetcher = vi.fn(async () => jsonResponse({
|
||||
updateAvailable: { currentVersion: "0.2.2", latestVersion: "0.3.6" },
|
||||
}));
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
render(
|
||||
<ClientProvider client={new NanobotClient({ url: "ws://localhost:8765" })} token="tok"
|
||||
webuiCapabilities={capabilities}>
|
||||
<AboutSettings settings={settingsPayload()} />
|
||||
</ClientProvider>,
|
||||
);
|
||||
expect(await screen.findByRole("link", { name: "Installation guide" })).toBeVisible();
|
||||
expect(fetcher).toHaveBeenCalledTimes(1);
|
||||
expect(fetcher).toHaveBeenCalledWith("/api/settings/version-check", expect.any(Object));
|
||||
expect(screen.queryByRole("button", { name: /^Update$/ })).not.toBeInTheDocument();
|
||||
},
|
||||
);
|
||||
|
||||
it("displays a caller-owned version result and delegates checking without a client provider", () => {
|
||||
const check = vi.fn();
|
||||
render(<VersionCheckRowView currentVersion="0.3.5" checking={false}
|
||||
const { rerender } = render(<VersionCheckRowView currentVersion="0.3.5" checking={false}
|
||||
result={{ type: "update", latestVersion: "0.3.6", pypiUrl: "https://pypi.org/project/nanobot-ai/" }} onCheck={check} />);
|
||||
expect(screen.getByText("Update available v0.3.6")).toBeVisible();
|
||||
expect(screen.getByText("v0.3.6")).toBeVisible();
|
||||
expect(screen.getByRole("link", { name: "PyPI" })).toHaveAttribute("href", "https://pypi.org/project/nanobot-ai/");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Check for updates" }));
|
||||
rerender(<VersionCheckRowView currentVersion="0.3.5" checking={false} result={{ type: "up-to-date" }} onCheck={check} />);
|
||||
expect(screen.getByText("You're up to date")).toBeVisible();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Check again" }));
|
||||
expect(check).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("delegates update actions and keeps saved-job details available in the shared view", () => {
|
||||
const requestUpdate = vi.fn();
|
||||
const props = { currentVersion: "0.3.5", checking: false, onCheck: vi.fn(),
|
||||
onRequestUpdate: requestUpdate };
|
||||
const { rerender } = render(<VersionCheckRowView {...props}
|
||||
result={{ type: "update", latestVersion: "0.3.7.dev2026101501",
|
||||
releaseUrl: "https://github.com/HKUDS/nanobot/releases/tag/v0.3.7.dev2026101501" }} />);
|
||||
expect(screen.getByText("v0.3.7.dev2026101501")).toBeVisible();
|
||||
expect(screen.getByRole("link", { name: "Release notes" })).toHaveAttribute("href",
|
||||
"https://github.com/HKUDS/nanobot/releases/tag/v0.3.7.dev2026101501");
|
||||
expect(requestUpdate).not.toHaveBeenCalled();
|
||||
expect(screen.queryByRole("link", { name: "Installation guide" })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: /^Update$/ }));
|
||||
expect(requestUpdate).toHaveBeenCalledTimes(1);
|
||||
|
||||
rerender(<VersionCheckRowView {...props} currentVersion="0.3.6"
|
||||
result={{ type: "up-to-date" }} hasPendingUpdate />);
|
||||
expect(screen.queryByRole("button", { name: /^Update$/ })).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "View details" }));
|
||||
expect(requestUpdate).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("lets the visible Preview label toggle the setting without consenting to an update", () => {
|
||||
const changeChannel = vi.fn().mockResolvedValue(undefined);
|
||||
const requestUpdate = vi.fn();
|
||||
render(<VersionCheckRowView currentVersion="0.3.6" checking={false} result={null} onCheck={vi.fn()}
|
||||
releaseStatus={{ channel: "stable", revision: 1, currentVersion: "0.3.6", state: "current" }}
|
||||
canChangeChannel onChangeChannel={changeChannel} onRequestUpdate={requestUpdate} />);
|
||||
const toggle = screen.getByRole("switch", { name: "Receive preview updates" });
|
||||
expect(toggle).toHaveAccessibleDescription("Try new features early.");
|
||||
fireEvent.click(document.querySelector(`label[for="${toggle.id}"]`)!);
|
||||
expect(changeChannel).toHaveBeenCalledTimes(1);
|
||||
expect(changeChannel).toHaveBeenCalledWith("preview");
|
||||
expect(requestUpdate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("opens the notifications section and preserves independent browser-local channel preferences", () => {
|
||||
writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, notificationSound: true });
|
||||
renderSettingsView({ initialSection: "appearance", initialSettings: settingsPayload(), showSidebar: true });
|
||||
@@ -74,7 +132,7 @@ describe("Settings overview and appearance", () => {
|
||||
initialSettings: { ...settingsPayload(), version: { current: "0.3.5", commit } },
|
||||
});
|
||||
expect(screen.getByText("v0.3.5")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "Check for updates" })).toBeEnabled();
|
||||
expect(screen.getByText("Checking...")).toBeVisible();
|
||||
expect(document.querySelector('a[href*="/commit/"]')).toBeNull();
|
||||
const reportUrl = new URL(screen.getByRole("link", { name: "Report an issue" }).getAttribute("href")!);
|
||||
expect(reportUrl.searchParams.get("version")).toBe("0.3.5");
|
||||
|
||||
Reference in new issue
Block a user