Skip to content

Conversation

@ONLY-yours
Copy link
Member

@ONLY-yours ONLY-yours commented Oct 21, 2025

💻 Change Type

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

🔀 Description of Change

📝 Additional Information

Summary by Sourcery

Convert the Discover section from Next.js server-rendered pages to a client-side SPA using React Router.

New Features:

  • Introduce a DiscoverRouter component backed by MemoryRouter and react-router-dom to handle client-side navigation
  • Create dedicated list and detail page components for assistants, models, providers, and plugins along with responsive layouts

Enhancements:

  • Replace Next.js useRouter/usePathname navigation with react-router-dom� useNavigate/useLocation and update all Link components to <Link to>
  • Restructure layouts into mobile and desktop variants for list, detail, and overall Discover views
  • Adjust URL paths to remove the /discover prefix in internal routing while synchronizing browser history

Build:

  • Add react-router-dom and react-responsive dependencies

Chores:

  • Export isMobileDevice from server utility for mobile detection

@vercel
Copy link

vercel bot commented Oct 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lobehub-database Ready Ready Preview Comment Oct 22, 2025 1:12pm
lobehub-lite Ready Ready Preview Comment Oct 22, 2025 1:12pm

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 21, 2025

Reviewer's Guide

This PR migrates the Discover section from Next.js RSC to a client-side SPA using react-router-dom MemoryRouter. It replaces Next.js navigation and routing APIs with react-router hooks, restructures pages and layouts into SPA routes, adjusts URL paths and base segments, and introduces responsive layout handling for mobile vs desktop.

Sequence diagram for navigation in Discover SPA

sequenceDiagram
  participant User as actor User
  participant UI as Discover UI
  participant Router as MemoryRouter
  participant UrlSync as UrlSynchronizer
  User->>UI: Clicks navigation link or button
  UI->>Router: Calls useNavigate(link)
  Router->>UI: Renders new route component
  UI->>UrlSync: Location changes
  UrlSync->>Browser: Updates browser URL (window.history.replaceState)
  Browser->>User: Shows updated URL and page
Loading

File-Level Changes

Change Details Files
Replace Next.js navigation hooks with react-router-dom
  • Swapped useRouter, usePathname, useQueryRoute for useNavigate and useLocation
  • Replaced Link href props with react-router-dom’s Link to or plain tags
  • Updated onClick handlers to call navigate() with URLSearchParams
Item.tsx
useNav.tsx
Pagination.tsx
Header.tsx
Various List/Item components
Nav.tsx
Category indexes
Title.tsx
Back.tsx
Convert Discover into SPA with MemoryRouter
  • Introduced DiscoverRouter component with MemoryRouter and UrlSynchronizer
  • Defined client-side Routes for list and detail pages under SPA context
  • Removed Next.js dynamic page files in favor of SPA route components
DiscoverRouter.tsx
DiscoverPage.tsx
AssistantPage.tsx
ModelPage.tsx
ProviderPage.tsx
McpPage.tsx
DetailPage components
Restructure and unify route paths
  • Dropped "/discover" prefix, mapping tabs to root segments
  • Adjusted urlJoin calls and path comparisons in useNav
  • Updated navigate targets across all list and item links
useNav.tsx
Item.tsx
Pagination.tsx
Nav.tsx
Category components
Introduce responsive layout wrappers
  • Added react-responsive useMediaQuery to detect mobile
  • Created DiscoverLayout, ListLayout, DetailLayout, and individual mobile/desktop wrappers
  • Conditionally render Mobile or Desktop components based on screen width
DiscoverLayout.tsx
ListLayout.tsx
DetailLayout.tsx
AssistantLayout.tsx
ModelLayout.tsx
ProviderLayout.tsx
McpLayout.tsx
Revise Pagination navigation logic
  • Removed custom useQueryRoute, using navigate and location.search
  • Built new URLSearchParams to update page query
  • Ensured smooth scroll to top after navigation
Pagination.tsx
Update package dependencies and exports
  • Added react-router-dom and react-responsive to package.json
  • Exported isMobileDevice from server utils
  • Changed layout components from async to synchronous
package.json
utils/src/server/responsive.ts
Desktop Layout files

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Oct 21, 2025
@gru-agent
Copy link
Contributor

gru-agent bot commented Oct 21, 2025

There is too much information in the pull request to test.

@lobehubbot
Copy link
Member

👍 @ONLY-yours

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.

@dosubot dosubot bot added the javascript Pull requests that update Javascript code label Oct 21, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider replacing MemoryRouter with BrowserRouter (or HashRouter) to simplify URL handling and remove the need for manual URL synchronizer logic.
  • The URL‐sync logic in UrlSynchronizer and getInitialPath is duplicated and could lead to subtle sync bugs—consolidate into a single effect or utility to avoid mismatches or infinite loops.
  • You're using react-router Link for external URLs (with target="_blank"); switch to plain tags for those to prevent React Router from intercepting external navigations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider replacing MemoryRouter with BrowserRouter (or HashRouter) to simplify URL handling and remove the need for manual URL synchronizer logic.
- The URL‐sync logic in UrlSynchronizer and getInitialPath is duplicated and could lead to subtle sync bugs—consolidate into a single effect or utility to avoid mismatches or infinite loops.
- You're using react-router Link for external URLs (with target="_blank"); switch to plain <a> tags for those to prevent React Router from intercepting external navigations.

## Individual Comments

### Comment 1
<location> `src/app/[variants]/(main)/discover/(list)/model/_layout/Desktop.tsx:7` </location>
<code_context>
 import CategoryContainer from '../../../components/CategoryContainer';
 import Category from '../features/Category';

-const Layout = async ({ children }: PropsWithChildren) => {
+const Layout = ({ children }: PropsWithChildren) => {
   return (
     <Flexbox gap={24} horizontal style={{ position: 'relative' }} width={'100%'}>
</code_context>

<issue_to_address>
**suggestion:** Removed unnecessary async from Layout component.

Removing 'async' clarifies the component's intent and aligns with React's best practices for component definitions.
</issue_to_address>

### Comment 2
<location> `src/app/[variants]/(main)/discover/features/useNav.tsx:18` </location>
<code_context>
    const pathname = location.pathname;

</code_context>

<issue_to_address>
**suggestion (code-quality):** Prefer object destructuring when accessing and using properties. ([`use-object-destructuring`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/use-object-destructuring))

```suggestion
    const {pathname} = location;
```

<br/><details><summary>Explanation</summary>Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the [Airbnb Javascript Style Guide](https://airbnb.io/javascript/#destructuring--object)
</details>
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

const { t } = useTranslation('discover');

const activeKey = useMemo(() => {
const pathname = location.pathname;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Prefer object destructuring when accessing and using properties. (use-object-destructuring)

Suggested change
const pathname = location.pathname;
const {pathname} = location;


ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.

From the Airbnb Javascript Style Guide

@codecov
Copy link

codecov bot commented Oct 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.55%. Comparing base (d481315) to head (de3dc01).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #9828     +/-   ##
=========================================
  Coverage   84.55%   84.55%             
=========================================
  Files         944      944             
  Lines       64507    64507             
  Branches     7900     9284   +1384     
=========================================
  Hits        54541    54541             
  Misses       9966     9966             
Flag Coverage Δ
app 80.21% <ø> (ø)
database 98.51% <ø> (ø)
packages/agent-runtime 99.63% <ø> (ø)
packages/context-engine 93.51% <ø> (ø)
packages/electron-server-ipc 93.76% <ø> (ø)
packages/file-loaders 92.21% <ø> (ø)
packages/model-bank 100.00% <ø> (ø)
packages/model-runtime 92.16% <ø> (ø)
packages/prompts 77.21% <ø> (ø)
packages/python-interpreter 96.50% <ø> (ø)
packages/utils 94.50% <ø> (ø)
packages/web-crawler 97.07% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 74.88% <ø> (ø)
Services 61.64% <ø> (ø)
Server 77.39% <ø> (ø)
Libs 50.82% <ø> (ø)
Utils 75.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

🚀 Desktop App Build Completed!

Version: 0.0.0-nightly.pr9828.7435
Build Time: 2025-10-22T16:34:14.051Z

📦 View All Build Artifacts

Build Artifacts

Platform File Size
macOS (Apple Silicon) LobeHub-Nightly-0.0.0-nightly.pr9828.7435-arm64.dmg 182.22 MB
macOS (Intel) LobeHub-Nightly-0.0.0-nightly.pr9828.7435-x64.dmg 189.35 MB
Windows LobeHub-Nightly-0.0.0-nightly.pr9828.7435-setup.exe 159.28 MB
Linux LobeHub-Nightly-0.0.0-nightly.pr9828.7435.AppImage 224.51 MB

Warning

Note: This is a temporary build for testing purposes only.

@ONLY-yours ONLY-yours removed the invalid Invalid issue or not a real issue label Oct 22, 2025
@arvinxx arvinxx changed the title feat: change discover page from rsc to spa render ♻️ refactor: change discover page from rsc to spa render Oct 22, 2025
Copy link
Member

@arvinxx arvinxx left a comment

Choose a reason for hiding this comment

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

lgtm now

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 22, 2025
@arvinxx arvinxx changed the title ♻️ refactor: change discover page from rsc to spa render ♻️ refactor: change discover page from rsc to SPA to improve performance Oct 22, 2025
@arvinxx arvinxx merged commit b59ee0a into main Oct 22, 2025
60 checks passed
@arvinxx arvinxx deleted the fix/discoverPage branch October 22, 2025 15:35
@lobehubbot
Copy link
Member

❤️ Great PR @ONLY-yours ❤️

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.

lobehubbot pushed a commit that referenced this pull request Oct 22, 2025
### [Version&nbsp;1.141.5](v1.141.4...v1.141.5)
<sup>Released on **2025-10-22**</sup>

#### ♻ Code Refactoring

- **misc**: Change discover page from RSC to SPA to improve performance.

<br/>

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

#### Code refactoring

* **misc**: Change discover page from RSC to SPA to improve performance, closes [#9828](#9828) ([b59ee0a](b59ee0a))

</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 1.141.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

JamieStivala pushed a commit to jaworldwideorg/OneJA-Bot that referenced this pull request Oct 27, 2025
## [Version&nbsp;1.135.0](v1.134.0...v1.135.0)
<sup>Released on **2025-10-27**</sup>

#### ♻ Code Refactoring

- **misc**: Change discover page from RSC to SPA to improve performance.

#### ✨ Features

- **misc**: Use env to control clerk allow origin feature.

#### 🐛 Bug Fixes

- **misc**: Loadmore not work & navbar not show in pwa.

#### 💄 Styles

- **misc**: Adjust modal setting form styles for improved layout and responsiveness, Allow removal of `top_p` and similar request parameters, improve local system tools render, improve provider modal height when creating custom provider, Improvement for Agent Team After Alpha Launch [LOB-517], Unzip file when uploading in knowledge base [LOB-500], update i18n.

<br/>

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

#### Code refactoring

* **misc**: Change discover page from RSC to SPA to improve performance, closes [lobehub#9828](https://github.com/jaworldwideorg/OneJA-Bot/issues/9828) ([b59ee0a](b59ee0a))

#### What's improved

* **misc**: Use env to control clerk allow origin feature, closes [lobehub#9863](https://github.com/jaworldwideorg/OneJA-Bot/issues/9863) ([490fee0](490fee0))

#### What's fixed

* **misc**: Loadmore not work & navbar not show in pwa, closes [lobehub#9855](https://github.com/jaworldwideorg/OneJA-Bot/issues/9855) ([411f875](411f875))

#### Styles

* **misc**: Adjust modal setting form styles for improved layout and responsiveness, closes [lobehub#9890](https://github.com/jaworldwideorg/OneJA-Bot/issues/9890) ([1997ec5](1997ec5))
* **misc**: Allow removal of `top_p` and similar request parameters, closes [lobehub#9498](https://github.com/jaworldwideorg/OneJA-Bot/issues/9498) ([4c313ce](4c313ce))
* **misc**: Improve local system tools render, closes [lobehub#9853](https://github.com/jaworldwideorg/OneJA-Bot/issues/9853) ([295e8fc](295e8fc))
* **misc**: Improve provider modal height when creating custom provider, closes [lobehub#9870](https://github.com/jaworldwideorg/OneJA-Bot/issues/9870) ([55d92c0](55d92c0))
* **misc**: Improvement for Agent Team After Alpha Launch [LOB-517], closes [lobehub#9748](https://github.com/jaworldwideorg/OneJA-Bot/issues/9748) ([28245be](28245be))
* **misc**: Unzip file when uploading in knowledge base [LOB-500], closes [lobehub#9854](https://github.com/jaworldwideorg/OneJA-Bot/issues/9854) ([e568ce6](e568ce6))
* **misc**: Update i18n, closes [lobehub#9862](https://github.com/jaworldwideorg/OneJA-Bot/issues/9862) ([8d3bc91](8d3bc91))

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

javascript Pull requests that update Javascript code lgtm This PR has been approved by a maintainer released size:XXL This PR changes 1000+ lines, ignoring generated files. trigger:build-desktop Trigger Desktop build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The window crashed and cannot perform operation

4 participants