mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-05 18:20:31 +08:00
- Promote "Answer now" to a universal escape hatch via answer_now_context; orchestrator re-routes any capability to chat._stage_answer_now. - Co-Writer: draggable split + persistent ratio + line-anchored bidirectional scroll sync using a hidden mirror for wrap-aware editor y. - SaveToNotebookModal: optional message-selection mode with quick presets; rebuild transcript / userQuery from the selected subset. - Adopt the real notebook API (/api/v1/notebook/*) across Knowledge tab, guide notebook picker, and save-to-notebook flow; new typed helpers in web/lib/notebook-api.ts (listNotebooks/getNotebook/createNotebook/...). - Extract CollapsibleConfigSection; unify Quiz / Math Animator / Visualize / Deep Research panels behind one collapsed-summary header. - Replace streaming spinner with a dedicated Stop button; persistent composer header; mask-gradient on messages container. - TutorBotManager: public load/save/merge API; atomic write via temp + Path.replace; merge_bot_config with explicit-clear semantics; new tests/services/tutorbot/test_manager_config.py. - MarkdownRenderer: trackSourceLines passes data-source-line through; RichCodeBlock skips Prism for unlabeled/plaintext fences; mermaid detection includes flow/seq/sequence editor.md fences. - UI/theme: deeper foregrounds + warmer borders for light/Snow themes; /guide migrated off hardcoded slate/indigo to design tokens; HistorySessionPicker themed and timestamp-seconds bug fixed. - Filter system messages out of UnifiedChatContext.hydrateMessages and ChatMessageList so backend grounding context never renders as a bubble. - Bug fixes (already merged earlier in dev): * tutorbot config wipe on restart (#332) * selective_access_log middleware unpack crash (#334/#335) * 15 npm security vulnerabilities — jspdf/next/mermaid (#330) - Drive-by: remove "// README" typo from .env.example_CN. - Add v1.1.1 release notes and update README. 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 "@/app/(workspace)/guide/components/NotebookSelector";
|
|
import { useNotebookSelection } from "@/app/(workspace)/guide/hooks/useNotebookSelection";
|
|
import type { SelectedRecord } from "@/app/(workspace)/guide/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>
|
|
);
|
|
}
|