-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/1958 ai left panel UI elements #1971
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
DSanich
wants to merge
13
commits into
main
Choose a base branch
from
feat/1958-ai-left-panel-ui-elements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ba74ed5
feat(#1957): add Drawer component
DSanich 23e28b1
feat(#1957): add useIsMobile hook
DSanich 894aabb
feat(#1957): add AI left panel components
DSanich 7d18130
feat(#1957): integrate AI left panel into app layout
DSanich d60f45c
feat(#1957): updated lock file
DSanich 06516cc
feat(#1958): add mock data and types
DSanich 688f81f
feat(#1958): add AiPanelHeader component
DSanich 94d966c
feat(#1958): add AiPanelMessageBubble component
DSanich a7db782
feat(#1958): add AiPanelSuggestions component
DSanich f9fa9ac
feat(#1958): add AiPanelChatBar component
DSanich 49a81c5
feat(#1958): add AiPanelMessages component
DSanich 8f51f03
feat(#1958): add index and refactor AiLeftPanel
DSanich b380b0f
feat(#1958): format fix
DSanich 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| 'use client'; | ||
|
|
||
| import { useCallback, useRef, useState } from 'react'; | ||
| import { Bot, ChevronsLeftRight, PanelLeftOpen } from 'lucide-react'; | ||
|
|
||
| import { AiLeftPanel } from './ai-left-panel'; | ||
| import { useIsMobile } from '../hooks'; | ||
| import { Drawer, DrawerContent } from '@hypha-platform/ui'; | ||
| import { cn } from '@hypha-platform/ui-utils'; | ||
|
|
||
| const MIN_WIDTH = 240; | ||
| const MAX_WIDTH = 600; | ||
| const DEFAULT_WIDTH = 320; | ||
|
|
||
| type AiLeftPanelLayoutProps = { | ||
| children: React.ReactNode; | ||
| }; | ||
|
|
||
| export function AiLeftPanelLayout({ children }: AiLeftPanelLayoutProps) { | ||
| const isMobile = useIsMobile(); | ||
| const [panelOpen, setPanelOpen] = useState(true); | ||
| const [panelWidth, setPanelWidth] = useState(DEFAULT_WIDTH); | ||
| const [isDragging, setIsDragging] = useState(false); | ||
| const dragStartX = useRef(0); | ||
| const dragStartWidth = useRef(DEFAULT_WIDTH); | ||
|
|
||
| const onResizeMouseDown = useCallback( | ||
| (e: React.MouseEvent) => { | ||
| e.preventDefault(); | ||
| dragStartX.current = e.clientX; | ||
| dragStartWidth.current = panelWidth; | ||
| setIsDragging(true); | ||
|
|
||
| const onMouseMove = (e: MouseEvent) => { | ||
| const delta = e.clientX - dragStartX.current; | ||
| const newWidth = Math.min( | ||
| MAX_WIDTH, | ||
| Math.max(MIN_WIDTH, dragStartWidth.current + delta), | ||
| ); | ||
| setPanelWidth(newWidth); | ||
| }; | ||
|
|
||
| const onMouseUp = () => { | ||
| setIsDragging(false); | ||
| window.removeEventListener('mousemove', onMouseMove); | ||
| window.removeEventListener('mouseup', onMouseUp); | ||
| }; | ||
|
|
||
| window.addEventListener('mousemove', onMouseMove); | ||
| window.addEventListener('mouseup', onMouseUp); | ||
| }, | ||
| [panelWidth], | ||
| ); | ||
|
|
||
| return ( | ||
| <div className="relative flex h-full min-h-0 flex-1 overflow-hidden"> | ||
| {!isMobile && ( | ||
| <> | ||
| <div | ||
| className={cn( | ||
| 'relative flex h-full flex-shrink-0 flex-col transition-all duration-300', | ||
| panelOpen ? '' : 'w-0 overflow-hidden', | ||
| )} | ||
| style={panelOpen ? { width: panelWidth } : undefined} | ||
| > | ||
| <AiLeftPanel onClose={() => setPanelOpen(false)} /> | ||
|
|
||
| {panelOpen && ( | ||
| <div | ||
| role="separator" | ||
| aria-orientation="vertical" | ||
| aria-valuenow={panelWidth} | ||
| onMouseDown={onResizeMouseDown} | ||
| className={cn( | ||
| 'absolute top-0 right-0 z-20 flex h-full w-1 cursor-col-resize items-center justify-center transition-colors', | ||
| isDragging | ||
| ? 'bg-primary' | ||
| : 'hover:bg-primary/20 group hover:bg-primary/20', | ||
| )} | ||
| title="Drag to resize" | ||
| > | ||
| <div | ||
| className={cn( | ||
| 'flex h-8 w-4 items-center justify-center rounded transition-opacity', | ||
| isDragging | ||
| ? 'opacity-100' | ||
| : 'opacity-0 group-hover:opacity-100', | ||
| )} | ||
| > | ||
| <ChevronsLeftRight className="h-3 w-3 text-primary" /> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </> | ||
| )} | ||
|
|
||
| {!panelOpen && ( | ||
| <button | ||
| type="button" | ||
| onClick={() => setPanelOpen(true)} | ||
| className="fixed left-0 top-[4.5rem] z-30 flex items-center gap-1.5 rounded-r-xl border border-l-0 border-border bg-card px-2 py-1.5 text-xs text-muted-foreground transition-all duration-200 hover:bg-muted hover:text-foreground" | ||
| title="Open AI panel" | ||
| > | ||
| <Bot className="h-3.5 w-3.5 text-primary" /> | ||
| <PanelLeftOpen className="h-3.5 w-3.5 text-primary" /> | ||
| </button> | ||
| )} | ||
|
|
||
| {isMobile && ( | ||
| <Drawer open={panelOpen} onOpenChange={setPanelOpen} direction="left"> | ||
| <DrawerContent | ||
| className="inset-x-auto right-auto left-0 h-full w-[85vw] max-w-[360px] rounded-r-2xl rounded-t-none border-r" | ||
| style={{ top: 0, bottom: 0, marginTop: 0 }} | ||
| > | ||
| <div className="h-full"> | ||
| <AiLeftPanel onClose={() => setPanelOpen(false)} /> | ||
| </div> | ||
| </DrawerContent> | ||
| </Drawer> | ||
| )} | ||
|
|
||
| <div className="flex min-h-0 flex-1 flex-col items-start overflow-auto pt-5"> | ||
| {children} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
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,66 @@ | ||
| 'use client'; | ||
|
|
||
| import { useState } from 'react'; | ||
|
|
||
| import { cn } from '@hypha-platform/ui-utils'; | ||
|
|
||
| import { | ||
| AiPanelHeader, | ||
| AiPanelMessages, | ||
| AiPanelChatBar, | ||
| MOCK_MODEL_OPTIONS, | ||
| MOCK_SUGGESTIONS, | ||
| MOCK_WELCOME_MESSAGE, | ||
| } from './ai-panel'; | ||
|
|
||
| type AiLeftPanelProps = { | ||
| onClose: () => void; | ||
| className?: string; | ||
| }; | ||
|
|
||
| export function AiLeftPanel({ onClose, className }: AiLeftPanelProps) { | ||
| const [input, setInput] = useState(''); | ||
| const [selectedModel, setSelectedModel] = useState(MOCK_MODEL_OPTIONS[0]!); | ||
| const [messages, setMessages] = useState([MOCK_WELCOME_MESSAGE]); | ||
| const [showSuggestions, setShowSuggestions] = useState(true); | ||
| const [isStreaming, setIsStreaming] = useState(false); | ||
|
|
||
| const handleSend = () => { | ||
| // Placeholder - no business logic | ||
| }; | ||
|
|
||
| const handleSuggestionSelect = (text: string) => { | ||
| setShowSuggestions(false); | ||
| setInput(text); | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
| className={cn( | ||
| 'flex h-full flex-col border-r border-border bg-background-2', | ||
| className, | ||
| )} | ||
| > | ||
| <AiPanelHeader | ||
| onClose={onClose} | ||
| modelOptions={MOCK_MODEL_OPTIONS} | ||
| selectedModel={selectedModel} | ||
| onModelSelect={setSelectedModel} | ||
| /> | ||
|
|
||
| <AiPanelMessages | ||
| messages={messages} | ||
| suggestions={MOCK_SUGGESTIONS} | ||
| showSuggestions={showSuggestions} | ||
| onSuggestionSelect={handleSuggestionSelect} | ||
| /> | ||
|
|
||
| <AiPanelChatBar | ||
| value={input} | ||
| onChange={setInput} | ||
| onSend={handleSend} | ||
| isStreaming={isStreaming} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
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.