Skip to content

feat: read the last Claude turn and add the voice prompts - #410

Merged
znat merged 3 commits into
feature/claude-voicefrom
voice/turns-and-prompts
Nov 7, 2026
Merged

znat merged 3 commits into
feature/claude-voicefrom
voice/turns-and-prompts

Conversation

@znat

@znat znat commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

PR 2 of the Claude voice train. ClaudeSpeakable can now read the turn that just ended from a session transcript. It also holds the prompts that turn that turn into speech. Nothing calls this code yet. PR 6 (ClaudeVoice) and PR 7 (the CLI) wire it in.

Checks. scripts/check-claude-voice.sh passes 104/104. PR 1 had 60, and this PR adds 44.

Changes from the target. Review found four problems in the target code. They are fixed here, and each has a check:

  • rewriteInput sent reply and recap to the model unredacted. So did reminderInput (latest) and explainInput (the assistant's text). These are transcript text, and the model may be remote. All of them now go through redacted(). This came from a security review.
  • Each field was cut to its length limit before it was redacted. A suffix cut could drop token= and leave the secret bare. Now each field is redacted first, then cut. This came from local CodeRabbit.
  • contentWords kept a trailing period, so "main." never matched "main". So grounded scored faithful answers too low. The period and quotes at a word's edges are now trimmed. This came from local CodeRabbit.
  • A transcript tail that starts inside a multi-byte character (French text) failed to decode, and the whole turn was lost. It now decodes with replacement characters. The cut first line is skipped as before. This came from local CodeRabbit.
What this PR adds

Sources/ParrotFlow/ClaudeSpeakable.swift, taken from claude-voice-target:

  • Transcript reading. TurnEnd, Earlier, lastTurn, turn(endingAt:in:), isPrompt, latestSummary. The answer is the text after the last tool call. A wrap-up recap is kept. Background task notices and meta reminder lines do not start a new turn.
  • Prompts and their inputs. rewritePrompt/rewriteInput, explainPrompt/explainInput, reminderPrompt/reminderInput.
  • Output handling. parseSpoken reads the model's JSON, or plain text. capped keeps at most 3 whole sentences, about 300 characters. capitalizedSentences, spokenOpener, fluent, instructions.
  • The grounding score. grounded gives the share of the output's content words that the source also has. groundedFloor is 0.4. kept is for keep mode.

Sources/ParrotFlow/ClaudeHooksCommand.swift: Cases decodes turns, parse, capped, grounded and summary. test(cases:) checks them. It also runs six inline checks: the capital after a period, three redaction checks, redact before the cut, and a tail cut inside a character.

tests/claude-voice-cases.yaml: 21 new cases in those five sections.

Compared with the target, ClaudeSpeakable.swift differs in PR 1's two review fixes and in the fixes above. PR 1's fixes are the folder path rule and word.last ?? " ". Both are kept.

Left for later PRs
  • naming cases, the introduction checks and the naming loop need ClaudeVoice. They come in PR 6.
  • spoken(transcript:), explain, say and their flags come in PR 7. They are the callers of lastTurn(transcript:), rewriteInput and explainInput.
How it was checked
  • swift build -c release is green.
  • scripts/check-claude-voice.sh gives 104/104. The 44 new checks: turns 12, parse 15, capped 4, grounded 5, summary 2, inline 6.
  • With the second commit's ClaudeSpeakable.swift (5f29b72), the new checks fail as they should, 101/104. The three failures are "a word before a period matches the same word", "a secret is redacted before the cut" and "a tail that starts inside a character still reads".
  • A copy of the cases with three wrong answers fails with exactly those three marked wrong, so the new loops really compare.
  • swiftlint lint on both Swift files gives 0 warnings and 0 errors. The two lossy String(decoding:) calls have a targeted swiftlint:disable:next, because the lossy decode is the fix.
  • Local CodeRabbit CLI: 3 findings on the first two commits, all fixed in the third. 0 findings on the third commit.
  • Remote CodeRabbit was rate-limited ("Review limit reached") when asked.

🤖 Generated with Claude Code

ClaudeSpeakable gets the rest of its text work. It reads the turn that
just ended from a session transcript, with the turn before it. It holds
the rewrite, explain and reminder prompts and builds their inputs. It
parses the model's JSON, caps a long answer to whole sentences, and
scores how well a rewrite sticks to its source.

The test runner checks turns, parse, capped, grounded and summary
cases. The naming cases wait for ClaudeVoice.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Nov 7, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

@znat

znat commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91946178-35df-4593-825f-e6a5ba1cde5d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

znat and others added 2 commits November 7, 2026 01:29
rewriteInput redacted the earlier turn but not the reply or recap.
reminderInput's latest summary and explainInput's context also went out
unredacted. All of it is transcript text that can hold a secret, and the
model may be remote. Each field now goes through redacted().

Three inline checks cover it.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the local CodeRabbit review:

- Each input field is redacted before its prefix or suffix cut. A
  suffix cut could drop "token=" and leave the secret bare.
- contentWords trims a trailing period or quote, so "main." matches
  "main" and grounded no longer scores a faithful answer low.
- A transcript tail that starts inside a multi-byte character is
  decoded with replacement characters instead of failing the whole read.

One grounded case and two inline checks cover them. All three fail on
the previous commit.

Signed-off-by: Nathan Zylbersztejn <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@znat

znat commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Remote CodeRabbit hit its review limit on the request above, so this PR relies on the local CodeRabbit CLI. It found 3 issues on 15b2e76..5f29b72: redact before the length cut, a trailing period in contentWords, and a tail read that starts inside a UTF-8 character. All 3 are fixed in 406e95e, and each has a check that fails without the fix. A local pass on 406e95e found nothing. The check script passes 104/104.

@znat
znat merged commit e100d34 into feature/claude-voice Nov 7, 2026
8 checks passed
@znat
znat deleted the voice/turns-and-prompts branch November 7, 2026 01:02
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.

1 participant