diff --git a/TODO.md b/TODO.md index 034e48e..1ed88ac 100644 --- a/TODO.md +++ b/TODO.md @@ -15,6 +15,26 @@ specs are in git history. viewed round (same / rotate / by name-stamp corner), via `teacher:set-background-multi`. - [ ] **A prepared breakout round** (see below): sets that round's worksheet template, so students who enter it later get it. + - [ ] **Set up worksheet variants (A–D) before class, on a prepared round.** Today variants can only be sent + from Live Grid → **Send worksheet…**, after the round is live and students already have boards. + - In the prepared-round form (Breakout manager → **Save for later** / **Edit**), let the teacher upload up to + four variants and pick the distribution: same for all / deal out in turn / by name-stamp corner. + - On **Launch**, the server gives each new board its variant. Corner mode reads the main board's stamps at + launch time. Late joiners get their variant by the same rule, not always A. + - Save variants and the distribution rule **on the round**, so they survive a restart. + - **Lesson packs must carry all of it.** Anything a teacher sets up ahead of time (prepared rounds, their + variants A–D, the distribution rule, the corner mapping, per-student overrides, the late-joiner rule) must + go into **Save lesson…** (`.allaboard`) and come back intact with **Load lesson…**. Per-student overrides + only make sense in the same class, so on load, match them by student name and drop the ones that don't + match. Add a round-trip test: save a pack, load it into a fresh room, and check that every prepared field + matches. + - [ ] **Make a sent distribution editable.** Reopening **Send worksheet…** starts empty: the uploaded variants + and who got which are forgotten, so changing one student's card means uploading everything again. + - Remember each round's variants and assignments, and reopen the modal with them filled in. + - Allow changing one board's letter, swapping a variant's file, or switching the distribution rule, and send + only the boards whose worksheet actually changes. + - Keep the existing rule: ink stays and only the worksheet underneath changes. Warn about boards that + already have work, as the modal does now. - **Server:** a teacher-only path that applies `internBackground` once and then reuses the same asset URL for every board. With content-addressed assets, 30 boards cost one stored image. @@ -71,6 +91,69 @@ Plan: [`PLANS_LESSON_PACKS.md`](PLANS_LESSON_PACKS.md) phases 2–3, with the op - [ ] **Owner setup:** turn on AllAboard reports in OverBoard's report script (BPMData/OverBoard PR 56), add the `REPORT_RELAY_URL` / `REPORT_RELAY_TOKEN` secrets, send a test report. Until then every report uses the fallback. +### A real eraser (remove objects instead of covering them) +- [ ] **Make the eraser delete or trim what it touches, instead of adding an "eraser stroke" element.** Today the + eraser is a white ink stroke stored like any other ink, and `getVisibleStrokeRuns` / `expandElementVisiblePieces` + (`src/lib/inkCore.ts`) work out what still shows at render time. Effects: + - Erasing makes a board **heavier**, not lighter. Each swipe is another element (it counts toward the 10,000-per-board + cap) and makes every later render, digest and PDF export do more work. + - Hidden objects still exist. That was the one-name-stamp bug (fixed Nov 2026 for **stamps only**: erasing a stamp + now deletes it, via `stampsHitByEraser`). Erased text notes (`allGoneNoteIds`) and fully erased strokes still sit + in the data, still show up in lasso selection, and still count in "N drawn". + - **Goal:** on pen-up, an eraser stroke turns into edits. + - Fully covered strokes, notes and shapes are **removed**. + - Partly erased freehand strokes are **split** into their visible pieces. `expandElementVisiblePieces` already + computes them, and lasso-move already uses it. + - No eraser element is stored. + - Undo stays one step: one `replace` entry with what was removed and what was added. + - **Watch out for:** + - Live erasing feedback while the pen is down. Keep drawing the white stroke locally and only commit edits on + pen-up. + - Other users' views. They get remove and add batches, not a stroke. + - Shapes and hollow strokes, which can't be split cleanly. Remove them only when fully covered, and otherwise + keep a covering stroke for just those. + - **Old rooms: no backward compatibility needed** (owner decision, Nov 2026: nobody but the owner has used + the app yet). Don't migrate or special-case existing rooms: whatever their old eraser strokes do after the + change is fine, and the rooms can just be wiped. + - Rate and size caps on large batches (`socketGuards.ts`). + - **Tests:** element counts go **down** after erasing, a partial erase leaves the right pieces, undo/redo restores + them exactly, and a second browser sees the same result. + +### Classroom simulator: fake students for testing alone +- [ ] **One command that fills a room with fake students** so a teacher can test breakouts, worksheet variants, + corner mode, late joiners and lesson-pack reloads from one laptop, without a pile of incognito tabs. + - **Build on `scripts/loadtest.ts`.** It already connects fake Socket.IO students, locally or to `--url`, and + gets through the HTTPS proxy. Put the new script at `scripts/classroom.ts`, add `"classroom": "tsx scripts/classroom.ts"` + to `package.json`, and add a short **"Test with fake students"** section to `README.md`. + - **What the fake students do:** + - Join with readable names (`Ava (bot)`, `Ben (bot)`, …) and stay connected until you stop the script. + - **Stamp their name** on the main board, either in random corners or as you set with + `--corners tl:5,tr:5,bl:4,br:6`. The stamp position is worked out from the main board's worksheet bounds, so + it lands inside the boxes. + - **Follow breakouts.** When moved to their own board or a group board, each one writes its name in a text box + there, so the Live Grid shows who is who and which worksheet each got. + - Set status (**Need help** / **Done**) at random if `--statuses` is given. + - **Controls while it runs** (keys in the terminal, listed when it starts): + `l` = one late joiner, `L` = five late joiners, `s` = everyone re-stamps, `r` = everyone disconnects and + rejoins, `d` = everyone draws a scribble, `q` = everyone leaves and the script quits. + - **Safety:** + - Refuse to start unless the room code begins with `test-` (or `--i-know`), so it can never land in a real + class. + - Cap at 40 students. + - Never send the teacher PIN. + - On quit, remove the bots' ink and stamps (`clear-user-drawings`) and disconnect cleanly. + - **How to launch it**, once built (the README section should say exactly this): + 1. **Against production (easiest):** open AllAboard yourself as teacher in room `test-whatever`. Then, in a + Claude Code session on this repo, say: *"Run `npm run classroom -- --url https:// + --room test-whatever --students 20` and leave it running."* Tell Claude when you're done, and it presses `q`. + 2. **On your own computer** (needs Node 22): `npm ci` once, then + `npm run classroom -- --url https:// --room test-whatever --students 20`. + 3. **Fully local:** run `npm run dev` in one terminal and `npm run classroom -- --room test-whatever` in + another. It defaults to `http://localhost:3000`. Then open `http://localhost:3000` as teacher. + - **Tests:** a `node:test` that runs the script against `startServer` with 5 bots, `--corners tl:2,br:3` and no + keyboard (`--seconds 5`). Check that 5 users joined, the stamps fall in the right quadrants + (`src/lib/stampQuadrants.ts`), and the bots' ink is gone after quit. + ### Housekeeping - [ ] **Hosting: undecided.** Options, measurements, prices and a Compute Engine VM sketch are archived in [`docs/HOSTING_OPTIONS.md`](docs/HOSTING_OPTIONS.md). Nothing chosen; first read the `[load]` logs after PR #48. diff --git a/e2e/classroom.spec.ts b/e2e/classroom.spec.ts index c849609..afb8432 100644 --- a/e2e/classroom.spec.ts +++ b/e2e/classroom.spec.ts @@ -263,6 +263,45 @@ test.describe('teacher and students', () => { await student.context.close(); }); + test('one name stamp rule: erasing the stamp with the eraser frees it too', async ({ browser }) => { + const room = uniqueRoom('erasestamp'); + const teacher = await newUser(browser); + const student = await newUser(browser); + await joinRoom(teacher.page, room, 'Ms T', PIN); + await joinRoom(student.page, room, 'Alex'); + await teacher.page.getByRole('button', { name: 'One Name Stamp: Off' }).click(); + await expect(teacher.page.getByRole('button', { name: 'One Name Stamp: On' })).toBeVisible(); + + await student.page.getByTitle(/Quick Stamp Tool/).click(); + await student.page.getByTitle('Stamp Your Username Badge').click(); + await student.page.mouse.click(800, 500); + await expect(student.page.getByText('1 drawn')).toBeVisible(); + await expect(student.page.getByTitle(/already placed your name stamp/)).toBeDisabled(); + + // Swipe the eraser across the stamp + await student.page.getByTitle(/Personal Eraser/).click(); + await student.page.mouse.move(700, 500); + await student.page.mouse.down(); + await student.page.mouse.move(800, 500, { steps: 5 }); + await student.page.mouse.move(900, 500, { steps: 5 }); + await student.page.mouse.up(); + + await student.page.getByTitle(/Quick Stamp Tool/).click(); + await expect(student.page.getByTitle('Stamp Your Username Badge')).toBeEnabled(); + await student.page.getByTitle('Stamp Your Username Badge').click(); + await student.page.mouse.click(600, 400); + await expect(student.page.getByTitle(/already placed your name stamp/)).toBeDisabled(); + + // One undo brings the erased stamp back (and removes the eraser stroke): undo the new stamp, then the erase + await student.page.getByRole('button', { name: 'Undo' }).click(); + await student.page.getByRole('button', { name: 'Undo' }).click(); + await student.page.getByTitle(/Quick Stamp Tool/).click(); + await expect(student.page.getByTitle(/already placed your name stamp/)).toBeDisabled(); + + await teacher.context.close(); + await student.context.close(); + }); + test('student status cycles via radial menu and the teacher can clear it', async ({ browser }) => { const room = uniqueRoom('status'); const teacher = await newUser(browser); diff --git a/e2e/sendWorksheet.spec.ts b/e2e/sendWorksheet.spec.ts index 8bc2b36..f64f696 100644 --- a/e2e/sendWorksheet.spec.ts +++ b/e2e/sendWorksheet.spec.ts @@ -43,7 +43,7 @@ test('Send worksheet rotates A/B across individual boards', async ({ browser }) await expect(dialog.getByText(/card_B\.png · 1 page/)).toBeVisible(); // Two variants default to rotate: boards sorted by title, Alex → A, Bea → B. - await expect(dialog.getByLabel(/Rotate/)).toBeChecked(); + await expect(dialog.getByLabel(/Deal out/)).toBeChecked(); await expect(dialog.getByLabel("Worksheet for Alex's Board")).toHaveValue('A'); await expect(dialog.getByLabel("Worksheet for Bea's Board")).toHaveValue('B'); await dialog.getByRole('button', { name: 'Send', exact: true }).click(); diff --git a/src/components/Canvas.tsx b/src/components/Canvas.tsx index 1a484e1..3fcd3f8 100644 --- a/src/components/Canvas.tsx +++ b/src/components/Canvas.tsx @@ -112,6 +112,7 @@ import { canUserModifyElement, expandElementVisiblePieces, hasSubsequentOverlappingEraser, + stampsHitByEraser, hitElementAtPoint, lassoSelectElements, translateElement, @@ -3457,7 +3458,14 @@ export default function Canvas({ strokeTool === 'rect' || strokeTool === 'circle' || strokeTool === 'line' ? pending : { ...pending, points: [...pts] }; - recordUndo({ kind: 'add', items: [completed] }); + // Erasing a stamp deletes it (one undo step brings both back), so one-name-stamp mode frees the name stamp. + const erasedStamps = strokeTool === 'eraser' ? stampsHitByEraser(elements, completed) : []; + if (erasedStamps.length > 0) { + onElementsBatchRemove(erasedStamps.map((el) => el.id)); + recordUndo({ kind: 'replace', removed: erasedStamps, added: [completed] }); + } else { + recordUndo({ kind: 'add', items: [completed] }); + } } } }; diff --git a/src/components/SendWorksheetModal.tsx b/src/components/SendWorksheetModal.tsx index 2b7edb0..a70bfcd 100644 --- a/src/components/SendWorksheetModal.tsx +++ b/src/components/SendWorksheetModal.tsx @@ -240,7 +240,7 @@ export function SendWorksheetModal({ round, boards, mainElements, mainBackground