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

@ -116,7 +116,7 @@ export function libraryRoutes(app: AppContext): Hono {
);
const decks = db.all<DeckRow & { cn: number }>(`SELECT d.*, (SELECT COUNT(*) FROM cards c WHERE c.deck_id = d.id) AS cn FROM decks d WHERE d.class_id = ?`, cls.id);
const documents = db.all<Record<string, any>>(
'SELECT id, folder_id, title, filename, kind, size, status, error, progress, page_count, token_count, needs_ocr, created_at, updated_at FROM documents WHERE class_id = ?',
'SELECT id, folder_id, title, filename, kind, size, status, error, progress, page_count, token_count, needs_ocr, sort_order, created_at, updated_at FROM documents WHERE class_id = ?',
cls.id,
);
const notes = db.all<NoteRow>('SELECT * FROM notes WHERE class_id = ?', cls.id);
@ -128,6 +128,7 @@ export function libraryRoutes(app: AppContext): Hono {
title: q.title,
description: q.description,
folderId: q.folder_id,
sortOrder: q.sort_order,
createdAt: q.created_at,
updatedAt: q.updated_at,
shared: shared('quiz', q.id),
@ -145,6 +146,7 @@ export function libraryRoutes(app: AppContext): Hono {
title: d.title,
description: d.description,
folderId: d.folder_id,
sortOrder: d.sort_order,
createdAt: d.created_at,
updatedAt: d.updated_at,
shared: shared('deck', d.id),
@ -160,6 +162,7 @@ export function libraryRoutes(app: AppContext): Hono {
title: d.title as string,
description: '',
folderId: d.folder_id as string | null,
sortOrder: d.sort_order as number,
createdAt: d.created_at as number,
updatedAt: d.updated_at as number,
shared: shared('document', d.id),
@ -179,6 +182,7 @@ export function libraryRoutes(app: AppContext): Hono {
title: n.title,
description: n.content.replace(/[#*_>`|-]/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 160),
folderId: n.folder_id,
sortOrder: n.sort_order,
createdAt: n.created_at,
updatedAt: n.updated_at,
shared: shared('note', n.id),
@ -278,6 +282,15 @@ export function libraryRoutes(app: AppContext): Hono {
const TABLES = { quiz: 'quizzes', deck: 'decks', note: 'notes', document: 'documents' } as const;
/** Manual order for one kind of material in a class. Ids from other classes are ignored. */
r.post('/classes/:id/items/reorder', async (c) => {
const cls = getClass(db, idParam(c));
const body = await readBody(c, z.object({ kind: z.enum(['quiz', 'deck', 'note', 'document']), ids: z.array(z.string()).max(2000) }));
const table = TABLES[body.kind];
db.tx(() => body.ids.forEach((id, i) => db.run(`UPDATE ${table} SET sort_order = ? WHERE id = ? AND class_id = ?`, i, id, cls.id)));
return c.json({ ok: true });
});
r.post('/items/move', async (c) => {
const body = await readBody(
c,