-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
β¨ feat(ui): move new topic button to navigation panel #11325
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's guide (collapsed on small PRs)Reviewer's GuideMoves the "Add New Topic" action from the sidebar header into the navigation panel by wiring it through the existing NavItem component, adding a loading state via useActionSWR, and handling navigation back from the agent profile before topic creation, while removing the now-unused header button wiring. Sequence diagram for creating a new topic from the navigation panelsequenceDiagram
actor User
participant NavItem
participant NavComponent
participant Router
participant ChatStore
participant ActionSWR
User->>NavItem: click
NavItem->>NavComponent: onClick handleNewTopic
alt isProfileActive and agentId exists
NavComponent->>Router: push /agent/{agentId}
end
NavComponent->>ActionSWR: mutate openNewTopicOrSaveTopic
ActionSWR->>ChatStore: openNewTopicOrSaveTopic
ChatStore-->>ActionSWR: topic created
ActionSWR-->>NavItem: isValidating false
NavItem-->>User: loading indicator hidden
Flow diagram for handleNewTopic logic in Nav componentflowchart TD
A[User clicks NavItem new topic] --> B[handleNewTopic]
B --> C{isProfileActive and agentId exists}
C -- Yes --> D[router.push /agent/agentId]
C -- No --> E[Skip navigation]
D --> F[useActionSWR mutate openNewTopicOrSaveTopic]
E --> F[useActionSWR mutate openNewTopicOrSaveTopic]
F --> G[openNewTopicOrSaveTopic in chat store]
G --> H[New topic created]
F --> I[isValidating true shown as loading on NavItem]
H --> J[isValidating false, loading hidden]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
TestGru AssignmentSummary
Tip You can |
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.
Hey - I've found 2 issues, and left some high level feedback:
- Consider wrapping
handleNewTopicin auseCallbackwithisProfileActive,agentId, andmutateas dependencies so the memoizedNavcomponent andNavItemprops remain stable and avoid unnecessary re-renders. - You might want to extract the
'openNewTopicOrSaveTopic'action key into a shared constant to avoid string mismatches betweenuseActionSWRand the store action name over time.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider wrapping `handleNewTopic` in a `useCallback` with `isProfileActive`, `agentId`, and `mutate` as dependencies so the memoized `Nav` component and `NavItem` props remain stable and avoid unnecessary re-renders.
- You might want to extract the `'openNewTopicOrSaveTopic'` action key into a shared constant to avoid string mismatches between `useActionSWR` and the store action name over time.
## Individual Comments
### Comment 1
<location> `src/app/[variants]/(main)/chat/_layout/Sidebar/Header/Nav.tsx:33-36` </location>
<code_context>
const toggleCommandMenu = useGlobalStore((s) => s.toggleCommandMenu);
const hideProfile = isInbox || !isAgentEditable;
const switchTopic = useChatStore((s) => s.switchTopic);
+ const [openNewTopicOrSaveTopic] = useChatStore((s) => [s.openNewTopicOrSaveTopic]);
+
+ const { mutate, isValidating } = useActionSWR('openNewTopicOrSaveTopic', openNewTopicOrSaveTopic);
</code_context>
<issue_to_address>
**suggestion (performance):** Avoid wrapping the selector result in an array to reduce unnecessary re-renders.
`useChatStore((s) => [s.openNewTopicOrSaveTopic])` allocates a new array on every store change, so the selector value is never referentially equal and can trigger extra renders. Instead, select the function directly so the reference stays stable:
```ts
const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);
```
This reduces unnecessary re-renders when other store fields change.
```suggestion
const switchTopic = useChatStore((s) => s.switchTopic);
const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);
const { mutate, isValidating } = useActionSWR('openNewTopicOrSaveTopic', openNewTopicOrSaveTopic);
```
</issue_to_address>
### Comment 2
<location> `src/app/[variants]/(main)/chat/_layout/Sidebar/Header/Nav.tsx:37-43` </location>
<code_context>
return (
<Flexbox gap={1} paddingInline={4}>
+ <NavItem
+ icon={MessageSquarePlusIcon}
+ loading={isValidating}
+ onClick={handleNewTopic}
+ title={tTopic('actions.addNewTopic')}
+ />
{!hideProfile && (
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider disabling the click action while `isValidating` is true to avoid duplicate topic actions.
`loading={isValidating}` only changes the visual state; `onClick={handleNewTopic}` can still fire multiple times while the request is in flight. To avoid duplicate `openNewTopicOrSaveTopic` mutations, either early-return in `handleNewTopic` when `isValidating` is true, or treat `loading` as a disabled state in `NavItem` so clicks are ignored while pending.
```suggestion
const handleNewTopic = () => {
// Avoid triggering multiple new topic actions while a request is in flight
if (isValidating) return;
// If in agent sub-route, navigate back to agent chat first
if (isProfileActive && agentId) {
router.push(urlJoin('/agent', agentId));
}
mutate();
};
```
</issue_to_address>Help me be more useful! Please click π or π on each comment and I'll use the feedback to improve your reviews.
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.
Pull request overview
This PR enhances the chat sidebar UX by moving the "Add New Topic" button from the header into the navigation panel for better visual hierarchy and discoverability.
Key Changes
- Relocated new topic button from sidebar header to navigation panel
- Integrated with
NavItemcomponent for consistent styling - Removed
AddTopicButoncomponent reference from header layout
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/app/[variants]/(main)/chat/_layout/Sidebar/Header/index.tsx |
Removed AddTopicButon import and component from header layout |
src/app/[variants]/(main)/chat/_layout/Sidebar/Header/Nav.tsx |
Added new topic button as NavItem with loading state and navigation logic |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #11325 +/- ##
=========================================
Coverage 76.10% 76.10%
=========================================
Files 1128 1128
Lines 86332 86332
Branches 12138 9784 -2354
=========================================
Hits 65699 65699
Misses 20557 20557
Partials 76 76
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
- Move "Add New Topic" button from header to navigation panel for better UX - Integrate with existing NavItem component for consistent styling - Add loading state during topic creation - Auto-navigate from agent profile back to chat when creating new topic
|
β€οΈ Great PR @Innei β€οΈ 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 2.0.0-next.237](v2.0.0-next.236...v2.0.0-next.237) <sup>Released on **2026-01-08**</sup> #### β¨ Features - **ui**: Move new topic button to navigation panel. #### π Bug Fixes - **onboarding**: Prevent step overflow and misc improvements. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's improved * **ui**: Move new topic button to navigation panel, closes [#11325](#11325) ([3d6b399](3d6b399)) #### What's fixed * **onboarding**: Prevent step overflow and misc improvements, closes [#11322](#11322) ([8586fd4](8586fd4)) </details> <div align="right"> [](#readme-top) </div>
|
π This PR is included in version 2.0.0-next.237 π The release is available on: Your semantic-release bot π¦π |
## [Version 1.150.0](v1.149.0...v1.150.0) <sup>Released on **2026-01-08**</sup> #### β» Code Refactoring - **memory-user-memory**: Migrated to use typescript module for prompts. #### β¨ Features - **image**: Improve image generation with new models and bug fixes. - **notebook**: Add i18n, Inspector and Streaming components. - **ui**: Move new topic button to navigation panel. - **misc**: Add browser compatibility detection and fallback page, add the lobehub market tools servers, add the twitter lobehub skill, change the klavis Linear to LobeHub oauth Linear. #### π Bug Fixes - **editor**: Fix slash command codeblock not working. - **onboarding**: Prevent step overflow and misc improvements. - **provider-config**: Update isFetchOnClient Switch component. - **misc**: Add separate border-radius for bottom-right corner on macOS 26 Chrome, correct BrandTextLoading position after removing SSG CSS-in-JS injection, fix edit rich render codeblock, topic renaming input focus issue in context menu, update desktop onboarding privacy description, update mobile topicRouter import path to lambda directory. #### π Styles - **misc**: Update i18n. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### Code refactoring * **memory-user-memory**: Migrated to use typescript module for prompts, closes [lobehub#11344](https://github.com/jaworldwideorg/OneJA-Bot/issues/11344) ([902cfe5](902cfe5)) #### What's improved * **image**: Improve image generation with new models and bug fixes, closes [lobehub#11311](https://github.com/jaworldwideorg/OneJA-Bot/issues/11311) ([4fc03bb](4fc03bb)) * **notebook**: Add i18n, Inspector and Streaming components, closes [lobehub#11212](https://github.com/jaworldwideorg/OneJA-Bot/issues/11212) ([f7dc54f](f7dc54f)) * **ui**: Move new topic button to navigation panel, closes [lobehub#11325](https://github.com/jaworldwideorg/OneJA-Bot/issues/11325) ([3d6b399](3d6b399)) * **misc**: Add browser compatibility detection and fallback page, closes [lobehub#11309](https://github.com/jaworldwideorg/OneJA-Bot/issues/11309) ([8be32c2](8be32c2)) * **misc**: Add the lobehub market tools servers, closes [lobehub#11315](https://github.com/jaworldwideorg/OneJA-Bot/issues/11315) ([a4003a3](a4003a3)) * **misc**: Add the twitter lobehub skill, closes [lobehub#11342](https://github.com/jaworldwideorg/OneJA-Bot/issues/11342) ([503acb3](503acb3)) * **misc**: Change the klavis Linear to LobeHub oauth Linear, closes [lobehub#11339](https://github.com/jaworldwideorg/OneJA-Bot/issues/11339) ([ec8ff26](ec8ff26)) #### What's fixed * **editor**: Fix slash command codeblock not working, closes [lobehub#11321](https://github.com/jaworldwideorg/OneJA-Bot/issues/11321) ([f9a35eb](f9a35eb)) * **onboarding**: Prevent step overflow and misc improvements, closes [lobehub#11322](https://github.com/jaworldwideorg/OneJA-Bot/issues/11322) ([8586fd4](8586fd4)) * **provider-config**: Update isFetchOnClient Switch component, closes [lobehub#11215](https://github.com/jaworldwideorg/OneJA-Bot/issues/11215) ([5bb038b](5bb038b)) * **misc**: Add separate border-radius for bottom-right corner on macOS 26 Chrome, closes [lobehub#11287](https://github.com/jaworldwideorg/OneJA-Bot/issues/11287) ([544931a](544931a)) * **misc**: Correct BrandTextLoading position after removing SSG CSS-in-JS injection, closes [lobehub#11312](https://github.com/jaworldwideorg/OneJA-Bot/issues/11312) ([0de4eb8](0de4eb8)) * **misc**: Fix edit rich render codeblock, closes [lobehub#11303](https://github.com/jaworldwideorg/OneJA-Bot/issues/11303) ([5338170](5338170)) * **misc**: Topic renaming input focus issue in context menu, closes [lobehub#11323](https://github.com/jaworldwideorg/OneJA-Bot/issues/11323) ([dd065fc](dd065fc)) * **misc**: Update desktop onboarding privacy description, closes [lobehub#11307](https://github.com/jaworldwideorg/OneJA-Bot/issues/11307) [lobehub#11308](https://github.com/jaworldwideorg/OneJA-Bot/issues/11308) ([58b10a2](58b10a2)) * **misc**: Update mobile topicRouter import path to lambda directory, closes [lobehub#11261](https://github.com/jaworldwideorg/OneJA-Bot/issues/11261) ([f591b77](f591b77)) #### Styles * **misc**: Update i18n, closes [lobehub#11297](https://github.com/jaworldwideorg/OneJA-Bot/issues/11297) ([4705abf](4705abf)) </details> <div align="right"> [](#readme-top) </div>
β¨ feat: move new topic button to navigation panel - Move "Add New Topic" button from header to navigation panel for better UX - Integrate with existing NavItem component for consistent styling - Add loading state during topic creation - Auto-navigate from agent profile back to chat when creating new topic
## [Version 2.0.0-next.237](lobehub/lobehub@v2.0.0-next.236...v2.0.0-next.237) <sup>Released on **2026-01-08**</sup> #### β¨ Features - **ui**: Move new topic button to navigation panel. #### π Bug Fixes - **onboarding**: Prevent step overflow and misc improvements. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's improved * **ui**: Move new topic button to navigation panel, closes [lobehub#11325](lobehub#11325) ([3d6b399](lobehub@3d6b399)) #### What's fixed * **onboarding**: Prevent step overflow and misc improvements, closes [lobehub#11322](lobehub#11322) ([8586fd4](lobehub@8586fd4)) </details> <div align="right"> [](#readme-top) </div>
π» Change Type
π Related Issue
N/A
π Description of Change
This PR improves the UX of the chat sidebar by relocating the "Add New Topic" button from the header into the navigation panel.
Changes:
NavItemcomponent for consistent stylingAddTopicButtoncomponent from header layoutBenefits:
π§ͺ How to Test
Testing steps:
πΈ Screenshots / Videos
π Additional Information
No breaking changes. This is a UI enhancement that maintains existing functionality while improving the user experience.
Summary by Sourcery
Relocate the chat "New Topic" action into the sidebar navigation for improved UX and consistency.
New Features:
Enhancements: