Skip to content

fix(chat): finish voice answer push after stream disconnect - #26045

Merged
aryanorastar merged 3 commits into
mainfrom
codex/25922-terminal-notification
Nov 22, 2026
Merged

aryanorastar merged 3 commits into
mainfrom
codex/25922-terminal-notification

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

The voice route now registers its existing answer notification before it emits done. The streaming response owns dispatch after sending the response or handling a disconnect. It shields bounded cleanup, preserves the released-client payload and send order, and records one content-free outcome keyed by the message ID.

Fixes #25922.

Product invariants affected

None of the locked invariant path globs changed. The route still persists into the same chat and returns the same terminal frame and notification payload.

Line-Count-Exception: backend/routers/chat.py | 1869 -> 1884 | Own the nested voice iterator and its cleanup in the existing voice route. The new ASGI finalizer and notification lifecycle are in a separate module.

How it was verified

  • Exercised the real /v2/voice-messages route over Uvicorn on loopback, with the production timeout middleware and an iOS-shaped multipart request that closes on done. A synthetic accepting provider and a synthetic rejecting provider each received one dispatch attempt. The persisted answer, SSE frame and APNs payload used the same message ID.
  • Ran all 42 cases in the new regression suite on the committed code. The broader focused run passed 143 cases.
  • Encoded the unchanged iOS alert using Firebase Admin SDK 6.5.0 with synthetic registration and no network. Visible iOS delivery and provider acceptance require separate release verification.
  • Injected that payload into the isolated iPhone 16 Pro simulator with the local QA app terminated. iOS Notification Center recorded one alert with the same message ID and destination. The test used provisional notification permission and direct OS injection.

Tests

backend/tests/unit/test_voice_terminal_notification.py exercises all three terminal branches through ASGI 2.3 and 2.4. It checks successful sends, immediate disconnect, cancellation before and after registration, generator cleanup, provider rejection, absent registration and timeout. It also verifies once-per-response dispatch and the unchanged message ID and collapse key.

UI evidence

UI-Evidence: none -- backend lifecycle change with no UI changes.

Failure class

Failure-Class: FC-peer-close-aborts-owed-write

@aryanorastar
aryanorastar marked this pull request as ready for review November 22, 2026 12:03
@aryanorastar
aryanorastar merged commit d311b24 into main Nov 22, 2026
73 of 75 checks passed
@aryanorastar
aryanorastar deleted the codex/25922-terminal-notification branch November 22, 2026 12:03
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T12:06:46.924703Z eef5eea 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.

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.

A saved pendant voice answer can miss push dispatch when the voice stream closes at its done frame

1 participant