Skip to content

feat(frontend): give the composer its own strip and let voice mode skip reading replies - #495

Merged
chriswritescode-dev merged 6 commits into
mainfrom
feature/composer-strip-and-voice-readback
Nov 28, 2026
Merged

chriswritescode-dev merged 6 commits into
mainfrom
feature/composer-strip-and-voice-readback

Conversation

@chriswritescode-dev

@chriswritescode-dev chriswritescode-dev commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

User description

Summary

Follow-up polish to the condensed composer, plus a voice-mode preference.

  • The composer sits in a full-width opaque strip across the chat column, so messages no longer show through behind the input; the composer frame itself is transparent inside it.
  • The scroll-to-bottom control is a small "Back to latest" tab attached to the top of the strip, in the theme's foreground colour.
  • The read-aloud button moves out of the floating stack into the composer: in the right gutter on wide layouts, at the end of the input row on narrower desktop layouts with a fixed slot so the input never shifts. On mobile it is dropped in favour of the per-reply speakers.
  • Composer controls and the input share one height: 44px on mobile, 40px on desktop.
  • Voice conversation mode gets a "Read replies aloud" toggle, remembered per device. When off, the loop goes straight back to listening after each reply; turning it off mid-reply stops reading and keeps waiting if the agent is still working.

Tests

Composer, session detail, voice conversation hook and voice bar tests are added or updated; frontend tests, typecheck and lint pass.


PR Type

Enhancement


Description

  • Composer sits in a full-width opaque strip

  • Read-aloud button moves into the composer input row

  • Scroll control becomes a "Back to latest" tab

  • Voice mode survives empty sends and transcription errors

    • Persisted "Read replies aloud" toggle in the voice bar
    • Failed messages kept and resent from the orb
    • Failure labels and notices split by cause

Diagram Walkthrough

flowchart LR
  Composer["Composer strip in SessionDetail"]
  Slot["trailingAction slot in PromptInput"]
  TTS["FloatingTTSButton in input row"]
  Latest["Back to latest tab"]
  Voice["useVoiceConversation"]
  Store["voiceConversationStore persist"]
  Bar["VoiceConversationBar toggle"]
  Reducer["reduceVoiceConversation resend"]
  Notice["Failure labels and notices"]

  Composer -- "opaque background" --> Slot
  Slot -- "desktop only" --> TTS
  Composer -- "scroll control" --> Latest
  Voice -- "readRepliesAloud" --> Store
  Store -- "toggle state" --> Bar
  Voice -- "resend event" --> Reducer
  Voice -- "transcription retry" --> Notice
Loading

File Walkthrough

Relevant files
Enhancement
8 files
FloatingTTSButton.tsx
Move pill sizing and rounding onto wrapper slot                   
+4/-4     
PromptInput.tsx
Add trailing action slot and drop frame background             
+18/-8   
SessionConfigMenu.tsx
Bump desktop config trigger to 40px                                           
+1/-1     
VoiceConversationBar.tsx
Add pressed-state read-aloud toggle button                             
+25/-5   
useVoiceConversation.ts
Keep listening, resend failed turns, toggle read-back       
+208/-29
SessionDetail.tsx
Move TTS into composer and add back-to-latest tab               
+19/-14 
voiceConversationStore.ts
Add persisted read-replies-aloud preference store               
+20/-0   
voiceConversation.ts
Add resend event, transcription source and labels               
+34/-6   
Tests
9 files
PromptInput.command.test.tsx
Update frame compositing assertions for opaque strip         
+2/-2     
PromptInput.composer.test.tsx
Add trailing slot tests and back-to-latest rename               
+36/-1   
PromptInput.config.test.tsx
Update desktop config trigger size expectation                     
+1/-1     
VoiceConversationBar.test.tsx
Test read-aloud toggle and failure notices                             
+53/-1   
useVoiceConversation.test.tsx
Test transcription retries, resend and muted read-back     
+284/-18
voiceConversation.test.ts
Test resend reducer and failure-specific labels                   
+98/-1   
SessionDetail.scroll-floating.test.tsx
Test composer speaker placement and back-to-latest tab     
+62/-6   
promptInput.tsx
Thread trailingAction through the prompt fixture                 
+2/-0     
test-utils.tsx
Extend voice controller mock with new fields                         
+3/-0     

Comment on lines +812 to +813
speakTokenRef.current += 1
speakingIdRef.current = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interrupted reply left unheard

When read-back is turned off mid-reply, the code clears speakingIdRef without adding that message to spokenIdsRef. The token bump also makes the TTS end callback ignore the stop, so that callback never marks it either. In the idle case the loop goes straight to listening, and the cut-off reply still counts as unheard. That differs from skipReading, which marks replies as heard. A later resume, through findNextUnspokenMessage in resumeConversation, can then move to working and read the stale reply again if read-back has been turned back on. The stop logic also repeats what skipReading does, which goes against the DRY rule in AGENTS.md.

Suggested change
speakTokenRef.current += 1
speakingIdRef.current = null
speakTokenRef.current += 1
if (speakingIdRef.current) spokenIdsRef.current.add(speakingIdRef.current)
speakingIdRef.current = null

Comment on lines +729 to +740
const composerTrailingAction = ttsEnabled && !isMobile && !isVoiceConversationActive
? !isFormSheetOpen && !hasPromptContent && !isSessionActive && latestPlayableAssistant
? (
<FloatingTTSButton
messageId={latestPlayableAssistant.messageId}
content={latestPlayableAssistant.text}
isScrolledUp={showScrollButton}
onSpeakVisible={handleSpeakVisibleMessages}
/>
)
: null
: undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mobile TTS controls removed

On mobile, composerTrailingAction is now always undefined, so FloatingTTSButton is never rendered there. That button was the entry point for "Read visible replies" and for the long-press auto-play toggle. Per-reply speakers cover playing a single reply, but mobile users may have no way left to turn auto-play on or off in the session view. Check that another control for this exists on mobile.

@lil-worker-cstech

lil-worker-cstech Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit eab3022)

Since the last review — 3 findings were open on the previous HEAD

  • ✅ 1 addressed by the pushes since then: frontend/src/hooks/useVoiceConversation.ts:449-451
  • ⏳ 2 still open
  • ✚ 1 newly found in this run

Here are some key observations to aid the review process:

⚠️ Risk checks: 1 finding(s) detected
Risky shapes (1): Removed JS/TS function in frontend/src/components/message/VoiceConversationBar.tsx
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
⚠️ Risk level: Medium
✅ Merge recommendation: Needs review
Merge recommendation checks
✅ CI on reviewed head: passed
✅ Head is current with its base: up to date
✅ Human authors: all authors are human
⚠️ No sensitive paths or risky changes: 1 finding(s)
⚠️ Changed lines within cap: 967 changed lines exceeds cap 100
🔎 Failure modes

What: A microphone or permission error that arrives after capture has started is handled as a transcription failure. Voice mode restarts capture up to three times, then pauses with "Transcription isn't working" and "Tap to try again" instead of the microphone label and the fix hint.
Where: frontend/src/hooks/useVoiceConversation.ts:handleTranscriptionFailure
Trigger: The STT backend reports `isError` with a message like "Microphone access denied" after `startRecording` has resolved, for example when Web Speech fires `not-allowed` asynchronously or the mic is revoked mid-session.
Detected by: nothing
Covered in this PR: No

What: A reply that is cut off by turning read-back off is never marked as heard. If read-back is turned back on later, resuming can read that stale reply again.
Where: frontend/src/hooks/useVoiceConversation.ts:toggleReadRepliesAloud
Trigger: The user turns off "Read replies aloud" while a reply is being spoken, then turns it back on and resumes after a pause.
Detected by: nothing
Covered in this PR: No

What: Mobile users lose the only session-view control for "Read visible replies" and the long-press auto-play toggle.
Where: frontend/src/pages/SessionDetail.tsx:SessionDetail
Trigger: Any mobile viewport with TTS enabled.
Detected by: nothing. The new mobile test asserts that the button is absent.
Covered in this PR: No

🧪 PR contains tests
🔒 No security concerns identified
✅ Resolved findings

frontend/src/hooks/useVoiceConversation.ts:449-451

Stale failure flag

transcriptionFailedRef is set when a transcription error arrives while endTurn/endRecording is in flight. It is cleared only on the empty-text path. If stopCapture still returns partial text, the turn is sent and the flag stays true. The next truly empty tap then silently skips the "Didn't hear anything" notice. Clear the flag on the text-present path too, in both endTurn and endRecording.

@lil-worker-cstech

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 99b8d85

@lil-worker-cstech

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit eca6a29

Comment on lines +405 to +417
const handleTranscriptionFailure = useCallback(() => {
const phase = phaseRef.current
if (phase !== 'listening' && phase !== 'recording') return
transcriptionFailureCountRef.current += 1
const message = sttRef.current?.error?.trim() || STT_FAILED_MESSAGE
const current = sttRef.current
if (current && (current.isRecording || current.isProcessing)) current.abortRecording()
if (transcriptionFailureCountRef.current >= TRANSCRIPTION_FAILURE_LIMIT) {
phaseRef.current = 'paused'
dispatch({ type: 'error', message, source: 'transcription' })
return
}
setNotice(`Couldn't transcribe that: ${message}. Still listening`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mic errors retried

Every STT error that arrives while listening or recording now goes to handleTranscriptionFailure. Before this PR it went to failCapture, with the capture source. A permission or device error raised after startRecording resolves (Web Speech reports not-allowed asynchronously) is shown as "Couldn't transcribe that: Microphone access denied… Still listening". Capture then restarts in a loop until the third failure, and the pause shows "Transcription isn't working / Tap to try again" instead of "Microphone problem / Allow microphone access". Classify microphone or permission errors as capture failures and pause right away.

@lil-worker-cstech

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit eab3022

@chriswritescode-dev
chriswritescode-dev merged commit bf2f81f into main Nov 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant