@lobehub/chat 0.151.5 → 0.151.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.151.6](https://github.com/lobehub/lobe-chat/compare/v0.151.5...v0.151.6)
6
+
7
+ <sup>Released on **2024-04-30**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Plugins with multiple settings cannot be correctly configured.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Plugins with multiple settings cannot be correctly configured, closes [#1991](https://github.com/lobehub/lobe-chat/issues/1991) ([0c041aa](https://github.com/lobehub/lobe-chat/commit/0c041aa))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 0.151.5](https://github.com/lobehub/lobe-chat/compare/v0.151.4...v0.151.5)
6
31
 
7
32
  <sup>Released on **2024-04-30**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.151.5",
3
+ "version": "0.151.6",
4
4
  "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.",
5
5
  "keywords": [
6
6
  "framework",
@@ -4,6 +4,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
 
5
5
  import { pluginService } from '@/services/plugin';
6
6
  import { LobeTool } from '@/types/tool';
7
+ import { merge } from '@/utils/merge';
7
8
 
8
9
  import { useToolStore } from '../../store';
9
10
 
@@ -91,6 +92,24 @@ describe('useToolStore:plugin', () => {
91
92
 
92
93
  expect(pluginService.updatePluginSettings).toBeCalledWith(pluginId, newSettings);
93
94
  });
95
+
96
+ it('should merge settings for a plugin with existing settings', async () => {
97
+ const pluginId = 'test-plugin';
98
+ const existingSettings = { setting1: 'old-value', setting2: 'old-value' };
99
+ const newSettings = { setting1: 'new-value' };
100
+ const mergedSettings = merge(existingSettings, newSettings);
101
+ useToolStore.setState({
102
+ installedPlugins: [{ identifier: pluginId, settings: existingSettings }] as LobeTool[],
103
+ });
104
+
105
+ const { result } = renderHook(() => useToolStore());
106
+
107
+ await act(async () => {
108
+ await result.current.updatePluginSettings(pluginId, newSettings);
109
+ });
110
+
111
+ expect(pluginService.updatePluginSettings).toBeCalledWith(pluginId, mergedSettings);
112
+ });
94
113
  });
95
114
 
96
115
  describe('removeAllPlugins', () => {
@@ -3,6 +3,7 @@ import useSWR, { SWRResponse } from 'swr';
3
3
  import { StateCreator } from 'zustand/vanilla';
4
4
 
5
5
  import { pluginService } from '@/services/plugin';
6
+ import { merge } from '@/utils/merge';
6
7
 
7
8
  import { ToolStore } from '../../store';
8
9
  import { pluginStoreSelectors } from '../store/selectors';
@@ -44,7 +45,11 @@ export const createPluginSlice: StateCreator<
44
45
  await get().refreshPlugins();
45
46
  },
46
47
  updatePluginSettings: async (id, settings) => {
47
- await pluginService.updatePluginSettings(id, settings);
48
+ const previousSettings = pluginSelectors.getPluginSettingsById(id)(get());
49
+
50
+ const nextSettings = merge(previousSettings, settings);
51
+ await pluginService.updatePluginSettings(id, nextSettings);
52
+
48
53
  await get().refreshPlugins();
49
54
  },
50
55
  useCheckPluginsIsInstalled: (plugins) => useSWR(plugins, get().checkPluginsIsInstalled),