From 2adbc173b142eeaa57e94a19d9fb39a141c9679e Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Sat, 12 Sep 2026 15:43:26 -0700 Subject: [PATCH 1/2] =?UTF-8?q?feat(desktop):=20"Relaunch=20now"=20on=20th?= =?UTF-8?q?e=20v1=E2=86=92v2=20flip=20notice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The flip lands on the next launch, and 227 people have completed the gate and are still on v1 waiting for one. The notice already says so; now it offers the relaunch. The button goes through the normal quit path (app.relaunch + quitApp) so cleanup and DB flushes run, unlike the unused restartApp which bypasses before-quit. "Later" keeps the old dismiss. Fires v1_flip_notice_relaunch so the funnel can count it. The card gets an optional primary action; the post-flip welcome card is unchanged. "Relaunch now" is translated in all 16 locales. Rebased on main after #7480, whose optInV2 pin holds the surface on v1 until relaunch; the relaunch is exactly that relaunch, so the two compose with no code change. The relaunched instance only dies in dev: electron-vite exits with the old Electron (ps.on('close', process.exit)), taking the renderer dev server with it, and the new instance's dev-only parent-exit poll quits it within a second. A production build relaunches, stays up, and lands on v2 with the welcome card. Claude-Session: https://claude.ai/code/session_016NkfQLLDdHvrPS1BRJtfhj Co-Authored-By: Claude Opus 5.5 --- .../src/lib/trpc/routers/settings/index.ts | 9 +- .../V1FlipNotice/V1FlipNotice.test.tsx | 99 +++++++++++++++++++ .../components/V1FlipNotice/V1FlipNotice.tsx | 14 ++- .../FlipNoticeCard/FlipNoticeCard.tsx | 20 +++- packages/i18n/locales/cs/messages.po | 3 + packages/i18n/locales/de/messages.po | 3 + packages/i18n/locales/en/messages.po | 3 + packages/i18n/locales/es/messages.po | 3 + packages/i18n/locales/fr/messages.po | 3 + packages/i18n/locales/id/messages.po | 3 + packages/i18n/locales/it/messages.po | 3 + packages/i18n/locales/ja/messages.po | 3 + packages/i18n/locales/ko/messages.po | 3 + packages/i18n/locales/nl/messages.po | 3 + packages/i18n/locales/pl/messages.po | 3 + packages/i18n/locales/pt-BR/messages.po | 3 + packages/i18n/locales/ru/messages.po | 3 + packages/i18n/locales/tr/messages.po | 3 + packages/i18n/locales/vi/messages.po | 3 + packages/i18n/locales/zh-CN/messages.po | 3 + packages/i18n/locales/zh-TW/messages.po | 3 + 21 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 apps/desktop/src/renderer/routes/_authenticated/components/V1FlipNotice/V1FlipNotice.test.tsx diff --git a/apps/desktop/src/lib/trpc/routers/settings/index.ts b/apps/desktop/src/lib/trpc/routers/settings/index.ts index ac43890cef5..b9c15720dc8 100644 --- a/apps/desktop/src/lib/trpc/routers/settings/index.ts +++ b/apps/desktop/src/lib/trpc/routers/settings/index.ts @@ -45,7 +45,7 @@ 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 { hasCustomRingtone } from "main/lib/custom-ringtones"; import { getHostServiceCoordinator } from "main/lib/host-service-coordinator"; import { applyAppLanguage, languageEvents } from "main/lib/language"; @@ -924,6 +924,13 @@ export const createSettingsRouter = () => { return { success: true }; }), + /** Relaunch through the normal quit path so cleanup and DB flushes run. */ + relaunchApp: publicProcedure.mutation(() => { + app.relaunch(); + quitApp(); + return { success: true }; + }), + getBranchPrefix: publicProcedure.query(() => { const row = getSettings(); return { 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 "重新啟動執行中的代理程式才能切換。" From c70f812e3c3006ffd79ad27be37932ce9e3b3dc6 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Sat, 26 Sep 2026 12:02:09 -0700 Subject: [PATCH 2/2] fix(desktop): Relaunch now installs a staged update instead of racing it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With an update downloaded, quitting hands the install to Squirrel.Mac (autoInstallOnAppQuit), and app.relaunch() started the old bundle in the same second. Reproduced with two locally signed builds and a localhost feed: the relaunched process came up as 1.30.2 about 1.3s before ShipIt finished swapping in 1.30.3 beneath it, then found 1.30.3 again, re-downloaded it and staged a second install for the next quit. Relaunch now routes through installUpdate() when an update is staged, so Squirrel restarts into the new version (1.30.3, "Updated: 1.30.2 → 1.30.3", no re-download). The quit still runs before-quit cleanup. With no staged update it relaunches as before. Co-Authored-By: Claude Opus 5.5 --- .../src/lib/trpc/routers/settings/index.ts | 10 ++++-- .../desktop/src/main/lib/relaunch-app.test.ts | 33 +++++++++++++++++++ apps/desktop/src/main/lib/relaunch-app.ts | 21 ++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 apps/desktop/src/main/lib/relaunch-app.test.ts create mode 100644 apps/desktop/src/main/lib/relaunch-app.ts diff --git a/apps/desktop/src/lib/trpc/routers/settings/index.ts b/apps/desktop/src/lib/trpc/routers/settings/index.ts index b9c15720dc8..c01d75bf5f4 100644 --- a/apps/desktop/src/lib/trpc/routers/settings/index.ts +++ b/apps/desktop/src/lib/trpc/routers/settings/index.ts @@ -46,10 +46,12 @@ import { observable } from "@trpc/server/observable"; import { app } from "electron"; import { env } from "main/env.main"; 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, @@ -926,8 +928,12 @@ export const createSettingsRouter = () => { /** Relaunch through the normal quit path so cleanup and DB flushes run. */ relaunchApp: publicProcedure.mutation(() => { - app.relaunch(); - quitApp(); + relaunchApp({ + isUpdateReadyToInstall, + installUpdate, + relaunch: () => app.relaunch(), + quit: quitApp, + }); return { success: true }; }), 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(); +}