-
Notifications
You must be signed in to change notification settings - Fork 6
Projects Prototype (Frontend-only, localStorage) #421
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
Draft
marksftw
wants to merge
3
commits into
master
Choose a base branch
from
feature/projects-prototype
base: master
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.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,176 @@ | ||
| import { useState } from "react"; | ||
| import { | ||
| CheckSquare, | ||
| ChevronLeft, | ||
| ChevronRight, | ||
| Folder, | ||
| FolderMinus, | ||
| FolderPlus, | ||
| MoreHorizontal, | ||
| Pencil, | ||
| Plus, | ||
| Trash2 | ||
| } from "lucide-react"; | ||
| import { | ||
| DropdownMenu, | ||
| DropdownMenuContent, | ||
| DropdownMenuItem, | ||
| DropdownMenuSeparator, | ||
| DropdownMenuTrigger | ||
| } from "@/components/ui/dropdown-menu"; | ||
|
|
||
| interface ChatContextMenuProps { | ||
| chatId: string; | ||
| isMobile: boolean; | ||
| // All projects for "Move to project" submenu | ||
| projects: { id: string; name: string }[]; | ||
| // If set, shows "Remove from {projectName}" and grays out current project in submenu | ||
| currentProjectName?: string; | ||
| currentProjectId?: string; | ||
| // Optional callbacks — item only rendered when provided | ||
| onSelect?: () => void; | ||
| onRename?: () => void; | ||
| onMoveToProject?: (projectId: string) => void; | ||
| onRemoveFromProject?: () => void; | ||
| onDelete?: () => void; | ||
| } | ||
|
|
||
| export function ChatContextMenu({ | ||
| chatId, | ||
| isMobile, | ||
| projects, | ||
| currentProjectName, | ||
| currentProjectId, | ||
| onSelect, | ||
| onRename, | ||
| onMoveToProject, | ||
| onRemoveFromProject, | ||
| onDelete | ||
| }: ChatContextMenuProps) { | ||
| const [showProjectSubmenu, setShowProjectSubmenu] = useState(false); | ||
|
|
||
| return ( | ||
| <DropdownMenu onOpenChange={(open) => !open && setShowProjectSubmenu(false)}> | ||
| <DropdownMenuTrigger asChild> | ||
| <button | ||
| className={`z-50 bg-background/80 absolute right-2 top-1/2 transform -translate-y-1/2 text-primary transition-opacity p-2 ${ | ||
| isMobile ? "opacity-100" : "opacity-0 group-hover:opacity-100" | ||
| }`} | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| }} | ||
| > | ||
| <MoreHorizontal size={16} /> | ||
| </button> | ||
| </DropdownMenuTrigger> | ||
| <DropdownMenuContent className="w-56 overflow-hidden"> | ||
| <div className="relative overflow-hidden"> | ||
| {/* Main menu layer — in-flow when active, absolute when hidden */} | ||
| <div | ||
| className={`transition-transform duration-300 ease-in-out ${ | ||
| showProjectSubmenu | ||
| ? "absolute top-0 left-0 w-full -translate-x-[200%]" | ||
| : "translate-x-0" | ||
| }`} | ||
| > | ||
| {onSelect && ( | ||
| <DropdownMenuItem onClick={onSelect}> | ||
| <CheckSquare className="mr-2 h-4 w-4" /> | ||
| <span>Select</span> | ||
| </DropdownMenuItem> | ||
| )} | ||
| {onRename && ( | ||
| <DropdownMenuItem onClick={onRename}> | ||
| <Pencil className="mr-2 h-4 w-4" /> | ||
| <span>Rename chat</span> | ||
| </DropdownMenuItem> | ||
| )} | ||
| {onMoveToProject && ( | ||
| <DropdownMenuItem | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| setShowProjectSubmenu(true); | ||
| }} | ||
| onSelect={(e) => e.preventDefault()} | ||
| > | ||
| <FolderPlus className="mr-2 h-4 w-4" /> | ||
| <span className="flex-1">Move to project</span> | ||
| <ChevronRight className="h-4 w-4 ml-auto" /> | ||
| </DropdownMenuItem> | ||
| )} | ||
| {onRemoveFromProject && currentProjectName && ( | ||
| <DropdownMenuItem onClick={onRemoveFromProject}> | ||
| <FolderMinus className="mr-2 h-4 w-4" /> | ||
| <span>Remove from {currentProjectName}</span> | ||
| </DropdownMenuItem> | ||
| )} | ||
| {onDelete && ( | ||
| <DropdownMenuItem | ||
| onClick={onDelete} | ||
| className="text-destructive focus:text-destructive" | ||
| > | ||
| <Trash2 className="mr-2 h-4 w-4" /> | ||
| <span>Delete chat</span> | ||
| </DropdownMenuItem> | ||
| )} | ||
| </div> | ||
|
|
||
| {/* Project submenu layer — in-flow when active, absolute when hidden */} | ||
| {onMoveToProject && ( | ||
| <div | ||
| className={`transition-transform duration-300 ease-in-out ${ | ||
| showProjectSubmenu | ||
| ? "translate-x-0" | ||
| : "absolute top-0 left-0 w-full translate-x-[200%]" | ||
| }`} | ||
| > | ||
| <DropdownMenuItem | ||
| onClick={(e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| setShowProjectSubmenu(false); | ||
| }} | ||
| onSelect={(e) => e.preventDefault()} | ||
| > | ||
| <ChevronLeft className="mr-2 h-4 w-4" /> | ||
| <span>Back</span> | ||
| </DropdownMenuItem> | ||
| <DropdownMenuSeparator /> | ||
| <DropdownMenuItem | ||
| onClick={() => { | ||
| window.dispatchEvent( | ||
| new CustomEvent("createprojectforchat", { | ||
| detail: { chatId } | ||
| }) | ||
| ); | ||
| }} | ||
| > | ||
| <Plus className="mr-2 h-4 w-4" /> | ||
| <span>New project</span> | ||
| </DropdownMenuItem> | ||
| {projects.length > 0 && <DropdownMenuSeparator />} | ||
| <div className="max-h-[40vh] overflow-y-auto"> | ||
| {projects.map((project) => { | ||
| const isCurrent = project.id === currentProjectId; | ||
| return ( | ||
| <DropdownMenuItem | ||
| key={project.id} | ||
| onClick={() => !isCurrent && onMoveToProject(project.id)} | ||
| onSelect={(e) => isCurrent && e.preventDefault()} | ||
| disabled={isCurrent} | ||
| > | ||
| <Folder className="mr-2 h-4 w-4" /> | ||
| <span className="truncate">{project.name}</span> | ||
| </DropdownMenuItem> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </DropdownMenuContent> | ||
| </DropdownMenu> | ||
| ); | ||
| } | ||
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.
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.
Trigger button lacks an accessible label.
The
<button>wrapping<MoreHorizontal />has noaria-label, so screen readers will announce it as an unlabeled button. Add anaria-labelfor accessibility.♻️ Suggested fix
<button className={`z-50 bg-background/80 absolute right-2 top-1/2 transform -translate-y-1/2 text-primary transition-opacity p-2 ${ isMobile ? "opacity-100" : "opacity-0 group-hover:opacity-100" }`} + aria-label="Chat actions" onClick={(e) => { e.preventDefault(); e.stopPropagation(); }} >📝 Committable suggestion
🤖 Prompt for AI Agents