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

@ -49,6 +49,11 @@ export function HomeworkScreen({ initialRecordId }: { initialRecordId?: string }
tooManyPhotosKey: "homework.source.tooManyPhotos",
tooManyDocsKey: "homework.source.tooManyDocs",
});
/* Mode "check" has its own intake: photos/scans of the attempt itself. */
const solutionIntake = useNotesIntake({
tooManyPhotosKey: "homework.solution.tooManyPhotos",
tooManyDocsKey: "homework.solution.tooManyDocs",
});
const [mode, setMode] = useState<HomeworkMode>("make");
const [text, setText] = useState("");
@ -88,16 +93,36 @@ export function HomeworkScreen({ initialRecordId }: { initialRecordId?: string }
...intake.images.map((image) => image.dataUrl),
...documentImages.map((image) => image.dataUrl),
].slice(0, MAX_IMAGES_TO_SEND);
/* Mode "check": the attempt can be typed and/or attached. Documents are
already text in the browser, so their text joins what was typed; photos
go to the server to be transcribed (see /api/homework). */
const solutionReady = solutionIntake.documents.filter((entry) => entry.status === "ready" && entry.extracted);
const solutionDocumentText = documentsToText(solutionReady.map((entry) => entry.extracted!));
const mergedSolution = [solution.trim(), solutionDocumentText.trim()].filter(Boolean).join("\n\n");
const solutionImages = [
...solutionIntake.images.map((image) => image.dataUrl),
...solutionReady.flatMap((entry) => entry.extracted!.images).map((image) => image.dataUrl),
].slice(0, MAX_IMAGES_TO_SEND);
return {
mode: modeValue,
images,
text: mergedText,
solution: modeValue === "check" ? solution.trim() : undefined,
solution: modeValue === "check" ? mergedSolution : undefined,
solutionImages: modeValue === "check" && solutionImages.length > 0 ? solutionImages : undefined,
};
};
const run = useCallback(
async (input: { mode: HomeworkMode; images: string[]; text: string; solution?: string; recordId?: string }) => {
async (input: {
mode: HomeworkMode;
images: string[];
text: string;
solution?: string;
solutionImages?: string[];
recordId?: string;
}) => {
setError(null);
setView({ kind: "loading" });
const vision = input.images.length > 0;
@ -116,12 +141,13 @@ export function HomeworkScreen({ initialRecordId }: { initialRecordId?: string }
abortRef.current = controller;
try {
const { homework } = await generateHomework(
const { homework, meta } = await generateHomework(
{
mode: input.mode,
images: input.images.length > 0 ? input.images : undefined,
text: input.text || undefined,
solution: input.solution,
solutionImages: input.solutionImages?.length ? input.solutionImages : undefined,
},
{ onProgress: setProgress, signal: controller.signal },
);
@ -148,7 +174,10 @@ export function HomeworkScreen({ initialRecordId }: { initialRecordId?: string }
correct: homework.correct,
wrong: homework.wrong,
corrected: homework.corrected,
attempt: input.solution,
/* What was actually checked: typed text plus the server's
transcription of any attached photos, so "Redo" can
re-check the same work (the photos are never stored). */
attempt: (typeof meta.solutionText === "string" && meta.solutionText.trim()) || input.solution,
}
: {
mode: "guide",
@ -182,11 +211,12 @@ export function HomeworkScreen({ initialRecordId }: { initialRecordId?: string }
/** `modeOverride` lets the phone flow start straight from a tapped mode card. */
const submit = (modeOverride?: HomeworkMode) => {
const target = modeOverride ?? mode;
if (target === "check" && !solution.trim()) {
const payload = buildPayload(target);
/* Check mode needs an attempt — typed, attached, or both. */
if (target === "check" && !payload.solution?.trim() && !payload.solutionImages?.length) {
setError({ message: t("homework.solution.required") });
return;
}
const payload = buildPayload(target);
void run(payload);
};
@ -216,6 +246,7 @@ export function HomeworkScreen({ initialRecordId }: { initialRecordId?: string }
const newAssignment = () => {
intake.clear();
solutionIntake.clear();
setText("");
setSolution("");
setError(null);
@ -272,6 +303,7 @@ export function HomeworkScreen({ initialRecordId }: { initialRecordId?: string }
solution={solution}
onSolutionChange={setSolution}
intake={intake}
solutionIntake={solutionIntake}
onSubmit={submit}
error={error}
history={history}