Add drag reordering, exam deadlines, frozen shared quizzes, batched OCR and semantic search
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 33s

- Drag-to-reorder for class materials, folders, quiz questions and deck cards. Pointer-based
  so touch works, plus keyboard (arrows/Home/End) with screen-reader announcements.
- Timed exams get a wall-clock deadline. The server refuses late answers, submits overdue
  exams with what was saved, and the countdown keeps running while the page is closed.
- Shared quiz sessions keep a frozen copy of their questions and flag later owner edits.
- Scanned PDFs are read in cached 8-page batches with real page numbers (pdf-lib), removing
  the 30 MB whole-file limit. Compatible providers now receive PDFs as file parts.
- Semantic search: embeddings for OpenAI, Gemini, Ollama and compatible servers, background
  indexing into chunk_vectors (migration 2), hybrid keyword + vector ranking for search, the
  assistant and focused generation, and a Settings -> AI section.

181 tests pass locally and in the Docker test stage on Node 24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-12 11:48:20 -07:00
parent 3046e46d1c
commit ccdad9728b
39 changed files with 1772 additions and 121 deletions

View file

@ -0,0 +1,49 @@
/**
* Splits a PDF into smaller PDFs of consecutive pages, so a long scanned document can be read by
* an AI model in batches instead of one oversized request.
*/
import { PDFDocument } from 'pdf-lib';
export interface PdfBatch {
/** 1-based page numbers, inclusive. */
start: number;
end: number;
bytes: Uint8Array;
}
export async function pdfPageCount(bytes: Uint8Array): Promise<number> {
const doc = await PDFDocument.load(bytes, { ignoreEncryption: true, updateMetadata: false });
return doc.getPageCount();
}
/**
* Yields batches of up to `pagesPerBatch` pages. A batch larger than `maxBytes` is split again
* (down to a single page); a single page that is still too large is yielded as-is for the caller
* to skip with a warning.
*/
export async function* splitPdf(bytes: Uint8Array, pagesPerBatch: number, maxBytes: number): AsyncGenerator<PdfBatch> {
const src = await PDFDocument.load(bytes, { ignoreEncryption: true, updateMetadata: false });
const total = src.getPageCount();
async function build(start: number, end: number): Promise<Uint8Array> {
const out = await PDFDocument.create({ updateMetadata: false });
const indices = Array.from({ length: end - start + 1 }, (_, i) => start - 1 + i);
for (const page of await out.copyPages(src, indices)) out.addPage(page);
return out.save({ useObjectStreams: true });
}
async function* emit(start: number, end: number): AsyncGenerator<PdfBatch> {
const part = await build(start, end);
if (part.length <= maxBytes || start === end) {
yield { start, end, bytes: part };
return;
}
const mid = Math.floor((start + end) / 2);
yield* emit(start, mid);
yield* emit(mid + 1, end);
}
for (let start = 1; start <= total; start += pagesPerBatch) {
yield* emit(start, Math.min(total, start + pagesPerBatch - 1));
}
}