mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 06:19:43 +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
51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
/**
|
|
* Geometry of the reader/chat split.
|
|
*
|
|
* Pure so the boundary arithmetic — the part that is easy to get wrong and
|
|
* invisible when it is — can be tested without a DOM. The component that drags
|
|
* the seam only measures and writes; every decision about *what* width is
|
|
* allowed happens here.
|
|
*/
|
|
|
|
/** Narrow enough to be useless as a reader below this. */
|
|
export const READER_MIN_PX = 360;
|
|
/** Always leave the conversation at least this much. */
|
|
export const CHAT_MIN_PX = 380;
|
|
/** No reason to go wider than this even on a huge display. */
|
|
export const READER_MAX_PX = 1400;
|
|
/** Arrow-key step; Shift multiplies it. */
|
|
export const READER_STEP_PX = 24;
|
|
|
|
/** CSS custom property both sides of the split read. */
|
|
export const READER_WIDTH_VAR = "--reader-width";
|
|
/** localStorage key for the user's chosen width. */
|
|
export const READER_WIDTH_KEY = "dt.reader.width";
|
|
|
|
/**
|
|
* Clamp a candidate reader width so neither side can be squeezed out of use.
|
|
*
|
|
* `available` is the width of the box the two panes share. When it is unknown
|
|
* (server render, or a measurement taken before layout) only the absolute
|
|
* bounds apply — the CSS carries its own percentage ceiling for that case, so a
|
|
* stored pixel value can never paint over the conversation either way.
|
|
*
|
|
* The floor wins over the ceiling on a genuinely narrow container: a reader
|
|
* clamped to 40px would be worse than one that overflows slightly, and below
|
|
* `lg` the split does not exist at all.
|
|
*/
|
|
export function clampReaderWidth(px: number, available: number): number {
|
|
if (!Number.isFinite(px)) return READER_MIN_PX;
|
|
const ceiling =
|
|
available > 0
|
|
? Math.min(READER_MAX_PX, available - CHAT_MIN_PX)
|
|
: READER_MAX_PX;
|
|
return Math.round(Math.max(READER_MIN_PX, Math.min(px, Math.max(READER_MIN_PX, ceiling))));
|
|
}
|
|
|
|
/** Parse a persisted width, or null when there is nothing usable stored. */
|
|
export function parseStoredWidth(raw: string | null): number | null {
|
|
if (!raw) return null;
|
|
const parsed = Number(raw);
|
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
}
|