From 9b1a9c3fa968286a1d61181967c2a8d924f8f2ec Mon Sep 17 00:00:00 2001
From: David McKay
Date: Fri, 4 Dec 2026 07:55:16 -0800
Subject: [PATCH 1/6] Every Update and restart asks to move first from the disk
image, and no button says Downloading before it does
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The update banner in OpenBot's page, Settings > This computer and the
version gate called the page's install_update, which went straight to the
install: OpenBot open from its disk image still downloaded the update and
failed with "Read-only file system". Every Update and restart now goes
through update_or_move, which asks to move to Applications first where
the install can't work, and nothing else reaches the install.
While the app asked, every update button already said "Downloading…", and
Not now then showed "Couldn't install the update". The shell now says in
its offer whether Update and restart moves first, and the buttons keep
their idle label until the download really starts, as an app's window
does while LetsMove or Electron's move to Applications asks.
---
.../components/layout/client-version-gate.tsx | 11 +-
app/src/components/layout/update-banner.tsx | 13 +-
.../settings/this-computer-sections.tsx | 7 +-
app/src/lib/desktop/queries.ts | 5 +
app/tests/update-banner-layout.fixture.tsx | 4 +
app/tests/update-banner-layout.test.tsx | 58 ++++++-
app/tests/update-banner.test.tsx | 38 +++++
desktop/src-tauri/src/app_update.rs | 36 ++--
desktop/src-tauri/src/desktop_page.rs | 10 +-
desktop/src-tauri/src/main.rs | 115 +++++++++----
.../src-tauri/src/update_or_move_ipc_tests.rs | 161 ++++++++++++++++++
desktop/src/CheckForUpdates.tsx | 31 ++--
desktop/src/SecurityFloor.tsx | 13 +-
desktop/src/UpdateOffer.test.tsx | 37 ++++
desktop/src/UpdateOffer.tsx | 26 ++-
desktop/src/UpdateOpenBot.tsx | 20 ++-
shared/desktop-updates.ts | 27 +++
17 files changed, 525 insertions(+), 87 deletions(-)
create mode 100644 desktop/src-tauri/src/update_or_move_ipc_tests.rs
diff --git a/app/src/components/layout/client-version-gate.tsx b/app/src/components/layout/client-version-gate.tsx
index cc56a430d4..4c5c8fb676 100644
--- a/app/src/components/layout/client-version-gate.tsx
+++ b/app/src/components/layout/client-version-gate.tsx
@@ -4,7 +4,11 @@ import {
SECURITY_UPDATE_SENTENCE,
SERVER_UPDATE_SENTENCE,
} from "@openbot/shared/client-version";
-import { DOESNT_UPDATE_ITSELF } from "@openbot/shared/desktop-updates";
+import {
+ DOESNT_UPDATE_ITSELF,
+ saysInstallFailure,
+ updateUnderWay,
+} from "@openbot/shared/desktop-updates";
import { useMutation, useQuery } from "@tanstack/react-query";
import { type ReactNode, useSyncExternalStore } from "react";
import AgentOrb from "@/components/agents/orb/agent-orb";
@@ -198,7 +202,8 @@ function DesktopUpdate({
const install = useMutation(installAppUpdateMutationOptions(queryClient));
const updatesItself = offer.data?.updatesItself !== false;
const progress = offer.data?.installing ?? null;
- const busy = install.isPending || progress !== null;
+ const movesFirst = offer.data?.movesFirst;
+ const busy = updateUnderWay(install.isPending, progress, movesFirst);
return (
<>
@@ -221,7 +226,7 @@ function DesktopUpdate({
) : (
{DOESNT_UPDATE_ITSELF}
)}
- {install.error && !busy ? (
+ {install.error && !busy && saysInstallFailure(movesFirst) ? (
Couldn't install the update: {reason(install.error)}
diff --git a/app/src/components/layout/update-banner.tsx b/app/src/components/layout/update-banner.tsx
index b53b54c55a..99d1153817 100644
--- a/app/src/components/layout/update-banner.tsx
+++ b/app/src/components/layout/update-banner.tsx
@@ -1,6 +1,10 @@
-import { updateOffered } from "@openbot/shared/desktop-updates";
-import { IconX } from "@/components/icons";
+import {
+ saysInstallFailure,
+ updateOffered,
+ updateUnderWay,
+} from "@openbot/shared/desktop-updates";
import { useMutation, useQuery } from "@tanstack/react-query";
+import { IconX } from "@/components/icons";
import { Button } from "@/components/ui/button";
import {
dismissAppUpdateMutationOptions,
@@ -32,7 +36,8 @@ export function UpdateBanner() {
const version = offer.data?.version;
if (!version) return null;
const progress = offer.data?.installing ?? null;
- const busy = install.isPending || progress !== null;
+ const movesFirst = offer.data?.movesFirst;
+ const busy = updateUnderWay(install.isPending, progress, movesFirst);
// Named for the app it updates: the page above can be an OpenBot elsewhere, on its own release.
const said = updateOffered(version, offer.data?.ready, "OpenBot Desktop");
@@ -76,7 +81,7 @@ export function UpdateBanner() {
)}
- {install.error && !busy ? (
+ {install.error && !busy && saysInstallFailure(movesFirst) ? (
Couldn't install the update: {reason(install.error)}
diff --git a/app/src/components/settings/this-computer-sections.tsx b/app/src/components/settings/this-computer-sections.tsx
index a97fa1866c..b45c0b88db 100644
--- a/app/src/components/settings/this-computer-sections.tsx
+++ b/app/src/components/settings/this-computer-sections.tsx
@@ -1,7 +1,9 @@
import {
DOESNT_UPDATE_ITSELF,
+ saysInstallFailure,
type UpdateReadiness,
updateOffered,
+ updateUnderWay,
} from "@openbot/shared/desktop-updates";
import { useMutation, useQuery } from "@tanstack/react-query";
import * as React from "react";
@@ -388,7 +390,8 @@ export function VersionRow({ status }: { status: DesktopStatus }) {
: false,
});
const progress = offer.data?.installing ?? null;
- const installing = install.isPending || progress !== null;
+ const movesFirst = offer.data?.movesFirst;
+ const installing = updateUnderWay(install.isPending, progress, movesFirst);
const found = check.data;
// An older desktop app doesn't say, and its check answers for itself. No button until the first
// answer, so a build that doesn't update itself never shows one for a moment.
@@ -419,7 +422,7 @@ export function VersionRow({ status }: { status: DesktopStatus }) {
{reason(check.error)}
)}
- {install.error && !installing && (
+ {install.error && !installing && saysInstallFailure(movesFirst) && (
{
if (command === "plugin:openbot-desktop|update_offer") return page.__offer;
+ // Update and restart: the app's own dialog asks to move first when `movesFirst`, and either way
+ // nothing answers while the test looks.
+ if (command === "plugin:openbot-desktop|install_update")
+ return new Promise(() => {});
throw `command ${command} not found`;
},
transformCallback: () => 0,
diff --git a/app/tests/update-banner-layout.test.tsx b/app/tests/update-banner-layout.test.tsx
index 215b5791ec..8bb6fc31a2 100644
--- a/app/tests/update-banner-layout.test.tsx
+++ b/app/tests/update-banner-layout.test.tsx
@@ -19,11 +19,16 @@ import { compile } from "tailwindcss";
*
* OPENBOT_APP_BROWSER=1 bun test app/tests/update-banner-layout.test.tsx
*
+ * With OPENBOT_APP_ENGINE=webkit it runs in WebKit, the engine OpenBot Desktop's Mac window uses.
+ *
* With OPENBOT_APP_SHOTS= it also saves the banner in each state at the default width, light
* and dark, as update-banner--.png.
*/
const asked = process.env.OPENBOT_APP_BROWSER === "1";
const shots = process.env.OPENBOT_APP_SHOTS;
+/** `OPENBOT_APP_ENGINE=webkit` draws it in WebKit, the engine OpenBot Desktop's Mac window uses. */
+const engine =
+ process.env.OPENBOT_APP_ENGINE === "webkit" ? "webkit" : "chromium";
const APP = join(import.meta.dir, "..");
const ORIGIN = "http://openbot.test";
@@ -48,6 +53,7 @@ type Offer = {
| { state: "preparing"; done: number; total: number }
| { state: "ready" }
| null;
+ movesFirst?: boolean;
};
/** The states the shell reports, in the order a person sees them, and words that say each one. */
@@ -153,9 +159,12 @@ async function stylesheet(classes: string[]): Promise {
*/
async function ready(): Promise<{ script: string; browser: Browser }> {
const script = await bundle();
- const { chromium } = await import("playwright-core");
+ const { chromium, webkit } = await import("playwright-core");
// The CI job installs full Chromium without the headless shell.
- const browser = await chromium.launch({ channel: "chromium" });
+ const browser =
+ engine === "webkit"
+ ? await webkit.launch()
+ : await chromium.launch({ channel: "chromium" });
return { script, browser };
}
@@ -296,6 +305,51 @@ describe.skipIf(!asked)("the update banner's height", () => {
}
}, 60_000);
+ /**
+ * Open from its disk image, Update and restart shows the app's own "Move OpenBot to Applications"
+ * dialog, and nothing downloads until OpenBot has moved. The banner behind it said "Downloading…";
+ * it keeps Update and restart, in the same place, while the app asks.
+ */
+ test("while the app asks to move to Applications, the banner keeps Update and restart where it was", async () => {
+ for (const theme of ["light", "dark"] as const) {
+ const page = await open(DEFAULT_WIDTH, theme);
+ try {
+ const offer = { ...states(RELEASE)[0].offer, movesFirst: true };
+ await show(page, offer, "is available");
+ const before = await measured(page);
+ const update = page.getByRole("button", { name: "Update and restart" });
+ const shot = (name: string) =>
+ shots
+ ? page.screenshot({
+ path: join(
+ shots,
+ `update-banner-moves-first-${name}-${theme}-${engine}.png`,
+ ),
+ clip: {
+ x: 0,
+ y: 0,
+ width: DEFAULT_WIDTH,
+ height: before.below + 48,
+ },
+ })
+ : undefined;
+ if (shots) mkdirSync(shots, { recursive: true });
+ await shot("before");
+ await update.click();
+ // The app's dialog is up and its call hasn't answered; the poll asks again meanwhile.
+ await page.waitForTimeout(700);
+ await shot("asking");
+ expect(await update.isVisible()).toBe(true);
+ expect(
+ await page.getByText("Downloading", { exact: false }).count(),
+ ).toBe(0);
+ expect(await measured(page)).toEqual(before);
+ } finally {
+ await page.close();
+ }
+ }
+ }, 60_000);
+
test.skipIf(!shots)(
"screenshots at the default window",
async () => {
diff --git a/app/tests/update-banner.test.tsx b/app/tests/update-banner.test.tsx
index 3d6580d8e5..975b00c85d 100644
--- a/app/tests/update-banner.test.tsx
+++ b/app/tests/update-banner.test.tsx
@@ -37,6 +37,8 @@ let fetches: string[];
let refuseOffer: string | null;
let installFailure: string | null;
let installRelease: (() => void) | null;
+/** Set while the shell's own dialog asks to move to Applications: the person's Not now. */
+let notNow: ((said: string) => void) | null;
const originalFetch = globalThis.fetch;
/** The shell's plugin commands, as desktop_page.rs answers them. */
@@ -53,6 +55,13 @@ async function shellInvoke(command: string, args?: Record) {
}
if (command === "plugin:openbot-desktop|install_update") {
if (installFailure) throw installFailure;
+ // Open from its disk image, the shell asks to move first in its own dialog, and answers only
+ // once the person has: Not now refuses with its sentence.
+ if (offer.movesFirst) {
+ await new Promise((_, reject) => {
+ notNow = reject;
+ });
+ }
// On success the app restarts and the call never answers.
await new Promise((resolve) => {
installRelease = resolve;
@@ -76,6 +85,7 @@ beforeEach(() => {
refuseOffer = null;
installFailure = null;
installRelease = null;
+ notNow = null;
offer = { version: "0.3.2", current: "0.3.1", installing: null };
globalThis.fetch = Object.assign(
async (input: RequestInfo | URL) => {
@@ -214,6 +224,34 @@ test("Update and restart asks the shell, then shows its progress in place of the
);
});
+/**
+ * Found on the Mac with OpenBot open from its disk image: Update and restart showed the app's
+ * "Move OpenBot to Applications" dialog, and behind it the banner already said "Downloading…",
+ * though nothing downloads until OpenBot has moved. Not now then said "Couldn't install the update"
+ * of the person's own choice. The banner stays as it was while the app asks, as an app's window
+ * does while LetsMove or Electron's move to Applications asks, and Not now leaves it so.
+ */
+test("open from its disk image, the banner keeps Update and restart while the app asks to move, and Not now leaves it as it was", async () => {
+ inDesktop();
+ offer = { ...offer, movesFirst: true };
+ const view = show();
+ fireEvent.click(
+ await view.findByRole("button", { name: "Update and restart" }),
+ );
+ // The app's dialog is up: the shell has the call and hasn't answered.
+ await waitFor(() => expect(notNow).not.toBeNull());
+ await queryClient.refetchQueries();
+ expect(view.queryByRole("status")).toBeNull();
+ expect(view.getByRole("button", { name: "Update and restart" })).toBeTruthy();
+ expect(view.getByRole("button", { name: "Dismiss" })).toBeTruthy();
+
+ notNow?.("OpenBot has to be in Applications to update.");
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ expect(view.queryByRole("alert")).toBeNull();
+ expect(view.queryByRole("status")).toBeNull();
+ expect(view.getByRole("button", { name: "Update and restart" })).toBeTruthy();
+});
+
test("an install that fails says why and offers it again", async () => {
inDesktop();
installFailure = "signature verification failed";
diff --git a/desktop/src-tauri/src/app_update.rs b/desktop/src-tauri/src/app_update.rs
index 43e9c30c49..e6f5845242 100644
--- a/desktop/src-tauri/src/app_update.rs
+++ b/desktop/src-tauri/src/app_update.rs
@@ -622,6 +622,11 @@ pub struct Status {
pub updates_itself: bool,
/// How ready the offered version is to install (`Readiness`), when OpenBot has started on it.
pub ready: Option,
+ /// Whether Update and restart asks to move to Applications first, in a native dialog
+ /// (`app_location`): OpenBot is open from its disk image or a translocated copy. Until the
+ /// person moves it nothing downloads, so a page keeps Update and restart as it was, and the
+ /// dialog says how it went.
+ pub moves_first: bool,
}
/// What to offer, given what the feed said and what this person closed.
@@ -638,6 +643,7 @@ pub fn status(
current: &Version,
config: Option<&Path>,
updates_itself: bool,
+ moves_first: bool,
) -> Status {
let installing = known.installing.lock().unwrap().clone();
let newer = known.newer();
@@ -653,6 +659,7 @@ pub fn status(
current: current.to_string(),
installing,
updates_itself,
+ moves_first,
}
}
@@ -1097,7 +1104,7 @@ mod tests {
let config = crate::test_support::temp_root("app-update-dismissed");
let known = Known::default();
known.record(&Ok(Some(v("0.3.2"))));
- let shown = |known: &Known| status(known, &v("0.3.1"), Some(&config), true).version;
+ let shown = |known: &Known| status(known, &v("0.3.1"), Some(&config), true, false).version;
assert_eq!(shown(&known).as_deref(), Some("0.3.2"));
dismiss(&config, &v("0.3.2")).unwrap();
@@ -1171,7 +1178,7 @@ mod tests {
known.begin_install();
known.downloaded(50, Some(200));
known.downloaded(50, None);
- let shown = status(&known, &v("0.3.1"), Some(&config), true);
+ let shown = status(&known, &v("0.3.1"), Some(&config), true, false);
assert_eq!(shown.version.as_deref(), Some("0.3.2"));
assert_eq!(
shown.installing,
@@ -1182,12 +1189,12 @@ mod tests {
})
);
known.restarting();
- assert!(status(&known, &v("0.3.1"), Some(&config), true)
+ assert!(status(&known, &v("0.3.1"), Some(&config), true, false)
.installing
.is_some_and(|i| i.restarting));
known.end_install();
assert_eq!(
- status(&known, &v("0.3.1"), Some(&config), true).version,
+ status(&known, &v("0.3.1"), Some(&config), true, false).version,
None
);
let _ = std::fs::remove_dir_all(&config);
@@ -1199,7 +1206,7 @@ mod tests {
fn the_offer_says_how_ready_the_offered_version_is() {
let known = Known::default();
known.record(&Ok(Some(v("0.3.2"))));
- assert_eq!(status(&known, &v("0.3.1"), None, true).ready, None);
+ assert_eq!(status(&known, &v("0.3.1"), None, true, false).ready, None);
known.readying(
&v("0.3.2"),
Readiness::Preparing {
@@ -1207,7 +1214,7 @@ mod tests {
total: 100,
},
);
- let shown = status(&known, &v("0.3.1"), None, true);
+ let shown = status(&known, &v("0.3.1"), None, true, false);
assert_eq!(
shown.ready,
Some(Readiness::Preparing {
@@ -1221,11 +1228,11 @@ mod tests {
);
known.readying(&v("0.3.2"), Readiness::Ready);
assert_eq!(
- serde_json::to_value(status(&known, &v("0.3.1"), None, true)).unwrap()["ready"],
+ serde_json::to_value(status(&known, &v("0.3.1"), None, true, false)).unwrap()["ready"],
serde_json::json!({"state": "ready"})
);
known.record(&Ok(Some(v("0.3.3"))));
- assert_eq!(status(&known, &v("0.3.1"), None, true).ready, None);
+ assert_eq!(status(&known, &v("0.3.1"), None, true, false).ready, None);
known.not_ready();
assert_eq!(known.readiness(&v("0.3.2")), None);
}
@@ -1421,7 +1428,7 @@ mod tests {
assert_eq!(known.newer(), Some(v("0.3.3")));
// The banner still keeps the person's close.
assert_eq!(
- status(&known, &v("0.3.2"), Some(&config), true).version,
+ status(&known, &v("0.3.2"), Some(&config), true, false).version,
None
);
let _ = std::fs::remove_dir_all(&config);
@@ -1450,7 +1457,7 @@ mod tests {
#[test]
fn the_status_says_whether_this_build_updates_itself() {
let internal = v("0.3.2-internal.731.gabc1234");
- let fixed = status(&Known::default(), &internal, None, false);
+ let fixed = status(&Known::default(), &internal, None, false, false);
assert_eq!(
serde_json::to_value(&fixed).unwrap(),
serde_json::json!({
@@ -1459,13 +1466,20 @@ mod tests {
"installing": null,
"updatesItself": false,
"ready": null,
+ "movesFirst": false,
})
);
- let release = status(&Known::default(), &v("0.3.2"), None, true);
+ let release = status(&Known::default(), &v("0.3.2"), None, true, false);
assert_eq!(
serde_json::to_value(&release).unwrap()["updatesItself"],
serde_json::json!(true)
);
+ // Open from its disk image, Update and restart asks to move to Applications first.
+ let on_image = status(&Known::default(), &v("0.3.2"), None, true, true);
+ assert_eq!(
+ serde_json::to_value(&on_image).unwrap()["movesFirst"],
+ serde_json::json!(true)
+ );
}
/// A feed that can't be read is said to whoever asked, and the last good answer stands.
diff --git a/desktop/src-tauri/src/desktop_page.rs b/desktop/src-tauri/src/desktop_page.rs
index ccd2eb1a97..02ece9b08a 100644
--- a/desktop/src-tauri/src/desktop_page.rs
+++ b/desktop/src-tauri/src/desktop_page.rs
@@ -375,7 +375,7 @@ async fn intelligence(
/// The update banner: a newer OpenBot Desktop, as the shell last read its update feed, unless
/// this person closed it. Answered from memory; the page never reaches the feed itself.
#[tauri::command]
-async fn update_offer(app: tauri::AppHandle) -> app_update::Status {
+pub async fn update_offer(app: tauri::AppHandle) -> app_update::Status {
crate::app_update_status(&app)
}
@@ -393,10 +393,12 @@ async fn dismiss_update(app: tauri::AppHandle, version: String) -> Result<(), St
crate::dismiss_app_update_for(&app, &version).map_err(|problem| problem.said)
}
-/// The banner's Update and restart. Returns only when it failed: on success the app restarts.
+/// Update and restart in the banner, Settings > This computer and the gate for an OpenBot that needs
+/// a newer app. Returns only when it did not install: on success the app restarts. Open from its
+/// disk image, OpenBot asks to move to Applications first (`update_or_move`).
#[tauri::command]
-async fn install_update(app: tauri::AppHandle) -> Result<(), String> {
- crate::install_app_update_now(app)
+pub async fn install_update(app: tauri::AppHandle) -> Result<(), String> {
+ crate::update_or_move(app)
.await
.map_err(|problem| problem.said)
}
diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs
index 7c1229abaf..0281c1d855 100644
--- a/desktop/src-tauri/src/main.rs
+++ b/desktop/src-tauri/src/main.rs
@@ -48,12 +48,25 @@ use serde::{Deserialize, Serialize};
use tauri::{Emitter, Manager};
/// What the shell is running, so the window and the tray say the same thing.
+/// A test's answer to one of the shell's native dialogs: whether the first button was chosen.
+#[cfg(test)]
+type AnswerPrompt = Box bool + Send>;
+
#[derive(Default)]
struct Shell {
/// An upgrade, or the app updating itself, excludes ordinary Start/Repair without replacing
/// the supervisor.
updating: std::sync::atomic::AtomicBool,
update_cancelled: std::sync::atomic::AtomicBool,
+ /// The offer to move to Applications is on screen, or the move it started is under way
+ /// (`offer_move_for_update`): a second Update and restart meanwhile asks nothing more.
+ asking_to_move: std::sync::atomic::AtomicBool,
+ /// Where a test says this app runs from, in place of `std::env::current_exe` (`this_app_place`).
+ #[cfg(test)]
+ place_for_test: Mutex