Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/components/workspace-canvas/SidebarQuickActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useRef, useState, useCallback } from "react";
import { toast } from "sonner";
import type { PdfData } from "@/lib/workspace-state/types";
import { CreateYouTubeDialog } from "@/components/modals/CreateYouTubeDialog";
import { focusComposerInput } from "@/lib/utils/composer-utils";

interface SidebarQuickActionsProps {
currentWorkspaceId: string;
Expand Down Expand Up @@ -91,8 +92,19 @@ export function SidebarQuickActions({ currentWorkspaceId, isChatExpanded, setIsC
}, [api, isChatExpanded, setIsChatExpanded, setSelectedActions]);

const handleQuizClick = useCallback(() => {
toast.info("Quizzes coming soon!");
}, []);
// Open chat if closed
if (setIsChatExpanded && !isChatExpanded) {
setIsChatExpanded(true);
}

// Fill composer with quiz creation prompt
api.composer().setText("Create a quiz about ");

// Focus the composer input
focusComposerInput();

toast.success("Quiz creation started");
}, [api, isChatExpanded, setIsChatExpanded]);

// PDF Upload Logic (Adapted from WorkspaceSection/BottomActionBar)
const handlePDFUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
36 changes: 32 additions & 4 deletions src/components/workspace-canvas/WorkspaceHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type React from "react";
import { useState, useRef, useEffect, useCallback } from "react";
import { Search, X, ChevronRight, ChevronDown, FolderOpen, ChevronLeft, Plus, Upload, Layers, FileText, Folder, Settings, Share2, Play, MoreHorizontal, Globe } from "lucide-react";
import { Search, X, ChevronRight, ChevronDown, FolderOpen, ChevronLeft, Plus, Upload, Layers, FileText, Folder, Settings, Share2, Play, MoreHorizontal, Globe, Brain } from "lucide-react";
import { LuBook } from "react-icons/lu";
import { PiCardsThreeFill } from "react-icons/pi";
import { cn } from "@/lib/utils";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { SidebarTrigger } from "@/components/ui/sidebar";
Expand All @@ -10,6 +12,7 @@ import ChatFloatingButton from "@/components/chat/ChatFloatingButton";
import { useUIStore } from "@/lib/stores/ui-store";
import { IconRenderer } from "@/hooks/use-icon-picker";
import { useAssistantApi } from "@assistant-ui/react";
import { focusComposerInput } from "@/lib/utils/composer-utils";
import {
DropdownMenu,
DropdownMenuContent,
Expand Down Expand Up @@ -654,8 +657,8 @@ export default function WorkspaceHeader({

<DropdownMenuSub>
<DropdownMenuSubTrigger className="flex items-center gap-2 cursor-pointer">
<MoreHorizontal className="size-4" />
Other
<LuBook className="size-4" />
Learn
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
<DropdownMenuItem
Expand All @@ -666,9 +669,34 @@ export default function WorkspaceHeader({
}}
className="flex items-center gap-2 cursor-pointer"
>
<Layers className="size-4" />
<PiCardsThreeFill className="size-4" />
Flashcards
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => {
// Open chat if closed
if (setIsChatExpanded && !isChatExpanded) {
setIsChatExpanded(true);
}
// Fill composer with quiz creation prompt
api?.composer().setText("Create a quiz about ");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: optional chaining on api doesn't prevent the error - if api is undefined, api?.composer() returns undefined, then calling .setText() on undefined throws an error

Suggested change
api?.composer().setText("Create a quiz about ");
api.composer().setText("Create a quiz about ");
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/components/workspace-canvas/WorkspaceHeader.tsx
Line: 682:682

Comment:
**logic:** optional chaining on `api` doesn't prevent the error - if `api` is undefined, `api?.composer()` returns undefined, then calling `.setText()` on undefined throws an error

```suggestion
                        api.composer().setText("Create a quiz about ");
```

How can I resolve this? If you propose a fix, please make it concise.

// Focus the composer input
focusComposerInput();
toast.success("Quiz creation started");
}}
className="flex items-center gap-2 cursor-pointer"
>
<Brain className="size-4" />
Quiz
</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuSub>
<DropdownMenuSub>
<DropdownMenuSubTrigger className="flex items-center gap-2 cursor-pointer">
<MoreHorizontal className="size-4" />
Other
</DropdownMenuSubTrigger>
<DropdownMenuSubContent>
<DropdownMenuItem
onClick={() => {
setShowYouTubeDialog(true);
Expand Down
36 changes: 32 additions & 4 deletions src/components/workspace-canvas/WorkspaceSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import {
ContextMenuSubTrigger,
} from "@/components/ui/context-menu";

import { FileText, Layers, Folder, Upload, Play, Plus, MoreHorizontal, Globe } from "lucide-react";
import { FileText, Layers, Folder, Upload, Play, Plus, MoreHorizontal, Globe, Brain } from "lucide-react";
import { LuBook } from "react-icons/lu";
import { PiCardsThreeFill } from "react-icons/pi";
import WorkspaceSettingsModal from "@/components/workspace/WorkspaceSettingsModal";
import ShareWorkspaceDialog from "@/components/workspace/ShareWorkspaceDialog";
import { CreateYouTubeDialog } from "@/components/modals/CreateYouTubeDialog";
Expand All @@ -42,6 +44,7 @@ import type { WorkspaceWithState } from "@/lib/workspace-state/types";
import { ItemOpenPrompt } from "./ItemOpenPrompt";
import { createPortal } from "react-dom";
import { useAssistantApi } from "@assistant-ui/react";
import { focusComposerInput } from "@/lib/utils/composer-utils";

interface WorkspaceSectionProps {
// Loading states
Expand Down Expand Up @@ -558,8 +561,8 @@ export function WorkspaceSection({

<ContextMenuSub>
<ContextMenuSubTrigger className="flex items-center gap-2 cursor-pointer">
<MoreHorizontal className="size-4" />
Other
<LuBook className="size-4" />
Learn
</ContextMenuSubTrigger>
<ContextMenuSubContent>
<ContextMenuItem
Expand All @@ -570,9 +573,34 @@ export function WorkspaceSection({
}}
className="flex items-center gap-2 cursor-pointer"
>
<Layers className="size-4" />
<PiCardsThreeFill className="size-4" />
Flashcards
</ContextMenuItem>
<ContextMenuItem
onSelect={() => {
// Open chat if closed
if (setIsChatExpanded && !isChatExpanded && isDesktop) {
setIsChatExpanded(true);
}
// Fill composer with quiz creation prompt
api.composer().setText("Create a quiz about ");
// Focus the composer input
focusComposerInput();
toast.success("Quiz creation started");
}}
className="flex items-center gap-2 cursor-pointer"
>
<Brain className="size-4" />
Quiz
</ContextMenuItem>
</ContextMenuSubContent>
</ContextMenuSub>
<ContextMenuSub>
<ContextMenuSubTrigger className="flex items-center gap-2 cursor-pointer">
<MoreHorizontal className="size-4" />
Other
</ContextMenuSubTrigger>
<ContextMenuSubContent>
<ContextMenuItem
onSelect={() => setShowYouTubeDialog(true)}
className="flex items-center gap-2 cursor-pointer"
Expand Down