diff --git a/CHANGELOG.md b/CHANGELOG.md index 72823827d6c7..00716b124fd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ # Changelog +### [Version 1.40.3](https://github.com/lobehub/lobe-chat/compare/v1.40.2...v1.40.3) + +Released on **2024-12-26** + +#### 🐛 Bug Fixes + +- **misc**: Fix fetch error in changelog modal. + +
+ +
+Improvements and Fixes + +#### What's fixed + +- **misc**: Fix fetch error in changelog modal, closes [#5194](https://github.com/lobehub/lobe-chat/issues/5194) ([e9433be](https://github.com/lobehub/lobe-chat/commit/e9433be)) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ ### [Version 1.40.2](https://github.com/lobehub/lobe-chat/compare/v1.40.1...v1.40.2) Released on **2024-12-26** diff --git a/changelog/v1.json b/changelog/v1.json index 12d78e12d100..5fad5db24dc9 100644 --- a/changelog/v1.json +++ b/changelog/v1.json @@ -1,4 +1,11 @@ [ + { + "children": { + "fixes": ["Fix fetch error in changelog modal."] + }, + "date": "2024-12-26", + "version": "1.40.3" + }, { "children": { "improvements": ["Refactor tokens to contextWindowTokens."] diff --git a/package.json b/package.json index ac6389ca812b..417f90a9ae45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lobehub/chat", - "version": "1.40.2", + "version": "1.40.3", "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.", "keywords": [ "framework", @@ -149,7 +149,7 @@ "antd": "^5.22.6", "antd-style": "^3.7.1", "brotli-wasm": "^3.0.1", - "chroma-js": "^2.6.0", + "chroma-js": "^3.1.2", "dayjs": "^1.11.13", "debug": "^4.3.7", "dexie": "^3.2.7", diff --git a/src/app/(main)/chat/(workspace)/features/ChangelogModal.tsx b/src/app/(main)/chat/(workspace)/features/ChangelogModal.tsx new file mode 100644 index 000000000000..b4c63dffd085 --- /dev/null +++ b/src/app/(main)/chat/(workspace)/features/ChangelogModal.tsx @@ -0,0 +1,11 @@ +import ChangelogModal from '@/features/ChangelogModal'; +import { ChangelogService } from '@/server/services/changelog'; + +const Changelog = async () => { + const service = new ChangelogService(); + const id = await service.getLatestChangelogId(); + + return ; +}; + +export default Changelog; diff --git a/src/app/(main)/chat/(workspace)/page.tsx b/src/app/(main)/chat/(workspace)/page.tsx index e175858a55e5..055e4a4a7160 100644 --- a/src/app/(main)/chat/(workspace)/page.tsx +++ b/src/app/(main)/chat/(workspace)/page.tsx @@ -1,14 +1,15 @@ +import { Suspense } from 'react'; + import StructuredData from '@/components/StructuredData'; import { serverFeatureFlags } from '@/config/featureFlags'; import { BRANDING_NAME } from '@/const/branding'; -import ChangelogModal from '@/features/ChangelogModal'; import { ldModule } from '@/server/ld'; import { metadataModule } from '@/server/metadata'; -import { ChangelogService } from '@/server/services/changelog'; import { translation } from '@/server/translation'; import { isMobileDevice } from '@/utils/server/responsive'; import PageTitle from '../features/PageTitle'; +import Changelog from './features/ChangelogModal'; import TelemetryNotification from './features/TelemetryNotification'; export const generateMetadata = async () => { @@ -21,7 +22,7 @@ export const generateMetadata = async () => { }; const Page = async () => { - const hideDocs = serverFeatureFlags().hideDocs; + const { hideDocs, showChangelog } = serverFeatureFlags(); const mobile = await isMobileDevice(); const { t } = await translation('metadata'); const ld = ldModule.generate({ @@ -35,8 +36,10 @@ const Page = async () => { - {!hideDocs && !mobile && ( - + {showChangelog && !hideDocs && !mobile && ( + + + )} ); diff --git a/src/components/Loading/BrandTextLoading/index.tsx b/src/components/Loading/BrandTextLoading/index.tsx index 9ae5fb6b8758..1fb8c87cfb21 100644 --- a/src/components/Loading/BrandTextLoading/index.tsx +++ b/src/components/Loading/BrandTextLoading/index.tsx @@ -1,8 +1,13 @@ import { Center } from 'react-layout-kit'; +import { isCustomBranding } from '@/const/version'; + +import CircleLoading from '../CircleLoading'; import LobeChatText from './LobeChatText'; export default () => { + if (isCustomBranding) return ; + return (
diff --git a/src/config/featureFlags/schema.ts b/src/config/featureFlags/schema.ts index 26407d5244e7..9ccd9749451f 100644 --- a/src/config/featureFlags/schema.ts +++ b/src/config/featureFlags/schema.ts @@ -24,6 +24,7 @@ export const FeatureFlagsSchema = z.object({ token_counter: z.boolean().optional(), welcome_suggest: z.boolean().optional(), + changelog: z.boolean().optional(), clerk_sign_up: z.boolean().optional(), @@ -72,6 +73,7 @@ export const DEFAULT_FEATURE_FLAGS: IFeatureFlags = { market: true, speech_to_text: true, + changelog: true, // the flags below can only be used with commercial license // if you want to use it in the commercial usage @@ -94,6 +96,7 @@ export const mapFeatureFlagsEnvToState = (config: IFeatureFlags) => { enablePlugins: config.plugins, showDalle: config.dalle, + showChangelog: config.changelog, enableCheckUpdates: config.check_updates, showWelcomeSuggest: config.welcome_suggest, diff --git a/src/server/services/changelog/index.test.ts b/src/server/services/changelog/index.test.ts index c9fa0adf840b..3724e1d2ffd0 100644 --- a/src/server/services/changelog/index.test.ts +++ b/src/server/services/changelog/index.test.ts @@ -93,7 +93,9 @@ describe('ChangelogService', () => { }); it('should handle fetch errors', async () => { - (global.fetch as any).mockRejectedValue(new Error('Fetch failed')); + (global.fetch as any).mockRejectedValue( + new Error('Fetch failed', { cause: { code: 'Timeout' } }), + ); const result = await service.getChangelogIndex(); expect(result).toEqual([]); diff --git a/src/server/services/changelog/index.ts b/src/server/services/changelog/index.ts index dd5a464afc37..ef1d0232409b 100644 --- a/src/server/services/changelog/index.ts +++ b/src/server/services/changelog/index.ts @@ -53,7 +53,15 @@ export class ChangelogService { return this.mergeChangelogs(data.cloud, data.community).slice(0, 5); } catch (e) { - console.error('Error getting changelog lists:', e); + const cause = (e as Error).cause as { code: string }; + if (cause.code.includes('ETIMEDOUT')) { + console.warn( + '[ChangelogFetchTimeout] fail to fetch changelog lists due to network timeout. Please check your network connection.', + ); + } else { + console.error('Error getting changelog lists:', e); + } + return []; } } diff --git a/src/store/serverConfig/selectors.test.ts b/src/store/serverConfig/selectors.test.ts index dbb11b674efe..fbf6c16905d6 100644 --- a/src/store/serverConfig/selectors.test.ts +++ b/src/store/serverConfig/selectors.test.ts @@ -21,6 +21,7 @@ describe('featureFlagsSelectors', () => { isAgentEditable: false, enablePlugins: true, showCreateSession: true, + showChangelog: true, enableRAGEval: false, showDalle: true, enableKnowledgeBase: true,