Skip to content

AI in action: live working cards, class mode, text that fits, nicer AI handwriting - #28

Merged
shaitrish37 merged 5 commits into
mainfrom
feat/ai-in-action
Nov 24, 2026
Merged

shaitrish37 merged 5 commits into
mainfrom
feat/ai-in-action

Conversation

@shaitrish37

Copy link
Copy Markdown
Collaborator

Make Rupok's AI feel "in action": the class watches it work on the board, live, with nothing to click.

The bugs

1. AI text ran off the page. add_text accepted any size and only capped the box width at the page edge. Height and position were never checked, and the board's text box had min-width with no maximum, so a paragraph at 96px crossed the frame and the window.

  • New crates/rupok-live/src/fit.rs fits every agent text inside the slide's safe margin (add_text, replace_items_with_text):
    • size: the asked size, else the page's own text size; long passages are capped;
    • wrap: estimated with Inter character widths;
    • if still too tall: move up into free space, then shrink to 24px, then continue on new pages.
  • The agent is told what changed (warnings with code fit, plus size and continued).
  • write_handwriting fits the same way: explicit spots are pulled inside the page, letters shrink to fit, and a new page is scaled to fit.
  • The board wraps every text box at the page's right edge.

2. The AI handwriting looked like a font. In rupok-ink/src/write:

  • centripetal Catmull-Rom smoothing replaces Chaikin, which shrank the bowls;
  • strokes follow a hand's pen order: v/w are one movement, stems are retraced in a/n/d, dots come last;
  • letters are spaced by their ink, with optical corrections;
  • the baseline wanders slowly instead of jittering letter by letter;
  • pressure swells on downstrokes and slow curves and tapers at the ends;
  • timing is about 35% faster, with shorter pauses;
  • a new joined style links the letters of a word.

The output is still deterministic and wasm-safe.

3. The AI panel sometimes didn't show. Three causes:

  • In Teach, once the chat had tucked itself away (the teacher drew), the AI button closed it (toggleAi saw chatOpen()), so the click showed nothing.
  • In Teach, before an AI was connected, there was no AI button at all (FloatingAiStatus needed livePhase() !== "idle").
  • The top bar moved the AI button into ⋯ early as the window narrowed. Separately, the Teach chat sheet covered the floating button.

Fixes:

  • The tucked state lives in chat.ts, and the button brings the chat back.
  • Teach always has a labelled Ask AI button.
  • The AI button is the last to collapse.
  • The Teach sheet sits below the button.
  • Student view says why chat is off.

4. Too many permission prompts.

  • Every MCP tool declares readOnlyHint, idempotentHint and openWorldHint, and destructiveHint only for real deletes and ink replacement. A test checks this.
  • New class mode (on in Teach by default) auto-approves routine board edits, with a visible "Claude added a Smart Object · Undo" toast. Destructive actions still ask: deletes, clearing, replacing ink, settings or mode. If one arrives without a prompt, the board confirms it itself.
  • Pre-approve setups for Claude Code, Codex and OpenCode are in the docs and in Settings → AI.
  • The MCP instructions and the skill tell agents to act on routine classroom requests instead of asking.

AI in action

  • Working cards (apps/board/src/aiAction/):
    • The card appears where the result will land: agent, current step, plan checklist, progress, live preview of a partial Smart Object, cancel.
    • The chat's ACP plan and tool calls stream into it.
    • The result animates in: objects fade and scale into place, handwriting writes itself, shapes are drawn on stroke by stroke (engine), with a small sparkle. A chime is available but off by default.
    • In Teach the card is large.
    • If a Smart Object fails validation, the card shows it is fixing, then offers Try again.
  • show_progress op and MCP tool (rupok_live::progress, mcp_progress.rs): any agent can post and update its card.
  • Solve this, live: with no teacher check, or in class mode, the agent writes its steps in a ```board block, and each line is written in handwriting as soon as it is complete. Writing queues behind the current reveal. write_handwriting gains anchor.group so outside agents can do the same.
  • Students ask AI (off by default):
    • In Student view, Ask AI to show me sends the question with a limit per student session and a visible count.
    • The result lands on the student's own layer, never in the lesson.
    • With no agent connected, it explains the options.

Op changes are additive: a new ShowProgress variant, Anchor.group, and new files where possible.

Tests

  • Rust:

    • text fit and wrap, flow onto new pages, ink-to-text stays on the page;
    • handwriting always fits, group continuation;
    • quality invariants: letters advance left to right, even gaps, ink inside its block, pen lifts like a hand, shared baseline, pressure varies;
    • show_progress shape, access and validation;
    • streamed lines queue, shapes are drawn on;
    • every MCP tool's annotations.
  • E2E ai-in-action.mjs (fake ACP agent extended): 40/40 pass.

  • Checks run locally:

    • cargo fmt --check;
    • clippy --workspace --all-targets -D warnings;
    • cargo test --workspace;
    • the wasm build;
    • tsc and vite build;
    • pen-latency.mjs --swiftshader --check: all budgets pass. One run on the overloaded machine failed "first frame of next stroke"; the rerun passed. The pen path is unchanged.

The screenshots, the GIF and the before/after handwriting were shared with the founder separately (the founder's local shots-ai-action/ folder).

…ed and drawn-on writing

- rupok-live fit.rs: add_text and replace_items_with_text size, wrap and
  place agent text inside the slide frame; too much text shrinks, moves up
  or continues on new pages.
- write_handwriting always fits the page (explicit spots, new pages),
  continues an earlier group (anchor.group) and has a joined style.
- rupok-ink write: Catmull-Rom smoothing, hand-like pen order, ink-based
  letter spacing, a wandering baseline, pressure on downstrokes, faster
  natural timing, optional joined letters.
- show_progress op (rupok_live::progress): the agent's working card.
- Engine: streamed writing queues behind the reveal; agent shapes draw on.
Every tool says readOnlyHint / destructiveHint (real deletes only) /
idempotentHint so clients can auto-allow safe calls. The fake ACP agent
streams plans, progress cards, a failing then fixed Smart Object, long
text, a delete, a streamed solve and a student's ask.
Working cards where results land (plan, step, live preview, cancel, retry),
results animate in with a small sparkle, class mode (routine edits apply
with an Undo toast, destructive ones still ask), Solve this streams line by
line, students can ask AI onto their own layer, and the AI button is
always there and reliable in Teach.
…utton, Class mode chip

- docs/ai-agents.md: AI in action (working cards, show_progress and the
  agent guide, text fit, class mode, live solve, students ask) and the
  pre-approve setups for Claude Code, Codex and OpenCode.
- skills/rupok-live-board: act, don't ask; let the class watch.
- Every MCP tool's annotations are checked by a test.
- Teach: the chat sits under the floating AI button so it stays clickable;
  the chat closes in Student view; toasts go by themselves.
@shaitrish37
shaitrish37 merged commit ac8ecc2 into main Nov 24, 2026
11 of 13 checks passed
@shaitrish37
shaitrish37 deleted the feat/ai-in-action branch November 24, 2026 10:16
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant