-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 fix: plugins with multiple settings cannot be correctly configured #1991
Conversation
@yanghanlin is attempting to deploy a commit to the LobeHub Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for raising your pull request and contributing to our Community |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1991 +/- ##
========================================
Coverage 92.56% 92.56%
========================================
Files 279 279
Lines 15973 15978 +5
Branches 1153 1851 +698
========================================
+ Hits 14785 14790 +5
Misses 1188 1188 ☔ View full report in Codecov by Sentry. |
@@ -74,7 +74,7 @@ const PluginSettingsConfig = memo<PluginSettingsConfigProps>(({ schema, id }) => | |||
maximum={item.maximum} | |||
minimum={item.minimum} | |||
onChange={(value) => { | |||
updatePluginSettings(id, { [item.name]: value }); | |||
updatePluginSettings(id, { ...pluginSetting, [item.name]: value }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
合并应该做在这里,还是应该做到更加底层的位置?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
重新看了下确实合并做到更底层一点的 Zustand action 层比较合适,如 PreferenceAction#updatePreference
:
lobe-chat/src/store/global/slices/preference/action.ts
Lines 69 to 75 in 904a3df
updatePreference: (preference, action) => { | |
const nextPreference = merge(get().preference, preference); | |
set({ preference: nextPreference }, false, action || n('updatePreference')); | |
get().preferenceStorage.saveToLocalStorage(nextPreference); | |
}, |
已更改。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外如此改动有一个副作用:LobeChat Plugin SDK 提供的插件侧修改设置相关 API 也依赖于这里的逻辑,因此该 API 的行为也会从全量更新插件设置改为增量更新;但目前插件市场中似乎还没有需要多个设置项的插件,因此影响可控。
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
e6ab2e7
to
b1e131a
Compare
b1e131a
to
862d0f6
Compare
@yanghanlin 我已经触发部署了一个版本: https://lobe-chat-community-git-fork-yanghanlin-fix-plug-d8e44a-lobehub.vercel.app/ 你看下在这个版本中 setting 的配置是否符合 mj 插件那个PR中的预期? |
@arvinxx 经测试符合预期,MJ 插件能顺利接收到宿主侧配置的 API URL 与 secret。 |
@arvinxx The test is in line with expectations. The MJ plug-in can successfully receive the API URL and secret configured on the host side. |
❤️ Great PR @yanghanlin ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
### [Version 0.151.6](v0.151.5...v0.151.6) <sup>Released on **2024-04-30**</sup> #### 🐛 Bug Fixes - **misc**: Plugins with multiple settings cannot be correctly configured. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Plugins with multiple settings cannot be correctly configured, closes [#1991](#1991) ([0c041aa](0c041aa)) </details> <div align="right"> [](#readme-top) </div>
🎉 This PR is included in version 0.151.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
### [Version 1.31.1](v1.31.0...v1.31.1) <sup>Released on **2024-04-30**</sup> #### ♻ Code Refactoring - **misc**: Move app page to the `(main)` layout group. #### 🐛 Bug Fixes - **misc**: Effectively interrupt auto scrolling, fix only inject welcome question in inbox, plugins with multiple settings cannot be correctly configured. #### 💄 Styles - **misc**: Add 404 and Error page, patching models info, Revise some text. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **misc**: Move app page to the `(main)` layout group, closes [lobehub#2297](https://github.com/bentwnghk/lobe-chat/issues/2297) ([6cc2c38](6cc2c38)) #### What's fixed * **misc**: Effectively interrupt auto scrolling, closes [lobehub#2223](https://github.com/bentwnghk/lobe-chat/issues/2223) ([afe4974](afe4974)) * **misc**: Fix only inject welcome question in inbox, closes [lobehub#2289](https://github.com/bentwnghk/lobe-chat/issues/2289) ([cc8edd3](cc8edd3)) * **misc**: Plugins with multiple settings cannot be correctly configured, closes [lobehub#1991](https://github.com/bentwnghk/lobe-chat/issues/1991) ([0c041aa](0c041aa)) #### Styles * **misc**: Add 404 and Error page, closes [lobehub#2299](https://github.com/bentwnghk/lobe-chat/issues/2299) ([938a3e9](938a3e9)) * **misc**: Patching models info, closes [lobehub#2269](https://github.com/bentwnghk/lobe-chat/issues/2269) [#22802280](https://github.com/bentwnghk/lobe-chat/issues/22802280) ([03bcb06](03bcb06)) * **misc**: Revise some text, closes [lobehub#2296](https://github.com/bentwnghk/lobe-chat/issues/2296) ([018427f](018427f)) </details> <div align="right"> [](#readme-top) </div>
…obehub#1991) * 🐛 fix: plugins with multiple settings cannot be correctly configured * ♻️ refactor: merge plugin setting in the action layer instead of UI * ✅ test: add a test to ensure plugin settings are correctly merged
### [Version 0.151.6](lobehub/lobe-chat@v0.151.5...v0.151.6) <sup>Released on **2024-04-30**</sup> #### 🐛 Bug Fixes - **misc**: Plugins with multiple settings cannot be correctly configured. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Plugins with multiple settings cannot be correctly configured, closes [lobehub#1991](lobehub#1991) ([0c041aa](lobehub@0c041aa)) </details> <div align="right"> [](#readme-top) </div>
…obehub#1991) * 🐛 fix: plugins with multiple settings cannot be correctly configured * ♻️ refactor: merge plugin setting in the action layer instead of UI * ✅ test: add a test to ensure plugin settings are correctly merged
### [Version 0.151.6](lobehub/lobe-chat@v0.151.5...v0.151.6) <sup>Released on **2024-04-30**</sup> #### 🐛 Bug Fixes - **misc**: Plugins with multiple settings cannot be correctly configured. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **misc**: Plugins with multiple settings cannot be correctly configured, closes [lobehub#1991](lobehub#1991) ([0c041aa](lobehub@0c041aa)) </details> <div align="right"> [](#readme-top) </div>
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
Currently, when a LobeChat plugin provides multiple fields in its settings, and the user edits one of the fields, the other fields will be cleared.
For example, the following screenshot demonstrates a plugin
Midjourney DEV
providing 2 fields in the settingsMIDJOURNEY_PROXY_URL
andMIDJOURNEY_PROXY_API_SECRET
. By adding a logging statement inPluginService.updatePluginSettings
, it can be seen that editing either of them will result in the other being cleared.This PR fixes this issue by merging the edited field into the existing settings object.
📝 补充信息 | Additional Information