Repository navigation
fix(desktop): align chat tool calls and keep HTTP 402 honest through worker recycle - #11522
Merged
Merged
Conversation
Tool names sat off their icons and the expand control drifted to the trailing edge. Live replies also hid thumbs and info because the footer waited on a journal remote id and ChatBubble ignored sync/metadata. Co-authored-by: Cursor <[email protected]>
Recycling a poisoned worker rewrote the user copy to "send again", so the existing 402 classifier never saw the technical status and the transcript invited a retry that cannot clear Payment Required. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 23 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…gentVm Dev desktop-backend ADC stays on based-hardware-dev for GCE/agentVm, so quota was minting Free on a miss and 402ing Architect users. Entitlements now use the Auth SA file as a second client and never provision a default plan. Failure-Class: none Co-authored-by: Cursor <[email protected]>
…ota reads Quota targeting has to stay next to the subscription document owner; the +11 lines are the injectable client and no-provision path that prevent a Free stamp on the compute project. Co-authored-by: Cursor <[email protected]>
… client The import swap left _record_session calling an undefined get_firestore_client, which pyright rejected and would have written sessions onto compute ADC. Failure-Class: none Co-authored-by: Cursor <[email protected]>
Resolve the modify/delete ratchet-ledger conflict by keeping main's git-base line-count check and dropping the deleted JSON baselines. Co-authored-by: Cursor <[email protected]>
…entity Match status-first 402 copy, let the classifier own auth/leak retryability, and treat late artifacts, journal status, and citations as visible bubble identity so the live tail cannot hide thumbs after those fields arrive. Failure-Class: none Co-authored-by: Cursor <[email protected]>
1 of 2 tasks
This was referenced Aug 13, 2026
Closed
kodjima33
added a commit
that referenced
this pull request
Aug 14, 2026
… split (#11531) (#11535) * fix(backend): decide the desktop trial gate before resolving customer credentials `is_desktop_trial_paywalled` passed `get_customer_firestore_client()` as an argument, so Python resolved the customer Firestore client before the function could apply the two guards that need no Firestore at all: the trial paywall is off by default (`TRIAL_PAYWALL_ENABLED=false`) and mobile platforms are never gated. Every desktop request therefore initialized credentials to compute an answer it already had, and an environment without ambient ADC got an exception out of `/v1/screen-activity/sync` instead of "not paywalled" — CI saw it as `BlockedNetworkError: Blocked outbound network connection to ('169.254.169.254', 80)` in `test_desktop_screen_crisp`. Before #11522 these routes did no credential work here. Run the cheap guards first; the client is resolved only when a Firestore decision is actually required. Verified: with `_build_customer_firestore_client` raising (no credentials), POST /v1/screen-activity/sync through the real router returns 200 {"synced":1,"last_id":7}; on the parent commit the same request raises. `bash test.sh` over test_paywall_reconnect_gate.py + test_desktop_screen_crisp.py -> 34 and 6 passed. Failure-Class: new * fix(backend): repair unit stubs and assertions for the customer-Firestore split #11522 added `from database._client import get_customer_firestore_client` to `utils.subscription` and `firestore_client=` / `provision=` routing kwargs on the entitlement lookups. Eight unit files still described the old shape, and the `Backend Unit Tests` lane is path-filtered on `backend/**`, so the desktop-only commits merged after it never re-ran it and main stayed red. - Import-isolation stubs (`memory_import_isolation.make_database_client_stub` and the file-local stub in `test_users_add_sample_transaction`) build a synthetic `database._client` with `get_firestore_client` only, so importing `database.users` raised `ImportError: cannot import name 'get_customer_firestore_client'` at fixture setup. Export it from both. - `test_byok_security` pinned `is_byok_active('byok-user-uid')`; the call now carries the routing kwarg. - `test_neo_desktop_grandfather` monkeypatched the entitlement lookups with single-arg lambdas. The `TypeError` was swallowed by the fail-open `except` in `_is_trial_expired_cached`, so the failure surfaced one step downstream as a missing cache clear. Accept the kwargs. - `test_paywall_reconnect_gate` asserted the exact literal `_is_trial_expired_cached(uid)` and `assert_called_with('uid1')`. Assert the delegation (callee and uid) rather than the caller's routing kwargs, which is what those tests are actually guarding. Verified: `BACKEND_UNIT_TEST_FILE_LIST=<the 9 CI failures> bash test.sh` -> 216 passed, exit 0 (same list was 9/9 red on main at 6083f7d). Failure-Class: none
Git-on-my-level
added a commit
that referenced
this pull request
Aug 14, 2026
…ds (#11529) ## Summary - Follow-up to #11522: thumbs stay visible on a just-finished reply, but the rating PATCH waits until journal sync so a 404 cannot wipe the optimistic rating. - Failed journal turns keep a local-only rating and never PATCH a missing backend row. Clearing thumbs before sync now still PATCHes after the remote id lands (a queued `nil` is not treated as a missing map entry). - Last write wins while sync is in flight; the queue flushes when the journal projection lands a remote id. The dual-client quota stub repair from #11522 landed separately in #11535, so this PR is desktop-only. ## Test plan - [x] `cd desktop/macos && ./scripts/dev-feedback.py --once swift 'ChatMessageRatingPersistenceTests'` — 8 tests passed - [ ] Named-bundle check: send a chat, tap thumbs on the live tail before the backend id appears, confirm the rating sticks after sync ## Product invariants - INV-CHAT-1 - INV-AUTH-1 Failure-Class: none
kodjima33
added a commit
that referenced
this pull request
Aug 15, 2026
…s isolation fixtures (#11633) ## What Five backend unit files have been failing on `main` since `6316415534` (merged today, 14:44 UTC) with the same error: ``` ModuleNotFoundError: No module named 'utils.memory.retraction_scope' ``` - `tests/unit/test_batch_upload_storage.py` - `tests/unit/test_conversation_events_bounds.py` - `tests/unit/test_conversation_search_date_validation.py` - `tests/unit/test_conversations_date_range_validation.py` - `tests/unit/test_merge_validation.py` Red lane on `main`: [run 31890773063](https://github.com/BasedHardware/omi/actions/runs/31890773063). ## Why PR #11627 added a new module, `utils/memory/retraction_scope.py`, and imported it from both `utils/conversations/merge_conversations.py:25` and `routers/conversations.py:51`. All five files load their module under test through the `stub_modules` + `load_module_fresh` isolation seam, and each stubs `utils.memory` as a package with an empty `__path__` plus a hand-listed set of submodules (`memory_service`, `memory_system`, `canonical_activation`). An empty `__path__` means any submodule that is *not* on that list cannot resolve at all — so the new import fails at fixture setup rather than falling through to the real module. Nothing in these five files exercises retraction; they cover audio-copy helpers, merge validation, event index bounds, and search/date validation. The stubs simply had not caught up with a new import in the graph they load. ## Fix Register a `utils.memory.retraction_scope` stub in each fixture, in that file's local idiom, exposing only the symbols its importer binds: - the two `merge_conversations` loaders get `canonical_intake_is_fenced`, `historical_source_conversation_ids`, `retraction_can_be_skipped` - the three `routers.conversations` loaders get `retraction_can_be_skipped` Test files only — no production code changes, and no assertion in any of the five was touched. ## On #11531 The issue's original cause (the customer-Firestore split, #11522) was fixed by #11535 and the issue was left open. Verified at `6316415534` that all nine files it named now pass: ``` BACKEND_UNIT_TEST_FILE_LIST=<the 9 files> bash test.sh -> 34 passed in 23.52s ``` The lane was red again for the unrelated cause above. With this change the lane is green, so the issue's condition is resolved. ## Tested ``` # the 5 failing files, before the fix (reproduced locally at 6316415) -> ModuleNotFoundError: No module named 'utils.memory.retraction_scope' in all 5 # after BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-fail5.txt bash test.sh -> 40 + 9 + 9 + 23 + 27 = 108 passed # full backend unit suite bash test.sh -> the 5 files pass. 14 other files fail; the identical 14 fail on unmodified main (stashed, same runner, same machine), so none are attributable to this diff. test_sync_v2.py failed only under full-suite parallel load and passes standalone (168 passed) both before and after. black --line-length 120 --skip-string-normalization --check -> 5 files would be left unchanged scripts/pr-preflight --pr-body-file <this body> -> PR preflight passed: 24 checks in 117.98s (includes backend-module-isolation, backend-import-purity) ``` Local runner is Python 3.12 / pytest 9.1.1 against CI's 3.11 / 8.4.1, which accounts for some of the 14 pre-existing local failures. ## Follow-up (not in this PR) This is the second time in two weeks that a new import into the conversations/memory graph broke hand-listed stub sets (#11531 was the same shape). The durable fix is to derive the stub set rather than hand-list it — e.g. letting a stubbed package auto-provide `AutoMockModule` submodules instead of failing on an empty `__path__`. That is a change to the shared `testing/import_isolation.py` seam with a much wider blast radius than a red-lane repair, so it is deliberately left out here. Auto-generated from issue feedback by the mini issues-improver — tested and merged. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/11633?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Chat tool-call rows sat off their icons and hid thumbs/info on the live tail. Separately, pi-mono worker recycle rewrote HTTP 402 as "send again", so the existing billing classifier never reached the transcript.
Dev desktop-backend then 402'd Architect users because quota ran against compute-project Firestore (
based-hardware-dev) and provisioned Free on a miss. Entitlements now use a second customer client from the Auth SA file (FIREBASE_AUTH_CREDENTIALS_PATH) without retargeting ADC;agentVmstays on compute. Desktop quota never merge-writes a default Free plan.Product invariants affected
Line-Count-Exception: backend/database/users.py | 2120 -> 2131 | Keep injectable customer-Firestore targeting and no-provision quota reads beside the subscription document owner so desktop-backend cannot stamp Free onto a paying user in a second project.
How it was verified
/Applications/omi-tool-call-align.app(com.omi.omi-tool-call-align) rebuilt with the agent runtime payload (not--fast-only) and launched signed-in on Chat.[pi-mono] turn_end ERROR: HTTP 402 status code (no body)wrapped asThe local agent reset its session after an error. Send your message again.cd desktop/macos && ./scripts/dev-feedback.py --once swift 'ChatTurnFailureNoticeTests|AgentErrorClassifierTests|ChatQueryTelemetryTests/testRecycledWorkerHTTP402|ChatQueryTelemetryTests/testWorkerRecoveryTelemetry|ChatQueryTelemetryTests/testRuntimeFailureDetail|ChatTurnStateFailureTests/testOnlyRealFailuresEarnAMarker'— 33 tests passed.cd desktop/macos/agent && npx vitest run tests/failures.test.ts tests/adapter-binding.test.ts— 12 passed.cd desktop/macos && ./scripts/agent-logic-harness.sh --node-only— passed.Could not exercise a successful 402-to-billing transcript in the live bundle because the AI proxy is still returning 402 until this desktop-backend revision is serving; the regression tests reconstruct that exact wrap.
Tests
ToolActivityTimelineLayoutTests— icon column, vertical center, disclosure hugging the label.ChatBubbleMetadataBandTests/ChatBubbleIdentityTests— finished unsynced replies offer ratings; sync/metadata are visible identity.ChatTurnFailureNoticeTests.testRecycledWorkerBillingFailureKeepsTheBillingMarker— the live wrap (userMessage= send-again,technicalMessage= HTTP 402) keeps the billing marker and does not invite retry.agent/tests/failures.test.tsandadapter-binding.test.ts— recycle still happens after 402, butretryablestays false and the user copy is not "send again".test_agent_vm_firebase_project_split.py/test_google_credentials.py— customer client uses the Auth SA file without overriding ADC;provision=Falsedoes not write Free.Failure class (fixes)
Failure-Class: none