"use client"; import type { ComponentProps, RefObject } from "react"; import { LoaderCircle, Plus } from "lucide-react"; import type { ApiDocument } from "@/lib/api/types"; import { studyIntentConfig, type StudyIntent } from "@/lib/study-intents"; import { cn } from "@/lib/utils"; import { QuickActions } from "./QuickActions"; import { StagedThinkingLine } from "./StagedThinking"; import { SelectedSourcesStrip } from "./SourceControls"; import { PlainAssistantMessage, StudyCardRenderer } from "./StudyCards"; import { StudyComposer } from "./StudyComposer"; import type { ChatMessage, StudyActionHandler } from "./types"; type ConversationWorkspaceProps = { activeIntent: StudyIntent; composerProps: ComponentProps; documents: ApiDocument[]; isLoading: boolean; messages: ChatMessage[]; onAction: StudyActionHandler; onClearSources: () => void; onNewChat: () => void; onStartRender?: (topic: string, sourceId: string | null, minutes: number) => void; onToggleSource: (sourceId: string) => void; onUpload?: () => void; selectedDocuments: ApiDocument[]; threadEndRef: RefObject; }; export function ConversationWorkspace({ activeIntent, composerProps, documents, isLoading, messages, onAction, onClearSources, onNewChat, onStartRender, onToggleSource, onUpload, selectedDocuments, threadEndRef, }: ConversationWorkspaceProps) { const intentLabel = studyIntentConfig[activeIntent].shortLabel ?? studyIntentConfig[activeIntent].label; const lastMessage = messages[messages.length - 1]; const showTypingIndicator = isLoading && (!lastMessage || lastMessage.role !== "assistant" || !lastMessage.card || lastMessage.card.kind !== "loading"); return ( <>

Study Chat

Study session

{intentLabel}
); } function ConversationThread({ messages, onAction, onUpload, onStartRender, showTypingIndicator, activeIntent, threadEndRef, }: { messages: ChatMessage[]; onAction: StudyActionHandler; onUpload?: () => void; onStartRender?: (topic: string, sourceId: string | null, minutes: number) => void; showTypingIndicator: boolean; activeIntent: StudyIntent; threadEndRef: RefObject; }) { return (
{messages.map((message) => (
{message.role === "user" ? (
{message.text}
) : message.card ? (
) : ( )}
))} {showTypingIndicator ? : null}
); } function TypingIndicator({ intent }: { intent: StudyIntent }) { return (
); }