Skip to content

Voice on the board: speak, and the words go on the slide - #26

Merged
shaitrish37 merged 1 commit into
mainfrom
feat/voice-board
Nov 24, 2026
Merged

shaitrish37 merged 1 commit into
mainfrom
feat/voice-board

Conversation

@shaitrish37

Copy link
Copy Markdown
Collaborator

Teachers talk during class and don't want to write whole sentences. This adds Voice text to the Smart Dock (a mic with a T, in Prepare and Teach): speak, and the words go on the slide while you say them.

What the teacher gets

  • Place: pick the tool, then tap the page (or drag across it to set the width). A voice box opens with a pulsing mint mic and starts listening. Drag the box to move it; drag its right edge to change the width.
  • Live words: interim results show lighter, final words in the pen colour (readable on dark boards too). Text wraps inside the box and stays on the page: the box moves in from the edges, then shrinks its text, and never runs off the slide.
  • Punctuation and lines: the existing punctuation module handles "comma", "full stop", "new line", কমা, দাঁড়ি, প্রশ্নবোধক চিহ্ন and the rest. A pause of about 2 s starts a new line.
  • Finish: tap the box, press Esc or ✓. The words become a normal text item (editable, resizable, recolourable) with the line breaks the teacher saw. ✕ discards them.
  • Undo, one step per box: the box stays out of the lesson until it is finished, then it is committed once (new engine call add_text_box).
  • Teach:
    • Hold the dock button for push-to-talk: a box opens under the last voice text, the words go on the board on release, and the pen stays the tool. Each hold is one undo step.
    • With the tool on, Space or a clicker's "blank" key (B or .) toggles listening.
  • On the box:
    • EN / বাং.
    • Text ↔ Ask AI.
    • typed ↔ hand-written (the Solve this synthesiser; English only, Bangla falls back to typed).
    • The existing privacy line: offline Whisper when downloaded (desktop), else Web Speech.
  • Ask AI:
    • The words become a prompt to the in-app chat through sendPrompt, with the page (or the selection) attached.
    • A small bubble confirms it. In Teach the chat stays closed; in Prepare the panel opens.
    • If the chat isn't connected yet, the panel opens with the words in the composer (setComposerDraft + openAiPanel).
    • The chat is not rebuilt; only its public API is used.
  • Student view: hidden by default. Settings → "Students may ask the AI by voice" plus adding the tool in Teaching modes enables Ask AI only. Students never write on the board.

For agents (agent-first)

  • New live ops and MCP tools, live only: start_voice_text(x?, y?, w?, lang?, mode?, style?) and stop_voice_text(cancel?).
    • They are board-only, like point_at: the board app owns the microphone, and rupok-live answers Unsupported.
    • Both have write access, so they need "Allow AI to edit live" and are refused in Student view.
    • stop_voice_text returns text, kind and item_id.
  • add_text with w now actually wraps on the board. The board breaks the lines at w, measured with its own font, and stores them as \n.
    • The tool docs already promised "long lines wrap", and snapshots wrapped, but the board didn't.
  • Documented in docs/ai-agents.md (new "Voice on the board" section, tools table, protocol op list), docs/ui-config.md (tool id voice), the live-board skill, skills/AGENTS.md and the MCP server instructions.

Settings (registry)

New entries under General → Voice on the board:

  • what a new box does (text / Ask AI);
  • tap or hold to talk;
  • hand-written by default;
  • the line-break pause (0 turns it off);
  • whether students may ask the AI by voice.

Keyboard → Space / B / . and Esc.

How it's built

  • voice/board.ts: state, dictation target, finish, push-to-talk, agent ops.
  • voice/VoiceBoard.tsx and voice-board.css: the place layer, the box in world units, the bar in screen pixels.
  • voice/wrap.ts: pure line breaking by grapheme cluster, plus a canvas measure with the board font.
  • dictation.ts:
    • custom targets can supply before(), for spacing and sentence capitals;
    • a session can hide the generic live-text bubble.
  • Shared files: the edits are small.
    • Dock.tsx: 3 hunks. A hold on the button is push-to-talk; the tool joins the phone-drop list.
    • modes.ts: the tool entry and its defaults.
    • state.ts: the Tool union.
    • controller.ts: setTool treats voice like text. Pointer handlers are untouched.
    • App.tsx: the mount.
    • live.ts: op dispatch and add_text wrapping.
    • chat.ts: untouched.
  • Icon: gen-icons.mjs gains composed icons (Solar mic, scaled, with a T). To resolve a conflict in icons.generated.ts, re-run the script.

Tests

  • Rust: cargo fmt --check and cargo clippy --workspace -D warnings are clean. cargo test -p rupok-live -p rupok-wasm -p rupok-cli passes, including:
    • a new engine test, add_text_box_stays_on_the_page_in_one_undo_step;
    • op parse and access tests;
    • an MCP schema test.
  • wasm build: OK.
  • Board: tsc --noEmit and vite build OK; node --test apps/board/test/*.test.ts passes (6 new wrap/split tests: Latin, Bangla with দাঁড়ি, conjuncts kept whole).
  • E2E voice-board.mjs, with a stubbed SpeechRecognition: 48/48 PASS. It covers:
    • placing a box; interim words appear and finalise;
    • a long sentence wraps and stays inside the page;
    • a box at the right edge is moved in, and a drag sets the width;
    • Bangla with দাঁড়ি → ।;
    • a 2 s pause gives a new line;
    • Esc gives one text item in the pen colour, one Ctrl+Z, and redo;
    • Teach push-to-talk keeps the pen, with one undo;
    • Space and the clicker key, and Esc stays in Teach;
    • the agent ops;
    • Ask AI through rupok agent + the fake ACP agent: the agent gets the prompt with page 1 attached and nothing is written on the board, in light and dark.
  • Pen latency bench/latency/pen-latency.mjs --swiftshader --check: all budgets pass (pointermove handler p95 0.30 ms, pen-up changed pixels 0.02 %).

Limitations

  • Hand-written style is English only: the synthesiser has no Bangla glyphs, so Bangla is written as typed text.
  • The handwriting is written through write_handwriting, so its commit carries the agent tag "Voice text".
  • The line breaks are stored in the text: resizing the box later scales the text, and editing it doesn't reflow the lines. Text items don't reflow anywhere today.
  • add_text wrapping applies on the live board only. A lesson file keeps the text as given.
  • Student-view Ask AI needs the chat already connected, because openAiPanel is disabled in Student view.

A Voice text tool on the Smart Dock (a mic with a T, Prepare and Teach):
tap or drag on the page to place a voice box and talk. Interim words show
live and lighter, final words in the pen colour, wrapped inside the box and
kept on the page (the box moves in, then shrinks its text). Spoken
punctuation in English and Bangla, a ~2 s pause starts a new line. Tap the
box, Esc or Done: one normal text item, one undo step per box. In Teach,
hold the dock button for push-to-talk (the pen stays the tool); Space or a
clicker's B / . toggles listening. On the box: EN / বাং, Text <-> Ask AI
(the words become a chat prompt with the page or selection attached),
typed <-> hand-written (the Solve this synthesiser), the privacy line.

- voice/board.ts, VoiceBoard.tsx, voice-board.css, wrap.ts (line breaking
  with the board font; unit-tested in test/voice-board.test.ts)
- dictation.ts: custom targets can give the text before the caret; the
  live-text bubble can be turned off per session
- engine: add_text_box (world box, kept on the page, one commit) + test
- live ops and MCP tools start_voice_text / stop_voice_text (board-only);
  the board wraps an agent's add_text at its w
- settings: default mode, tap or hold to talk, hand-written default, pause
  length, students may ask the AI by voice
- docs: ai-agents.md (Voice on the board, tools, protocol), ui-config.md,
  the live-board skill
@shaitrish37
shaitrish37 merged commit 14b67f5 into main Nov 24, 2026
9 checks passed
shaitrish37 added a commit that referenced this pull request Nov 24, 2026
… dock

Voice on the board (#26) joins the agent-first checks: the Voice dock
button, start_voice_text/stop_voice_text and the Voice on the board
settings get rows in docs/agent-capabilities.md; the four presentation
settings are in the agent allowlist, the students switch stays the
teacher's. The voice ops are board-only, like the other board-app ops.

# Conflicts:
#	AGENTS.md
#	apps/board/src/components/Dock.tsx
#	apps/board/src/live.ts
#	crates/rupok-live/src/apply.rs
#	crates/rupok-live/src/op.rs
#	docs/ai-agents.md
shaitrish37 added a commit that referenced this pull request Nov 24, 2026
…ting

Joined with #26 and #27:
- show_progress and the AI in action, Class mode and students-ask settings
  get rows in docs/agent-capabilities.md; the four presentation settings
  (progress, sparkle, chime, line-by-line solutions) join the agent
  allowlist, Class mode and what students may ask stay the teacher's.
- MCP annotations: the annotations test covers the agent-control tools;
  every write tool from #26/#27 declares idempotentHint, destructiveHint is
  kept for real deletes (delete_items, delete_pages, delete_stamp,
  library_trash) and dropped from undo_last_change (it only takes back the
  agent's own step); library_list counts as a read.
- Class mode confirms the new destructive ops (delete_pages, delete_stamp,
  library_trash, dock layout changes) like the others.
- update_text fits new words or a new size inside the page like add_text
  (never spilling onto a new page), with a regression test.
- show_progress is a board-only op, like the voice ops.
- Clippy (all targets): slice::from_ref in a voice test.

# Conflicts:
#	AGENTS.md
#	apps/board/src/live.ts
#	crates/rupok-cli/src/lib.rs
#	crates/rupok-cli/src/mcp.rs
#	crates/rupok-cli/tests/fake-acp-agent.mjs
#	crates/rupok-live/src/op.rs
#	docs/ai-agents.md
@shaitrish37
shaitrish37 deleted the feat/voice-board 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