Skip to content

fix(web): relay Codex responses to voice sessions#640

Open
PeterDraex wants to merge 1 commit into
tiann:mainfrom
PeterDraex:fix/codex-voice-relay
Open

fix(web): relay Codex responses to voice sessions#640
PeterDraex wants to merge 1 commit into
tiann:mainfrom
PeterDraex:fix/codex-voice-relay

Conversation

@PeterDraex
Copy link
Copy Markdown

Summary

  • format Codex message payloads for realtime voice context so completed Codex responses reach ElevenLabs sessions
  • format Codex tool calls through the same voice helper as Claude tool calls
  • trigger the voice ready notification when a ready/completion event arrives as a message, not only when session.thinking transitions

Testing

  • bun run test src/realtime/hooks/contextFormatters.test.ts src/components/SessionChat.test.ts
  • bun run typecheck:web

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Findings

  • [Major] Historical ready messages can trigger fresh voice-ready prompts — newMessages here means “not in this component ref yet,” not “arrived live.” Initial message hydration, refetches, or loading older history can add old ready / task_complete messages to props.messages; the new scan then calls reportVoiceReady() and sends a stale ready prompt to an active voice session. Evidence: web/src/components/SessionChat.tsx:244
    Suggested fix:
    // Move ready detection to the live SSE message path instead of scanning the
    // whole visible message window in SessionChat.
    if (event.type === 'message-received') {
        ingestIncomingMessages(event.sessionId, [event.message])
        if (
            event.sessionId === getCurrentRealtimeSessionId()
            && isVoiceReadyMessage(event.message)
        ) {
            voiceHooks.onReady(event.sessionId)
        }
    }

Summary

  • Review mode: initial
  • One issue found: the new ready-message trigger can replay historical completion events as current voice-ready notifications.

Testing

  • Not run (automation)

HAPI Bot


if (newMessages.length > 0) {
voiceHooks.onMessages(props.session.id, newMessages)
if (newMessages.some(isVoiceReadyMessage)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Major] Historical ready messages can trigger fresh voice-ready prompts

newMessages is only “not present in prevMessagesRef,” so it also includes messages introduced by initial hydration/refetch and older-history loads. With this new branch, any historical ready / task_complete in those batches calls reportVoiceReady() and can send a stale ready prompt to an active voice session.

Suggested fix:

// Move ready detection to the live SSE message path instead of scanning the
// whole visible message window in SessionChat.
if (event.type === 'message-received') {
    ingestIncomingMessages(event.sessionId, [event.message])
    if (
        event.sessionId === getCurrentRealtimeSessionId()
        && isVoiceReadyMessage(event.message)
    ) {
        voiceHooks.onReady(event.sessionId)
    }
}

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