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: refactor user store and fix custom model list form #2620

Merged
merged 9 commits into from
May 23, 2024

Conversation

arvinxx
Copy link
Contributor

@arvinxx arvinxx commented May 23, 2024

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • ⚡️ perf
  • 📝 docs

🔀 变更说明 | Description of Change

我们在 #2022 中从 globalStore 中拆分出来了独立的 userStore ,并基于此初步实现了用户鉴权的功能。

但是之前的实现以快速上线为主,这也导致现在的 userStore 的代码比较乱:

  • 之前 globalStore 中存在的 preference 和 userStore 的 userConfig 的获取,需要调用多个 userService 的方法才能完成。
  • 同时之前在 globalStore 中存在的 serverConfig 请求也污染了 userStore的数据流

因此在本 PR 中对 userStore 做一次相对完整的重构。

  • 移除 userStore 的 serverConfig,在初始化时将关键字段 languageModel 注入 useStore;
  • 收敛所有 user 初始化相关方法,到一个统一的 useInitUserState 中;
  • 抽取 modelList 相关的实现到独立 slice,并优化细节的实现逻辑;
  • 优化 sync 的启动逻辑,结合 featureFlag 实现更加精准的初始化;
  • 优化 trace 判断逻辑,不再调用 messageService 进行判断,同样由 userState 中存取
  • 补充 slice 和 service 的单元测试;

📝 补充信息 | Additional Information

refs:

Copy link

vercel bot commented May 23, 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 May 23, 2024 2:29pm

@lobehubbot
Copy link
Member

👍 @arvinxx

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 May 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.65%. Comparing base (b287b0a) to head (02e9cff).
Report is 773 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2620      +/-   ##
==========================================
+ Coverage   93.54%   93.65%   +0.10%     
==========================================
  Files         344      347       +3     
  Lines       20287    20286       -1     
  Branches     1548     1563      +15     
==========================================
+ Hits        18978    18998      +20     
+ Misses       1309     1288      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arvinxx arvinxx changed the title ♻️ refactor: refactor user store 🐛 fix: refactor user store and fix custom model list form May 23, 2024
@arvinxx arvinxx merged commit 81ea886 into main May 23, 2024
10 checks passed
@arvinxx arvinxx deleted the refactor/user-store branch May 23, 2024 14:33
@lobehubbot
Copy link
Member

❤️ Great PR @arvinxx ❤️

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 May 23, 2024
### [Version 0.161.10](v0.161.9...v0.161.10)
<sup>Released on **2024-05-23**</sup>

#### 🐛 Bug Fixes

- **misc**: Refactor user store and fix custom model list form.

<br/>

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

#### What's fixed

* **misc**: Refactor user store and fix custom model list form, closes [#2620](#2620) ([81ea886](81ea886))

</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.161.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request May 23, 2024
### [Version&nbsp;1.41.5](v1.41.4...v1.41.5)
<sup>Released on **2024-05-23**</sup>

#### 🐛 Bug Fixes

- **misc**: Refactor user store and fix custom model list form.

#### 💄 Styles

- **misc**: Fix image style and improve drag upload box.

<br/>

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

#### What's fixed

* **misc**: Refactor user store and fix custom model list form, closes [lobehub#2620](https://github.com/bentwnghk/lobe-chat/issues/2620) ([81ea886](81ea886))

#### Styles

* **misc**: Fix image style and improve drag upload box, closes [lobehub#2610](https://github.com/bentwnghk/lobe-chat/issues/2610) ([5e1a4d6](5e1a4d6))

</details>

<div align="right">

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

</div>
ipoly pushed a commit to ipoly/lobe-chat that referenced this pull request Jul 29, 2024
* ♻️ refactor: refactor user store

* ♻️ refactor: refactor the user trace

* 🐛 fix: fix parser model

* 🐛 fix: fix parser model

* 🐛 fix: fix parser model

* ♻️ refactor: refactor modal

* 🐛 fix: try to fix modal

* 🐛 fix: fix model list select error

* ✅ test: add test for model list
ipoly pushed a commit to ipoly/lobe-chat that referenced this pull request Jul 29, 2024
### [Version&nbsp;0.161.10](lobehub/lobe-chat@v0.161.9...v0.161.10)
<sup>Released on **2024-05-23**</sup>

#### 🐛 Bug Fixes

- **misc**: Refactor user store and fix custom model list form.

<br/>

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

#### What's fixed

* **misc**: Refactor user store and fix custom model list form, closes [lobehub#2620](lobehub#2620) ([81ea886](lobehub@81ea886))

</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
2 participants