Repository navigation
fix(listen): send the first onboarding question when a speech-profile session starts - #11505
Conversation
… session starts PR #9853's split of transcribe.py into routers/listen/ dropped the spawn(onboarding_handler.send_current_question()) kickoff, so onboarding-mode sessions never received the first onboarding_question event: the speech profile page showed no question and its progress bar stayed at 0% forever. Restore the kickoff at handler creation in ListenSessionRuntime._bootstrap and add the regression test that would have caught the drop. Failure-Class: none
There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 3/5
- In
backend/routers/listen/runtime.py(process_loop()/kickoff path), the onboarding Omi question segment can be queued before any audio timestamp exists and then dropped, so users who wait for audio may miss the first question entirely—preserve or replay pre-audio segments instead of discarding them. - In
backend/routers/listen/runtime.py(send_onboardingspawned task), a disconnect between theclient_statecheck andsend_jsoncan raiseWebSocketDisconnect/RuntimeErrorand bubble out of the task, creating noisy failures during onboarding—wrap the send with closed-socket exception handling and exit cleanly.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/routers/listen/runtime.py">
<violation number="1" location="backend/routers/listen/runtime.py:353">
P2: When an onboarding client waits for audio after receiving the question, the new kickoff queues the Omi question segment and `process_loop()` drops it before the first audio timestamp exists. Preserve pre-audio segments or defer their processing until the first audio frame so the question is retained in the conversation transcript.</violation>
<violation number="2" location="backend/routers/listen/runtime.py:353">
P3: The spawned first-question task has no closed-socket handling: if the client disconnects between the client_state check and send_json inside the send_onboarding closure, the WebSocketDisconnect/RuntimeError propagates to the task's done-callback, which only logs it and does not set state.active = False (unlike asend_event/_send_ping). Wrap the websocket send in a try/except that sets self.state.active = False, or catch it around the spawned send.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| await request.websocket.send_json(event) | ||
|
|
||
| self.onboarding_handler = OnboardingHandler(request.uid, send_onboarding, self.transcripts.enqueue) | ||
| self.spawn(self.onboarding_handler.send_current_question(), name='onboarding_first_question') |
There was a problem hiding this comment.
P2: When an onboarding client waits for audio after receiving the question, the new kickoff queues the Omi question segment and process_loop() drops it before the first audio timestamp exists. Preserve pre-audio segments or defer their processing until the first audio frame so the question is retained in the conversation transcript.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/routers/listen/runtime.py, line 353:
<comment>When an onboarding client waits for audio after receiving the question, the new kickoff queues the Omi question segment and `process_loop()` drops it before the first audio timestamp exists. Preserve pre-audio segments or defer their processing until the first audio frame so the question is retained in the conversation transcript.</comment>
<file context>
@@ -350,6 +350,7 @@ async def send_onboarding(event: Dict[str, Any]) -> None:
await request.websocket.send_json(event)
self.onboarding_handler = OnboardingHandler(request.uid, send_onboarding, self.transcripts.enqueue)
+ self.spawn(self.onboarding_handler.send_current_question(), name='onboarding_first_question')
return True
</file context>
| await request.websocket.send_json(event) | ||
|
|
||
| self.onboarding_handler = OnboardingHandler(request.uid, send_onboarding, self.transcripts.enqueue) | ||
| self.spawn(self.onboarding_handler.send_current_question(), name='onboarding_first_question') |
There was a problem hiding this comment.
P3: The spawned first-question task has no closed-socket handling: if the client disconnects between the client_state check and send_json inside the send_onboarding closure, the WebSocketDisconnect/RuntimeError propagates to the task's done-callback, which only logs it and does not set state.active = False (unlike asend_event/_send_ping). Wrap the websocket send in a try/except that sets self.state.active = False, or catch it around the spawned send.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/routers/listen/runtime.py, line 353:
<comment>The spawned first-question task has no closed-socket handling: if the client disconnects between the client_state check and send_json inside the send_onboarding closure, the WebSocketDisconnect/RuntimeError propagates to the task's done-callback, which only logs it and does not set state.active = False (unlike asend_event/_send_ping). Wrap the websocket send in a try/except that sets self.state.active = False, or catch it around the spawned send.</comment>
<file context>
@@ -350,6 +350,7 @@ async def send_onboarding(event: Dict[str, Any]) -> None:
await request.websocket.send_json(event)
self.onboarding_handler = OnboardingHandler(request.uid, send_onboarding, self.transcripts.enqueue)
+ self.spawn(self.onboarding_handler.send_current_question(), name='onboarding_first_question')
return True
</file context>
fix(listen): send the first onboarding question when a speech-profile session starts
Problem
The speech profile page (onboarding and Settings > Profile > Speech Profile) shows no question and its progress bar never moves. Audio still streams and a conversation/recording appears later, so the session looks half-alive.
The question flow is server-driven: the client renders whatever
onboarding_questionevent the backend pushes, and computes progress asquestion_index / total_questions. PR #9853 splittranscribe.pyintorouters/listen/, and the split dropped the one-shot kickoffspawn(onboarding_handler.send_current_question(), ...)that existed since the flow shipped (#3859).ListenSessionRuntime._bootstrapstill constructs theOnboardingHandler, but nothing ever sends question 0 —OnboardingHandler.send_current_questionis only reachable after an answer or a skip, which can never happen before the first question exists. The client waits forever on an empty screen at 0%.Fix
Restore the kickoff at handler creation in
_bootstrap, spawned through the session task supervisor (same placement and semantics as the pre-refactor code).Regression test
test_bootstrap_sends_first_onboarding_question_before_any_audioruns the real_bootstrapwith a realOnboardingHandlerand a recording websocket, and asserts that — with no segments having arrived — the client receives exactly oneonboarding_questionevent (question 0 oflen(ONBOARDING_QUESTIONS)) and the question transcript segment is enqueued with the Omi speaker id. This test fails onmaintoday and would have caught the drop in #9853.The existing
_bootstraponboarding test's stub handler grew asend_current_questioncoroutine and a real task supervisor, since the production path now calls it.Failure class
Failure-Class: none
No existing class matches "one-shot side effect dropped while splitting a module"; this is the first known instance of that cause in this subsystem, so it lands as an instance fix plus the behavioral guard test above.
Verification
BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-target.txt bash test.sh(file =tests/unit/test_listen_runtime_regressions.py): 20 passed (includes the new test and the two updated bootstrap tests)._bootstrap+OnboardingHandlerwiring.Product invariants affected
none