Skip to content
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

Merged
merged 3 commits into from Apr 30, 2024

Conversation

YangHanlin
Copy link
Contributor

๐Ÿ’ป ๅ˜ๆ›ด็ฑปๅž‹ | Change Type

  • โœจ feat
  • ๐Ÿ› fix
  • โ™ป๏ธ refactor
  • ๐Ÿ’„ style
  • ๐Ÿ”จ chore
  • โšก๏ธ perf
  • ๐Ÿ“ docs

๐Ÿ”€ ๅ˜ๆ›ด่ฏดๆ˜Ž | 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 settings MIDJOURNEY_PROXY_URL and MIDJOURNEY_PROXY_API_SECRET. By adding a logging statement in PluginService.updatePluginSettings, it can be seen that editing either of them will result in the other being cleared.

image

This PR fixes this issue by merging the edited field into the existing settings object.

๐Ÿ“ ่กฅๅ……ไฟกๆฏ | Additional Information

Copy link

vercel bot commented Apr 11, 2024

@YangHanlin is attempting to deploy a commit to the LobeHub Team on Vercel.

A member of the Team first needs to authorize it.

@lobehubbot
Copy link
Member

๐Ÿ‘ @YangHanlin

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
้žๅธธๆ„Ÿ่ฐขๆ‚จๆๅ‡บๆ‹‰ๅ–่ฏทๆฑ‚ๅนถไธบๆˆ‘ไปฌ็š„็คพๅŒบๅšๅ‡บ่ดก็Œฎ๏ผŒ่ฏท็กฎไฟๆ‚จๅทฒ็ป้ตๅพชไบ†ๆˆ‘ไปฌ็š„่ดก็ŒฎๆŒ‡ๅ—๏ผŒๆˆ‘ไปฌไผšๅฐฝๅฟซๅฎกๆŸฅๅฎƒใ€‚
ๅฆ‚ๆžœๆ‚จ้‡ๅˆฐไปปไฝ•้—ฎ้ข˜๏ผŒ่ฏท้šๆ—ถไธŽๆˆ‘ไปฌ่”็ณปใ€‚

Copy link

codecov bot commented Apr 11, 2024

Codecov Report

All modified and coverable lines are covered by tests โœ…

Project coverage is 92.56%. Comparing base (74b1ae0) to head (3a8f936).
Report is 2 commits behind head on main.

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.
๐Ÿ“ข Have feedback on the report? Share it here.

@@ -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 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ๅˆๅนถๅบ”่ฏฅๅšๅœจ่ฟ™้‡Œ๏ผŒ่ฟ˜ๆ˜ฏๅบ”่ฏฅๅšๅˆฐๆ›ดๅŠ ๅบ•ๅฑ‚็š„ไฝ็ฝฎ๏ผŸ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

้‡ๆ–ฐ็œ‹ไบ†ไธ‹็กฎๅฎžๅˆๅนถๅšๅˆฐๆ›ดๅบ•ๅฑ‚ไธ€็‚น็š„ Zustand action ๅฑ‚ๆฏ”่พƒๅˆ้€‚๏ผŒๅฆ‚ PreferenceAction#updatePreference:

updatePreference: (preference, action) => {
const nextPreference = merge(get().preference, preference);
set({ preference: nextPreference }, false, action || n('updatePreference'));
get().preferenceStorage.saveToLocalStorage(nextPreference);
},

ๅทฒๆ›ดๆ”นใ€‚

Copy link
Contributor Author

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 ็š„่กŒไธบไนŸไผšไปŽๅ…จ้‡ๆ›ดๆ–ฐๆ’ไปถ่ฎพ็ฝฎๆ”นไธบๅขž้‡ๆ›ดๆ–ฐ๏ผ›ไฝ†็›ฎๅ‰ๆ’ไปถๅธ‚ๅœบไธญไผผไนŽ่ฟ˜ๆฒกๆœ‰้œ€่ฆๅคšไธช่ฎพ็ฝฎ้กน็š„ๆ’ไปถ๏ผŒๅ› ๆญคๅฝฑๅ“ๅฏๆŽงใ€‚

Copy link

vercel bot commented Apr 22, 2024

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Comments Updated (UTC)
lobe-chat-community โœ… Ready (Inspect) Visit Preview ๐Ÿ’ฌ Add feedback Apr 27, 2024 5:37pm

@arvinxx
Copy link
Contributor

arvinxx commented Apr 29, 2024

@YangHanlin ๆˆ‘ๅทฒ็ป่งฆๅ‘้ƒจ็ฝฒไบ†ไธ€ไธช็‰ˆๆœฌ๏ผš https://lobe-chat-community-git-fork-yanghanlin-fix-plug-d8e44a-lobehub.vercel.app/ ไฝ ็œ‹ไธ‹ๅœจ่ฟ™ไธช็‰ˆๆœฌไธญ setting ็š„้…็ฝฎๆ˜ฏๅฆ็ฌฆๅˆ mj ๆ’ไปถ้‚ฃไธชPRไธญ็š„้ข„ๆœŸ๏ผŸ

@YangHanlin
Copy link
Contributor Author

ไฝ ็œ‹ไธ‹ๅœจ่ฟ™ไธช็‰ˆๆœฌไธญ setting ็š„้…็ฝฎๆ˜ฏๅฆ็ฌฆๅˆ mj ๆ’ไปถ้‚ฃไธชPRไธญ็š„้ข„ๆœŸ๏ผŸ

@arvinxx ็ปๆต‹่ฏ•็ฌฆๅˆ้ข„ๆœŸ๏ผŒMJ ๆ’ไปถ่ƒฝ้กบๅˆฉๆŽฅๆ”ถๅˆฐๅฎฟไธปไพง้…็ฝฎ็š„ API URL ไธŽ secretใ€‚

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


Can you see if the setting configuration in this version meets the expectations in the PR of the mj plug-in?

@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.

@arvinxx arvinxx merged commit 0c041aa into lobehub:main Apr 30, 2024
6 checks passed
@lobehubbot
Copy link
Member

โค๏ธ 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.
้กน็›ฎ็š„ๆˆ้•ฟ็ฆปไธๅผ€็”จๆˆทๅ้ฆˆๅ’Œ่ดก็Œฎ๏ผŒๆ„Ÿ่ฐขๆ‚จ็š„่ดก็Œฎ! ๅฆ‚ๆžœๆ‚จๅฏน LobeHub ๅผ€ๅ‘่€…็คพๅŒบๆ„Ÿๅ…ด่ถฃ๏ผŒ่ฏทๅŠ ๅ…ฅๆˆ‘ไปฌ็š„ discord๏ผŒ็„ถๅŽ็งไฟก @arvinxx ๆˆ– @canisminor1990ใ€‚ไป–ไปฌไผš้‚€่ฏทๆ‚จๅŠ ๅ…ฅๆˆ‘ไปฌ็š„็งๅฏ†ๅผ€ๅ‘่€…้ข‘้“ใ€‚ๆˆ‘ไปฌๅฐ†ไผš่ฎจ่ฎบๅ…ณไบŽ Lobe Chat ็š„ๅผ€ๅ‘๏ผŒๅˆ†ไบซๅ’Œ่ฎจ่ฎบๅ…จ็ƒ่Œƒๅ›ดๅ†…็š„ AI ๆถˆๆฏใ€‚

github-actions bot pushed a commit that referenced this pull request Apr 30, 2024
### [Version&nbsp;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">

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

</div>
@lobehubbot
Copy link
Member

๐ŸŽ‰ This PR is included in version 0.151.6 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Apr 30, 2024
### [Version&nbsp;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">

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

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants