Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Fix desktop updates and version display across connection modes (#8315)

Anthony Stirling9c9a57f40c0b
diff --git a/frontend/editor/public/locales/en-GB/translation.toml b/frontend/editor/public/locales/en-GB/translation.toml
index ac8abb5e80..0f6109de55 100644
--- a/frontend/editor/public/locales/en-GB/translation.toml
+++ b/frontend/editor/public/locales/en-GB/translation.toml
@@ -11684,7 +11684,7 @@ updateBehaviorError = "Could not change update behaviour"
updateBehaviorErrorLocked = "This setting is locked by your administrator."
updateBehaviorLockedDescription = "Your administrator has configured how Stirling-PDF handles updates on this machine. Contact them to change this."
updateBehaviorSaved = "Update behaviour saved."
-versionMismatch = "Warning: A mismatch has been detected between the client version and the AppConfig version. Using different versions can lead to compatibility issues, errors, and security risks. Please ensure that server and client are using the same version."
+versionMismatch = "Your desktop application and server are running different versions. Update both to the same version to avoid compatibility issues."
viewDetails = "View Details"
[settings.general.versionInfo]
diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.toml
index 2016fab9fa..b819c53735 100644
--- a/frontend/editor/public/locales/en-US/translation.toml
+++ b/frontend/editor/public/locales/en-US/translation.toml
@@ -11832,7 +11832,7 @@ updateBehaviorError = "Could not change update behavior"
updateBehaviorErrorLocked = "This setting is locked by your administrator."
updateBehaviorLockedDescription = "Your administrator has configured how Stirling-PDF handles updates on this machine. Contact them to change this."
updateBehaviorSaved = "Update behavior saved."
-versionMismatch = "Warning: A mismatch has been detected between the client version and the AppConfig version. Using different versions can lead to compatibility issues, errors, and security risks. Please ensure that server and client are using the same version."
+versionMismatch = "Your desktop application and server are running different versions. Update both to the same version to avoid compatibility issues."
viewDetails = "View Details"
[settings.general.versionInfo]
diff --git a/frontend/editor/src/core/components/shared/config/configSections/preferences/SoftwareUpdatesCard.tsx b/frontend/editor/src/core/components/shared/config/configSections/preferences/SoftwareUpdatesCard.tsx
index 7c5aa9488b..4c6fc84096 100644
--- a/frontend/editor/src/core/components/shared/config/configSections/preferences/SoftwareUpdatesCard.tsx
+++ b/frontend/editor/src/core/components/shared/config/configSections/preferences/SoftwareUpdatesCard.tsx
@@ -10,6 +10,11 @@ import { updateService, UpdateSummary } from "@app/services/updateService";
import { useFrontendVersionInfo } from "@app/hooks/useFrontendVersionInfo";
import { Z_INDEX_OVER_CONFIG_MODAL } from "@app/styles/zIndex";
import type { SoftwareUpdatesCardProps } from "@app/components/shared/config/configSections/preferences/preferencesCardProps";
+import {
+ AppVersionLabel,
+ BackendVersionLabel,
+ VersionMismatchMessage,
+} from "@app/components/shared/config/configSections/preferences/VersionLabels";
/**
* Version information and the update check. The page decides whether this card
@@ -28,14 +33,13 @@ export function SoftwareUpdatesCard({
);
const [updateModalOpened, setUpdateModalOpened] = useState(false);
const [checkingUpdate, setCheckingUpdate] = useState(false);
- const { appVersion, mismatchVersion } = useFrontendVersionInfo(
- config?.appVersion,
- );
+ const { appVersion, backendVersion, mismatchVersion } =
+ useFrontendVersionInfo(config?.appVersion);
const frontendVersionLabel = appVersion ?? t("common.loading", "Loading..."); // null = loading, shown only when appVersion !== undefined
// The version update checks run against: the Tauri app version on desktop,
// falling back to the backend version.
- const currentVersion = appVersion ?? config?.appVersion ?? null;
+ const currentVersion = appVersion ?? backendVersion ?? null;
// Check for updates on mount. The card is not rendered at all when the update
// UI is hidden (SaaS build, managed-disabled desktop), so no call ever fires.
@@ -110,21 +114,14 @@ export function SoftwareUpdatesCard({
<Group justify="space-between" align="center">
<div>
<Text size="sm" c="dimmed">
- {t(
- "settings.general.updates.currentFrontendVersion",
- "Current Frontend Version",
- )}
- :{" "}
+ <AppVersionLabel />:{" "}
<Text component="span" fw={500}>
{frontendVersionLabel}
</Text>
</Text>
{mismatchVersion && (
<Text size="sm" c="var(--color-red-dark)" mt={4}>
- {t(
- "settings.general.updates.versionMismatch",
- "Warning: A mismatch has been detected between the client version and the AppConfig version. Using different versions can lead to compatibility issues, errors, and security risks. Please ensure that server and client are using the same version.",
- )}
+ <VersionMismatchMessage />
</Text>
)}
</div>
@@ -132,15 +129,11 @@ export function SoftwareUpdatesCard({
)}
<Group justify="space-between" align="center">
<div>
- {config?.appVersion && (
+ {backendVersion && (
<Text size="sm" c="dimmed">
- {t(
- "settings.general.updates.currentBackendVersion",
- "Current Backend Version",
- )}
- :{" "}
+ <BackendVersionLabel />:{" "}
<Text component="span" fw={500}>
- {config.appVersion}
+ {backendVersion}
</Text>
</Text>
)}
@@ -281,7 +274,7 @@ export function SoftwareUpdatesCard({
String(Date.now() + 24 * 60 * 60 * 1000),
);
}}
- currentVersion={appVersion ?? config?.appVersion ?? ""}
+ currentVersion={currentVersion ?? ""}
updateSummary={updateSummary}
machineInfo={{
machineType: config?.machineType ?? "unknown",
diff --git a/frontend/editor/src/core/components/shared/config/configSections/preferences/VersionLabels.tsx b/frontend/editor/src/core/components/shared/config/configSections/preferences/VersionLabels.tsx
new file mode 100644
index 0000000000..1177819e27
--- /dev/null
+++ b/frontend/editor/src/core/components/shared/config/configSections/preferences/VersionLabels.tsx
@@ -0,0 +1,25 @@
+import { useTranslation } from "react-i18next";
+
+export function AppVersionLabel() {
+ const { t } = useTranslation();
+ return t(
+ "settings.general.updates.currentFrontendVersion",
+ "Current Frontend Version",
+ );
+}
+
+export function BackendVersionLabel() {
+ const { t } = useTranslation();
+ return t(
+ "settings.general.updates.currentBackendVersion",
+ "Current Backend Version",
+ );
+}
+
+export function VersionMismatchMessage() {
+ const { t } = useTranslation();
+ return t(
+ "settings.general.updates.versionMismatch",
+ "Your application and server are running different versions. Update both to the same version to avoid compatibility issues.",
+ );
+}
diff --git a/frontend/editor/src/core/hooks/useFrontendVersionInfo.ts b/frontend/editor/src/core/hooks/useFrontendVersionInfo.ts
index 94cadc4cb0..40ea6ac301 100644
--- a/frontend/editor/src/core/hooks/useFrontendVersionInfo.ts
+++ b/frontend/editor/src/core/hooks/useFrontendVersionInfo.ts
@@ -1,10 +1,12 @@
export interface FrontendVersionInfo {
appVersion: string | null | undefined; // undefined = not applicable, null = loading, string = loaded
+ /** Backend version to display and compare, when relevant to this connection. */
+ backendVersion: string | undefined;
mismatchVersion: boolean;
}
export function useFrontendVersionInfo(
- _backendVersion: string | undefined,
+ backendVersion: string | undefined,
): FrontendVersionInfo {
- return { appVersion: undefined, mismatchVersion: false };
+ return { appVersion: undefined, backendVersion, mismatchVersion: false };
}
diff --git a/frontend/editor/src/desktop/components/shared/config/configSections/GeneralSection.test.tsx b/frontend/editor/src/desktop/components/shared/config/configSections/GeneralSection.test.tsx
new file mode 100644
index 0000000000..3e367a396f
--- /dev/null
+++ b/frontend/editor/src/desktop/components/shared/config/configSections/GeneralSection.test.tsx
@@ -0,0 +1,139 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { act, render, screen, waitFor } from "@testing-library/react";
+import { MantineProvider } from "@mantine/core";
+import GeneralSection from "@app/components/shared/config/configSections/GeneralSection";
+import { SoftwareUpdatesCard } from "@app/components/shared/config/configSections/preferences/SoftwareUpdatesCard";
+import type { PreferencesSectionProps } from "@app/components/shared/config/configSections/preferences/PreferencesSection";
+import {
+ desktopUpdateService,
+ type UpdateModeInfo,
+} from "@app/services/desktopUpdateService";
+import { updateService } from "@app/services/updateService";
+
+const { checkTauriUpdate } = vi.hoisted(() => ({
+ checkTauriUpdate: vi.fn().mockResolvedValue(false),
+}));
+
+vi.mock("@app/hooks/useDesktopInstall", () => ({
+ useDesktopInstall: () => ({
+ state: "idle",
+ progress: null,
+ errorMessage: null,
+ tauriInstallReady: false,
+ canInstall: null,
+ actions: { startInstall: vi.fn(), restartApp: vi.fn() },
+ checkTauriUpdate,
+ }),
+}));
+vi.mock("@app/services/desktopUpdateService", () => ({
+ desktopUpdateService: {
+ getUpdateModeInfo: vi.fn(),
+ setUpdateMode: vi.fn(),
+ },
+}));
+vi.mock(
+ "@core/components/shared/config/configSections/preferences/PreferencesSection",
+ () => ({
+ default: ({
+ hideUpdateSection,
+ desktopInstall,
+ desktopUpdateMode,
+ }: PreferencesSectionProps) =>
+ hideUpdateSection ? null : (
+ <SoftwareUpdatesCard
+ desktopInstall={desktopInstall}
+ desktopUpdateMode={desktopUpdateMode}
+ />
+ ),
+ }),
+);
+vi.mock(
+ "@app/components/shared/config/configSections/DefaultAppSettings",
+ () => ({
+ DefaultAppSettings: () => null,
+ }),
+);
+vi.mock("@app/contexts/AppConfigContext", () => ({
+ useAppConfig: () => ({ config: { appVersion: "3.0.1" } }),
+}));
+vi.mock("@tauri-apps/api/app", () => ({
+ getVersion: vi.fn().mockResolvedValue("3.0.1"),
+}));
+vi.mock("@app/hooks/useSaaSMode", () => ({ useSaaSMode: () => true }));
+vi.mock("@app/components/shared/UpdateModal", () => ({ default: () => null }));
+vi.mock("@app/ui/Icon", () => ({ Icon: () => null }));
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (_key: string, fallback: string) => fallback }),
+}));
+
+function renderSection() {
+ return render(
+ <MantineProvider>
+ <GeneralSection />
+ </MantineProvider>,
+ );
+}
+
+describe("desktop GeneralSection update policy", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ vi.spyOn(updateService, "getUpdateSummary").mockResolvedValue({
+ latest_version: "3.0.2",
+ max_priority: "normal",
+ any_breaking: false,
+ });
+ });
+
+ it("does not mount update controls or check updates before managed-disabled policy loads", async () => {
+ let resolvePolicy!: (info: UpdateModeInfo) => void;
+ vi.mocked(desktopUpdateService.getUpdateModeInfo).mockReturnValue(
+ new Promise<UpdateModeInfo>((resolve) => {
+ resolvePolicy = resolve;
+ }),
+ );
+
+ renderSection();
+
+ expect(
+ screen.queryByRole("button", { name: "Check for Updates" }),
+ ).not.toBeInTheDocument();
+ expect(updateService.getUpdateSummary).not.toHaveBeenCalled();
+ expect(checkTauriUpdate).not.toHaveBeenCalled();
+
+ await act(async () => {
+ resolvePolicy({ mode: "disabled", locked: true });
+ });
+
+ expect(
+ screen.queryByRole("button", { name: "Check for Updates" }),
+ ).not.toBeInTheDocument();
+ expect(screen.queryByLabelText("Update behavior")).not.toBeInTheDocument();
+ expect(updateService.getUpdateSummary).not.toHaveBeenCalled();
+ expect(checkTauriUpdate).not.toHaveBeenCalled();
+ });
+
+ it.each<UpdateModeInfo>([
+ { mode: "prompt", locked: false },
+ { mode: "auto", locked: true },
+ { mode: "disabled", locked: false },
+ ])(
+ "shows settings after $mode / locked=$locked policy loads",
+ async (info) => {
+ vi.mocked(desktopUpdateService.getUpdateModeInfo).mockResolvedValue(info);
+
+ renderSection();
+
+ expect(await screen.findByText("3.0.2")).toBeInTheDocument();
+ expect(updateService.getUpdateSummary).toHaveBeenCalled();
+ const control = screen.getByLabelText("Update behavior");
+ if (info.locked) expect(control).toBeDisabled();
+ else expect(control).toBeEnabled();
+
+ await waitFor(() => {
+ if (info.mode === "disabled")
+ expect(checkTauriUpdate).not.toHaveBeenCalled();
+ else expect(checkTauriUpdate).toHaveBeenCalledOnce();
+ });
+ },
+ );
+});
diff --git a/frontend/editor/src/desktop/components/shared/config/configSections/GeneralSection.tsx b/frontend/editor/src/desktop/components/shared/config/configSections/GeneralSection.tsx
index 4ca1e43b32..7791f6efe7 100644
--- a/frontend/editor/src/desktop/components/shared/config/configSections/GeneralSection.tsx
+++ b/frontend/editor/src/desktop/components/shared/config/configSections/GeneralSection.tsx
@@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next";
import PreferencesSection from "@core/components/shared/config/configSections/preferences/PreferencesSection";
import { DefaultAppSettings } from "@app/components/shared/config/configSections/DefaultAppSettings";
import { useDesktopInstall } from "@app/hooks/useDesktopInstall";
-import { useSaaSMode } from "@app/hooks/useSaaSMode";
import {
desktopUpdateService,
type UpdateMode,
@@ -28,19 +27,16 @@ interface GeneralSectionProps {
const GeneralSection: React.FC<GeneralSectionProps> = () => {
const { t } = useTranslation();
const install = useDesktopInstall();
- // In SaaS connection mode the cloud owns app versioning — hide the update
- // section (which also stops the core auto-check from firing).
- const isSaaSMode = useSaaSMode();
- const [updateModeInfo, setUpdateModeInfo] = useState<UpdateModeInfo>({
- mode: "prompt",
- locked: false,
- });
+ const [updateModeInfo, setUpdateModeInfo] = useState<UpdateModeInfo | null>(
+ null,
+ );
const [updateModeError, setUpdateModeError] = useState<string | null>(null);
- // Check for Tauri updater availability on mount
+ // Provisioning can prohibit update requests before Settings opens.
useEffect(() => {
+ if (!updateModeInfo || updateModeInfo.mode === "disabled") return;
void install.checkTauriUpdate();
- }, [install.checkTauriUpdate]);
+ }, [install.checkTauriUpdate, updateModeInfo]);
// Load the current update mode + lock status on mount. We intentionally
// re-fetch on every mount so that a provisioning file dropped while the
@@ -101,8 +97,9 @@ const GeneralSection: React.FC<GeneralSectionProps> = () => {
)}
<PreferencesSection
editorDefaultsSlot={<DefaultAppSettings />}
+ // Mounting the card starts its summary request, so policy must be known first.
hideUpdateSection={
- isSaaSMode ||
+ !updateModeInfo ||
(updateModeInfo.mode === "disabled" && updateModeInfo.locked)
}
desktopInstall={{
@@ -113,11 +110,15 @@ const GeneralSection: React.FC<GeneralSectionProps> = () => {
canInstall: install.canInstall,
actions: install.actions,
}}
- desktopUpdateMode={{
- mode: updateModeInfo.mode,
- locked: updateModeInfo.locked,
- onChange: handleUpdateModeChange,
- }}
+ desktopUpdateMode={
+ updateModeInfo
+ ? {
+ mode: updateModeInfo.mode,
+ locked: updateModeInfo.locked,
+ onChange: handleUpdateModeChange,
+ }
+ : undefined
+ }
/>
</Stack>
);
diff --git a/frontend/editor/src/desktop/components/shared/config/configSections/SoftwareUpdatesCard.test.tsx b/frontend/editor/src/desktop/components/shared/config/configSections/SoftwareUpdatesCard.test.tsx
new file mode 100644
index 0000000000..6cd21ed388
--- /dev/null
+++ b/frontend/editor/src/desktop/components/shared/config/configSections/SoftwareUpdatesCard.test.tsx
@@ -0,0 +1,124 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { render, screen, waitFor } from "@testing-library/react";
+import { MantineProvider } from "@mantine/core";
+import { getVersion } from "@tauri-apps/api/app";
+import { SoftwareUpdatesCard } from "@app/components/shared/config/configSections/preferences/SoftwareUpdatesCard";
+import { useSaaSMode } from "@app/hooks/useSaaSMode";
+import { updateService } from "@app/services/updateService";
+import { expectConsole } from "@app/tests/failOnConsole";
+
+vi.mock("@tauri-apps/api/app", () => ({ getVersion: vi.fn() }));
+vi.mock("@app/hooks/useSaaSMode", () => ({ useSaaSMode: vi.fn() }));
+vi.mock("@app/contexts/AppConfigContext", () => ({
+ useAppConfig: () => ({
+ config: {
+ appVersion: "2.9.0",
+ machineType: "Client-win",
+ activeSecurity: false,
+ license: "NORMAL",
+ },
+ }),
+}));
+vi.mock("@app/components/shared/UpdateModal", () => ({
+ default: () => null,
+}));
+vi.mock("@app/ui/Icon", () => ({ Icon: () => null }));
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (_key: string, fallback: string) => fallback }),
+}));
+
+function renderCard() {
+ return render(
+ <MantineProvider>
+ <SoftwareUpdatesCard
+ desktopUpdateMode={{ mode: "prompt", locked: false, onChange: vi.fn() }}
+ />
+ </MantineProvider>,
+ );
+}
+
+describe("desktop SoftwareUpdatesCard", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ vi.mocked(getVersion).mockResolvedValue("3.0.1");
+ vi.mocked(useSaaSMode).mockReturnValue(true);
+ vi.spyOn(updateService, "getUpdateSummary").mockResolvedValue({
+ latest_version: "3.0.2",
+ max_priority: "normal",
+ any_breaking: false,
+ });
+ });
+
+ it("shows app updates without backend information or mismatch warnings in SaaS mode", async () => {
+ renderCard();
+
+ expect(await screen.findByText("3.0.1")).toBeInTheDocument();
+ expect(screen.getByText(/Desktop Version/)).toBeInTheDocument();
+ expect(screen.queryByText(/Frontend Version/)).not.toBeInTheDocument();
+ expect(await screen.findByText("3.0.2")).toBeInTheDocument();
+ expect(screen.queryByText(/Server Version/)).not.toBeInTheDocument();
+ expect(screen.queryByText("2.9.0")).not.toBeInTheDocument();
+ expect(
+ screen.queryByText(/desktop application and server/),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.getByRole("button", { name: "Check for Updates" }),
+ ).toBeEnabled();
+ expect(screen.getByLabelText("Update behavior")).toBeEnabled();
+ expect(updateService.getUpdateSummary).toHaveBeenCalledWith("3.0.1", {
+ machineType: "Client-win",
+ activeSecurity: false,
+ licenseType: "NORMAL",
+ });
+ expect(updateService.getUpdateSummary).not.toHaveBeenCalledWith(
+ "2.9.0",
+ expect.anything(),
+ );
+ });
+
+ it("waits for the app version instead of checking the backend version in SaaS mode", () => {
+ vi.mocked(getVersion).mockReturnValue(new Promise<string>(() => {}));
+
+ renderCard();
+
+ expect(screen.getByText("Loading...")).toBeInTheDocument();
+ expect(
+ screen.getByRole("button", { name: "Check for Updates" }),
+ ).toBeDisabled();
+ expect(screen.queryByText(/Server Version/)).not.toBeInTheDocument();
+ expect(updateService.getUpdateSummary).not.toHaveBeenCalled();
+ });
+
+ it("keeps backend information outside SaaS mode and removes it when switching to SaaS", async () => {
+ vi.mocked(useSaaSMode).mockReturnValue(false);
+ expectConsole.warn(
+ /Mismatch between frontend version and AppConfig version/,
+ );
+
+ const { rerender } = renderCard();
+
+ expect(
+ await screen.findByText(/desktop application and server/),
+ ).toBeInTheDocument();
+ expect(screen.getByText("2.9.0")).toBeInTheDocument();
+ expect(screen.getByText(/Server Version/)).toBeInTheDocument();
+ expect(screen.queryByText(/AppConfig/)).not.toBeInTheDocument();
+ expect(
+ screen.queryByText(/Current Backend Version/),
+ ).not.toBeInTheDocument();
+ expect(screen.getByText(/Desktop Version/)).toBeInTheDocument();
+
+ vi.mocked(useSaaSMode).mockReturnValue(true);
+ rerender(
+ <MantineProvider>
+ <SoftwareUpdatesCard />
+ </MantineProvider>,
+ );
+
+ expect(screen.queryByText(/Server Version/)).not.toBeInTheDocument();
+ expect(
+ screen.queryByText(/desktop application and server/),
+ ).not.toBeInTheDocument();
+ await waitFor(() => expect(screen.getByText("3.0.2")).toBeInTheDocument());
+ });
+});
diff --git a/frontend/editor/src/desktop/components/shared/config/configSections/preferences/VersionLabels.tsx b/frontend/editor/src/desktop/components/shared/config/configSections/preferences/VersionLabels.tsx
new file mode 100644
index 0000000000..e9333e18c2
--- /dev/null
+++ b/frontend/editor/src/desktop/components/shared/config/configSections/preferences/VersionLabels.tsx
@@ -0,0 +1,19 @@
+import { useTranslation } from "react-i18next";
+
+export function AppVersionLabel() {
+ const { t } = useTranslation();
+ return t("settings.general.versionInfo.desktop", "Desktop Version");
+}
+
+export function BackendVersionLabel() {
+ const { t } = useTranslation();
+ return t("settings.general.versionInfo.server", "Server Version");
+}
+
+export function VersionMismatchMessage() {
+ const { t } = useTranslation();
+ return t(
+ "settings.general.updates.versionMismatch",
+ "Your desktop application and server are running different versions. Update both to the same version to avoid compatibility issues.",
+ );
+}
diff --git a/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.test.ts b/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.test.ts
index 241edbeee4..4308a9cfd1 100644
--- a/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.test.ts
+++ b/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.test.ts
@@ -200,17 +200,36 @@ describe("useDesktopUpdatePopup — auto mode", () => {
expect(invocations).toContain("restart_app");
});
- it("skips the update check entirely in SaaS connection mode", async () => {
- // In SaaS mode the cloud owns versioning — the self-hosted update check
- // must never run: no mode lookup, no external summary fetch, no install.
+ it("still checks and auto-installs in SaaS connection mode", async () => {
+ // The desktop binary is local even when signed in to the cloud, so it must keep updating.
getCurrentModeMock.mockResolvedValue("saas");
+ invokeMock.mockImplementation((cmd: string) => {
+ if (cmd === "check_for_update") {
+ return Promise.resolve({
+ version: "2.0.0",
+ currentVersion: "1.0.0",
+ releaseNotes: null,
+ });
+ }
+ return Promise.resolve();
+ });
+
+ await runStartup();
+
+ expect(getUpdateModeMock).toHaveBeenCalled();
+ expect(getUpdateSummaryMock).toHaveBeenCalled();
+ const invocations = invokeMock.mock.calls.map((c) => c[0]);
+ expect(invocations).toContain("download_and_install_update");
+ expect(invocations).toContain("restart_app");
+ });
+
+ it("does nothing when the update mode is disabled", async () => {
+ getUpdateModeMock.mockResolvedValue("disabled");
await runStartup();
- expect(getUpdateModeMock).not.toHaveBeenCalled();
expect(getUpdateSummaryMock).not.toHaveBeenCalled();
const invocations = invokeMock.mock.calls.map((c) => c[0]);
expect(invocations).not.toContain("download_and_install_update");
- expect(invocations).not.toContain("restart_app");
});
});
diff --git a/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.ts b/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.ts
index 0cd0fcd003..a38dec165e 100644
--- a/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.ts
+++ b/frontend/editor/src/desktop/hooks/useDesktopUpdatePopup.ts
@@ -6,7 +6,6 @@ import {
desktopUpdateService,
type CanInstallResult,
} from "@app/services/desktopUpdateService";
-import { connectionModeService } from "@app/services/connectionModeService";
const SNOOZE_KEY = "stirling-pdf-updater:snoozedUntil";
const STARTUP_DELAY_MS = 15_000;
@@ -24,9 +23,9 @@ const AUTO_FAILURE_KEY = "stirling-pdf-updater:autoFailedAt";
const AUTO_FAILURE_BACKOFF_MS = 6 * 60 * 60 * 1000;
/**
- * Desktop-only hook that checks for updates on startup and handles the
- * three update modes configured via the tauri store (or the MDM
- * provisioning file):
+ * Desktop-only hook that checks for updates on startup, in every connection
+ * mode (local, self-hosted and cloud), and handles the three update modes
+ * configured via the tauri store (or the MDM provisioning file):
*
* * `disabled` — no check is performed, no UI is shown, no network call.
* * `auto` — FULLY HEADLESS. We download + install + restart in the
@@ -73,10 +72,7 @@ export function useDesktopUpdatePopup() {
hasChecked.current = true;
const timer = setTimeout(async () => {
- // In SaaS connection mode the cloud owns app versioning — the self-hosted
- // update check + popup must never run (no external call, no modal).
- if ((await connectionModeService.getCurrentMode()) === "saas") return;
-
+ // Runs in every connection mode: the desktop binary is local even when signed in to the cloud.
let mode: Awaited<ReturnType<typeof desktopUpdateService.getUpdateMode>> =
"prompt";
try {
diff --git a/frontend/editor/src/desktop/hooks/useFrontendVersionInfo.ts b/frontend/editor/src/desktop/hooks/useFrontendVersionInfo.ts
index d8bd40bbc2..d4874e3b41 100644
--- a/frontend/editor/src/desktop/hooks/useFrontendVersionInfo.ts
+++ b/frontend/editor/src/desktop/hooks/useFrontendVersionInfo.ts
@@ -1,10 +1,13 @@
import { useState, useEffect } from "react";
import { getVersion } from "@tauri-apps/api/app";
import type { FrontendVersionInfo } from "@core/hooks/useFrontendVersionInfo";
+import { useSaaSMode } from "@app/hooks/useSaaSMode";
export function useFrontendVersionInfo(
backendVersion: string | undefined,
): FrontendVersionInfo {
+ const isSaaSMode = useSaaSMode();
+ const visibleBackendVersion = isSaaSMode ? undefined : backendVersion;
const [appVersion, setAppVersion] = useState<string | null>(null);
const [mismatchVersion, setMismatchVersion] = useState(false);
@@ -30,15 +33,15 @@ export function useFrontendVersionInfo(
}, []);
useEffect(() => {
- if (!appVersion || !backendVersion) {
+ if (!appVersion || !visibleBackendVersion) {
setMismatchVersion(false);
return;
}
- if (appVersion !== backendVersion) {
+ if (appVersion !== visibleBackendVersion) {
console.warn(
"[useFrontendVersionInfo] Mismatch between frontend version and AppConfig version:",
{
- backendVersion,
+ backendVersion: visibleBackendVersion,
frontendVersion: appVersion,
},
);
@@ -46,7 +49,11 @@ export function useFrontendVersionInfo(
} else {
setMismatchVersion(false);
}
- }, [appVersion, backendVersion]);
+ }, [appVersion, visibleBackendVersion]);
- return { appVersion, mismatchVersion };
+ return {
+ appVersion,
+ backendVersion: visibleBackendVersion,
+ mismatchVersion: Boolean(visibleBackendVersion) && mismatchVersion,
+ };
}