DocDoeAI / src /components /study-chat /MainWorkspace.tsx
asnannp's picture
deploy: sync backend to Space root (learn-lesson HF cache fix)
65d68f5
Raw History Blame Contribute Delete
2.76 kB
"use client";
import type { ComponentProps, RefObject } from "react";
import type { ApiDocument } from "@/lib/api/types";
import type { StudyIntent } from "@/lib/study-intents";
import { ConversationWorkspace } from "./ConversationWorkspace";
import { EmptyStudyWorkspace } from "./EmptyStudyWorkspace";
import { StudyComposer } from "./StudyComposer";
import { MobileTopBar } from "./WorkspacePanels";
import type { ChatMessage, StudyActionHandler } from "./types";
type MainWorkspaceProps = {
activeIntent: StudyIntent;
composerProps: ComponentProps<typeof StudyComposer>;
documents: ApiDocument[];
heroSubtitle: string;
heroTitle: string;
isLoading: boolean;
messages: ChatMessage[];
onAction: StudyActionHandler;
onClearSources: () => void;
onNewChat: () => void;
onOpenProfile: () => void;
onOpenSources: () => void;
onStartRender?: (topic: string, sourceId: string | null, minutes: number) => void;
onToggleSource: (sourceId: string) => void;
onUpload?: () => void;
selectedDocuments: ApiDocument[];
studentName: string;
threadEndRef: RefObject<HTMLDivElement | null>;
};
export function MainWorkspace({
activeIntent,
composerProps,
documents,
heroSubtitle,
heroTitle,
isLoading,
messages,
onAction,
onClearSources,
onNewChat,
onOpenProfile,
onOpenSources,
onStartRender,
onToggleSource,
onUpload,
selectedDocuments,
studentName,
threadEndRef,
}: MainWorkspaceProps) {
return (
<main className="relative flex min-h-0 min-w-0 flex-col overflow-hidden">
<MobileTopBar
selectedCount={selectedDocuments.length}
onOpenSources={onOpenSources}
onOpenProfile={onOpenProfile}
/>
{messages.length === 0 ? (
<EmptyStudyWorkspace
activeIntent={activeIntent}
composerProps={composerProps}
documents={documents}
heroSubtitle={heroSubtitle}
heroTitle={heroTitle}
isLoading={isLoading}
onAction={onAction}
onClearSources={onClearSources}
onToggleSource={onToggleSource}
onUpload={onUpload}
selectedDocuments={selectedDocuments}
studentName={studentName}
/>
) : (
<ConversationWorkspace
activeIntent={activeIntent}
composerProps={composerProps}
documents={documents}
isLoading={isLoading}
messages={messages}
onAction={onAction}
onClearSources={onClearSources}
onNewChat={onNewChat}
onStartRender={onStartRender}
onToggleSource={onToggleSource}
onUpload={onUpload}
selectedDocuments={selectedDocuments}
threadEndRef={threadEndRef}
/>
)}
</main>
);
}