Repository navigation
fix(desktop): make conversation cache reconciliation authoritative - #9354
Conversation
Make Firestore update_time the canonical conversation revision, preserve user-owned fields across processing transactions, and return canonical snapshots from mutations. Route desktop list/detail/search/mutations/delete through a cache-first ConversationRepository with explicit cache completeness and revision ordering. Verification:\n- 182 Swift XCTest suites passed with 4 isolated workers\n- 44 focused repository/reconciliation/storage/API tests passed\n- 69 backend revision and lock-contract tests passed\n- backend unit suite ran 495 files; one unrelated parallel prompt-cache flake passed on isolated rerun\n- OpenAPI and generated client checks passed\n- backend import-purity and async-blocker scans passed\n- INV-UI-1 brand ratchet passed\n- named omi-conversation-store bundle built, installed, launched, and navigated to Conversations (no seeded auth was available for live rows)
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 257800ee05
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let conversationDate = conversation.startedAt ?? conversation.createdAt | ||
| if conversationDate < start || conversationDate >= end { return false } |
There was a problem hiding this comment.
Use createdAt when reconciling date filters
When a date filter is active, this client-side membership check can remove a row that the server would still return, because /v1/conversations and its count filter on created_at (get_conversations_without_photos applies the range to created_at) while this code prefers startedAt. For conversations recorded before the selected day but created/synced during it, any canonical mutation response (star/title/folder) fails matchesCurrentQuery, disappears from the filtered list, and decrements the count even though the next server refresh will add it back.
Useful? React with 👍 / 👎.
| if let cached = try? await local.detail(id: id) { | ||
| onCached?(cached) |
There was a problem hiding this comment.
Merge cached detail without regressing the seed
If the list has already painted a newer server snapshot but the SQLite detail cache still has an older revision (for example because the post-list cache write is still running, or the app is offline), passing the cached row wholesale to onCached regresses server-owned fields like title/summary/status while only trying to enrich the transcript. The detail path should compare revisions or merge cached transcript fields into the seed instead of replacing the visible conversation with an older cache projection.
Useful? React with 👍 / 👎.
## Summary - reject detail, mutation, delete, and cache work that belongs to a reset/account session - serialize remote edits and deletes per conversation while keeping title, star, and folder changes instantly optimistic - settle fields by operation UUID so sibling, duplicate, cyclic, refreshed, failed, and cancelled edits cannot erase newer intent - keep conversation cache admission session-aware without blocking the main actor on SQLite work - route the desktop star automation action through the repository exactly once This preserves the high-value hardening that remained after #9354 landed, supersedes the now-closed #9365, and is a focused follow-up to #8197. ## Failure cases covered - old-account detail/mutation/delete acknowledgements after reset - reset while a detail cache write is suspended before transaction admission - overlapping title + star success and partial failure - duplicate and A → B → A title operations, including a refresh reflecting the older A - two queued failures rolling back to the last confirmed value - delete racing an in-flight mutation - transport cancellation and cancellation while queued - older canonical revisions and active-filter removal - automation double-call/invalid async routing regression ## Verification - `xcrun swift test --package-path Desktop --filter 'ConversationRepositoryTests|ConversationReconciliationPolicyTests|DesktopAutomationSecondaryActionTests'` — 57 passed - `OMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh` — 184 suites passed in isolated processes - every `desktop/macos/tests/test-*.sh` launcher/shell test passed - strict desktop E2E flow coverage passed for all changed production Swift files - repository pre-push hook passed, including a clean desktop Swift compile - launched the ad-hoc-signed `omi-conversation-races` named bundle and exercised the real `set_conversation_starred` semantic action; the cold signed-out profile returned the expected safe `no conversations available` failure - independent subagent review iterated through concurrency, refresh, delete, storage, and cancellation findings and approved the final diff with no remaining findings ## Risk No API, schema, or migration changes. The behavioral change is limited to conversation cache/session admission and repository-owned mutation ordering. Optimistic UI remains immediate; only remote acknowledgement order is serialized per conversation. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9371?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. -->
Summary
update_timethe canonical conversation revision exposed asupdated_atConversationRepositoryCloses #8197.
Why this is the 80/20
This removes timestamp heuristics and view-owned cache/API decisions without introducing a change feed or offline mutation journal. Firestore remains authoritative, SQLite remains an instant/offline projection, and optimistic mutations settle from an exact canonical response.
Follow-up #9355 tracks durable mutation IDs, cursored deltas/tombstones, and separating local capture sessions from the server projection.
Substantial regression coverage
Product invariants affected
Verification
OMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh: 182 suites passedBACKEND_FAST_UNIT_FAIL_SECONDS=0.25 BACKEND_PYTEST_WORKERS=8 backend/test.sh: all 496 backend unit-test files passed under the CI duration budget after merging currentorigin/maintest.shwith the CI timing guardomi-conversation-storebundle built, installed, re-signed locally, launched, and navigated to Conversations via the bridge; the signed-out flow failure was verified, but authenticated Tier-2 execution was unavailable because this Mac has no seeded auth session or Docker/Auth-emulator stack