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.

🐛 fix(desktop): hide the core segment in the updater toast (#20895)

Innei593504f193e4
diff --git a/src/features/Electron/updater/UpdateNotification.tsx b/src/features/Electron/updater/UpdateNotification.tsx
index 06e129945fb..85b339d6f88 100644
--- a/src/features/Electron/updater/UpdateNotification.tsx
+++ b/src/features/Electron/updater/UpdateNotification.tsx
@@ -14,6 +14,7 @@ import { useUserStore } from '@/store/user';
import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { applyCoreUpdate } from './applyCoreUpdate';
+import { formatCoreVersion } from './coreVersion';
import { selectUpdateInfo } from './selectUpdateInfo';
const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -204,7 +205,9 @@ export const UpdateNotification: React.FC = () => {
if (updateInfo?.kind === 'renderer' || updateInfo?.kind === 'core-reload') {
return (
<div className={styles.installLaterToast}>
- <span>{tElectron('updater.rendererReady', { version: updateInfo.version })}</span>
+ <span>
+ {tElectron('updater.rendererReady', { version: formatCoreVersion(updateInfo.version) })}
+ </span>
<BaseButton size={'small'} type={'text'} onClick={() => setUpdateInfo(null)}>
{tElectron('updater.ignore')}
</BaseButton>
@@ -225,7 +228,7 @@ export const UpdateNotification: React.FC = () => {
<div className={styles.installLaterToast}>
<span>
{tElectron('updater.updateReady')}
- {isDevMode ? ` · ${updateInfo.version}` : ''}
+ {isDevMode ? ` · ${formatCoreVersion(updateInfo.version)}` : ''}
</span>
<BaseButton size={'small'} type={'text'} onClick={() => setUpdateInfo(null)}>
{tElectron('updater.later')}
@@ -245,7 +248,9 @@ export const UpdateNotification: React.FC = () => {
if (!updateInfo)
return appliedVersion ? (
<div className={styles.installLaterToast}>
- <span>{tElectron('updater.rendererUpdated', { version: appliedVersion })}</span>
+ <span>
+ {tElectron('updater.rendererUpdated', { version: formatCoreVersion(appliedVersion) })}
+ </span>
<BaseButton size={'small'} type={'text'} onClick={() => setAppliedVersion(null)}>
{tElectron('updater.ignore')}
</BaseButton>
diff --git a/src/features/Electron/updater/coreVersion.test.ts b/src/features/Electron/updater/coreVersion.test.ts
new file mode 100644
index 00000000000..3dc4350ae6b
--- /dev/null
+++ b/src/features/Electron/updater/coreVersion.test.ts
@@ -0,0 +1,14 @@
+import { describe, expect, it } from 'vitest';
+
+import { formatCoreVersion } from './coreVersion';
+
+describe('formatCoreVersion', () => {
+ it('hides the core pack segment of an OTA version', () => {
+ expect(formatCoreVersion('2.2.19-canary.33-core.2')).toBe('2.2.19-canary.33-2');
+ });
+
+ it('keeps versions that carry no core segment untouched', () => {
+ expect(formatCoreVersion('2.2.19-canary.33-2')).toBe('2.2.19-canary.33-2');
+ expect(formatCoreVersion('2.2.19')).toBe('2.2.19');
+ });
+});
diff --git a/src/features/Electron/updater/coreVersion.ts b/src/features/Electron/updater/coreVersion.ts
new file mode 100644
index 00000000000..c2a254977b1
--- /dev/null
+++ b/src/features/Electron/updater/coreVersion.ts
@@ -0,0 +1,8 @@
+/**
+ * Core OTA builds are named `<appVersion>-core.<seq>`: the trailing segment is
+ * the OTA pack sequence for that shell version — an implementation detail, not
+ * something the user reads as a version. Every user-facing core version (the
+ * About tag and the updater toast) goes through here so the segment is hidden
+ * in one place.
+ */
+export const formatCoreVersion = (version: string): string => version.replace('-core.', '-');
diff --git a/src/features/Settings/about/features/otaVersion.ts b/src/features/Settings/about/features/otaVersion.ts
index 65f498869a8..acda4bb6735 100644
--- a/src/features/Settings/about/features/otaVersion.ts
+++ b/src/features/Settings/about/features/otaVersion.ts
@@ -1,7 +1,9 @@
import type { CoreUpdateStatus } from '@lobechat/electron-client-ipc';
+import { formatCoreVersion } from '@/features/Electron/updater/coreVersion';
+
export const getDisplayedOtaVersion = (status: CoreUpdateStatus | null): string | null =>
status?.appliedVersion ?? status?.running ?? status?.current ?? null;
export const formatOtaVersionLabel = (version: string): string =>
- `OTA ${version.replace('-core.', '-')}`;
+ `OTA ${formatCoreVersion(version)}`;