Repository navigation
Conversation
…asedHardware#5388) Web listen attached to the shared Redis in_progress pointer when the pendant was already live, so meeting audio merged into the device session and stop finalized the wrong conversation. Refuse cross-source attach, give web its own client_conversation_id, and finalize by that id (desktop pattern). Co-authored-by: Cursor <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
4 issues found across 7 files
Confidence score: 3/5
- In
web/app/src/hooks/useRecording.ts, finalization can run before the WebSocket conversation session is established (and right aftersocket.disconnect()), so very short or tail-end audio may be dropped and transcripts can be incomplete—gate finalize on authoritativeconversation_sessionand/or add a finalize retry after session creation. - In
backend/routers/listen/conversations.py, unsupported listen sources may start a fresh conversation on each reconnect instead of reusing the prior session, which can fragment a single user session across multiple conversation IDs—canonicalize source parsing on reconnect with the sameConversationSourceconversion path. - In
backend/utils/transcribe_decisions.py, mixed-case or whitespace-padded source values can be treated as canonical for routing but persisted asunknownin cross-source creation, leading to inconsistent metadata and downstream logic drift—normalize source input before both classification and persistence.
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/conversations.py">
<violation number="1" location="backend/routers/listen/conversations.py:272">
P2: Unsupported listen sources now create a new conversation on every reconnect instead of reusing the existing session. Canonicalize the request source with the same `ConversationSource` conversion used when creating the conversation before calling the attach decision.</violation>
</file>
<file name="backend/utils/transcribe_decisions.py">
<violation number="1" location="backend/utils/transcribe_decisions.py:180">
P2: Mixed-case or whitespace-padded source values are classified as canonical sources here but persisted as `unknown` when the cross-source branch creates a conversation. Normalize the request source before both this comparison and `ConversationSource(...)`, or avoid case/whitespace normalization here until the persistence boundary does the same.</violation>
</file>
<file name="web/app/src/hooks/useRecording.ts">
<violation number="1" location="web/app/src/hooks/useRecording.ts:228">
P2: A very short recording can be lost because finalization is sent before the WebSocket has established its conversation. Waiting for the authoritative `conversation_session` (or retrying finalization after session creation) would prevent the 404 from being treated as a successful no-op.</violation>
<violation number="2" location="web/app/src/hooks/useRecording.ts:228">
P2: The web conversation is finalized via `/v1/conversations/{id}/finalize` immediately after `socket.disconnect()`. Unlike the desktop source (where the backend also finalizes on disconnect, giving ordered drain), a `web` conversation has no backend-side finalization on close, so the frontend `/finalize` request races with the listen session still draining buffered audio. If the request lands before trailing segments are flushed, the conversation can be marked processed/completed with the tail of the recording lost — the same failure class this PR addresses. Consider deferring the `/finalize` call until the backend session confirms it has finished writing (for example by waiting for a terminal/`finalize` acknowledgement from the socket, or relying on the backend's own disconnect finalization for web too) instead of firing it the instant the socket is closed.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| # Cross-source sockets (pendant + web meeting) must not share one conversation (#5388). | ||
| if not should_attach_to_existing_in_progress( | ||
| existing_source=existing_source if isinstance(existing_source, str) else None, | ||
| request_source=self.host.request.source, |
There was a problem hiding this comment.
P2: Unsupported listen sources now create a new conversation on every reconnect instead of reusing the existing session. Canonicalize the request source with the same ConversationSource conversion used when creating the conversation before calling the attach decision.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/routers/listen/conversations.py, line 272:
<comment>Unsupported listen sources now create a new conversation on every reconnect instead of reusing the existing session. Canonicalize the request source with the same `ConversationSource` conversion used when creating the conversation before calling the attach decision.</comment>
<file context>
@@ -262,6 +263,16 @@ async def prepare(self) -> Optional[str]:
+ # Cross-source sockets (pendant + web meeting) must not share one conversation (#5388).
+ if not should_attach_to_existing_in_progress(
+ existing_source=existing_source if isinstance(existing_source, str) else None,
+ request_source=self.host.request.source,
+ ):
+ await self.create_new_in_progress_conversation()
</file context>
| """Collapse empty/missing listen sources onto the default pendant source.""" | ||
| if not isinstance(value, str) or not value.strip(): | ||
| return 'omi' | ||
| return value.strip().lower() |
There was a problem hiding this comment.
P2: Mixed-case or whitespace-padded source values are classified as canonical sources here but persisted as unknown when the cross-source branch creates a conversation. Normalize the request source before both this comparison and ConversationSource(...), or avoid case/whitespace normalization here until the persistence boundary does the same.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/utils/transcribe_decisions.py, line 180:
<comment>Mixed-case or whitespace-padded source values are classified as canonical sources here but persisted as `unknown` when the cross-source branch creates a conversation. Normalize the request source before both this comparison and `ConversationSource(...)`, or avoid case/whitespace normalization here until the persistence boundary does the same.</comment>
<file context>
@@ -173,6 +173,27 @@ def decide_existing_conversation_action(
+ """Collapse empty/missing listen sources onto the default pendant source."""
+ if not isinstance(value, str) or not value.strip():
+ return 'omi'
+ return value.strip().lower()
+
+
</file context>
| const conversationId = conversationIdRef.current || clientConversationIdRef.current; | ||
| conversationIdRef.current = null; | ||
| clientConversationIdRef.current = null; | ||
| const finalize = conversationId |
There was a problem hiding this comment.
P2: A very short recording can be lost because finalization is sent before the WebSocket has established its conversation. Waiting for the authoritative conversation_session (or retrying finalization after session creation) would prevent the 404 from being treated as a successful no-op.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/app/src/hooks/useRecording.ts, line 228:
<comment>A very short recording can be lost because finalization is sent before the WebSocket has established its conversation. Waiting for the authoritative `conversation_session` (or retrying finalization after session creation) would prevent the 404 from being treated as a successful no-op.</comment>
<file context>
@@ -211,8 +221,14 @@ export function useRecording() {
+ const conversationId = conversationIdRef.current || clientConversationIdRef.current;
+ conversationIdRef.current = null;
+ clientConversationIdRef.current = null;
+ const finalize = conversationId
+ ? finalizeConversationById(conversationId)
+ : processInProgressConversation();
</file context>
| const conversationId = conversationIdRef.current || clientConversationIdRef.current; | ||
| conversationIdRef.current = null; | ||
| clientConversationIdRef.current = null; | ||
| const finalize = conversationId |
There was a problem hiding this comment.
P2: The web conversation is finalized via /v1/conversations/{id}/finalize immediately after socket.disconnect(). Unlike the desktop source (where the backend also finalizes on disconnect, giving ordered drain), a web conversation has no backend-side finalization on close, so the frontend /finalize request races with the listen session still draining buffered audio. If the request lands before trailing segments are flushed, the conversation can be marked processed/completed with the tail of the recording lost — the same failure class this PR addresses. Consider deferring the /finalize call until the backend session confirms it has finished writing (for example by waiting for a terminal/finalize acknowledgement from the socket, or relying on the backend's own disconnect finalization for web too) instead of firing it the instant the socket is closed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/app/src/hooks/useRecording.ts, line 228:
<comment>The web conversation is finalized via `/v1/conversations/{id}/finalize` immediately after `socket.disconnect()`. Unlike the desktop source (where the backend also finalizes on disconnect, giving ordered drain), a `web` conversation has no backend-side finalization on close, so the frontend `/finalize` request races with the listen session still draining buffered audio. If the request lands before trailing segments are flushed, the conversation can be marked processed/completed with the tail of the recording lost — the same failure class this PR addresses. Consider deferring the `/finalize` call until the backend session confirms it has finished writing (for example by waiting for a terminal/`finalize` acknowledgement from the socket, or relying on the backend's own disconnect finalization for web too) instead of firing it the instant the socket is closed.</comment>
<file context>
@@ -211,8 +221,14 @@ export function useRecording() {
+ const conversationId = conversationIdRef.current || clientConversationIdRef.current;
+ conversationIdRef.current = null;
+ clientConversationIdRef.current = null;
+ const finalize = conversationId
+ ? finalizeConversationById(conversationId)
+ : processInProgressConversation();
</file context>
…ardware#5388) Co-authored-by: Cursor <[email protected]>
|
OpenAPI contract failure was from adding |
…urce canonicalize Refresh remaining OpenAPI surfaces and generated TS/Swift clients for ConversationSource.web. Canonicalize attach decisions via ConversationSource (match persistence), ignore non-in_progress conversation_session events, and collapse to a single conversation id ref. Co-authored-by: Cursor <[email protected]>
|
Follow-up pushed for Cubic P2s + OpenAPI lane:
Deferred (pre-existing / out of shrink): finalize-vs-drain race on socket close; ultra-short stop before prepare completes (same class as prior |
…ompatible (BasedHardware#5388) Adding a new response enum member is a released-client breaking change under check_app_client_openapi_compatibility. Web listen already persists as unknown via ConversationSource._missing_; cross-source attach still refuses omi↔unknown without expanding the public contract. Co-authored-by: Cursor <[email protected]>
|
OpenAPI still red was not stale schemas — it was Fix: removed Local: |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for this well-targeted fix for #5388 — the cross-source attach refusal in prepare() and the client_conversation_id + finalize-by-ID pattern are the right approach for keeping pendant and web recordings on separate conversations.
A few observations for the maintainer:
-
PR description is now stale. It still says "add
ConversationSource.web," but that member was removed for OpenAPI compatibility andsource=webnow maps tounknownvia_missing_. The behavior is correct (unknown != omi, so cross-source attach still refuses), but updating the description would help reviewers. -
Finalize-vs-drain race (pre-existing, acknowledged). The backend only auto-finalizes
desktop-source conversations on clean disconnect (runtime.pyclose_code == 1000path). Web recordings rely on the frontend/finalizecall, which fires immediately aftersocket.disconnect()and may race with trailing buffered-audio segments. This is strictly better than before (correct conversation vs wrong conversation), but worth tracking as a follow-up so short tail-end audio isn't dropped. -
Unknown-source bucketing. Since
source=webmaps tounknown, any other unrecognized source would share that bucket with web. Not a blocker for #5388 (pendant isomi), just noting the coarseness is intentional to avoid an OpenAPI breaking change.
Unit tests for the cross-source decision logic are solid. Requesting human maintainer review since this touches conversation routing and finalization (user-data persistence).
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
@Git-on-my-level PR description is now updated to match the landed diff (no ConversationSource.web contract expansion; source=web stays mapped to unknown).\n\nAll scoped checks are green, and this is ready for human maintainer approval/merge when you’re comfortable.\n\nFollow-up race (finalize vs tail-drain) is tracked as separate out-of-scope hardening. |
|
@Git-on-my-level All CI checks are green on the current head of #11173 (only the human approval gate remains).\n\nAlso, I updated the PR description to remove the stale wording about adding ConversationSource.web (the merged behavior keeps source=web mapping via missing to unknown, and cross-source attach still refuses omi vs unknown).\n\nWhen you’re comfortable, could you please proceed with approval to clear the remaining needs-maintainer-review gate? The finalize-vs-drain timing item is still tracked as an explicit follow-up/out-of-scope, per the PR. |
kodjima33
left a comment
There was a problem hiding this comment.
Refuses cross-source in-progress attach so web and device recordings no longer collide; unit test covers the refusal.
Summary
h.omi.me) recording no longer silently loses the web meeting (Bug: Simultaneous device + web app recording fails — both are lost #5388 / related Bug: 30-min conversation split into multiple short fragments during simultaneous device + web recording #5389).prepare()attached new listen sockets to the single Redisin_progressconversation. Web audio could write into a device session, and stop/finalize could complete the shared pointer.should_attach_to_existing_in_progress) soomiandunknownsources do not share one in-progress conversation.client_conversation_id, keepconversation_sessiononly when status isin_progress, and finalize by explicit ID via/v1/conversations/{id}/finalizeinstead of the global pointer.ConversationSource.webis not present in the public app-client contract;source=webstill maps through_missing_tounknown.Test plan
pytest tests/unit/test_transcribe_decisions.py(cross-source attach refusal coverage)Follow-up (separate from this shrink fix)
Failure-Class: none
Fixes #5388