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) && (
Promise;
+ /** Set once Update and restart has reached the desktop app. */
+ __installAsked?: boolean;
__TAURI_INTERNALS__: unknown;
};
const page = window as unknown as Page;
@@ -30,6 +32,12 @@ page.__offer = {
page.__TAURI_INTERNALS__ = {
invoke: async (command: string) => {
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") {
+ page.__installAsked = true;
+ 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..fa9c38c27f 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,57 @@ 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 press has reached the app, whose dialog is up and hasn't answered. Then the banner
+ // reads the app's offer once more, as its poll does, and has drawn what that said.
+ await page.waitForFunction(
+ () =>
+ (window as unknown as { __installAsked?: boolean })
+ .__installAsked === true,
+ );
+ await show(page, offer, "is available");
+ 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_location.rs b/desktop/src-tauri/src/app_location.rs
index 9dcabc90c6..f709336273 100644
--- a/desktop/src-tauri/src/app_location.rs
+++ b/desktop/src-tauri/src/app_location.rs
@@ -492,33 +492,74 @@ mod tests {
app
}
+ /// One disk image at a time. `hdiutil create -srcfolder` attaches an image of its own while it
+ /// copies, and several at once from this suite's threads left one waiting for good (seen on
+ /// 2026-12-04: `hdiutil create` idle for 16 minutes with its image attached).
+ static ONE_IMAGE_AT_A_TIME: std::sync::Mutex<()> = std::sync::Mutex::new(());
+
+ /// `hdiutil` with `args`, given two minutes: one that takes longer is stopped and the test
+ /// fails, saying which, never left waiting.
+ fn hdiutil(args: &[&std::ffi::OsStr]) {
+ let mut running = std::process::Command::new("/usr/bin/hdiutil")
+ .args(args)
+ .spawn()
+ .unwrap();
+ let deadline = std::time::Instant::now() + std::time::Duration::from_secs(120);
+ loop {
+ if let Some(status) = running.try_wait().unwrap() {
+ assert!(status.success(), "hdiutil {args:?}: {status}");
+ return;
+ }
+ if std::time::Instant::now() > deadline {
+ let _ = running.kill();
+ let _ = running.wait();
+ panic!("hdiutil {args:?} took over two minutes");
+ }
+ std::thread::sleep(std::time::Duration::from_millis(50));
+ }
+ }
+
/// A real disk image holding `app`, mounted read-only as Finder mounts a downloaded one, and
/// ejected when the test ends.
struct DiskImage {
volume: PathBuf,
+ _one_at_a_time: std::sync::MutexGuard<'static, ()>,
}
impl DiskImage {
fn holding(scratch: &Path, app_folder: &Path) -> Self {
+ // A test that failed while holding it still lets the others make theirs.
+ let one_at_a_time = ONE_IMAGE_AT_A_TIME
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
let image = scratch.join("OpenBot.dmg");
- let made = std::process::Command::new("/usr/bin/hdiutil")
- .args(["create", "-quiet", "-fs", "HFS+", "-volname", "OpenBot"])
- .arg("-srcfolder")
- .arg(app_folder)
- .arg(&image)
- .status()
- .unwrap();
- assert!(made.success(), "hdiutil create");
let volume = scratch.join("mounted");
std::fs::create_dir_all(&volume).unwrap();
- let attached = std::process::Command::new("/usr/bin/hdiutil")
- .args(["attach", "-quiet", "-readonly", "-nobrowse", "-mountpoint"])
- .arg(&volume)
- .arg(&image)
- .status()
- .unwrap();
- assert!(attached.success(), "hdiutil attach");
- Self { volume }
+ let os = std::ffi::OsStr::new;
+ hdiutil(&[
+ os("create"),
+ os("-quiet"),
+ os("-fs"),
+ os("HFS+"),
+ os("-volname"),
+ os("OpenBot"),
+ os("-srcfolder"),
+ app_folder.as_os_str(),
+ image.as_os_str(),
+ ]);
+ hdiutil(&[
+ os("attach"),
+ os("-quiet"),
+ os("-readonly"),
+ os("-nobrowse"),
+ os("-mountpoint"),
+ volume.as_os_str(),
+ image.as_os_str(),
+ ]);
+ Self {
+ volume,
+ _one_at_a_time: one_at_a_time,
+ }
}
}
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..9924b0419f 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