mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 06:19:43 +08:00
Self-hostable PageIndex, a fileable question bank, and third-party plugins. - PageIndex: adds PageIndex OSS as its own knowledge-base type, bound to the base's local library and driven by the configured LLM rather than a PageIndex API key. Retrieval moves off the built-in MCP server (removed) onto a workflow-owned reading loop that walks the document tree. - Question bank: addEntryToCategory shipped in v1.3.6 and was never called from the frontend, so categories could be created but never filled. The quiz card now uses the shared CategoryMenu, the page is rebuilt around search / batch selection / an unfiled inbox, and a new question_bank tool lets the tutor file questions instead of misrouting them to write_note. - Plugins: deeptutor.plugins was imported behind a try/except but the module never existed — implemented, plus a deeptutor.loop_capabilities group so third-party packages can register chat-loop capabilities. Builtins win on name collisions; broken entry points are skipped. - Parsing: remote Apache Tika engine (TIKA_SERVER_URL), with no local package and no model download. - LightRAG: the three indexing knobs from #877 get inputs under their own Indexing divider; unsupported keywords are dropped with a warning. - Knowledge bases: uploads take a destination folder, same-named documents from different subtrees stop dropping one another, and linked folders keep their source-relative structure — closing #866. - Book: a learning-capture inbox with an explicit status lifecycle, and drift warnings scoped to the KB documents that actually changed. - Whisper: /whisper moves out of the primary nav into Learning Space → More Projects, credited to its contributor; the room needs its own capability package. The reusable half is CAPABILITY_COMPLETE forwarding of a capability-declared body and its declared extras. - README: a Collaborate badge beside the Docs badge, in all twelve languages. - Lint: nosec B608 on four false-positive question-bank queries (literal fragments only, every value bound), and three mypy fixes. Release notes: assets/releases/ver1-5-15.md
108 lines
3.6 KiB
TypeScript
108 lines
3.6 KiB
TypeScript
"use client";
|
|
|
|
import type { AnnotationItem, NormalisedRect } from "@/lib/reading-api";
|
|
|
|
/** Ink for each palette colour, tuned to stay readable over black-on-white text. */
|
|
const COLOR_INK: Record<string, string> = {
|
|
yellow: "250 220 90",
|
|
green: "140 219 148",
|
|
blue: "122 192 250",
|
|
pink: "250 161 199",
|
|
purple: "199 174 250",
|
|
};
|
|
|
|
function ink(color: string): string {
|
|
return COLOR_INK[color] ?? COLOR_INK.yellow;
|
|
}
|
|
|
|
export interface AnnotationLayerProps {
|
|
annotations: AnnotationItem[];
|
|
highlightedAnnotationId?: string | null;
|
|
flashRects?: NormalisedRect[];
|
|
onAnnotationClick?: (annotation: AnnotationItem) => void;
|
|
}
|
|
|
|
/**
|
|
* Overlay that paints stored marks over one rendered unit.
|
|
*
|
|
* Positioned entirely in percentages from the annotation's normalised rects, so
|
|
* it needs no measurement and stays correct through zoom and pane resizing.
|
|
*
|
|
* `multiply` blending is what makes a highlight look like a highlighter rather
|
|
* than a coloured box on top of the words: the text below stays fully legible
|
|
* instead of being tinted.
|
|
*
|
|
* The layer itself is click-through (`pointer-events-none`); only the marks take
|
|
* clicks, so highlighting never blocks text selection on the layer beneath.
|
|
*/
|
|
export function AnnotationLayer({
|
|
annotations,
|
|
highlightedAnnotationId,
|
|
flashRects,
|
|
onAnnotationClick,
|
|
}: AnnotationLayerProps) {
|
|
return (
|
|
<div className="pointer-events-none absolute inset-0">
|
|
{annotations.map((annotation) =>
|
|
annotation.rects.map((rect, index) => {
|
|
const [x0, y0, x1, y1] = rect;
|
|
const isFocused =
|
|
annotation.annotation_id === highlightedAnnotationId;
|
|
const isUnderline = annotation.kind === "underline";
|
|
return (
|
|
<button
|
|
key={`${annotation.annotation_id}-${index}`}
|
|
type="button"
|
|
title={annotation.note || annotation.quote || undefined}
|
|
onClick={() => onAnnotationClick?.(annotation)}
|
|
className={[
|
|
"pointer-events-auto absolute cursor-pointer transition-[box-shadow,filter] duration-150",
|
|
isUnderline ? "" : "mix-blend-multiply",
|
|
isFocused ? "ring-2 ring-[var(--ring)] ring-offset-1" : "",
|
|
]
|
|
.filter(Boolean)
|
|
.join(" ")}
|
|
style={{
|
|
left: `${x0 * 100}%`,
|
|
top: `${y0 * 100}%`,
|
|
width: `${Math.max(0, x1 - x0) * 100}%`,
|
|
height: `${Math.max(0, y1 - y0) * 100}%`,
|
|
background: isUnderline
|
|
? undefined
|
|
: `rgb(${ink(annotation.color)} / ${isFocused ? 0.85 : 0.6})`,
|
|
borderBottom: isUnderline
|
|
? `2px solid rgb(${ink(annotation.color)})`
|
|
: undefined,
|
|
borderRadius: isUnderline ? 0 : 2,
|
|
}}
|
|
>
|
|
{annotation.author === "assistant" && index === 0 && (
|
|
<span
|
|
aria-hidden
|
|
className="absolute -top-1 -right-1 h-1.5 w-1.5 rounded-full bg-[var(--primary)] shadow-sm"
|
|
/>
|
|
)}
|
|
</button>
|
|
);
|
|
}),
|
|
)}
|
|
{(flashRects ?? []).map((rect, index) => {
|
|
const [x0, y0, x1, y1] = rect;
|
|
return (
|
|
<span
|
|
key={`flash-${index}`}
|
|
aria-hidden
|
|
className="dt-reader-flash absolute rounded-[2px]"
|
|
style={{
|
|
left: `${x0 * 100}%`,
|
|
top: `${y0 * 100}%`,
|
|
width: `${Math.max(0, x1 - x0) * 100}%`,
|
|
height: `${Math.max(0, y1 - y0) * 100}%`,
|
|
}}
|
|
/>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|