🧭 refactor: Modernize Nav/Header (#7094)
* refactor: streamline model preset handling in conversation setup
* refactor: integrate navigation and location hooks in chat functions and event handlers, prevent cache from fetching on final event handling
* fix: prevent adding code interpreter non-image output to file list on message attachment event, fix all unhandled edge cases when this is done (treating the file download as an image attachment, undefined fields, message tokenCount issues, use of `startsWith` on undefined "text") although it is now prevent altogether
* chore: remove unused jailbreak prop from MinimalIcon component in EndpointIcon
* feat: add new SVG icons (MobileSidebar, Sidebar, XAIcon), fix: xAI styling in dark vs. light modes, adjust styling of Landing icons
* fix: open conversation in new tab on navigation with ctrl/meta key
* refactor: update Nav & Header to use close/open sidebar buttons, as well as redesign "New Chat"/"Bookmarks" buttons to the top of the Nav, matching the latest design of ChatGPT for simplicity and to free up space
* chore: remove unused isToggleHovering state and simplify opacity logic in Nav component
* style: match mobile nav to mobile header
2025-04-27 14:03:25 -04:00
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
import type { FC } from 'react';
|
2024-07-29 07:45:59 -07:00
|
|
|
import { useRecoilValue } from 'recoil';
|
2024-08-16 10:30:14 +02:00
|
|
|
import { Menu, MenuButton, MenuItems } from '@headlessui/react';
|
2024-07-29 07:45:59 -07:00
|
|
|
import { BookmarkFilledIcon, BookmarkIcon } from '@radix-ui/react-icons';
|
|
|
|
|
import { BookmarkContext } from '~/Providers/BookmarkContext';
|
2024-08-08 21:25:10 -04:00
|
|
|
import { useGetConversationTags } from '~/data-provider';
|
2024-07-29 07:45:59 -07:00
|
|
|
import BookmarkNavItems from './BookmarkNavItems';
|
🧭 refactor: Modernize Nav/Header (#7094)
* refactor: streamline model preset handling in conversation setup
* refactor: integrate navigation and location hooks in chat functions and event handlers, prevent cache from fetching on final event handling
* fix: prevent adding code interpreter non-image output to file list on message attachment event, fix all unhandled edge cases when this is done (treating the file download as an image attachment, undefined fields, message tokenCount issues, use of `startsWith` on undefined "text") although it is now prevent altogether
* chore: remove unused jailbreak prop from MinimalIcon component in EndpointIcon
* feat: add new SVG icons (MobileSidebar, Sidebar, XAIcon), fix: xAI styling in dark vs. light modes, adjust styling of Landing icons
* fix: open conversation in new tab on navigation with ctrl/meta key
* refactor: update Nav & Header to use close/open sidebar buttons, as well as redesign "New Chat"/"Bookmarks" buttons to the top of the Nav, matching the latest design of ChatGPT for simplicity and to free up space
* chore: remove unused isToggleHovering state and simplify opacity logic in Nav component
* style: match mobile nav to mobile header
2025-04-27 14:03:25 -04:00
|
|
|
import { TooltipAnchor } from '~/components/ui';
|
2024-07-29 07:45:59 -07:00
|
|
|
import { useLocalize } from '~/hooks';
|
|
|
|
|
import { cn } from '~/utils';
|
|
|
|
|
import store from '~/store';
|
|
|
|
|
|
|
|
|
|
type BookmarkNavProps = {
|
|
|
|
|
tags: string[];
|
|
|
|
|
setTags: (tags: string[]) => void;
|
2024-09-13 08:59:09 -04:00
|
|
|
isSmallScreen: boolean;
|
2024-07-29 07:45:59 -07:00
|
|
|
};
|
2024-08-08 18:16:17 +02:00
|
|
|
|
2024-09-13 08:59:09 -04:00
|
|
|
const BookmarkNav: FC<BookmarkNavProps> = ({ tags, setTags, isSmallScreen }: BookmarkNavProps) => {
|
2024-07-29 07:45:59 -07:00
|
|
|
const localize = useLocalize();
|
|
|
|
|
const { data } = useGetConversationTags();
|
2024-11-01 18:54:17 -04:00
|
|
|
const conversation = useRecoilValue(store.conversationByIndex(0));
|
🧭 refactor: Modernize Nav/Header (#7094)
* refactor: streamline model preset handling in conversation setup
* refactor: integrate navigation and location hooks in chat functions and event handlers, prevent cache from fetching on final event handling
* fix: prevent adding code interpreter non-image output to file list on message attachment event, fix all unhandled edge cases when this is done (treating the file download as an image attachment, undefined fields, message tokenCount issues, use of `startsWith` on undefined "text") although it is now prevent altogether
* chore: remove unused jailbreak prop from MinimalIcon component in EndpointIcon
* feat: add new SVG icons (MobileSidebar, Sidebar, XAIcon), fix: xAI styling in dark vs. light modes, adjust styling of Landing icons
* fix: open conversation in new tab on navigation with ctrl/meta key
* refactor: update Nav & Header to use close/open sidebar buttons, as well as redesign "New Chat"/"Bookmarks" buttons to the top of the Nav, matching the latest design of ChatGPT for simplicity and to free up space
* chore: remove unused isToggleHovering state and simplify opacity logic in Nav component
* style: match mobile nav to mobile header
2025-04-27 14:03:25 -04:00
|
|
|
const label = useMemo(
|
|
|
|
|
() => (tags.length > 0 ? tags.join(', ') : localize('com_ui_bookmarks')),
|
|
|
|
|
[tags, localize],
|
|
|
|
|
);
|
2024-07-29 07:45:59 -07:00
|
|
|
|
|
|
|
|
return (
|
2024-08-16 10:30:14 +02:00
|
|
|
<Menu as="div" className="group relative">
|
|
|
|
|
{({ open }) => (
|
|
|
|
|
<>
|
🧭 refactor: Modernize Nav/Header (#7094)
* refactor: streamline model preset handling in conversation setup
* refactor: integrate navigation and location hooks in chat functions and event handlers, prevent cache from fetching on final event handling
* fix: prevent adding code interpreter non-image output to file list on message attachment event, fix all unhandled edge cases when this is done (treating the file download as an image attachment, undefined fields, message tokenCount issues, use of `startsWith` on undefined "text") although it is now prevent altogether
* chore: remove unused jailbreak prop from MinimalIcon component in EndpointIcon
* feat: add new SVG icons (MobileSidebar, Sidebar, XAIcon), fix: xAI styling in dark vs. light modes, adjust styling of Landing icons
* fix: open conversation in new tab on navigation with ctrl/meta key
* refactor: update Nav & Header to use close/open sidebar buttons, as well as redesign "New Chat"/"Bookmarks" buttons to the top of the Nav, matching the latest design of ChatGPT for simplicity and to free up space
* chore: remove unused isToggleHovering state and simplify opacity logic in Nav component
* style: match mobile nav to mobile header
2025-04-27 14:03:25 -04:00
|
|
|
<TooltipAnchor
|
|
|
|
|
description={label}
|
|
|
|
|
render={
|
|
|
|
|
<MenuButton
|
|
|
|
|
id="bookmark-menu-button"
|
|
|
|
|
aria-label={localize('com_ui_bookmarks')}
|
|
|
|
|
className={cn(
|
|
|
|
|
'flex items-center justify-center',
|
|
|
|
|
'size-10 border-none text-text-primary hover:bg-accent hover:text-accent-foreground',
|
|
|
|
|
'rounded-full border-none p-2 hover:bg-surface-hover md:rounded-xl',
|
|
|
|
|
open ? 'bg-surface-hover' : '',
|
|
|
|
|
)}
|
|
|
|
|
data-testid="bookmark-menu"
|
|
|
|
|
>
|
2024-08-22 17:09:05 -04:00
|
|
|
{tags.length > 0 ? (
|
🧭 refactor: Modernize Nav/Header (#7094)
* refactor: streamline model preset handling in conversation setup
* refactor: integrate navigation and location hooks in chat functions and event handlers, prevent cache from fetching on final event handling
* fix: prevent adding code interpreter non-image output to file list on message attachment event, fix all unhandled edge cases when this is done (treating the file download as an image attachment, undefined fields, message tokenCount issues, use of `startsWith` on undefined "text") although it is now prevent altogether
* chore: remove unused jailbreak prop from MinimalIcon component in EndpointIcon
* feat: add new SVG icons (MobileSidebar, Sidebar, XAIcon), fix: xAI styling in dark vs. light modes, adjust styling of Landing icons
* fix: open conversation in new tab on navigation with ctrl/meta key
* refactor: update Nav & Header to use close/open sidebar buttons, as well as redesign "New Chat"/"Bookmarks" buttons to the top of the Nav, matching the latest design of ChatGPT for simplicity and to free up space
* chore: remove unused isToggleHovering state and simplify opacity logic in Nav component
* style: match mobile nav to mobile header
2025-04-27 14:03:25 -04:00
|
|
|
<BookmarkFilledIcon
|
|
|
|
|
/** `isSmallScreen` is used because lazy loading is not influencing `md:` prefix for some reason */
|
|
|
|
|
className={cn('text-text-primary', isSmallScreen ? 'icon-md-heavy' : 'icon-lg')}
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
/>
|
2024-08-22 17:09:05 -04:00
|
|
|
) : (
|
🧭 refactor: Modernize Nav/Header (#7094)
* refactor: streamline model preset handling in conversation setup
* refactor: integrate navigation and location hooks in chat functions and event handlers, prevent cache from fetching on final event handling
* fix: prevent adding code interpreter non-image output to file list on message attachment event, fix all unhandled edge cases when this is done (treating the file download as an image attachment, undefined fields, message tokenCount issues, use of `startsWith` on undefined "text") although it is now prevent altogether
* chore: remove unused jailbreak prop from MinimalIcon component in EndpointIcon
* feat: add new SVG icons (MobileSidebar, Sidebar, XAIcon), fix: xAI styling in dark vs. light modes, adjust styling of Landing icons
* fix: open conversation in new tab on navigation with ctrl/meta key
* refactor: update Nav & Header to use close/open sidebar buttons, as well as redesign "New Chat"/"Bookmarks" buttons to the top of the Nav, matching the latest design of ChatGPT for simplicity and to free up space
* chore: remove unused isToggleHovering state and simplify opacity logic in Nav component
* style: match mobile nav to mobile header
2025-04-27 14:03:25 -04:00
|
|
|
<BookmarkIcon
|
|
|
|
|
className={cn('text-text-primary', isSmallScreen ? 'icon-md-heavy' : 'icon-lg')}
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
/>
|
2024-08-22 17:09:05 -04:00
|
|
|
)}
|
🧭 refactor: Modernize Nav/Header (#7094)
* refactor: streamline model preset handling in conversation setup
* refactor: integrate navigation and location hooks in chat functions and event handlers, prevent cache from fetching on final event handling
* fix: prevent adding code interpreter non-image output to file list on message attachment event, fix all unhandled edge cases when this is done (treating the file download as an image attachment, undefined fields, message tokenCount issues, use of `startsWith` on undefined "text") although it is now prevent altogether
* chore: remove unused jailbreak prop from MinimalIcon component in EndpointIcon
* feat: add new SVG icons (MobileSidebar, Sidebar, XAIcon), fix: xAI styling in dark vs. light modes, adjust styling of Landing icons
* fix: open conversation in new tab on navigation with ctrl/meta key
* refactor: update Nav & Header to use close/open sidebar buttons, as well as redesign "New Chat"/"Bookmarks" buttons to the top of the Nav, matching the latest design of ChatGPT for simplicity and to free up space
* chore: remove unused isToggleHovering state and simplify opacity logic in Nav component
* style: match mobile nav to mobile header
2025-04-27 14:03:25 -04:00
|
|
|
</MenuButton>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<MenuItems
|
|
|
|
|
anchor="bottom"
|
|
|
|
|
className="absolute left-0 top-full z-[100] mt-1 w-60 translate-y-0 overflow-hidden rounded-lg bg-surface-secondary p-1.5 shadow-lg outline-none"
|
|
|
|
|
>
|
2024-08-08 18:16:17 +02:00
|
|
|
{data && conversation && (
|
2024-07-29 07:45:59 -07:00
|
|
|
<BookmarkContext.Provider value={{ bookmarks: data.filter((tag) => tag.count > 0) }}>
|
|
|
|
|
<BookmarkNavItems
|
|
|
|
|
// Currently selected conversation
|
|
|
|
|
conversation={conversation}
|
|
|
|
|
// List of selected tags(string)
|
|
|
|
|
tags={tags}
|
|
|
|
|
// When a user selects a tag, this `setTags` function is called to refetch the list of conversations for the selected tag
|
|
|
|
|
setTags={setTags}
|
|
|
|
|
/>
|
|
|
|
|
</BookmarkContext.Provider>
|
|
|
|
|
)}
|
2024-08-16 10:30:14 +02:00
|
|
|
</MenuItems>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Menu>
|
2024-07-29 07:45:59 -07:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default BookmarkNav;
|