diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx index 0f751bc52aef6..d908ee2b385a5 100644 --- a/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx +++ b/apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx @@ -11,8 +11,15 @@ const mocks = vi.hoisted(() => { const listeners = new Set<() => void>(); return { update: null as DesktopUpdateState | null, - hasUpdates: false, - rows: [] as ReadonlyArray, + isElectron: true, + everything: { + hasUpdates: false, + summary: "Update everything", + version: null, + providerCount: 0, + rows: [] as ReadonlyArray, + restarts: [], + }, subscribe: (listener: () => void) => { listeners.add(listener); return () => listeners.delete(listener); @@ -30,20 +37,18 @@ vi.mock("../../state/desktopUpdate", async (importOriginal) => ({ () => mocks.update, ), })); -// The pill only renders in the desktop app. vi.mock("../../env", async (importOriginal) => ({ ...(await importOriginal()), - isElectron: true, + get isElectron() { + return mocks.isElectron; + }, })); -vi.mock("./useUpdateEverything", () => ({ - useUpdateEverything: () => ({ - hasUpdates: mocks.hasUpdates, - summary: "Update everything", - version: null, - providerCount: 0, - rows: mocks.rows, - restarts: [], - }), +vi.mock("./useUpdateEverything", async () => ({ + useUpdateEverything: (await import("react")).useSyncExternalStore.bind( + null, + mocks.subscribe, + () => mocks.everything, + ), })); function nightlyUpdate(releaseNotes: DesktopUpdateState["releaseNotes"]): DesktopUpdateState { @@ -76,11 +81,12 @@ function setup( { hasUpdates = false, rows = [], - }: { hasUpdates?: boolean; rows?: ReadonlyArray } = {}, + isElectron = true, + }: { hasUpdates?: boolean; rows?: ReadonlyArray; isElectron?: boolean } = {}, ) { mocks.update = update; - mocks.hasUpdates = hasUpdates; - mocks.rows = rows; + mocks.isElectron = isElectron; + mocks.everything = { ...mocks.everything, hasUpdates, rows }; } function publish(update: DesktopUpdateState | null) { @@ -90,6 +96,14 @@ function publish(update: DesktopUpdateState | null) { }); } +const LAPTOP_CODEX: UpdateEverythingRow = { + environmentId: null, + label: "Laptop", + app: null, + skipped: null, + providers: ["Codex"], +}; + const releaseNotes = () => document.querySelector('[aria-label="Update release notes"]'); describe("SidebarUpdatePill release notes", () => { @@ -127,7 +141,7 @@ describe("SidebarUpdatePill release notes", () => { describe("SidebarUpdatePill update everything", () => { it("does not refocus the update button after a pointer cancel", async () => { - setup(null, { hasUpdates: true }); + setup(null, { hasUpdates: true, rows: [LAPTOP_CODEX] }); await using screen = await render(); const button = screen.getByRole("button", { name: "Update everything" }); await userEvent.click(button); @@ -140,7 +154,7 @@ describe("SidebarUpdatePill update everything", () => { }); it("returns focus to the update button after Escape", async () => { - setup(null, { hasUpdates: true }); + setup(null, { hasUpdates: true, rows: [LAPTOP_CODEX] }); await using screen = await render(); const button = screen.getByRole("button", { name: "Update everything" }); await userEvent.click(button); @@ -167,4 +181,23 @@ describe("SidebarUpdatePill update everything", () => { await expect.element(row.getByRole("cell", { name: label, exact: true })).toBeVisible(); await expect.element(row.getByRole("cell", { name: "Claude", exact: true })).toBeVisible(); }); + + it("keeps an open dialog on web when the updates finish and the pill hides", async () => { + setup(null, { hasUpdates: true, rows: [LAPTOP_CODEX], isElectron: false }); + await using screen = await render(); + await userEvent.click(screen.getByRole("button", { name: "Update everything" })); + await expect.element(page.getByRole("button", { name: "Update", exact: true })).toBeVisible(); + + await act(() => { + mocks.everything = { ...mocks.everything, hasUpdates: false, rows: [] }; + mocks.notify(); + }); + await expect + .element(screen.getByRole("button", { name: "Update everything" })) + .not.toBeInTheDocument(); + const dialog = page.getByRole("alertdialog"); + await expect.element(dialog.getByText("Everything is up to date")).toBeVisible(); + await userEvent.click(dialog.getByRole("button", { name: "Close" })); + await vi.waitFor(() => expect(document.querySelector('[role="alertdialog"]')).toBeNull()); + }); }); diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx index 71fce36f3ed43..78284ab509f80 100644 --- a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx +++ b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx @@ -3,7 +3,7 @@ import { managedUpdatesDenial } from "@t3tools/client-runtime/contract-labels"; import { type DesktopBridge, type DesktopUpdateState } from "@t3tools/contracts"; import { TriangleAlertIcon } from "lucide-react"; import { msg, T, useGT, useMessages } from "gt-react"; -import { type ComponentProps, useId, useRef, useState } from "react"; +import { type ComponentProps, type ReactNode, useId, useRef, useState } from "react"; import { flushSync } from "react-dom"; import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime"; import { isElectron } from "../../env"; @@ -409,8 +409,6 @@ function SidebarUpdateControl() { ); }; - if (!isElectron && !runsEverything && !isRunningEverything) return null; - const statusIcon = ( void runEverything()} /> ); + // Every path renders the same [pill, dialog] shape, so an open dialog outlives a hidden pill. + const withDialog = (pill: ReactNode) => ( + <> + {pill} + {confirmDialog} + + ); + if (!isElectron && !runsEverything && !isRunningEverything) return withDialog(null); if (run !== null) { const local: UpdateRunLocalState = @@ -440,7 +446,7 @@ function SidebarUpdateControl() { : state?.status === "downloading" ? { status: "downloading", percent: state.downloadPercent } : { status: "waiting" }; - return ( + return withDialog( - {confirmDialog} - + , ); } @@ -519,7 +524,7 @@ function SidebarUpdateControl() { ); - return ( + return withDialog( ) : null} - {confirmDialog} - + , ); } diff --git a/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx b/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx index 048aa54ae620a..c4eba5059f1ce 100644 --- a/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx +++ b/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx @@ -129,32 +129,51 @@ function UpdateEverythingDialogContent({ const restarting = new Set(restarts.map((machine) => machine.environmentId)); const updating = rows.filter((row) => row.app !== null || row.providers.length > 0); const skipped = rows.filter((row) => row.skipped !== null); + // Updates can finish elsewhere while this is open. A track switch with no rows still saves the track. + const empty = title === undefined && updating.length === 0; return ( <> - {title ?? - gt("{count, plural, one {Update {count} machine?} other {Update {count} machines?}}", { - count: updating.length, - })} + {empty + ? checking + ? gt("Checking for updates…") + : skipped.length > 0 + ? gt("Nothing to update right now") + : gt("Everything is up to date") + : (title ?? + gt( + "{count, plural, one {Update {count} machine?} other {Update {count} machines?}}", + { + count: updating.length, + }, + ))} - {version !== null ? ( + {empty ? ( + checking || skipped.length > 0 ? null : ( + gt("Nothing is left to update.") + ) + ) : ( <> - T3 Code {version} + {version !== null ? ( + <> + T3 Code {version} + + ) : null} + {version !== null && providerCount > 0 ? " · " : null} + {providerCount > 0 + ? gt( + "{count, plural, one {{count} provider update} other {{count} provider updates}}", + { count: providerCount }, + ) + : null} + {checking + ? `${version !== null || providerCount > 0 ? " · " : ""}${gt("Checking for more…")}` + : null} - ) : null} - {version !== null && providerCount > 0 ? " · " : null} - {providerCount > 0 - ? gt( - "{count, plural, one {{count} provider update} other {{count} provider updates}}", - { count: providerCount }, - ) - : null} - {checking - ? `${version !== null || providerCount > 0 ? " · " : ""}${gt("Checking for more…")}` - : null} + )} @@ -164,63 +183,65 @@ function UpdateEverythingDialogContent({ {note}

))} - {/* Machine names truncate first. Provider lists wrap between names, never inside one. */} -
+ {empty ? null : ( + // Machine names truncate first. Provider lists wrap between names, never inside one.
- - Machine - - T3 Code - - Providers - - -
- {updating.map((row) => (
- - {row.label} - - - - {row.app !== null ? m(APP_LABELS[row.app]) : null} - {row.app === null && row.skipped !== null ? ( - - Skipped - - ) : null} - {row.app === "this-app" ? ( - - restarts last - - ) : null} - - - {row.providers.map((provider, index) => ( - - {provider} - {index < row.providers.length - 1 ? ", " : null} - - ))} + + Machine - - {row.environmentId !== null && restarting.has(row.environmentId) ? ( - - ) : null} + T3 Code + + Providers +
- ))} -
+ {updating.map((row) => ( +
+ + {row.label} + + + + {row.app !== null ? m(APP_LABELS[row.app]) : null} + {row.app === null && row.skipped !== null ? ( + + Skipped + + ) : null} + {row.app === "this-app" ? ( + + restarts last + + ) : null} + + + {row.providers.map((provider, index) => ( + + {provider} + {index < row.providers.length - 1 ? ", " : null} + + ))} + + + {row.environmentId !== null && restarting.has(row.environmentId) ? ( + + ) : null} + +
+ ))} + + )} {skipped.length > 0 ? ( @@ -272,11 +293,13 @@ function UpdateEverythingDialogContent({

) : null} }> - Cancel + {empty ? Close : Cancel} - + {empty ? null : ( + + )} ); diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 08294d6583996..38386ea538672 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -11975,7 +11975,10 @@ } ], "e7f35f60e6229cf5": "Desktop-App", + "8907bc7124be3655": "Gerade gibt es nichts zu aktualisieren", + "e2b6767a6f691040": "Alles ist auf dem neuesten Stand", "77be1b7e2a1d3d31": "{count, plural, one {{count} Rechner aktualisieren?} other {{count} Rechner aktualisieren?}}", + "f2008fcdc60c6cdf": "Es gibt nichts mehr zu aktualisieren.", "e4892b21e88abb60": "{count, plural, one {{count} Anbieter-Update} other {{count} Anbieter-Updates}}", "36d530903a763a14": "Suche nach weiteren…", "f34dd019e6000fe3": "{count, plural, one {{count} übersprungen} other {{count} übersprungen}}", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index 490aab5d7897a..711ad377da435 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -11983,7 +11983,10 @@ } ], "e7f35f60e6229cf5": "Desktop app", + "8907bc7124be3655": "Nothing to update right now", + "e2b6767a6f691040": "Everything is up to date", "77be1b7e2a1d3d31": "{count, plural, one {Update {count} machine?} other {Update {count} machines?}}", + "f2008fcdc60c6cdf": "Nothing is left to update.", "e4892b21e88abb60": "{count, plural, one {{count} provider update} other {{count} provider updates}}", "36d530903a763a14": "Checking for more…", "f34dd019e6000fe3": "{count, plural, one {{count} skipped} other {{count} skipped}}", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index d09c34ee915e3..4894b97d92eae 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -11968,7 +11968,10 @@ } ], "e7f35f60e6229cf5": "App de escritorio", + "8907bc7124be3655": "No hay nada que actualizar ahora mismo", + "e2b6767a6f691040": "Todo está actualizado", "77be1b7e2a1d3d31": "{count, plural, one {¿Actualizar {count} máquina?} other {¿Actualizar {count} máquinas?}}", + "f2008fcdc60c6cdf": "No queda nada por actualizar.", "e4892b21e88abb60": "{count, plural, one {{count} actualización de proveedor} other {{count} actualizaciones de proveedores}}", "36d530903a763a14": "Buscando más…", "f34dd019e6000fe3": "{count, plural, one {{count} omitido} other {{count} omitidos}}", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 496a0075ce751..0c8b2ea49aaa7 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -11973,7 +11973,10 @@ } ], "e7f35f60e6229cf5": "App de bureau", + "8907bc7124be3655": "Rien à mettre à jour pour le moment", + "e2b6767a6f691040": "Tout est à jour", "77be1b7e2a1d3d31": "{count, plural, one {Mettre à jour {count} machine ?} other {Mettre à jour {count} machines ?}}", + "f2008fcdc60c6cdf": "Il ne reste rien à mettre à jour.", "e4892b21e88abb60": "{count, plural, one {{count} mise à jour de fournisseur} other {{count} mises à jour de fournisseurs}}", "36d530903a763a14": "Recherche d’autres…", "f34dd019e6000fe3": "{count, plural, one {{count} ignoré} other {{count} ignorés}}", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index c6295db2ad24e..ea251a879e82e 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -11923,7 +11923,10 @@ " の変更内容" ], "e7f35f60e6229cf5": "デスクトップアプリ", + "8907bc7124be3655": "今は更新するものがありません", + "e2b6767a6f691040": "すべて最新です", "77be1b7e2a1d3d31": "{count, plural, other {{count} 台のマシンを更新しますか?}}", + "f2008fcdc60c6cdf": "更新が必要なものは残っていません。", "e4892b21e88abb60": "{count, plural, other {{count} 件のプロバイダーの更新}}", "36d530903a763a14": "さらに確認しています…", "f34dd019e6000fe3": "{count, plural, other {{count} 件をスキップ}}", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index 84311b25cd463..feaa22889c5dd 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -11920,7 +11920,10 @@ "의 변경 사항" ], "e7f35f60e6229cf5": "데스크톱 앱", + "8907bc7124be3655": "지금은 업데이트할 항목이 없습니다", + "e2b6767a6f691040": "모두 최신 상태입니다", "77be1b7e2a1d3d31": "{count, plural, other {머신 {count}대를 업데이트할까요?}}", + "f2008fcdc60c6cdf": "더 이상 업데이트할 항목이 없습니다.", "e4892b21e88abb60": "{count, plural, other {제공자 업데이트 {count}개}}", "36d530903a763a14": "추가 확인 중…", "f34dd019e6000fe3": "{count, plural, other {{count}개 건너뜀}}", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index 0a566f1e7c18a..81807e03a6994 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -11972,7 +11972,10 @@ } ], "e7f35f60e6229cf5": "App desktop", + "8907bc7124be3655": "Nada para atualizar no momento", + "e2b6767a6f691040": "Tudo está atualizado", "77be1b7e2a1d3d31": "{count, plural, one {Atualizar {count} máquina?} other {Atualizar {count} máquinas?}}", + "f2008fcdc60c6cdf": "Não resta nada para atualizar.", "e4892b21e88abb60": "{count, plural, one {{count} atualização de provedor} other {{count} atualizações de provedores}}", "36d530903a763a14": "Verificando mais…", "f34dd019e6000fe3": "{count, plural, one {{count} ignorada} other {{count} ignoradas}}", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index c948f268338ce..034299edd765c 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -11973,7 +11973,10 @@ } ], "e7f35f60e6229cf5": "Десктопное приложение", + "8907bc7124be3655": "Сейчас нечего обновлять", + "e2b6767a6f691040": "Всё обновлено", "77be1b7e2a1d3d31": "{count, plural, one {Обновить {count} машину?} few {Обновить {count} машины?} many {Обновить {count} машин?} other {Обновить {count} машины?}}", + "f2008fcdc60c6cdf": "Обновлять больше нечего.", "e4892b21e88abb60": "{count, plural, one {{count} обновление провайдера} few {{count} обновления провайдеров} many {{count} обновлений провайдеров} other {{count} обновления провайдеров}}", "36d530903a763a14": "Проверка дальше…", "f34dd019e6000fe3": "{count, plural, one {Пропущено: {count}} few {Пропущено: {count}} many {Пропущено: {count}} other {Пропущено: {count}}}", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index 9e631e68a8c0e..5f5ae0c24df0f 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -11981,7 +11981,10 @@ } ], "e7f35f60e6229cf5": "Skrivbordsapp", + "8907bc7124be3655": "Inget att uppdatera just nu", + "e2b6767a6f691040": "Allt är uppdaterat", "77be1b7e2a1d3d31": "{count, plural, one {Uppdatera {count} dator?} other {Uppdatera {count} datorer?}}", + "f2008fcdc60c6cdf": "Det finns inget kvar att uppdatera.", "e4892b21e88abb60": "{count, plural, one {{count} leverantörsuppdatering} other {{count} leverantörsuppdateringar}}", "36d530903a763a14": "Söker efter fler…", "f34dd019e6000fe3": "{count, plural, one {{count} hoppades över} other {{count} hoppades över}}", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index ac25c9237c4fe..d58841af52cc4 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -11998,7 +11998,10 @@ " 中的更改" ], "e7f35f60e6229cf5": "桌面应用", + "8907bc7124be3655": "目前没有可更新的内容", + "e2b6767a6f691040": "一切都是最新的", "77be1b7e2a1d3d31": "{count, plural, other {更新 {count} 台机器?}}", + "f2008fcdc60c6cdf": "没有需要更新的内容了。", "e4892b21e88abb60": "{count, plural, other {{count} 个提供方更新}}", "36d530903a763a14": "正在检查更多…", "f34dd019e6000fe3": "{count, plural, other {已跳过 {count} 个}}",