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.

💄 style(spa): show the boot loading hint only on slow boots and keep it steady across the shell handoff (#21941)

AmAzing-91c6bc632f3e
diff --git a/locales/ar/common.json b/locales/ar/common.json
index 3e4a2c591d7..f9ba4a22f76 100644
--- a/locales/ar/common.json
+++ b/locales/ar/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "قد لا تعمل بعض الميزات بشكل صحيح أو قد تتصرف بشكل غير متوقع. يُرجى تحديث الخادم للحصول على أفضل تجربة.",
"setting": "الإعدادات",
"share": "مشاركة",
- "stillLoading": "لا يزال يتم التحميل...",
"stop": "إيقاف",
"supportAgent.context.attached": "تم إرفاق معلومات التشخيص",
"supportAgent.context.remove": "إزالة",
diff --git a/locales/bg-BG/common.json b/locales/bg-BG/common.json
index df2d5796cca..babc0c6db4a 100644
--- a/locales/bg-BG/common.json
+++ b/locales/bg-BG/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Някои функции може да не работят правилно или да се държат неочаквано. Моля, актуализирайте сървъра си за най-добро изживяване.",
"setting": "Настройки",
"share": "Сподели",
- "stillLoading": "Все още се зарежда...",
"stop": "Спри",
"supportAgent.context.attached": "Прикачена диагностична информация",
"supportAgent.context.remove": "Премахване",
diff --git a/locales/de-DE/common.json b/locales/de-DE/common.json
index 04e523ae843..24b619e7446 100644
--- a/locales/de-DE/common.json
+++ b/locales/de-DE/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Einige Funktionen könnten nicht richtig funktionieren oder sich unerwartet verhalten. Bitte aktualisiere deinen Server für das beste Nutzungserlebnis.",
"setting": "Einstellungen",
"share": "Teilen",
- "stillLoading": "Wird noch geladen...",
"stop": "Stopp",
"supportAgent.context.attached": "Diagnoseinformationen angehängt",
"supportAgent.context.remove": "Entfernen",
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index 21ccceb82fa..50a823f53c2 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -62,6 +62,7 @@
"betaFeedback.wechat.desc": "Scan with WeChat to join the group.",
"betaFeedback.wechat.title": "WeChat group",
"blog": "Product Blog",
+ "bootLoadingHint": "Setting the stage…",
"branching": "Create Subtopic",
"branchingRequiresSavedTopic": "Current topic is not saved, please save it first to use subtopic feature",
"cancel": "Cancel",
@@ -413,7 +414,6 @@
"serverVersionOutdated.warning": "Some features may not work properly or behave unexpectedly. Please update your server for the best experience.",
"setting": "Settings",
"share": "Share",
- "stillLoading": "Still loading...",
"stop": "Stop",
"supportAgent.context.attached": "Diagnostic info attached",
"supportAgent.context.remove": "Remove",
diff --git a/locales/es-ES/common.json b/locales/es-ES/common.json
index db853a1c5bf..6a5c2792c97 100644
--- a/locales/es-ES/common.json
+++ b/locales/es-ES/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Es posible que algunas funciones no funcionen correctamente o se comporten de forma inesperada. Por favor, actualiza tu servidor para una mejor experiencia.",
"setting": "Configuración",
"share": "Compartir",
- "stillLoading": "Cargando aún...",
"stop": "Detener",
"supportAgent.context.attached": "Información de diagnóstico adjunta",
"supportAgent.context.remove": "Eliminar",
diff --git a/locales/fa-IR/common.json b/locales/fa-IR/common.json
index e2078dcd18f..8fa7837f56f 100644
--- a/locales/fa-IR/common.json
+++ b/locales/fa-IR/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "برخی قابلیت‌ها ممکن است به درستی کار نکنند یا رفتار غیرمنتظره‌ای داشته باشند. لطفاً برای بهترین تجربه، سرور خود را به‌روزرسانی کنید.",
"setting": "تنظیمات",
"share": "اشتراک‌گذاری",
- "stillLoading": "هنوز در حال بارگذاری...",
"stop": "توقف",
"supportAgent.context.attached": "اطلاعات تشخیصی پیوست شد",
"supportAgent.context.remove": "حذف",
diff --git a/locales/fr-FR/common.json b/locales/fr-FR/common.json
index 0ef232642c1..b7961d42207 100644
--- a/locales/fr-FR/common.json
+++ b/locales/fr-FR/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Certaines fonctionnalités peuvent ne pas fonctionner correctement ou se comporter de manière inattendue. Veuillez mettre à jour votre serveur pour une expérience optimale.",
"setting": "Paramètres",
"share": "Partager",
- "stillLoading": "Chargement en cours...",
"stop": "Arrêter",
"supportAgent.context.attached": "Informations de diagnostic jointes",
"supportAgent.context.remove": "Supprimer",
diff --git a/locales/it-IT/common.json b/locales/it-IT/common.json
index 2b2aaaa494b..8c803202757 100644
--- a/locales/it-IT/common.json
+++ b/locales/it-IT/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Alcune funzionalità potrebbero non funzionare correttamente o comportarsi in modo imprevisto. Aggiorna il server per un'esperienza ottimale.",
"setting": "Impostazioni",
"share": "Condividi",
- "stillLoading": "Caricamento in corso...",
"stop": "Ferma",
"supportAgent.context.attached": "Informazioni diagnostiche allegate",
"supportAgent.context.remove": "Rimuovi",
diff --git a/locales/ja-JP/common.json b/locales/ja-JP/common.json
index ffa4e843e66..cf394d05d40 100644
--- a/locales/ja-JP/common.json
+++ b/locales/ja-JP/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "一部の機能が正しく動作しない、または予期しない動作をする可能性があります。最適な体験のためにサーバーを更新してください。",
"setting": "設定",
"share": "共有",
- "stillLoading": "読み込み中...",
"stop": "停止",
"supportAgent.context.attached": "診断情報が添付されました",
"supportAgent.context.remove": "削除",
diff --git a/locales/ko-KR/common.json b/locales/ko-KR/common.json
index f3d3c2acae9..544b084248f 100644
--- a/locales/ko-KR/common.json
+++ b/locales/ko-KR/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "일부 기능이 제대로 작동하지 않거나 예기치 않게 동작할 수 있습니다. 최상의 사용을 위해 서버를 업데이트해 주세요.",
"setting": "설정",
"share": "공유",
- "stillLoading": "여전히 로드 중...",
"stop": "중지",
"supportAgent.context.attached": "진단 정보가 첨부되었습니다",
"supportAgent.context.remove": "제거",
diff --git a/locales/nl-NL/common.json b/locales/nl-NL/common.json
index 8ee4e2984f5..c0aa3e74d9a 100644
--- a/locales/nl-NL/common.json
+++ b/locales/nl-NL/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Sommige functies werken mogelijk niet goed of gedragen zich onverwacht. Werk je server bij voor de beste ervaring.",
"setting": "Instellingen",
"share": "Delen",
- "stillLoading": "Nog steeds aan het laden...",
"stop": "Stoppen",
"supportAgent.context.attached": "Diagnostische informatie toegevoegd",
"supportAgent.context.remove": "Verwijderen",
diff --git a/locales/pl-PL/common.json b/locales/pl-PL/common.json
index 9a690361e87..6ce8e6353d7 100644
--- a/locales/pl-PL/common.json
+++ b/locales/pl-PL/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Niektóre funkcje mogą nie działać poprawnie lub zachowywać się nieoczekiwanie. Zaktualizuj serwer, aby uzyskać najlepsze wrażenia.",
"setting": "Ustawienia",
"share": "Udostępnij",
- "stillLoading": "Wciąż się ładuje...",
"stop": "Zatrzymaj",
"supportAgent.context.attached": "Dołączono informacje diagnostyczne",
"supportAgent.context.remove": "Usuń",
diff --git a/locales/pt-BR/common.json b/locales/pt-BR/common.json
index 7bc59fd8198..720fce5769d 100644
--- a/locales/pt-BR/common.json
+++ b/locales/pt-BR/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Alguns recursos podem não funcionar corretamente ou apresentar comportamentos inesperados. Atualize seu servidor para a melhor experiência.",
"setting": "Configurações",
"share": "Compartilhar",
- "stillLoading": "Ainda carregando...",
"stop": "Parar",
"supportAgent.context.attached": "Informações de diagnóstico anexadas",
"supportAgent.context.remove": "Remover",
diff --git a/locales/ru-RU/common.json b/locales/ru-RU/common.json
index a6e52730474..41e1d448d3a 100644
--- a/locales/ru-RU/common.json
+++ b/locales/ru-RU/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Некоторые функции могут работать некорректно или вести себя непредсказуемо. Пожалуйста, обновите сервер для наилучшей работы.",
"setting": "Настройки",
"share": "Поделиться",
- "stillLoading": "Все еще загружается...",
"stop": "Остановить",
"supportAgent.context.attached": "Диагностическая информация прикреплена",
"supportAgent.context.remove": "Удалить",
diff --git a/locales/tr-TR/common.json b/locales/tr-TR/common.json
index 3e3a751e45c..3364f8f823f 100644
--- a/locales/tr-TR/common.json
+++ b/locales/tr-TR/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Bazı özellikler düzgün çalışmayabilir veya beklenmedik şekilde davranabilir. En iyi deneyim için lütfen sunucunuzu güncelleyin.",
"setting": "Ayarlar",
"share": "Paylaş",
- "stillLoading": "Hâlâ yükleniyor...",
"stop": "Durdur",
"supportAgent.context.attached": "Tanılama bilgisi eklendi",
"supportAgent.context.remove": "Kaldır",
diff --git a/locales/vi-VN/common.json b/locales/vi-VN/common.json
index 7b74d581d75..8b9feb72ab6 100644
--- a/locales/vi-VN/common.json
+++ b/locales/vi-VN/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "Một số tính năng có thể không hoạt động đúng hoặc hoạt động không như mong đợi. Vui lòng cập nhật máy chủ để có trải nghiệm tốt nhất.",
"setting": "Cài đặt",
"share": "Chia sẻ",
- "stillLoading": "Đang tải...",
"stop": "Dừng",
"supportAgent.context.attached": "Thông tin chẩn đoán đã được đính kèm",
"supportAgent.context.remove": "Xóa",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index 294e6b7ed36..b24fc9d8d4b 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -62,6 +62,7 @@
"betaFeedback.wechat.desc": "用微信扫码加入群聊。",
"betaFeedback.wechat.title": "微信群",
"blog": "产品博客",
+ "bootLoadingHint": "好戏在后头…",
"branching": "创建子话题",
"branchingRequiresSavedTopic": "当前话题未保存。保存后即可使用子话题",
"cancel": "取消",
@@ -413,7 +414,6 @@
"serverVersionOutdated.warning": "部分功能可能无法正常使用或出现非预期行为。建议更新服务端以获得最佳体验。",
"setting": "设置",
"share": "分享",
- "stillLoading": "仍在加载中…",
"stop": "停止",
"supportAgent.context.attached": "已附带诊断信息",
"supportAgent.context.remove": "移除",
diff --git a/locales/zh-TW/common.json b/locales/zh-TW/common.json
index 960c1f69d6e..684a70849a3 100644
--- a/locales/zh-TW/common.json
+++ b/locales/zh-TW/common.json
@@ -412,7 +412,6 @@
"serverVersionOutdated.warning": "某些功能可能無法正常運作或出現異常行為。請更新您的伺服器以獲得最佳體驗。",
"setting": "設定",
"share": "分享",
- "stillLoading": "仍在載入中...",
"stop": "停止",
"supportAgent.context.attached": "診斷資訊已附加",
"supportAgent.context.remove": "移除",
diff --git a/packages/locales/src/default/common.ts b/packages/locales/src/default/common.ts
index 656c64bc6e3..b7c1f6627d8 100644
--- a/packages/locales/src/default/common.ts
+++ b/packages/locales/src/default/common.ts
@@ -417,7 +417,7 @@ export default {
'layoutInitializing': 'Loading layout...',
'legal': 'Legal Disclaimer',
'loading': 'Loading...',
- 'stillLoading': 'Still loading...',
+ 'bootLoadingHint': 'Setting the stage…',
'mail.business': 'Business Cooperation',
'mail.support': 'Email Support',
'deleteHistoryMigrating':
diff --git a/src/spa/BootShell/AppShellSkeleton.tsx b/src/spa/BootShell/AppShellSkeleton.tsx
index 0490186a235..712de40cae0 100644
--- a/src/spa/BootShell/AppShellSkeleton.tsx
+++ b/src/spa/BootShell/AppShellSkeleton.tsx
@@ -3,7 +3,7 @@
import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';
import { createStaticStyles, Flexbox, keyframes } from '@lobehub/ui';
import { LobeHub } from '@lobehub/ui/brand';
-import { memo, useEffect, useLayoutEffect, useState } from 'react';
+import { memo, useLayoutEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { retainSkeleton } from '@/components/Skeleton/skeletonHandover';
@@ -16,6 +16,7 @@ import { styles as containerStyles } from '@/features/DesktopLayoutContainer/sty
import { electronStylish } from '@/styles/electron';
import { readBootShellGeometry } from './geometry';
+import { useLoadingHint } from './useLoadingHint';
// antd emits its design tokens as `.lobe-vars{--ant-*: …}` — a plain global
// class rule, not a `:root` one. The shell renders outside `AppTheme`, so it has
@@ -25,20 +26,16 @@ const CSS_VAR_CLASS = 'lobe-vars';
export const APP_SHELL_FALLBACK_ID = 'app-shell-fallback';
-const HINT_DELAY = 1000;
-
-// The X half of the transform is the centering, not the motion — it has to be
-// restated in both frames or the keyframe overwrites it and the caption jumps
-// to the anchor's left edge.
-const slideUp = keyframes`
+// Opacity only: on an otherwise still boot screen a rising caption reads as
+// the layout jumping, and leaving `transform` alone keeps the centering in one
+// place.
+const fadeIn = keyframes`
from {
opacity: 0;
- transform: translate(-50%, 10px);
}
to {
opacity: 1;
- transform: translate(-50%, 0);
}
`;
@@ -61,11 +58,18 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
position: absolute;
inset-block-start: calc(100% + 8px);
inset-inline-start: 50%;
+ transform: translateX(-50%);
font-size: 13px;
white-space: nowrap;
- animation: ${slideUp} 0.42s ${cssVar.motionEaseOut} both;
+ &[data-enter] {
+ animation: ${fadeIn} 0.3s ${cssVar.motionEaseOut} both;
+
+ @media (prefers-reduced-motion: reduce) {
+ animation: none;
+ }
+ }
`,
brand: css`
position: relative;
@@ -103,10 +107,14 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
* i18n, so calling it up front would hit react-i18next with no instance —
* a console warning and a first render that echoes the raw key.
*/
-const LoadingHint = memo(() => {
+const LoadingHint = memo<{ enter: boolean }>(({ enter }) => {
const { t } = useTranslation('common');
- return <div className={styles.hint}>{t('stillLoading')}</div>;
+ return (
+ <div className={styles.hint} data-enter={enter || undefined}>
+ {t('bootLoadingHint')}
+ </div>
+ );
});
LoadingHint.displayName = 'AppShellLoadingHint';
@@ -117,15 +125,10 @@ interface AppShellSkeletonProps {
const AppShellSkeleton = memo<AppShellSkeletonProps>(({ id }) => {
const { isDark, navPanelBackground, navPanelWidth, showLeftPanel } = readBootShellGeometry();
- const [waiting, setWaiting] = useState(false);
+ const hint = useLoadingHint();
useLayoutEffect(retainSkeleton, []);
- useEffect(() => {
- const timer = setTimeout(() => setWaiting(true), HINT_DELAY);
- return () => clearTimeout(timer);
- }, []);
-
return (
<div aria-hidden className={`${CSS_VAR_CLASS} ${styles.root}`} id={id}>
{isDesktop && <div className={`${styles.dragRegion} ${electronStylish.draggable}`} />}
@@ -160,7 +163,7 @@ const AppShellSkeleton = memo<AppShellSkeletonProps>(({ id }) => {
<div className={styles.contentBrand}>
<div className={styles.brand}>
<LobeHub size={40} type={'text'} />
- {waiting && <LoadingHint />}
+ {hint && <LoadingHint enter={hint === 'enter'} />}
</div>
</div>
</Flexbox>
diff --git a/src/spa/BootShell/hintClock.ts b/src/spa/BootShell/hintClock.ts
new file mode 100644
index 00000000000..330bfd52eb1
--- /dev/null
+++ b/src/spa/BootShell/hintClock.ts
@@ -0,0 +1,37 @@
+import { HANDOVER_WINDOW } from '@/components/Skeleton/skeletonHandover';
+
+// Long enough that a normal cold boot never sees it — the caption reads as
+// "slower than usual", so showing it on every boot turns it into noise.
+export const HINT_DELAY = 3000;
+
+let mounted = 0;
+let shownSince = 0;
+let lastSeenAt = -Infinity;
+
+/**
+ * One wait clock shared by every shell instance. `BootShell` and the main
+ * layout's Suspense fallback are separate mounts of the same screen; a
+ * per-mount timer restarts on that handoff and the caption vanishes, then
+ * fades in again a full delay later. An instance that mounts while another is
+ * up, or right after one left, continues the wait instead of starting over.
+ *
+ * Returns when the wait started.
+ */
+export const acquireHintClock = (now = performance.now()) => {
+ if (mounted === 0 && now - lastSeenAt >= HANDOVER_WINDOW) shownSince = now;
+ mounted += 1;
+
+ return shownSince;
+};
+
+export const releaseHintClock = (now = performance.now()) => {
+ mounted = Math.max(0, mounted - 1);
+ lastSeenAt = now;
+};
+
+/** Test-only: forget every previous wait. */
+export const resetHintClock = () => {
+ mounted = 0;
+ shownSince = 0;
+ lastSeenAt = -Infinity;
+};
diff --git a/src/spa/BootShell/useLoadingHint.test.ts b/src/spa/BootShell/useLoadingHint.test.ts
new file mode 100644
index 00000000000..c3090edc1d4
--- /dev/null
+++ b/src/spa/BootShell/useLoadingHint.test.ts
@@ -0,0 +1,77 @@
+import { act, renderHook } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { HINT_DELAY, resetHintClock } from './hintClock';
+import { useLoadingHint } from './useLoadingHint';
+
+const elapse = (ms: number) =>
+ act(() => {
+ vi.advanceTimersByTime(ms);
+ });
+
+beforeEach(() => {
+ vi.useFakeTimers();
+ resetHintClock();
+});
+
+afterEach(() => {
+ vi.useRealTimers();
+});
+
+describe('useLoadingHint', () => {
+ it('stays quiet through a normal wait and fades in once the delay elapses', () => {
+ const { result } = renderHook(() => useLoadingHint());
+
+ elapse(HINT_DELAY - 1);
+ expect(result.current).toBeUndefined();
+
+ elapse(1);
+ expect(result.current).toBe('enter');
+ });
+
+ it('continues the wait when the layout fallback takes over from the boot shell', () => {
+ const boot = renderHook(() => useLoadingHint());
+
+ elapse(HINT_DELAY - 500);
+ boot.unmount();
+ const fallback = renderHook(() => useLoadingHint());
+
+ elapse(499);
+ expect(fallback.result.current).toBeUndefined();
+ elapse(1);
+ expect(fallback.result.current).toBe('enter');
+ });
+
+ it('continues the wait for a fallback that mounts while the boot shell is still up', () => {
+ renderHook(() => useLoadingHint());
+
+ elapse(HINT_DELAY - 500);
+ const fallback = renderHook(() => useLoadingHint());
+
+ elapse(500);
+ expect(fallback.result.current).toBe('enter');
+ });
+
+ it('keeps an already-shown hint on screen across the handoff without replaying it', () => {
+ const boot = renderHook(() => useLoadingHint());
+
+ elapse(HINT_DELAY);
+ boot.unmount();
+ const fallback = renderHook(() => useLoadingHint());
+
+ expect(fallback.result.current).toBe('static');
+ });
+
+ it('starts a fresh wait for a shell that mounts well after the last one left', () => {
+ const first = renderHook(() => useLoadingHint());
+ elapse(HINT_DELAY);
+ first.unmount();
+
+ elapse(5000);
+ const next = renderHook(() => useLoadingHint());
+
+ expect(next.result.current).toBeUndefined();
+ elapse(HINT_DELAY);
+ expect(next.result.current).toBe('enter');
+ });
+});
diff --git a/src/spa/BootShell/useLoadingHint.ts b/src/spa/BootShell/useLoadingHint.ts
new file mode 100644
index 00000000000..65168d98525
--- /dev/null
+++ b/src/spa/BootShell/useLoadingHint.ts
@@ -0,0 +1,30 @@
+import { useLayoutEffect, useState } from 'react';
+
+import { acquireHintClock, HINT_DELAY, releaseHintClock } from './hintClock';
+
+/**
+ * `enter` once the wait outlasts `HINT_DELAY`; `static` when taking over a wait
+ * whose caption is already on screen, so the handoff doesn't replay the
+ * fade-in.
+ */
+export type LoadingHintState = 'enter' | 'static';
+
+export const useLoadingHint = (): LoadingHintState | undefined => {
+ const [hint, setHint] = useState<LoadingHintState>();
+
+ // Layout effect: the previous instance releases the clock in the same commit,
+ // and an already-due caption must be in place before this one paints.
+ useLayoutEffect(() => {
+ const remaining = acquireHintClock() + HINT_DELAY - performance.now();
+ if (remaining <= 0) setHint('static');
+
+ const timer = remaining > 0 ? setTimeout(() => setHint('enter'), remaining) : undefined;
+
+ return () => {
+ clearTimeout(timer);
+ releaseHintClock();
+ };
+ }, []);
+
+ return hint;
+};