mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 10:20:23 +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
107 lines
3.6 KiB
TypeScript
107 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>
|
|
);
|
|
}
|