Skip to content

feat(planning): read aloud and dictation on the shared interview page - #9042

Merged
kyle-sexton merged 7 commits into
mainfrom
feat/shared-read-aloud
Oct 22, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
feat/shared-read-aloud

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #7694

Summary

People on the shared interview page can now listen to a question and speak their answers. Each person gets two switches in their own card: Read questions aloud and Dictate answers and comments. Both are off until that person turns them on, and they are saved as the readAloud and dictate prefs, the same way toolbar and autoAdvance are. Both features use the browser's built-in Web Speech API, so the page makes no network requests of its own for them and the CSP is unchanged.

Live support check (MDN browser-compat-data, read 2026-10-22):

  • SpeechSynthesis is supported in Chrome 33, Edge 14, Firefox 49 and Safari 7, and on their mobile versions.
  • SpeechRecognition:
    • Chrome supports it unprefixed from 139 and as webkitSpeechRecognition from 33. Edge, Opera and Chrome Android follow Chrome.
    • Safari and iOS Safari support it from 14.1, prefixed as webkitSpeechRecognition only.
    • Firefox has it in preview only.
  • Recognition can run on a server. MDN says Chrome's "involves a server-based recognition engine. Your audio is sent to a web service". Apple does not document where Safari's audio goes.
  • On-device recognition (processLocally, available(), install()) is in Chrome 139+ and Edge on desktop only. Chrome Android and Safari do not have it.
  • MDN and the spec disagree on the error a missing on-device language raises:
    • MDN says language-not-supported.
    • The W3C draft says service-not-allowed.
    • Headless Chromium raised language-not-supported. The page handles both.

Fix

  • Prefs: session.py PREFS accepts the booleans readAloud and dictate, and state.schema.json declares both.
  • Read aloud:
    • A speaker button sits at the end of the question's row.
    • It speaks the question, then each option label the person's page shows (choice, multi, rank, confirm, scale ends). The text is read from the rendered page, never from state, so it cannot speak another person's unshared answer or anything else hidden from that person.
    • Each part is its own utterance. When the browser lists an on-device voice (localService) for the page's language, the page uses it.
    • A second press, Escape, a move to another question, or turning the switch off stops it.
    • A negative block margin keeps the row's height, so turning the feature on moves nothing.
  • Dictate:
    • A microphone button sits in the answer box and in the Discussion comment box. It is hidden where SpeechRecognition and webkitSpeechRecognition are both missing; the switch is hidden there too.
    • The words are inserted at the caret, within the box's length limit, and fire input so the counter and drafts update. Nothing is ever sent.
    • A second press or Escape stops listening.
    • Where processLocally exists, a press asks for on-device recognition first. If the device does not have the language, the page falls back at once to the browser's service.
    • Until words have been heard on the device, the card shows one line under the Dictate switch, tied to it with aria-describedby: "Your browser may send what you say to its maker's speech service to turn it into text."
  • Design choices:
    • The page never calls SpeechRecognition.available(). In a Chromium build without Chrome's handler for it, calling it ends the page's process. Headless Chromium did this here (Target crashed), and Electron fixed the same failure in electron#52955.
    • The page never calls install(), since that would be a language-pack download started by the page.
  • Accessibility:
    • All controls are native buttons, so the keyboard reaches them.
    • The switches use role="switch" and aria-checked. The icon buttons have names and toggle aria-pressed, and their label changes between "Read the question aloud" and "Stop reading aloud", and between "Dictate your answer" and "Stop dictating".

Verification

  • python3 -m unittest discover -s plugins/planning/shared/tests -p 'test_*.py': 1165 tests OK (1 skipped), exit 0. The new test_read_aloud_and_dictate_are_per_person_switches_off_until_set checks that both prefs are absent by default, belong to each person, refuse non-booleans, clear on null, and validate against the state schema.

  • node plugins/planning/shared/tests/ui_speech.js (new): 40 passed, 0 failed, exit 0. It stubs speechSynthesis and SpeechRecognition in the page and covers:

    • both off by default, turned on by keyboard, and kept on the server;
    • no shift of the question when they turn on;
    • read order: the question, then Card, Saved method, Something else…;
    • a second press and Escape (with focus in the answer box) both stop reading;
    • Bo's unshared answer is never spoken;
    • dictation fills the answer and comment boxes with no /api/answer, /api/pick or /api/discussion POST;
    • the disclosure, and the on-device cases: confirmed, and fallback with the disclosure kept;
    • available() is never called;
    • no Dictate switch or button without the API;
    • no CSP violations and no page errors.

    Removing the negative margin made the no-shift check fail (366 → 374 px), so that check can fail.

  • node plugins/planning/shared/tests/align.js (full, run alone under the browser gate): PASS 542 / 542. That run includes the new speech-choice and speech-answer views, with both controls on at every tested size and theme.

Left out: real speech engines and real microphones. The suites stub both, and headless Chromium has no voices and no microphone. A manual check in desktop Chrome, Safari and Android Chrome would cover what the stubs cannot.

Related

Sources read for this change:

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 22, 2026 01:48
Two per-person switches, off by default and kept as the readAloud and
dictate prefs. Read aloud speaks the question, then the option labels
the page shows, and stops on a second press, Escape or a question
change. Dictate fills the answer or comment box at the caret and never
sends; it asks for on-device recognition first where the browser offers
it and discloses that the browser may send audio to its maker's speech
service until on-device is confirmed. Both use the browser's own Web
Speech API: no request of the page's own, CSP unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 22, 2026 05:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T05:56:10.846283Z 6df2358 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6df235841b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/planning/shared/web/app.js Resolved
Comment thread plugins/planning/shared/web/app.js Resolved
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed e73919ef2c1645bae1b742c7eac958824d53869e: 0 finding(s), 0 as inline comments.

Security review: PR #9042 (head e73919e)

No security findings. I read the full diff (9 files); I did not run the tests.

Scope. The PR adds opt-in read-aloud (speech synthesis) and dictation (speech recognition) to the shared interview page. It has two persisted booleans, readAloud and dictate. It changes no plugin manifest, workflow, CLAUDE.md, AGENTS.md, rules file or hook, so the manifest and instruction-deletion checks do not apply (the instruction-exception register was not needed).

Checked and clean

  • Preference validation: session.py L345-346 validates both new preferences as strict booleans. The schema entries reuse the existing $defs/pref. No untyped value reaches persisted state.
  • Injection: dictated text is written with setRangeText and a bubbled input event, so it is never parsed as HTML. It is capped by maxLength and never auto-submitted. Read-aloud text comes from textContent of elements that are actually shown, so hidden content is not spoken.
  • Audio and privacy: both features are off by default and set per person. On-device recognition is requested first. When the browser might send audio to its maker's speech service, the settings card says so, and the notice stays until a transcribed result confirms on-device recognition. The fallback to the browser's own service happens only after the person has turned Dictate on and pressed the button, and the notice is showing then.
  • Stale sessions: a late onresult from a replaced session or a previous question is dropped. It cannot write into another question's box.
  • Other: SpeechRecognition.available() is not called and no language pack is installed from the page. Escape stops speech, and the microphone is released through abort().

No inline comments were posted.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed e73919ef2c1645bae1b742c7eac958824d53869e: 0 finding(s), 0 as inline comments.

Code review of #9042 at e73919ef: no findings. I read the whole diff (9 files) and the PR context, and checked it against the closing issue #7694. I ran none of the tests; the test results below are the author's claims.

Manifests: the diff touches no plugin.json or marketplace.json, so no manifest <field> lines apply. The changelog fragment is bump: minor, which fits a new opt-in feature.

Acceptance criteria from #7694 (the issue-level criteria, then its Agent Brief checklist). Each is met by the change and covered by a test that could fail if it broke. The tests are author-claimed, not run by me:

  • Read aloud speaks the question, then its options, and stops on a second press or Escape: spokenParts, readAloud and stopReading in app.js, plus the Escape capture handler, which sits on window and so runs before the document capture handler for fields. ui_speech.js checks the order, the second press and Escape from inside the answer box.
  • Dictated text lands in the box, editable, and is never sent: dictInto inserts at the caret within maxLength and fires input. ui_speech.js asserts that no /api/answer, /api/pick or /api/discussion POST happens.
  • Keyboard reach and screen-reader labels: native buttons, role="switch" with aria-checked, and aria-pressed with a changing label. ui_speech.js toggles the switches with Enter and Space.
  • No layout shift: the negative block margin on .vf-readbtn, checked by an assertion in ui_speech.js and by the new speech-choice and speech-answer views in align.js.
  • Both prefs off means the page behaves as before: both buttons are hidden unless the pref is on and the API exists. ui_speech.js asserts that neither button shows by default.

Other checks:

  • The readAloud and dictate prefs are wired in all three places: session.py PREFS, state.schema.json, and test_session.py.
  • The helpers the new code uses (ibtn, on, pref, flash, fillPcard) exist in app.js, and the option label classes that spokenParts queries match the ones the page builds.
  • I found no other file that lists the prefs, so nothing else needs a matching change.
  • Stale dictation is guarded: results are ignored once SPEECH.rec or SPEECH.dq no longer matches, and onend returns early for a replaced session.
  • The new tests are listed in the README.

Left unverified: real speech engines and microphones. The suites stub both, and the PR body says so.

kyle-sexton and others added 5 commits October 22, 2026 02:07
The answer and comment boxes are reused across questions, so a result
arriving after a rail tap or the auto-advance countdown wrote the first
question's words into the next question's draft. Dictation now ends when
the current question changes, and a result from a session that is no
longer current, or started on another question, is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	plugins/planning/shared/web/app.js
Lane-Activity: pr-unblock/resolve-conflicts
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 141b8f3 Oct 22, 2026
35 checks passed
@kyle-sexton
kyle-sexton deleted the feat/shared-read-aloud branch October 22, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(planning): read aloud and dictation on the shared interview page

1 participant