Skip to content

fix(desktop): make conversation cache reconciliation authoritative - #9354

Merged
Git-on-my-level merged 9 commits into
mainfrom
codex/conversation-store-8197
Jul 10, 2026
Merged

Git-on-my-level merged 9 commits into
mainfrom
codex/conversation-store-8197

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Summary

  • make Firestore document update_time the canonical conversation revision exposed as updated_at
  • preserve user-owned title, starred, folder, and visibility fields in the same transaction that writes processing results
  • return the post-write canonical conversation from title/star/folder mutations
  • route the desktop Conversations list, detail, search, refresh, mutations, delete, and cache writes through one ConversationRepository
  • track SQLite cache revision and list/detail completeness separately from local write time
  • keep cache-first/offline UX while always revalidating server-owned summary/status data

Closes #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

  • cache paints immediately, remains visibly loading, then settles to canonical summary/status
  • offline/server failure keeps useful cache instead of blanking
  • detail paints cached transcript and always revalidates server-owned fields
  • optimistic success settles from canonical processing output
  • failure restores the exact pre-mutation state
  • older revisions cannot regress visible or persisted state
  • older detail can enrich transcript without regressing newer list metadata
  • title/star/folder processing races preserve user-owned fields, including a simulated Firestore transaction retry
  • filtered mutation/delete counts reconcile correctly
  • superseded list and search requests cannot overwrite newer UI state
  • mutation response decoding carries revision plus canonical fields
  • legacy unversioned cache rows hydrate conservatively

Product invariants affected

  • INV-AUTH-1 — authentication and session invalidation behavior is unchanged; the API client changes are limited to canonical conversation response decoding and return values

Verification

  • OMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh: 182 suites passed
  • focused Swift repository/reconciliation/storage/API suites: 44 tests passed
  • focused backend revision/endpoint/lock suites: 69 tests passed
  • BACKEND_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 current origin/main
  • focused CI regressions: both duration-guard nodes passed; the fair-use Redis-key suite passed 39/39 with its clock frozen
  • current-main runtime-env validator: 21/21 passed through test.sh with the CI timing guard
  • hermetic backend E2E: 102 passed, 3 skipped; Firestore native and protobuf-like revision timestamps are covered at the database boundary
  • app-client/public/integration OpenAPI contracts and Swift/TS/Dart generators are current
  • import-side-effect and async-blocker scans passed
  • INV-UI-1 brand ratchet passed
  • strict desktop E2E coverage: 13/13 changed Swift files covered; 27 flows and 66 bridge actions lint; desktop core self-check passed
  • pre-push typecheck/build/contract hooks passed
  • named omi-conversation-store bundle 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

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)
@mintlify

mintlify Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Jul 9, 2026, 8:47 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@Git-on-my-level
Git-on-my-level marked this pull request as ready for review July 9, 2026 22:41
@Git-on-my-level

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +394 to +395
let conversationDate = conversation.startedAt ?? conversation.createdAt
if conversationDate < start || conversationDate >= end { return false }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +248 to +249
if let cached = try? await local.detail(id: id) {
onCached?(cached)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 6803d28 into main Jul 10, 2026
25 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/conversation-store-8197 branch July 10, 2026 00:01
Git-on-my-level added a commit that referenced this pull request Jul 10, 2026
## 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. -->
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.

Desktop Conversations: clarify backend authority while preserving cache-first UX

1 participant