Repository navigation
Fix desktop conversation session and mutation races - #9371
Conversation
Avoid the duplicate direct API plus repository mutation path and keep the automation action on the same optimistic reconciliation path as the UI.\n\nVerified: xcrun swift test --package-path Desktop --filter 'DesktopAutomationSecondaryActionTests'
Fence cache writes by account session, serialize per-conversation mutations and deletes, and settle optimistic fields by operation identity so overlapping, duplicate, refreshed, failed, or cancelled edits preserve the latest user intent.\n\nVerified: 57 focused conversation/automation tests; 184 Swift XCTest suites via scripts/swift-test-suites.sh with 4 workers; all desktop tests/test-*.sh scripts; strict desktop E2E flow coverage; named omi-conversation-races bundle launch and semantic star action failure path. Independent subagent review approved with no remaining findings.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33021538d8
ℹ️ 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".
| try Task.checkCancellation() | ||
| try ensureCurrentSession(session) | ||
| let canonical = try await remotely() | ||
| try Task.checkCancellation() |
There was a problem hiding this comment.
Apply successful mutations despite later cancellation
For any caller that cancels a repository mutation task after the PATCH has already completed, this post-response check sends the code into the cancellation rollback path even though the server side effect succeeded. That leaves the UI/cache showing the old value until a later refresh while the server has committed the new title/star/folder state; cancellation should be checked before sending the mutation, not after receiving the canonical response.
Useful? React with 👍 / 👎.
| } | ||
| } | ||
|
|
||
| try ensureCurrentSession(session) |
There was a problem hiding this comment.
Honor cancellation before queued deletes
When a delete is queued behind an active mutation, acquireMutationSlot can suspend; if the delete task is cancelled during that wait, this path still proceeds to remote.delete because it only checks the session generation. In that cancelled-while-queued case the app can delete a conversation after the caller abandoned the operation, so add a cancellation check after acquiring the slot and before issuing the remote delete.
Useful? React with 👍 / 👎.
|
@cursor resolve merge conflicts and address review comments |
|
Merge conflicts are resolved and both Codex P2 review comments are addressed. Merge conflicts resolved
Review comments addressed1. Apply successful mutations despite later cancellation ( Removed the post-response 2. Honor cancellation before queued deletes Added Regression tests added
PushedCommit xcrun swift test --package-path Desktop --filter 'ConversationRepositoryTests|DesktopAutomationSecondaryActionTests' |
Resolve automation bridge merge conflicts and fix conversation mutation cancellation handling: - apply successful remote mutations even if the caller cancels after the PATCH completes, instead of rolling back committed server state - honor cancellation after a queued delete acquires the mutation slot and before issuing the remote delete Add regression tests for both cases. Co-authored-by: David Zhang <[email protected]>


Summary
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
Verification
xcrun swift test --package-path Desktop --filter 'ConversationRepositoryTests|ConversationReconciliationPolicyTests|DesktopAutomationSecondaryActionTests'— 57 passedOMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh— 184 suites passed in isolated processesdesktop/macos/tests/test-*.shlauncher/shell test passedomi-conversation-racesnamed bundle and exercised the realset_conversation_starredsemantic action; the cold signed-out profile returned the expected safeno conversations availablefailureRisk
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.