Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/lobehub/lobe-chat
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 26, 2024
2 parents 5a6edef + 0533150 commit e43ac26
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 9 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

# Changelog

### [Version 1.40.3](https://github.com/lobehub/lobe-chat/compare/v1.40.2...v1.40.3)

<sup>Released on **2024-12-26**</sup>

#### 🐛 Bug Fixes

- **misc**: Fix fetch error in changelog modal.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### 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))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.40.2](https://github.com/lobehub/lobe-chat/compare/v1.40.1...v1.40.2)

<sup>Released on **2024-12-26**</sup>
Expand Down
7 changes: 7 additions & 0 deletions changelog/v1.json
Original file line number Diff line number Diff line change
@@ -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."]
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions src/app/(main)/chat/(workspace)/features/ChangelogModal.tsx
Original file line number Diff line number Diff line change
@@ -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 <ChangelogModal currentId={id} />;
};

export default Changelog;
13 changes: 8 additions & 5 deletions src/app/(main)/chat/(workspace)/page.tsx
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand All @@ -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({
Expand All @@ -35,8 +36,10 @@ const Page = async () => {
<StructuredData ld={ld} />
<PageTitle />
<TelemetryNotification mobile={mobile} />
{!hideDocs && !mobile && (
<ChangelogModal currentId={await new ChangelogService().getLatestChangelogId()} />
{showChangelog && !hideDocs && !mobile && (
<Suspense>
<Changelog />
</Suspense>
)}
</>
);
Expand Down
5 changes: 5 additions & 0 deletions src/components/Loading/BrandTextLoading/index.tsx
Original file line number Diff line number Diff line change
@@ -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 <CircleLoading />;

return (
<Center height={'100%'} width={'100%'}>
<LobeChatText />
Expand Down
3 changes: 3 additions & 0 deletions src/config/featureFlags/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),

Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/server/services/changelog/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
Expand Down
10 changes: 9 additions & 1 deletion src/server/services/changelog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}
}
Expand Down
1 change: 1 addition & 0 deletions src/store/serverConfig/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('featureFlagsSelectors', () => {
isAgentEditable: false,
enablePlugins: true,
showCreateSession: true,
showChangelog: true,
enableRAGEval: false,
showDalle: true,
enableKnowledgeBase: true,
Expand Down

0 comments on commit e43ac26

Please sign in to comment.