mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:29:27 +08:00
- Add new `deeptutor/book/` module with multi-agent pipeline (ideation, spine, page planner, source explorer, synthesizer) and rich block system (text, code, figure, quiz, flash cards, callout, deep dive, timeline, animation, concept graph, etc.) - Add `/api/routers/book.py` and `deeptutor_cli/book.py` entry points - Add web UI under `web/app/(workspace)/book/` with sidebar, chat panel, page reader, spine editor, progress timeline, and block renderers - Move `deeptutor/agents/co_writer` -> `deeptutor/co_writer` and `deeptutor/agents/guide` -> `deeptutor/guide` (then remove guide entirely now superseded by book) - Remove legacy guide UI, hooks, types, and API router - Update visualize agents/prompts, notebook service, prompt manager, session turn runtime, and shared services to support new flows - Refresh chat composer, sidebar, notebook selector, and locales Made-with: Cursor
95 lines
3.4 KiB
TypeScript
95 lines
3.4 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { Layers, X } from "lucide-react";
|
|
import { useTranslation } from "react-i18next";
|
|
import NotebookSelector from "@/components/notebook/NotebookSelector";
|
|
import { useNotebookSelection } from "@/components/notebook/useNotebookSelection";
|
|
import type { SelectedRecord } from "@/lib/notebook-selection-types";
|
|
|
|
interface NotebookRecordPickerProps {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
onApply: (records: SelectedRecord[]) => void;
|
|
actionLabel?: string;
|
|
}
|
|
|
|
export default function NotebookRecordPicker({
|
|
open,
|
|
onClose,
|
|
onApply,
|
|
actionLabel = "Use Selected Records ({n})",
|
|
}: NotebookRecordPickerProps) {
|
|
const { t } = useTranslation();
|
|
const {
|
|
notebooks,
|
|
expandedNotebooks,
|
|
notebookRecordsMap,
|
|
selectedRecords,
|
|
loadingNotebooks,
|
|
loadingRecordsFor,
|
|
fetchNotebooks,
|
|
toggleNotebookExpanded,
|
|
toggleRecordSelection,
|
|
selectAllFromNotebook,
|
|
deselectAllFromNotebook,
|
|
clearAllSelections,
|
|
} = useNotebookSelection();
|
|
|
|
useEffect(() => {
|
|
if (!open) return;
|
|
void fetchNotebooks();
|
|
}, [fetchNotebooks, open]);
|
|
|
|
if (!open) return null;
|
|
|
|
return (
|
|
<div className="fixed inset-0 z-[85] flex items-center justify-center bg-[var(--background)]/65 p-4 backdrop-blur-md">
|
|
<div className="surface-card w-full max-w-4xl overflow-hidden rounded-2xl border border-[var(--border)] bg-[var(--card)] text-[var(--card-foreground)] shadow-[0_22px_70px_rgba(0,0,0,0.18)]">
|
|
<div className="flex items-start justify-between gap-3 border-b border-[var(--border)] px-5 py-4">
|
|
<div className="min-w-0">
|
|
<div className="mb-1 inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.14em] text-[var(--primary)]">
|
|
<Layers className="h-3 w-3" />
|
|
{t("Notebook Reference")}
|
|
</div>
|
|
<h2 className="text-lg font-semibold text-[var(--foreground)]">
|
|
{t("Select Notebook Records")}
|
|
</h2>
|
|
<p className="mt-0.5 text-sm text-[var(--muted-foreground)]">
|
|
{t("Choose records across one or more notebooks to ground the next request.")}
|
|
</p>
|
|
</div>
|
|
<button
|
|
onClick={onClose}
|
|
className="rounded-lg p-2 text-[var(--muted-foreground)] transition-colors hover:bg-[var(--muted)] hover:text-[var(--foreground)]"
|
|
aria-label={t("Close")}
|
|
>
|
|
<X className="h-4 w-4" />
|
|
</button>
|
|
</div>
|
|
<div className="bg-[var(--background)]/40 p-5">
|
|
<NotebookSelector
|
|
notebooks={notebooks}
|
|
expandedNotebooks={expandedNotebooks}
|
|
notebookRecordsMap={notebookRecordsMap}
|
|
selectedRecords={selectedRecords}
|
|
loadingNotebooks={loadingNotebooks}
|
|
loadingRecordsFor={loadingRecordsFor}
|
|
isLoading={false}
|
|
onToggleExpanded={toggleNotebookExpanded}
|
|
onToggleRecord={toggleRecordSelection}
|
|
onSelectAll={selectAllFromNotebook}
|
|
onDeselectAll={deselectAllFromNotebook}
|
|
onClearAll={clearAllSelections}
|
|
onCreateSession={() => {
|
|
onApply(Array.from(selectedRecords.values()) as SelectedRecord[]);
|
|
onClose();
|
|
}}
|
|
actionLabel={actionLabel}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|