Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(settings): show desktop OTA version in About (#20147)

Innei4834476cb26f
diff --git a/apps/desktop/src/main/core/infrastructure/coreOta/CoreUpdateManager.ts b/apps/desktop/src/main/core/infrastructure/coreOta/CoreUpdateManager.ts
index 148d7103de3..d86767750c2 100644
--- a/apps/desktop/src/main/core/infrastructure/coreOta/CoreUpdateManager.ts
+++ b/apps/desktop/src/main/core/infrastructure/coreOta/CoreUpdateManager.ts
@@ -285,6 +285,7 @@ export class CoreUpdateManager {
lastCheckAt: this.lastCheckAt,
lastError: this.lastError,
needsFullRelease: this.needsFullRelease,
+ running: this.shell?.manifest?.version ?? null,
staged: this.staged?.version ?? null,
});
diff --git a/packages/electron-client-ipc/src/types/update.ts b/packages/electron-client-ipc/src/types/update.ts
index 4f139efc37c..b6a07cb1823 100644
--- a/packages/electron-client-ipc/src/types/update.ts
+++ b/packages/electron-client-ipc/src/types/update.ts
@@ -26,6 +26,18 @@ export interface UpdateInfo {
version: string;
}
+export interface CoreUpdateStatus {
+ applyMode: 'reload' | 'relaunch' | null;
+ current: string | null;
+ disabledReasons: string[];
+ enabled: boolean;
+ lastCheckAt: number | null;
+ lastError: string | null;
+ needsFullRelease: boolean;
+ running: string | null;
+ staged: string | null;
+}
+
export type UpdaterStage = 'idle' | 'checking' | 'downloading' | 'downloaded' | 'latest' | 'error';
export interface UpdaterState {
diff --git a/src/features/Settings/about/features/Version.tsx b/src/features/Settings/about/features/Version.tsx
index 2a05b2d0ddb..7ea3c4ecc66 100644
--- a/src/features/Settings/about/features/Version.tsx
+++ b/src/features/Settings/about/features/Version.tsx
@@ -5,9 +5,9 @@ import {
useWatchBroadcast,
} from '@lobechat/electron-client-ipc';
import { Block, Flexbox } from '@lobehub/ui';
-import { Button, Tag } from '@lobehub/ui/base-ui';
+import { Button, Skeleton, Tag } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
-import { memo, useEffect, useMemo, useRef, useState } from 'react';
+import { memo, Suspense, use, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ProductLogo } from '@/components/Branding';
@@ -15,6 +15,7 @@ import { CHANGELOG_URL, MANUAL_UPGRADE_URL, OFFICIAL_SITE } from '@/const/url';
import { CURRENT_VERSION } from '@/const/version';
import { useNewVersion } from '@/features/User/UserPanel/useNewVersion';
import { autoUpdateService } from '@/services/electron/autoUpdate';
+import { rendererOtaService } from '@/services/electron/rendererOta';
import { useGlobalStore } from '@/store/global';
import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
import {
@@ -24,6 +25,25 @@ import {
} from '@/utils/devDockUnlock';
import { APP_VERSION } from './appVersion';
+import { formatOtaVersionLabel, getDisplayedOtaVersion } from './otaVersion';
+
+let otaVersionPromise: Promise<string | null> | undefined;
+
+const getOtaVersion = () => {
+ otaVersionPromise ??= rendererOtaService.getStatus().then(getDisplayedOtaVersion);
+
+ return otaVersionPromise;
+};
+
+const OtaVersionTag = memo(() => {
+ const otaVersion = use(getOtaVersion());
+
+ if (!otaVersion) return null;
+
+ return <Tag style={{ minWidth: 60 }}>{formatOtaVersionLabel(otaVersion)}</Tag>;
+});
+
+OtaVersionTag.displayName = 'OtaVersionTag';
const styles = createStaticStyles(({ css, cssVar }) => ({
logo: css`
@@ -181,6 +201,12 @@ const Version = memo<{ mobile?: boolean }>(({ mobile }) => {
v{APP_VERSION}
</Tag>
+ {isDesktop && (
+ <Suspense fallback={<Skeleton height={22} radius={6} width={60} />}>
+ <OtaVersionTag />
+ </Suspense>
+ )}
+
{buildChannel && buildChannel !== 'stable' && (
<Tag color={'gold'}>
{t(`setting:tab.advanced.updateChannel.${buildChannel}`, {
diff --git a/src/features/Settings/about/features/otaVersion.test.ts b/src/features/Settings/about/features/otaVersion.test.ts
new file mode 100644
index 00000000000..3c05ef2e4e2
--- /dev/null
+++ b/src/features/Settings/about/features/otaVersion.test.ts
@@ -0,0 +1,39 @@
+import type { CoreUpdateStatus } from '@lobechat/electron-client-ipc';
+import { describe, expect, it } from 'vitest';
+
+import { formatOtaVersionLabel, getDisplayedOtaVersion } from './otaVersion';
+
+const status = (patch: Partial<CoreUpdateStatus>): CoreUpdateStatus => ({
+ applyMode: null,
+ current: null,
+ disabledReasons: [],
+ enabled: true,
+ lastCheckAt: null,
+ lastError: null,
+ needsFullRelease: false,
+ running: null,
+ staged: null,
+ ...patch,
+});
+
+describe('getDisplayedOtaVersion', () => {
+ it('uses the running core version when present', () => {
+ expect(
+ getDisplayedOtaVersion(status({ current: '2.2.13', running: '2.2.14', staged: '2.2.15' })),
+ ).toBe('2.2.14');
+ });
+
+ it('falls back to current for older status payloads', () => {
+ expect(getDisplayedOtaVersion(status({ current: '2.2.13' }))).toBe('2.2.13');
+ });
+
+ it('does not expose a staged version as the running OTA version', () => {
+ expect(getDisplayedOtaVersion(status({ staged: '2.2.15' }))).toBeNull();
+ });
+});
+
+describe('formatOtaVersionLabel', () => {
+ it('does not add a v prefix to non-semver OTA names', () => {
+ expect(formatOtaVersionLabel('r1')).toBe('OTA r1');
+ });
+});
diff --git a/src/features/Settings/about/features/otaVersion.ts b/src/features/Settings/about/features/otaVersion.ts
new file mode 100644
index 00000000000..e71493fb604
--- /dev/null
+++ b/src/features/Settings/about/features/otaVersion.ts
@@ -0,0 +1,6 @@
+import type { CoreUpdateStatus } from '@lobechat/electron-client-ipc';
+
+export const getDisplayedOtaVersion = (status: CoreUpdateStatus | null): string | null =>
+ status?.running ?? status?.current ?? null;
+
+export const formatOtaVersionLabel = (version: string): string => `OTA ${version}`;
diff --git a/src/services/electron/rendererOta.ts b/src/services/electron/rendererOta.ts
index d9e1c6a14dc..0bcb1697be8 100644
--- a/src/services/electron/rendererOta.ts
+++ b/src/services/electron/rendererOta.ts
@@ -1,3 +1,5 @@
+import type { CoreUpdateStatus } from '@lobechat/electron-client-ipc';
+
import { ensureElectronIpc } from '@/utils/electron/ipc';
class RendererOtaService {
@@ -9,7 +11,7 @@ class RendererOtaService {
return ensureElectronIpc().rendererOta.applyNow();
};
- getStatus = async () => {
+ getStatus = async (): Promise<CoreUpdateStatus> => {
return ensureElectronIpc().rendererOta.getStatus();
};
}