diff --git a/apps/desktop/src/lib/trpc/routers/settings/index.ts b/apps/desktop/src/lib/trpc/routers/settings/index.ts
index ac43890cef5..c01d75bf5f4 100644
--- a/apps/desktop/src/lib/trpc/routers/settings/index.ts
+++ b/apps/desktop/src/lib/trpc/routers/settings/index.ts
@@ -45,11 +45,13 @@ import { TRPCError } from "@trpc/server";
import { observable } from "@trpc/server/observable";
import { app } from "electron";
import { env } from "main/env.main";
-import { exitImmediately } from "main/index";
+import { exitImmediately, quitApp } from "main/index";
+import { installUpdate, isUpdateReadyToInstall } from "main/lib/auto-updater";
import { hasCustomRingtone } from "main/lib/custom-ringtones";
import { getHostServiceCoordinator } from "main/lib/host-service-coordinator";
import { applyAppLanguage, languageEvents } from "main/lib/language";
import { localDb } from "main/lib/local-db";
+import { relaunchApp } from "main/lib/relaunch-app";
import {
DEFAULT_AUTO_APPLY_DEFAULT_PRESET,
DEFAULT_CONFIRM_ON_QUIT,
@@ -924,6 +926,17 @@ export const createSettingsRouter = () => {
return { success: true };
}),
+ /** Relaunch through the normal quit path so cleanup and DB flushes run. */
+ relaunchApp: publicProcedure.mutation(() => {
+ relaunchApp({
+ isUpdateReadyToInstall,
+ installUpdate,
+ relaunch: () => app.relaunch(),
+ quit: quitApp,
+ });
+ return { success: true };
+ }),
+
getBranchPrefix: publicProcedure.query(() => {
const row = getSettings();
return {
diff --git a/apps/desktop/src/main/lib/relaunch-app.test.ts b/apps/desktop/src/main/lib/relaunch-app.test.ts
new file mode 100644
index 00000000000..23c8ccd5169
--- /dev/null
+++ b/apps/desktop/src/main/lib/relaunch-app.test.ts
@@ -0,0 +1,33 @@
+import { describe, expect, mock, test } from "bun:test";
+import { type RelaunchAppDeps, relaunchApp } from "./relaunch-app";
+
+function createDeps(updateReady: boolean) {
+ const calls: string[] = [];
+ const deps: RelaunchAppDeps = {
+ isUpdateReadyToInstall: () => updateReady,
+ installUpdate: mock(() => calls.push("installUpdate")),
+ relaunch: mock(() => calls.push("relaunch")),
+ quit: mock(() => calls.push("quit")),
+ };
+ return { deps, calls };
+}
+
+describe("relaunchApp", () => {
+ test("without a staged update, relaunches and then quits through the normal path", () => {
+ const { deps, calls } = createDeps(false);
+
+ relaunchApp(deps);
+
+ expect(calls).toEqual(["relaunch", "quit"]);
+ });
+
+ test("with a staged update, hands off to the updater and never relaunches the old bundle", () => {
+ const { deps, calls } = createDeps(true);
+
+ relaunchApp(deps);
+
+ expect(calls).toEqual(["installUpdate"]);
+ expect(deps.relaunch).not.toHaveBeenCalled();
+ expect(deps.quit).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/desktop/src/main/lib/relaunch-app.ts b/apps/desktop/src/main/lib/relaunch-app.ts
new file mode 100644
index 00000000000..b9280cbf86c
--- /dev/null
+++ b/apps/desktop/src/main/lib/relaunch-app.ts
@@ -0,0 +1,21 @@
+export interface RelaunchAppDeps {
+ isUpdateReadyToInstall: () => boolean;
+ installUpdate: () => void;
+ relaunch: () => void;
+ quit: () => void;
+}
+
+/**
+ * With an update staged, Squirrel.Mac installs it once this process exits.
+ * `app.relaunch()` would start the old bundle in that same second, so the
+ * user comes back on the old version while ShipIt swaps the bundle beneath
+ * it. The updater's own install restarts into the new version instead.
+ */
+export function relaunchApp(deps: RelaunchAppDeps): void {
+ if (deps.isUpdateReadyToInstall()) {
+ deps.installUpdate();
+ return;
+ }
+ deps.relaunch();
+ deps.quit();
+}
diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.test.tsx b/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.test.tsx
new file mode 100644
index 00000000000..87167d76cb9
--- /dev/null
+++ b/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.test.tsx
@@ -0,0 +1,99 @@
+import { afterAll, afterEach, describe, expect, mock, test } from "bun:test";
+import { GlobalRegistrator } from "@happy-dom/global-registrator";
+
+// happy-dom for real clicks; unregister in afterAll so the shared mock
+// document used by the other renderer suites is restored (see Redirect.test).
+const alreadyRegistered = GlobalRegistrator.isRegistered;
+if (!alreadyRegistered) GlobalRegistrator.register();
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const ORG = "org-flip-notice";
+const tracked: string[] = [];
+let relaunchCalls = 0;
+
+mock.module("renderer/lib/analytics", () => ({
+ track: (event: string) => {
+ tracked.push(event);
+ },
+}));
+mock.module("renderer/lib/trpc-client", () => ({
+ electronTrpcClient: {
+ settings: {
+ relaunchApp: {
+ mutate: async () => {
+ relaunchCalls++;
+ return { success: true };
+ },
+ },
+ },
+ },
+}));
+const realAuthClient = await import("renderer/lib/auth-client");
+mock.module("renderer/lib/auth-client", () => ({
+ ...realAuthClient,
+ authClient: {
+ ...realAuthClient.authClient,
+ useSession: () => ({
+ data: { session: { activeOrganizationId: ORG }, user: {} },
+ }),
+ },
+}));
+// The card's cover shader needs WebGL; the notice's behaviour does not.
+mock.module("@paper-design/shaders-react", () => ({
+ Dithering: () => null,
+}));
+
+// Queries come from render(): the module-level `screen` binds document.body
+// at first import, which an earlier suite may have done against the shared
+// mock document rather than happy-dom.
+const { act, cleanup, fireEvent, render } = await import(
+ "@testing-library/react"
+);
+const { markV1MigrationComplete } = await import(
+ "renderer/lib/v1-migration/completion"
+);
+const { V1FlipNotice } = await import("./V1FlipNotice");
+
+afterEach(() => {
+ cleanup();
+ tracked.length = 0;
+ relaunchCalls = 0;
+});
+afterAll(async () => {
+ if (!alreadyRegistered) await GlobalRegistrator.unregister();
+});
+
+describe("V1FlipNotice", () => {
+ test("renders nothing until the org's migration completes", () => {
+ const { queryByText } = render();
+ expect(queryByText("A better Superset is ready")).toBeNull();
+ });
+
+ test("shows once complete; Relaunch now tracks and relaunches", async () => {
+ const { getByRole, getByText } = render();
+ await act(async () => {
+ markV1MigrationComplete(ORG);
+ });
+ expect(getByText("A better Superset is ready")).toBeTruthy();
+ expect(tracked).toContain("v1_flip_notice_shown");
+
+ fireEvent.click(getByRole("button", { name: "Relaunch now" }));
+ await act(async () => {});
+ expect(relaunchCalls).toBe(1);
+ expect(tracked).toContain("v1_flip_notice_relaunch");
+ expect(tracked).not.toContain("v1_flip_notice_dismissed");
+ });
+
+ test("Later dismisses without relaunching", async () => {
+ const { getByRole, queryByText } = render();
+ await act(async () => {
+ markV1MigrationComplete(ORG);
+ });
+ fireEvent.click(getByRole("button", { name: "Later" }));
+ expect(queryByText("A better Superset is ready")).toBeNull();
+ expect(tracked).toContain("v1_flip_notice_dismissed");
+ expect(relaunchCalls).toBe(0);
+ });
+});
diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.tsx b/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.tsx
index c41e70c20e8..d15486a0bca 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.tsx
@@ -3,6 +3,7 @@ import { useLingui as useTranslation } from "@lingui/react";
import { useEffect, useRef, useState } from "react";
import { track } from "renderer/lib/analytics";
import { authClient } from "renderer/lib/auth-client";
+import { electronTrpcClient } from "renderer/lib/trpc-client";
import {
isV1MigrationComplete,
V1_MIGRATION_COMPLETED_EVENT,
@@ -53,12 +54,23 @@ export function V1FlipNotice() {
setDismissed(true);
};
+ const relaunch = () => {
+ track("v1_flip_notice_relaunch");
+ electronTrpcClient.settings.relaunchApp.mutate().catch((err) => {
+ console.error("[v1-migration] relaunch failed", err);
+ });
+ };
+
return (
);
diff --git a/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/components/FlipNoticeCard/FlipNoticeCard.tsx b/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/components/FlipNoticeCard/FlipNoticeCard.tsx
index 58a0f848deb..2b28290044e 100644
--- a/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/components/FlipNoticeCard/FlipNoticeCard.tsx
+++ b/apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/components/FlipNoticeCard/FlipNoticeCard.tsx
@@ -18,6 +18,8 @@ interface FlipNoticeCardProps {
body: string;
/** Rendered as an amber callout row (WorkspaceHoverCard idiom). */
warning?: string;
+ /** Primary button; when present the dismiss cta renders as secondary. */
+ action?: { label: string; onClick: () => void };
ctaLabel: string;
onDismiss: () => void;
}
@@ -32,6 +34,7 @@ export function FlipNoticeCard({
title,
body,
warning,
+ action,
ctaLabel,
onDismiss,
}: FlipNoticeCardProps) {
@@ -74,9 +77,20 @@ export function FlipNoticeCard({
{warning}
) : null}
-
+
+ {action ? (
+
+ ) : null}
+
+
);
diff --git a/packages/i18n/locales/cs/messages.po b/packages/i18n/locales/cs/messages.po
index da10be44903..9db10ee4fd0 100644
--- a/packages/i18n/locales/cs/messages.po
+++ b/packages/i18n/locales/cs/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Související články"
msgid "Relative path copied"
msgstr "Relativní cesta zkopírována"
+msgid "Relaunch now"
+msgstr "Restartovat nyní"
+
msgid "Relaunch running agents to switch them."
msgstr "Běžící agenty přepnete jejich novým spuštěním."
diff --git a/packages/i18n/locales/de/messages.po b/packages/i18n/locales/de/messages.po
index 68cec77953c..9564a17d09d 100644
--- a/packages/i18n/locales/de/messages.po
+++ b/packages/i18n/locales/de/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Verwandte Beiträge"
msgid "Relative path copied"
msgstr "Relativer Pfad kopiert"
+msgid "Relaunch now"
+msgstr "Jetzt neu starten"
+
msgid "Relaunch running agents to switch them."
msgstr "Starte laufende Agenten neu, um sie umzustellen."
diff --git a/packages/i18n/locales/en/messages.po b/packages/i18n/locales/en/messages.po
index 8b5d9cdf9ed..6712e91b23d 100644
--- a/packages/i18n/locales/en/messages.po
+++ b/packages/i18n/locales/en/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Related Posts"
msgid "Relative path copied"
msgstr "Relative path copied"
+msgid "Relaunch now"
+msgstr "Relaunch now"
+
msgid "Relaunch running agents to switch them."
msgstr "Relaunch running agents to switch them."
diff --git a/packages/i18n/locales/es/messages.po b/packages/i18n/locales/es/messages.po
index a0b9b2da7c4..c3273d0aeb9 100644
--- a/packages/i18n/locales/es/messages.po
+++ b/packages/i18n/locales/es/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Publicaciones relacionadas"
msgid "Relative path copied"
msgstr "Ruta relativa copiada"
+msgid "Relaunch now"
+msgstr "Reiniciar ahora"
+
msgid "Relaunch running agents to switch them."
msgstr "Vuelve a lanzar los agentes en marcha para cambiarlos."
diff --git a/packages/i18n/locales/fr/messages.po b/packages/i18n/locales/fr/messages.po
index 7e599fc6631..fea932712c9 100644
--- a/packages/i18n/locales/fr/messages.po
+++ b/packages/i18n/locales/fr/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Articles liés"
msgid "Relative path copied"
msgstr "Chemin relatif copié"
+msgid "Relaunch now"
+msgstr "Redémarrer maintenant"
+
msgid "Relaunch running agents to switch them."
msgstr "Relancez les agents en cours pour les basculer."
diff --git a/packages/i18n/locales/id/messages.po b/packages/i18n/locales/id/messages.po
index 42fb0bbc8ad..7c128d9edda 100644
--- a/packages/i18n/locales/id/messages.po
+++ b/packages/i18n/locales/id/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Tulisan Terkait"
msgid "Relative path copied"
msgstr "Path relatif disalin"
+msgid "Relaunch now"
+msgstr "Mulai ulang sekarang"
+
msgid "Relaunch running agents to switch them."
msgstr "Jalankan ulang agen yang sedang berjalan untuk menggantinya."
diff --git a/packages/i18n/locales/it/messages.po b/packages/i18n/locales/it/messages.po
index 2607ce37663..4f1fbd29f5d 100644
--- a/packages/i18n/locales/it/messages.po
+++ b/packages/i18n/locales/it/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Post correlati"
msgid "Relative path copied"
msgstr "Percorso relativo copiato"
+msgid "Relaunch now"
+msgstr "Riavvia ora"
+
msgid "Relaunch running agents to switch them."
msgstr "Riavvia gli agenti in esecuzione per cambiarli."
diff --git a/packages/i18n/locales/ja/messages.po b/packages/i18n/locales/ja/messages.po
index 7a16227a8d6..4a1f97bfce8 100644
--- a/packages/i18n/locales/ja/messages.po
+++ b/packages/i18n/locales/ja/messages.po
@@ -11984,6 +11984,9 @@ msgstr "関連記事"
msgid "Relative path copied"
msgstr "相対パスをコピーしました"
+msgid "Relaunch now"
+msgstr "今すぐ再起動"
+
msgid "Relaunch running agents to switch them."
msgstr "実行中のエージェントを切り替えるには再起動してください。"
diff --git a/packages/i18n/locales/ko/messages.po b/packages/i18n/locales/ko/messages.po
index 3d3ab907aaf..e0f4001a1ab 100644
--- a/packages/i18n/locales/ko/messages.po
+++ b/packages/i18n/locales/ko/messages.po
@@ -11984,6 +11984,9 @@ msgstr "관련 게시물"
msgid "Relative path copied"
msgstr "상대 경로 복사됨"
+msgid "Relaunch now"
+msgstr "지금 다시 시작"
+
msgid "Relaunch running agents to switch them."
msgstr "실행 중인 에이전트는 다시 실행해야 바뀝니다."
diff --git a/packages/i18n/locales/nl/messages.po b/packages/i18n/locales/nl/messages.po
index 184d28085d0..bcc15b037fd 100644
--- a/packages/i18n/locales/nl/messages.po
+++ b/packages/i18n/locales/nl/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Gerelateerde berichten"
msgid "Relative path copied"
msgstr "Relatief pad gekopieerd"
+msgid "Relaunch now"
+msgstr "Nu opnieuw starten"
+
msgid "Relaunch running agents to switch them."
msgstr "Herstart draaiende agents om ze te wisselen."
diff --git a/packages/i18n/locales/pl/messages.po b/packages/i18n/locales/pl/messages.po
index 28f1276bd73..3e6cfb6d0e3 100644
--- a/packages/i18n/locales/pl/messages.po
+++ b/packages/i18n/locales/pl/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Powiązane wpisy"
msgid "Relative path copied"
msgstr "Skopiowano ścieżkę względną"
+msgid "Relaunch now"
+msgstr "Uruchom ponownie teraz"
+
msgid "Relaunch running agents to switch them."
msgstr "Uruchom ponownie działających agentów, aby ich przełączyć."
diff --git a/packages/i18n/locales/pt-BR/messages.po b/packages/i18n/locales/pt-BR/messages.po
index c693afdde51..7b0b46b4c4d 100644
--- a/packages/i18n/locales/pt-BR/messages.po
+++ b/packages/i18n/locales/pt-BR/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Posts relacionados"
msgid "Relative path copied"
msgstr "Caminho relativo copiado"
+msgid "Relaunch now"
+msgstr "Reiniciar agora"
+
msgid "Relaunch running agents to switch them."
msgstr "Reinicie os agentes em execução para trocar a conta deles."
diff --git a/packages/i18n/locales/ru/messages.po b/packages/i18n/locales/ru/messages.po
index 88f07c9515b..10c58bf63a2 100644
--- a/packages/i18n/locales/ru/messages.po
+++ b/packages/i18n/locales/ru/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Похожие посты"
msgid "Relative path copied"
msgstr "Относительный путь скопирован"
+msgid "Relaunch now"
+msgstr "Перезапустить сейчас"
+
msgid "Relaunch running agents to switch them."
msgstr "Перезапустите работающих агентов, чтобы переключить их."
diff --git a/packages/i18n/locales/tr/messages.po b/packages/i18n/locales/tr/messages.po
index c816f1fca41..60fb20500c4 100644
--- a/packages/i18n/locales/tr/messages.po
+++ b/packages/i18n/locales/tr/messages.po
@@ -11984,6 +11984,9 @@ msgstr "İlgili yazılar"
msgid "Relative path copied"
msgstr "Göreli yol kopyalandı"
+msgid "Relaunch now"
+msgstr "Şimdi yeniden başlat"
+
msgid "Relaunch running agents to switch them."
msgstr "Değiştirmek için çalışan ajanları yeniden başlatın."
diff --git a/packages/i18n/locales/vi/messages.po b/packages/i18n/locales/vi/messages.po
index d2ab486fa21..add4ebb268c 100644
--- a/packages/i18n/locales/vi/messages.po
+++ b/packages/i18n/locales/vi/messages.po
@@ -11984,6 +11984,9 @@ msgstr "Bài viết liên quan"
msgid "Relative path copied"
msgstr "Đã sao chép đường dẫn tương đối"
+msgid "Relaunch now"
+msgstr "Khởi động lại ngay"
+
msgid "Relaunch running agents to switch them."
msgstr "Hãy khởi chạy lại các agent đang chạy để đổi sang tài khoản này."
diff --git a/packages/i18n/locales/zh-CN/messages.po b/packages/i18n/locales/zh-CN/messages.po
index 5d1e2582c53..a552b01beaf 100644
--- a/packages/i18n/locales/zh-CN/messages.po
+++ b/packages/i18n/locales/zh-CN/messages.po
@@ -11984,6 +11984,9 @@ msgstr "相关文章"
msgid "Relative path copied"
msgstr "已复制相对路径"
+msgid "Relaunch now"
+msgstr "立即重启"
+
msgid "Relaunch running agents to switch them."
msgstr "重新启动运行中的智能体才能切换。"
diff --git a/packages/i18n/locales/zh-TW/messages.po b/packages/i18n/locales/zh-TW/messages.po
index 18c0d0857a5..e17420ab47f 100644
--- a/packages/i18n/locales/zh-TW/messages.po
+++ b/packages/i18n/locales/zh-TW/messages.po
@@ -11984,6 +11984,9 @@ msgstr "相關文章"
msgid "Relative path copied"
msgstr "已複製相對路徑"
+msgid "Relaunch now"
+msgstr "立即重啟"
+
msgid "Relaunch running agents to switch them."
msgstr "重新啟動執行中的代理程式才能切換。"