mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 09:29:39 +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
144 lines
4.3 KiB
TypeScript
144 lines
4.3 KiB
TypeScript
"use client";
|
|
|
|
import { useTranslation } from "react-i18next";
|
|
import type {
|
|
DeepResearchFormConfig,
|
|
ResearchDepth,
|
|
ResearchMode,
|
|
} from "@/lib/research-types";
|
|
import { summarizeResearchConfig } from "@/lib/research-types";
|
|
import {
|
|
CollapsibleConfigSection,
|
|
Field,
|
|
INPUT_CLS,
|
|
} from "@/components/chat/home/composer-field";
|
|
|
|
interface ResearchConfigPanelProps {
|
|
value: DeepResearchFormConfig;
|
|
errors: Record<string, string>;
|
|
collapsed: boolean;
|
|
onChange: (next: DeepResearchFormConfig) => void;
|
|
onToggleCollapsed: () => void;
|
|
}
|
|
|
|
const MODE_OPTIONS: Array<{ value: Exclude<ResearchMode, "">; label: string }> = [
|
|
{ value: "notes", label: "Study Notes" },
|
|
{ value: "report", label: "Report" },
|
|
{ value: "comparison", label: "Comparison" },
|
|
{ value: "learning_path", label: "Learning Path" },
|
|
];
|
|
|
|
const DEPTH_OPTIONS: Array<{ value: Exclude<ResearchDepth, "">; label: string }> = [
|
|
{ value: "quick", label: "Quick" },
|
|
{ value: "standard", label: "Standard" },
|
|
{ value: "deep", label: "Deep" },
|
|
{ value: "manual", label: "Manual" },
|
|
];
|
|
|
|
function NumberSlider({
|
|
label,
|
|
value,
|
|
min,
|
|
max,
|
|
onChange,
|
|
}: {
|
|
label: string;
|
|
value: number;
|
|
min: number;
|
|
max: number;
|
|
onChange: (n: number) => void;
|
|
}) {
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<span className="shrink-0 text-[10px] text-[var(--muted-foreground)]/60">{label}</span>
|
|
<input
|
|
type="range"
|
|
min={min}
|
|
max={max}
|
|
step={1}
|
|
value={value}
|
|
onChange={(e) => onChange(Number(e.target.value))}
|
|
className="h-1 flex-1 cursor-pointer appearance-none rounded-full bg-[var(--muted-foreground)]/15 accent-[var(--primary)] [&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary)]"
|
|
/>
|
|
<span className="w-5 text-center text-[11px] font-semibold tabular-nums text-[var(--foreground)]">
|
|
{value}
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default function ResearchConfigPanel({
|
|
value,
|
|
errors: _errors,
|
|
collapsed,
|
|
onChange,
|
|
onToggleCollapsed,
|
|
}: ResearchConfigPanelProps) {
|
|
const { t } = useTranslation();
|
|
const update = <K extends keyof DeepResearchFormConfig>(
|
|
key: K,
|
|
next: DeepResearchFormConfig[K],
|
|
) => onChange({ ...value, [key]: next });
|
|
|
|
const rawSummary = summarizeResearchConfig(value);
|
|
const summary = rawSummary === "Incomplete settings" ? undefined : rawSummary;
|
|
|
|
return (
|
|
<CollapsibleConfigSection
|
|
collapsed={collapsed}
|
|
summary={summary}
|
|
onToggleCollapsed={onToggleCollapsed}
|
|
bodyClassName="space-y-2 px-3.5 pb-2.5"
|
|
>
|
|
<div className="flex flex-wrap items-end gap-x-3 gap-y-2">
|
|
<Field label="Mode" width="min-w-[130px] flex-1">
|
|
<select
|
|
value={value.mode}
|
|
onChange={(e) => update("mode", e.target.value as ResearchMode)}
|
|
className={`${INPUT_CLS} w-full`}
|
|
>
|
|
<option value="">{t("Select...")}</option>
|
|
{MODE_OPTIONS.map((option) => (
|
|
<option key={option.value} value={option.value}>
|
|
{option.label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</Field>
|
|
<Field label="Depth" width="min-w-[130px] flex-1">
|
|
<select
|
|
value={value.depth}
|
|
onChange={(e) => update("depth", e.target.value as ResearchDepth)}
|
|
className={`${INPUT_CLS} w-full`}
|
|
>
|
|
<option value="">{t("Select...")}</option>
|
|
{DEPTH_OPTIONS.map((option) => (
|
|
<option key={option.value} value={option.value}>
|
|
{option.label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</Field>
|
|
</div>
|
|
{value.depth === "manual" && (
|
|
<div className="space-y-1.5 rounded-md bg-[var(--muted-foreground)]/5 px-3 py-2">
|
|
<NumberSlider
|
|
label="Sub-topics"
|
|
value={value.manual_subtopics ?? 3}
|
|
min={1}
|
|
max={10}
|
|
onChange={(n) => update("manual_subtopics", n)}
|
|
/>
|
|
<NumberSlider
|
|
label="Iterations"
|
|
value={value.manual_max_iterations ?? 3}
|
|
min={1}
|
|
max={8}
|
|
onChange={(n) => update("manual_max_iterations", n)}
|
|
/>
|
|
</div>
|
|
)}
|
|
</CollapsibleConfigSection>
|
|
);
|
|
}
|