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

@ -13,9 +13,31 @@ container itself, not your workstation or Unraid host. Use a reachable LAN addre
Keys are encrypted with AES-256-GCM in SQLite using `/data/secret.key` or `APP_SECRET`.
Only the server decrypts them. Keep the key with backups; changing it breaks decryption.
Documents are sent to the selected provider when you request AI processing; extraction and
full-text indexing otherwise run locally. OCR requires a compatible vision/PDF model.
Retrieval uses chunked SQLite FTS search; it is lexical retrieval, not embedding similarity.
Review generated nursing content and source references before using it for study.
full-text indexing otherwise run locally. Review generated nursing content and source
references before using it for study.
## Reading scanned PDFs (OCR)
A PDF with little selectable text is read by the "Vision and OCR" model, which must accept
PDFs (OpenAI, Anthropic, Gemini; OpenAI-compatible servers when the model is marked "PDF").
Long files are split with pdf-lib into batches of 8 pages (smaller if a batch exceeds 24 MB)
and sent one batch per request, so there is no whole-file size cap. Each batch keeps its real
page numbers for citations. Finished batches are cached beside the upload
(`uploads/<file>.ocr.json`), so a restart or a failed batch does not repeat paid work; "Read
with AI" on the document forces a fresh read. A batch that fails twice is skipped with a
warning on the document. At most 600 pages are read per file.
## Semantic search
Settings → AI → Semantic search chooses an embeddings provider and model (suggested:
OpenAI `text-embedding-3-small`, Gemini `gemini-embedding-001`, Ollama `nomic-embed-text`;
Anthropic has no embeddings API). Every document passage is embedded in the background and
stored as a vector in SQLite (`chunk_vectors`). Search, the assistant's document search and
focused generation then merge keyword (FTS5) and meaning-based rankings with reciprocal-rank
fusion, so exact terms still match while paraphrased questions find the right passage. If the
embedding provider fails, search silently falls back to keywords. Changing the model clears
and rebuilds the index. Costs appear under Usage as "semantic indexing" / "semantic search".
Quiz questions, flashcards and notes are still searched by keyword.
## ChatGPT account investigation (2026-11-11)
@ -36,7 +58,9 @@ ChatGPT browser session tokens or a Codex client's registration/credentials into
Mock protocol tests cover request translation, streams, tools, usage and error handling.
Integration tests use a local OpenAI-compatible mock to generate/edit/save drafts, search
documents with citations and exercise confirmed assistant actions. They cost no API credits.
documents with citations and exercise confirmed assistant actions, batched OCR of a 20-page
scanned PDF and semantic indexing/search (the mock returns deterministic word-hash vectors).
They cost no API credits.
No successful real-provider inference or real ChatGPT OAuth authorization is claimed.
For manual local AI testing: `npx tsx scripts/mock-ai.ts` starts a scripted mock at

View file

@ -10,7 +10,7 @@ establish real-provider compatibility, and sampled desktop/mobile QA is not exha
| --- | --- |
| New architecture and UI | Rebuilt: React/Vite, Hono, built-in SQLite; distinct responsive light/dark design |
| Single administrator and public visitors | Implemented: secure local login, revocable links, isolated visitor progress |
| Classes and organization | Classes/folders, edit/move/search/delete, quiz/deck duplication; manual ordering and duplication are not equally exposed for every content type |
| Classes and organization | Classes/folders, edit/move/search/delete, quiz/deck duplication, drag-to-reorder (mouse, touch, keyboard) for materials, folders, questions and cards |
| Quizzes | MC/SATA, per-option explanations, question rationale, partial credit, practice/exam, shuffle, resume, missed review and history implemented |
| Flashcards | Decks, browse/self-assessment, persistent FSRS, reviews, undo and class/deck scoping implemented |
| Imports/templates/export | Preview/validation/editing, JSON/text bulk input, reusable templates and exports implemented |
@ -31,9 +31,10 @@ exam engine are not implemented; the brief listed additional types as optional.
independent schedules and new-card limits. V2 schedules each card once, with a global
daily new-card limit and deck/class/all review scopes. A practical simplification, but
it cannot reproduce separate course/exam review sets or independent per-set schedules.
- **Manual material order:** V1 supported drag/drop ordering of decks within material groups.
V2 class lists sort by recent update or title; the visible drag/drop is for file upload.
Some reorder APIs exist without matching UI. Quiz questions do have move-up/down controls.
- **Manual material order:** restored on 2026-11-12. The class page's default "Your order"
sort shows grip handles: drag (mouse or touch) or use arrow keys/Home/End on a handle to
reorder quizzes, decks, documents and notes within their group, and to reorder folders.
Quiz questions and deck cards are reorderable the same way.
- **Migration fidelity:** V2 imports source content, completed attempts and one selected
schedule per card. V1 interrupted StudyProgress sessions, named sets and their independent
schedules are not recreated. Historical reviewSnapshotJson is not consumed: imported
@ -73,18 +74,18 @@ Screenshot: ignored local `.test-data/rationale-check/correct-inline.png`.
## Remaining usability/feature priorities
Done on 2026-11-12: drag-to-reorder; wall-clock exam deadlines enforced by the server
(answers after the deadline plus a 5 s grace are refused and overdue exams are submitted with
what was saved, even if nobody reopens them); frozen shared-quiz sessions (a visitor's session
keeps the questions as they were at the start and notes later edits); batched, cached OCR for
long scanned PDFs; semantic (embedding) search merged with keyword search.
1. Restore selected-deck named review collections if replacing that V1 workflow is important.
2. Expose consistent ordering and duplication controls across content types.
3. Make timed exams use an explicit wall-clock deadline. The current runner is an active-study
clock: it pauses when hidden, and server completion does not enforce a deadline.
4. Preserve shared quiz question snapshots if scores must remain stable across owner edits;
public saved sessions currently rebuild against the latest published quiz content.
5. Add better import reporting/preservation for V1 history and interrupted sessions.
6. Improve large scanned-document OCR: currently sent as one native vision/PDF request with
a 30 MB scanned-PDF limit and an output cap, rather than paginated OCR. Lexical retrieval
and sampled long-document generation are implemented; comprehensive textbook coverage
and semantic matching are not guaranteed.
7. Full offline private studying, rich-text WYSIWYG authoring, study-plan generation and
2. Better import reporting/preservation for V1 history and interrupted sessions.
3. Scanned PDFs need a vision model that accepts PDFs; vision-only models (e.g. most Ollama
vision models) cannot read scanned PDFs yet because pages are not rendered to images.
4. Semantic search covers document passages; questions, cards and notes are keyword-only.
5. Full offline private studying, rich-text WYSIWYG authoring, study-plan generation and
additional case/question types remain optional future enhancements.
No obvious missing basic flip/streak/quiz-answer feedback remains by source review. Visual