Check-my-work attachments, smart review follows deletions, GPL-3.0-only

- "Check my work" now takes photos and documents of the attempt: documents
  are read in the browser into text, photos go to /api/homework as
  solutionImages and are transcribed by the vision model before the check
  ("Reading your solution..."). The finished attempt comes back in
  meta.solutionText and is stored as the record's attempt, so "Redo"
  re-checks the same work without keeping the files.
- Deleting a deck now drops its due schedules and mistakes from the library's
  smart review immediately (the counts resolve against the live deck list);
  Undo brings them back, because the learning data itself is never erased.
- The phone override for the glacier blobs was still at 0.1/0.2: it is now a
  quarter of the original value there too (0.025/0.05), matching the desktop.
- License: GPL-3.0-only (LICENSE, package.json, README section).

Tests: phase-3 photos-only API + desktop attachment checks (28/28), review
suite deck-delete checks (18/18), i18n/mobile/phase-2 green. README:
decisions 57-58. SW -> freezmo-v45.
This commit is contained in:
Martin Dvořák 2026-10-12 16:04:53 +00:00
commit d559865a09
13 changed files with 1033 additions and 24 deletions

View file

@ -24,6 +24,8 @@ const requestSchema = z.object({
text: z.string().max(120_000).optional(),
/** Mode "check": the student's own attempt at the assignment. */
solution: z.string().max(120_000).optional(),
/** Mode "check": photos of the attempt (handwritten work, scanned pages). */
solutionImages: z.array(z.string().min(32).max(MAX_IMAGE_CHARS)).max(16).optional(),
/** Language of the assignment (usually detected by the vision step). */
language: z.string().max(60).optional(),
});
@ -82,13 +84,14 @@ export async function POST(request: Request) {
);
}
const { mode, images, text, solution, language } = parsed.data;
const { mode, images, text, solution, solutionImages, language } = parsed.data;
const imageList = (images ?? []).map(stripDataUrlPrefix).filter(Boolean);
const solutionImageList = (solutionImages ?? []).map(stripDataUrlPrefix).filter(Boolean);
if (imageList.length === 0 && !text?.trim()) {
return Response.json({ error: translate(locale, "server.needAssignment") }, { status: 400 });
}
if (mode === "check" && !solution?.trim()) {
if (mode === "check" && !solution?.trim() && solutionImageList.length === 0) {
return Response.json({ error: translate(locale, "server.needSolution") }, { status: 400 });
}
@ -151,11 +154,31 @@ export async function POST(request: Request) {
};
if (mode === "check") {
/* Photos of the attempt (handwritten working, scanned pages) are
transcribed first; whatever was typed stays as it is. */
let solutionText = solution?.trim() ?? "";
if (solutionImageList.length > 0) {
send({
type: "stage",
stage: "vision",
message: translate(locale, "homework.loading.readingSolution"),
});
const transcription = await extractNotes({
model: config.visionModel,
repairModel: config.textModel,
auth: auth.auth,
images: solutionImageList,
signal: abort.signal,
onProgress: (message) => send({ type: "stage", stage: "vision", message }),
});
solutionText = [solutionText, notesToText(transcription.notes)].filter(Boolean).join("\n\n");
}
const result = await checkHomework({
model: config.textModel,
auth: auth.auth,
assignment: assignmentText,
solution: solution!.trim(),
solution: solutionText,
language: detectedLanguage,
signal: abort.signal,
});
@ -171,7 +194,10 @@ export async function POST(request: Request) {
corrected: result.corrected,
sourceText: assignmentText,
},
meta,
/* The full attempt (typed + transcribed) travels back so the client
can store it: "Redo" then re-checks the same work without the
photos — they are never stored. */
meta: { ...meta, solutionText },
});
} else if (mode === "make") {
const result = await makeHomework({