-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
📌 fix: Fetch Pinned Chats Independently of the Chats List #14860
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
Open
+1,527
−100
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3b8a33f
feat: give the pinned chats section its own fetch
berry-13 0e41f98
fix: address review findings on the pinned chats section
berry-13 1b88ff9
fix: keep the pinned cache reconciled across the other convo mutations
berry-13 ceb2a3a
fix: invalidate pins on tag and project-deletion changes
berry-13 987dda6
fix: cancel in-flight pinned fetches when deleting a conversation
berry-13 34de556
test: make the SSE query-cache mock key-aware
berry-13 431ce23
fix: keep pins in sync through upsert and pin-only pages
berry-13 077edf5
fix: keep pins current through SSE recovery and project delete
berry-13 6c84cac
fix: keep pins current after bookmark edits and failed pages
berry-13 da104d9
fix: keep pins visible after a failed refetch
berry-13 f372c57
test: type the pinned conversation fixtures correctly
berry-13 3de6486
style: sort the sidebar imports to the repo order
berry-13 4693f54
fix: keep drained pins and empty chat caches from breaking the sidebar
berry-13 5a4d087
fix: order fallback pins by their timestamp
berry-13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { memo, useMemo } from 'react'; | ||
| import { ChevronDown } from 'lucide-react'; | ||
| import type { TConversation } from 'librechat-data-provider'; | ||
| import { useLocalize, useLocalStorage } from '~/hooks'; | ||
| import { useActiveJobs } from '~/data-provider'; | ||
| import { cn } from '~/utils'; | ||
| import Convo from './Convo'; | ||
|
|
||
| const noop = () => {}; | ||
|
|
||
| interface PinnedSectionProps { | ||
| conversations: TConversation[]; | ||
| toggleNav: () => void; | ||
| } | ||
|
|
||
| const PinnedSection = ({ conversations, toggleNav }: PinnedSectionProps) => { | ||
| const localize = useLocalize(); | ||
| const [isExpanded, setIsExpanded] = useLocalStorage('pinnedSectionExpanded', true); | ||
| const { data: activeJobsData } = useActiveJobs(); | ||
| const activeJobIds = useMemo( | ||
| () => new Set(activeJobsData?.activeJobIds ?? []), | ||
| [activeJobsData?.activeJobIds], | ||
| ); | ||
|
|
||
| if (conversations.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| className="flex flex-col px-3 text-sm" | ||
| role="region" | ||
| aria-label={localize('com_ui_pinned')} | ||
| > | ||
| <div className="flex h-8 w-full items-center pr-2"> | ||
| <button | ||
| onClick={() => setIsExpanded(!isExpanded)} | ||
| className="group flex min-w-0 flex-1 items-center gap-1 rounded-lg px-1 py-2 text-xs font-bold text-text-secondary outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-text-primary" | ||
| type="button" | ||
| aria-expanded={isExpanded} | ||
| > | ||
| <span className="select-none truncate">{localize('com_ui_pinned')}</span> | ||
| <ChevronDown | ||
| className={cn( | ||
| 'h-3 w-3 shrink-0 transition-transform duration-200', | ||
| isExpanded ? '' : '-rotate-90', | ||
| )} | ||
| aria-hidden="true" | ||
| /> | ||
| </button> | ||
| </div> | ||
|
|
||
| {isExpanded && ( | ||
| <div className="scrollbar-gutter-stable max-h-[30vh] overflow-y-auto"> | ||
| <ul className="m-0 list-none p-0"> | ||
| {conversations.map((convo) => ( | ||
| <li key={convo.conversationId} className="list-none"> | ||
| <Convo | ||
|
berry-13 marked this conversation as resolved.
|
||
| conversation={convo} | ||
| retainView={noop} | ||
|
berry-13 marked this conversation as resolved.
berry-13 marked this conversation as resolved.
|
||
| toggleNav={toggleNav} | ||
| isGenerating={activeJobIds.has(convo.conversationId ?? '')} | ||
| /> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| PinnedSection.displayName = 'PinnedSection'; | ||
|
|
||
| export default memo(PinnedSection); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.