Repository navigation
fix(memories): preserve deletion ownership through refresh and retry - #24980
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a17b4246e5
ℹ️ 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".
| if (deletion != null) { | ||
| deletion.serverMemory = serverMemory; | ||
| _ledgerProjectionRevision++; | ||
| return; |
There was a problem hiding this comment.
Keep an uploaded draft cached when deletion is undone
When a draft's POST succeeds while its deletion is staged, the caller removes it from pendingMemories before this branch returns without saving the canonical row to cachedMemories. If the user then undoes the deletion or the DELETE is refused, the row is restored only in _memories; an offline reopen after restart has neither a pending nor cached copy and hides a memory that still exists on the server. Preserve the canonical row in the offline cache when restoring it.
Useful? React with 👍 / 👎.
| final key = _userScopedKey('confirmedMemoryDeletes', ownerUid); | ||
| var markerSaved = false; | ||
| try { | ||
| markerSaved = await saveStringList(key, {...getStringList(key), id}.toList()); |
There was a problem hiding this comment.
Serialize concurrent memory deletion cache updates
When two per-ID deletes finish close together, both can read the same owner-scoped marker and cache lists before either asynchronous write completes. Each then writes a list pruned only for its own ID, so the last write can drop the other deletion marker and reintroduce its row into the cached projection; that row can reappear after restart. Serialize these read-modify-write updates or otherwise merge against the latest stored lists.
Useful? React with 👍 / 👎.
Deleting a second memory could expose the first again during refresh, and a refused request could restore an old account's private row after sign-out. A draft deleted during upload could also leave its newly created server record behind.
The shared memory delete flow now owns one operation per ID, joins repeated commits, stops Undo at submission, reports refusals, and guards publication by owner and session. Uploading drafts hand off their canonical IDs before deletion. Create/delete authorization is rechecked after authentication waits and before every HTTP retry. Confirmed owner-scoped deletion markers protect cached and pending projections through failed writes and restart; HTTP 404 is treated as already absent.
Refs #24719. This is a separate reproducible mobile memory boundary. #24774 already merged the conversation-cache fix. This PR does not close the umbrella account/desktop/recording-storage trace investigation or claim that either fix is in a store release.
Verification
Implementation and verification checklist: app/docs/memory-deletion-lifecycle.md.
Product invariants affected
Failure class
Failure-Class: FC-continuation-resumed-after-unmount
UI evidence
Synthetic component harness using the production MemoryItem and shared deletion helper; loopback HTTP 409 restores the row and shows failure. The separate simulator integration also exercised actual swipe, Undo, 5xx retries and offline reopen.