Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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://<the AllAboard URL>
--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://<the AllAboard URL> --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.
Expand Down
39 changes: 39 additions & 0 deletions e2e/classroom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion e2e/sendWorksheet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion src/components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import {
canUserModifyElement,
expandElementVisiblePieces,
hasSubsequentOverlappingEraser,
stampsHitByEraser,
hitElementAtPoint,
lassoSelectElements,
translateElement,
Expand Down Expand Up @@ -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] });
}
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/SendWorksheetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export function SendWorksheetModal({ round, boards, mainElements, mainBackground
</label>
<label className="flex gap-2">
<input type="radio" name="sw-mode" checked={effectiveMode === 'rotate'} onChange={() => setChosenMode('rotate')} />
Rotate {letters.join(' → ')} by board name
Deal out {letters.join(', ')} in turn (alphabetical by student)
</label>
<label className={`flex gap-2 ${cornerDisabledReason ? 'text-slate-400' : ''}`} title={cornerDisabledReason || undefined}>
<input
Expand Down
34 changes: 34 additions & 0 deletions src/lib/inkCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,40 @@ export function hasSubsequentOverlappingEraser(
return false;
}

/**
* Stamps that an eraser stroke touches, so they can be deleted outright. A stamp is one object: covering it
* with eraser ink only hides it, which left one-name-stamp mode thinking the student's name stamp was still
* down. Same rule as stroke erasing: only stamps by the eraser's own author.
*/
export function stampsHitByEraser(elements: CanvasElement[], eraser: CanvasElement): CanvasElement[] {
const pts = eraser.points;
if (eraser.tool !== 'eraser' || !pts || pts.length < 2) return [];
const r = Math.max(8, (eraser.strokeWidth || 6) * 1.5) / 2;
const step = Math.max(2, r / 2);
const hit: CanvasElement[] = [];
for (const el of elements) {
if (el.tool !== 'stamp' || el.userId !== eraser.userId) continue;
const [x0, y0, x1, y1] = getElementBounds(el);
const inside = (x: number, y: number) => x >= x0 - r && x <= x1 + r && y >= y0 - r && y <= y1 + r;
let touched = pts.length < 4 && inside(pts[0], pts[1]);
for (let i = 0; !touched && i + 3 < pts.length; i += 2) {
const ax = pts[i];
const ay = pts[i + 1];
const dx = pts[i + 2] - ax;
const dy = pts[i + 3] - ay;
const n = Math.max(1, Math.ceil(Math.hypot(dx, dy) / step));
for (let k = 0; k <= n; k++) {
if (inside(ax + (dx * k) / n, ay + (dy * k) / n)) {
touched = true;
break;
}
}
}
if (touched) hit.push(el);
}
return hit;
}

/**
* Find the topmost modifiable, non-erased element at world coordinates (x, y) within `tol`.
*/
Expand Down
34 changes: 34 additions & 0 deletions tests/inkCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
hitElementAtPoint,
lassoSelectElements,
translateElement,
stampsHitByEraser,
} from '../src/lib/inkCore';

function makeEl(overrides: Partial<CanvasElement> & Pick<CanvasElement, 'id' | 'tool'>): CanvasElement {
Expand Down Expand Up @@ -691,3 +692,36 @@ describe('hollow shape brush: a finished stroke becomes one picture', () => {
assert.ok(hollowBitmapPixelsInUse() > 0);
});
});

describe('stampsHitByEraser', () => {
const stamp = (id: string, x: number, y: number, userId = 'u1'): CanvasElement =>
({ id, tool: 'stamp', stamp: 'username', userId, userName: 'Ava', color: '#000', strokeWidth: 6, x, y }) as CanvasElement;
const eraser = (points: number[], strokeWidth = 20, userId = 'u1'): CanvasElement =>
({ id: 'e', tool: 'eraser', userId, userName: 'Ava', color: '#fff', strokeWidth, points }) as CanvasElement;

it('finds a stamp the eraser passes over, and not one far away', () => {
const els = [stamp('near', 0, 0), stamp('far', 1000, 1000)];
const hit = stampsHitByEraser(els, eraser([-200, 0, 200, 0]));
assert.deepEqual(hit.map((e) => e.id), ['near']);
});

it('catches a stamp between two widely spaced points of a fast swipe', () => {
const hit = stampsHitByEraser([stamp('s', 0, 0)], eraser([-2000, 0, 2000, 0], 8));
assert.equal(hit.length, 1);
});

it('catches a single-click eraser dab on the stamp', () => {
assert.equal(stampsHitByEraser([stamp('s', 50, 50)], eraser([50, 50])).length, 1);
});

it("ignores other users' stamps and non-stamp elements", () => {
const pen = { id: 'p', tool: 'solid', userId: 'u1', userName: 'Ava', color: '#000', strokeWidth: 4, points: [0, 0, 5, 5] } as CanvasElement;
const hit = stampsHitByEraser([stamp('theirs', 0, 0, 'u2'), pen], eraser([-50, 0, 50, 0]));
assert.equal(hit.length, 0);
});

it('returns nothing for a non-eraser stroke', () => {
const pen = { ...eraser([-50, 0, 50, 0]), tool: 'solid' } as CanvasElement;
assert.equal(stampsHitByEraser([stamp('s', 0, 0)], pen).length, 0);
});
});
Binary file added thanksgiving-bug-bingo/bug_bingo.pdf
Binary file not shown.
Binary file added thanksgiving-bug-bingo/card_A.pdf
Binary file not shown.
Binary file added thanksgiving-bug-bingo/card_B.pdf
Binary file not shown.
Binary file added thanksgiving-bug-bingo/card_C.pdf
Binary file not shown.
Binary file added thanksgiving-bug-bingo/card_D.pdf
Binary file not shown.
Binary file added thanksgiving-bug-bingo/four_corners.pdf
Binary file not shown.
Binary file added thanksgiving-bug-bingo/pictionary.pdf
Binary file not shown.
Loading
Loading