-
-
Notifications
You must be signed in to change notification settings - Fork 7
Restore Branch Head to Commit 488b47c #456
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| 'use client' | ||
|
|
||
| import { | ||
| Sheet, | ||
| SheetContent, | ||
| SheetHeader, | ||
| SheetTitle, | ||
| } from '@/components/ui/sheet' | ||
| import { History as HistoryIcon } from 'lucide-react' | ||
| import { ChatHistoryClient } from './sidebar/chat-history-client' | ||
| import { Suspense } from 'react' | ||
| import { HistorySkeleton } from './history-skelton' | ||
| import { useHistoryToggle } from './history-toggle-context' | ||
|
|
||
| export function HistorySidebar() { | ||
| const { isHistoryOpen, setHistoryOpen } = useHistoryToggle() | ||
|
|
||
| return ( | ||
| <Sheet open={isHistoryOpen} onOpenChange={setHistoryOpen}> | ||
| <SheetContent className="w-64 rounded-tl-xl rounded-bl-xl" data-testid="history-panel"> | ||
| <SheetHeader> | ||
|
Comment on lines
+15
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
SuggestionWrap the handler to lock the contract to a boolean and to give yourself a single place to coordinate overlays later. <Sheet
open={isHistoryOpen}
onOpenChange={(open) => setHistoryOpen(open)}
>If you want coordination (recommended), this is also where you can close |
||
| <SheetTitle className="flex items-center gap-1 text-sm font-normal mb-2"> | ||
| <HistoryIcon size={14} /> | ||
| History | ||
| </SheetTitle> | ||
| </SheetHeader> | ||
| <div className="my-2 h-full pb-12 md:pb-10"> | ||
| <Suspense fallback={<HistorySkeleton />}> | ||
| <ChatHistoryClient /> | ||
| </Suspense> | ||
| </div> | ||
| </SheetContent> | ||
| </Sheet> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| 'use client' | ||
|
|
||
| import { createContext, useContext, useState, ReactNode } from "react" | ||
|
|
||
| interface HistoryToggleContextType { | ||
| isHistoryOpen: boolean | ||
| toggleHistory: () => void | ||
| setHistoryOpen: (open: boolean) => void | ||
| } | ||
|
|
||
| const HistoryToggleContext = createContext<HistoryToggleContextType | undefined>(undefined) | ||
|
|
||
| export const HistoryToggleProvider: React.FC<{ children: ReactNode }> = ({ children }) => { | ||
| const [isHistoryOpen, setIsHistoryOpen] = useState(false) | ||
|
|
||
| const toggleHistory = () => setIsHistoryOpen(prev => !prev) | ||
| const setHistoryOpen = (open: boolean) => setIsHistoryOpen(open) | ||
|
|
||
| return ( | ||
| <HistoryToggleContext.Provider value={{ isHistoryOpen, toggleHistory, setHistoryOpen }}> | ||
| {children} | ||
| </HistoryToggleContext.Provider> | ||
| ) | ||
| } | ||
|
|
||
| export const useHistoryToggle = () => { | ||
| const context = useContext(HistoryToggleContext) | ||
| if (!context) throw new Error('useHistoryToggle must be used within HistoryToggleProvider') | ||
| return context | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,28 @@ | ||
| import { | ||
| Sheet, | ||
| SheetContent, | ||
| SheetHeader, | ||
| SheetTitle, | ||
| SheetTrigger | ||
| } from '@/components/ui/sheet' | ||
| 'use client' | ||
|
|
||
| import { Button } from '@/components/ui/button' | ||
| import { ChevronLeft, Menu } from 'lucide-react' | ||
| import { cn } from '@/lib/utils' | ||
| import { History as HistoryIcon } from 'lucide-react' | ||
| import { ChatHistoryClient } from './sidebar/chat-history-client' // Updated import | ||
| import { Suspense } from 'react' | ||
| import { HistorySkeleton } from './history-skelton' | ||
| import { useHistoryToggle } from './history-toggle-context' | ||
|
|
||
| type HistoryProps = { | ||
| location: 'sidebar' | 'header' | ||
| } | ||
|
|
||
| export function History({ location }: HistoryProps) { | ||
| const { toggleHistory } = useHistoryToggle() | ||
|
|
||
| return ( | ||
| <Sheet> | ||
| <SheetTrigger asChild> | ||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| className={cn({ | ||
| 'rounded-full text-foreground/30': location === 'sidebar' | ||
| })} | ||
| data-testid="history-button" | ||
| > | ||
| {location === 'header' ? <Menu /> : <ChevronLeft size={16} />} | ||
| </Button> | ||
| </SheetTrigger> | ||
| <SheetContent className="w-64 rounded-tl-xl rounded-bl-xl" data-testid="history-panel"> | ||
| <SheetHeader> | ||
| <SheetTitle className="flex items-center gap-1 text-sm font-normal mb-2"> | ||
| <HistoryIcon size={14} /> | ||
| History | ||
| </SheetTitle> | ||
| </SheetHeader> | ||
| <div className="my-2 h-full pb-12 md:pb-10"> | ||
| <Suspense fallback={<HistorySkeleton />}> | ||
| <ChatHistoryClient /> | ||
| </Suspense> | ||
| </div> | ||
| </SheetContent> | ||
| </Sheet> | ||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| className={cn({ | ||
| 'rounded-full text-foreground/30': location === 'sidebar' | ||
| })} | ||
| data-testid="history-button" | ||
| onClick={toggleHistory} | ||
| > | ||
| {location === 'header' ? <Menu /> : <ChevronLeft size={16} />} | ||
| </Button> | ||
| ) | ||
| } |
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.
handleUsageTogglecloses the profile view when opening usage, but the inverse coordination is handled elsewhere (ProfileTogglecloses usage when opening a profile section). History is now also a global overlay, but it isn't coordinated with either usage or profile. This will likely allow multiple overlays to be open at once (history sheet + usage view), which can produce confusing input focus/scroll behavior.Suggestion
Centralize overlay coordination so only one of
{history, usage, profile}can be open at a time. A minimal improvement is to close history when opening usage and close usage when opening history.Example (in
handleUsageToggle):You may want to add
closeHistory()toHistoryToggleContextTypefor symmetry. Reply with "@CharlieHelps yes please" if you'd like me to add a commit implementing this coordination.