mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:09:53 +08:00
Immersive Reading, self-configuration, and a two-way IMA library. - Immersive Reading: a new capability that opens a document beside the thread. New reading engine (PDF pages / slides / page-sized sections), five reading tools, a deterministic locate pre-pass that grounds the turn without a second LLM call, /api/v1/reading, and a reader pane with selection, highlights, notes, and export to an annotated PDF or Markdown. - Setup capability: inspect the install, apply a setting, install a parsing engine, or request a credential from a chat turn. New settings spec table; a candidate value is probed before it is committed, and API keys never enter the model's context. - Tencent IMA: pipeline split into transport/envelope/models/sources/ notes/media/inventory, an additive capability with five tools, and connected libraries that can finally be enumerated (bounded listings are reported as a lower bound). - Retrieval: supports_rag_retrieval() replaces is_connected_kb() for the "can I sweep this?" question, so linked / lightrag_server / ima sources stop being silently dropped from every book. - Notebooks: their own console at /notebook, per-notebook locks and atomic writes, copy / move / export routes, damaged files surfaced instead of dropped, and renaming a record no longer clears its knowledge-base link. - Settings persistence: one lock and one atomic replace shared by every writer of interface.json; the PUT endpoints stop writing the defaults-merged view back to disk. Release notes: assets/releases/ver1-5-14.md
145 lines
4.7 KiB
TypeScript
145 lines
4.7 KiB
TypeScript
"use client";
|
|
|
|
import { useCallback, useEffect, useState } from "react";
|
|
import {
|
|
ChevronDown,
|
|
ChevronRight,
|
|
Circle,
|
|
CircleCheck,
|
|
CircleDot,
|
|
Loader2,
|
|
} from "lucide-react";
|
|
|
|
import {
|
|
fetchObjectiveReport,
|
|
type MasteryMap,
|
|
type ObjectiveReport,
|
|
type ObjectiveStatus,
|
|
} from "@/lib/learning-api";
|
|
|
|
import { ObjectiveDetail } from "./ObjectiveDetail";
|
|
import type { Translate } from "./format";
|
|
|
|
export const STATUS_META: Record<
|
|
ObjectiveStatus,
|
|
{ cn: string; en: string; className: string }
|
|
> = {
|
|
mastered: { cn: "已掌握", en: "Mastered", className: "text-green-500" },
|
|
learning: { cn: "学习中", en: "Learning", className: "text-yellow-500" },
|
|
new: {
|
|
cn: "未开始",
|
|
en: "Not started",
|
|
className: "text-[var(--muted-foreground)]",
|
|
},
|
|
};
|
|
|
|
/**
|
|
* The module → objective map, with each objective openable.
|
|
*
|
|
* Rows stay as terse as before; the evidence behind one only loads when it is
|
|
* opened, so a large path costs a single map request until the learner asks a
|
|
* question of it. `revision` re-fetches whatever is open, which is how an
|
|
* expanded objective keeps up with a live tutoring session.
|
|
*/
|
|
export function PathMap({
|
|
pathId,
|
|
map,
|
|
revision,
|
|
tr,
|
|
zh,
|
|
}: {
|
|
pathId: string;
|
|
map: MasteryMap;
|
|
revision: number;
|
|
tr: Translate;
|
|
zh: boolean;
|
|
}) {
|
|
const [openId, setOpenId] = useState<string | null>(null);
|
|
const [report, setReport] = useState<ObjectiveReport | null>(null);
|
|
// Loading is derived rather than tracked: a report that does not match the
|
|
// open objective is, by definition, still on its way.
|
|
const loaded = openId !== null && report?.id === openId;
|
|
|
|
useEffect(() => {
|
|
if (!openId) return;
|
|
const controller = new AbortController();
|
|
fetchObjectiveReport(pathId, openId, { signal: controller.signal })
|
|
.then(setReport)
|
|
.catch(() => {
|
|
if (!controller.signal.aborted) setReport(null);
|
|
});
|
|
return () => controller.abort();
|
|
}, [pathId, openId, revision]);
|
|
|
|
const toggle = useCallback((id: string) => {
|
|
setOpenId((current) => (current === id ? null : id));
|
|
setReport(null);
|
|
}, []);
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
{map.modules.map((module) => (
|
|
<div key={module.id}>
|
|
<div className="flex items-center justify-between">
|
|
<h3 className="text-sm font-medium text-[var(--foreground)]">
|
|
{module.name}
|
|
</h3>
|
|
<span className="text-xs text-[var(--muted-foreground)]">
|
|
{module.mastered}/{module.total}
|
|
</span>
|
|
</div>
|
|
<div className="mt-1.5">
|
|
{module.knowledge_points.map((kp) => {
|
|
const open = openId === kp.id;
|
|
return (
|
|
<div key={kp.id}>
|
|
<button
|
|
onClick={() => toggle(kp.id)}
|
|
aria-expanded={open}
|
|
className="flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-sm hover:bg-[var(--accent)] cursor-pointer"
|
|
>
|
|
{open ? (
|
|
<ChevronDown className="h-3 w-3 shrink-0 text-[var(--muted-foreground)]" />
|
|
) : (
|
|
<ChevronRight className="h-3 w-3 shrink-0 text-[var(--muted-foreground)]" />
|
|
)}
|
|
<StatusIcon status={kp.status} />
|
|
<span className="flex-1 truncate text-[var(--foreground)]">
|
|
{kp.name}
|
|
</span>
|
|
<span className="text-[10px] uppercase tracking-wide text-[var(--muted-foreground)]">
|
|
{kp.type}
|
|
</span>
|
|
<span
|
|
className={`text-xs ${STATUS_META[kp.status].className}`}
|
|
>
|
|
{zh
|
|
? STATUS_META[kp.status].cn
|
|
: STATUS_META[kp.status].en}
|
|
</span>
|
|
</button>
|
|
{open &&
|
|
(loaded && report ? (
|
|
<ObjectiveDetail report={report} tr={tr} zh={zh} />
|
|
) : (
|
|
<div className="ml-8 py-2 text-[var(--muted-foreground)]">
|
|
<Loader2 className="h-3 w-3 animate-spin" />
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function StatusIcon({ status }: { status: ObjectiveStatus }) {
|
|
const cls = `w-3 h-3 shrink-0 ${STATUS_META[status].className}`;
|
|
if (status === "mastered") return <CircleCheck className={cls} />;
|
|
if (status === "learning") return <CircleDot className={cls} />;
|
|
return <Circle className={cls} />;
|
|
}
|