Skip to content

fix(app): restore a conversation row when its server delete fails - #21605

Merged
kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/conversation-failed-delete-restore
Oct 15, 2026
Merged

kodjima33 merged 2 commits into
BasedHardware:mainfrom
apoorvdarshan:fix/conversation-failed-delete-restore

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Collaborator

What changed and why

Fixes #21572

Deleting a conversation hides its row at once and sends DELETE when the Undo toast closes. If the server refused that request (deleteConversationServer returns false for anything but 204 or no response) or it threw, ConversationProvider only restored the Siri entry and cleared the tombstone. The row was never put back, so the conversation stayed hidden until the next refresh even though the server still had it.

On a failed or thrown DELETE, the provider now puts the row back the same way Undo does. Undo's restore steps moved into one helper, _restoreDeletedConversation, which both Undo and the two failure paths call: it re-adds the conversation to conversations if it is missing, regroups (so it shows again in the list and in active search results) and restores the Siri entry. The server cursor is still left alone on failure, and a result from a previous session is still ignored.

This follows what memories already do when a delete fails (MemoriesProvider._finalizeDeletion puts the memory back). No error toast is added: the provider has no UI context, and the memories path does not show one either.

Product invariants affected

none

How it was verified

  • Read the delete flow end to end: deleteConversationsWithUndo → deleteConversationLocally → commitPendingDelete → deleteConversationOnServer, plus the search and detail-page entry points.
  • dart format --line-length 120 on the changed files: no changes.
  • scripts/pr-preflight --pr-body-file <this body>: 23 checks passed.
  • I did not run tests locally: CI with ci:full runs the regression tests and the full app suites. I wrote the new tests to fail without the fix (the row stays out of conversations and displayedConversations) and to pass with it.

Tests

app/test/providers/conversation_pending_delete_test.dart:

  • a rejected server delete puts the row back in the list and a throws server delete puts the row back in the list: after a refused or thrown DELETE, the row is back in conversations and displayedConversations, and no tombstone is left.
  • a failed server delete puts the row back in active search results: same thing while a search is active.

The existing tests for the cursor, the session fence and the Siri restore are unchanged.

UI-Evidence: none -- provider state only, no layout change; the restored row uses the existing list rendering. Covered by the provider tests above.

Failure class (fixes)

Failure-Class: FC-refused-mutation-bool-confirmed-as-success

Line-Count-Exception: app/lib/providers/conversation_provider.dart | 2119 -> 2125 | the shared restore helper's signature and doc comment; Undo's body moved into it rather than being duplicated

🤖 Generated with Claude Code

A conversation delete hides the row at once and sends DELETE when the
Undo toast closes. When that request was refused or threw, the provider
restored the Siri index entry and cleared the tombstone but never put
the row back, so the conversation stayed hidden until the next refresh
even though the server still had it.

Put the row back the same way Undo does, for the list and active
search results.

Fixes BasedHardware#21572

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@apoorvdarshan apoorvdarshan added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 14, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member

Reviewed the delete flow end to end — this is a clean, well-scoped fix for #21572. Per file:

  • app/lib/providers/conversation_provider.dart: _restoreDeletedConversation is the old undoDeletedConversation body moved verbatim (tombstone release, re-add into conversations with the startedAt ?? createdAt sort, groupConversationsByDate, Siri upsert), now also called from the refused-DELETE and onError branches of deleteConversationOnServer. Undo itself keeps its timer guard and delegates to the same helper, so its behavior is unchanged. The session-generation checks are retained in both async callbacks, and the server-offset rebase stays gated on the DELETE succeeding, so a failed delete can no longer leave the row hidden without also risking pagination desync — nice.
  • app/test/providers/conversation_pending_delete_test.dart: good coverage — both the rejected (false) and thrown paths assert the row returns to conversations/displayedConversations and memoriesToDelete is cleared, and the new search test verifies the row reappears in active search results. I confirmed groupConversationsByDate() branches on hasActiveSearch internally, so that restore path is real, not just test-shaped.
  • app/changelog/unreleased/20261015-conversation-failed-delete-restore.json: accurate user-facing wording; matches the actual behavior change.

Aligning with the memories path (_finalizeDeletion) and skipping an error toast for symmetry is a reasonable product call. Leaving for maintainer merge; no changes requested.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution flutter flutter work labels Oct 14, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Reviewed the delete flow end to end — this is a clean, well-scoped fix for #21572. Per file:

  • app/lib/providers/conversation_provider.dart: _restoreDeletedConversation is the old undoDeletedConversation body moved verbatim (tombstone release, re-add into conversations with the startedAt ?? createdAt sort, groupConversationsByDate, Siri upsert), now also called from the refused-DELETE and onError branches of deleteConversationOnServer. Undo itself keeps its timer guard and delegates to the same helper, so its behavior is unchanged. The session-generation checks are retained in both async callbacks, and the server-offset rebase stays gated on the DELETE succeeding, so a failed delete can no longer leave the row hidden without also risking pagination desync — nice.
  • app/test/providers/conversation_pending_delete_test.dart: good coverage — both the rejected (false) and thrown paths assert the row returns to conversations/displayedConversations and memoriesToDelete is cleared, and the new search test verifies the row reappears in active search results. I confirmed groupConversationsByDate() branches on hasActiveSearch internally, so that restore path is real, not just test-shaped.
  • app/changelog/unreleased/20261015-conversation-failed-delete-restore.json: accurate user-facing wording; matches the actual behavior change.

Aligning with the memories path (_finalizeDeletion) and skipping an error toast for symmetry is a reasonable product call. Leaving for maintainer merge; no changes requested.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added the security-review Touches auth, provider routing, secrets, or security-sensitive surfaces label Oct 15, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Verified the fix end to end against the delete flow — correct, well-tested bug fix. Detail per file:

  • app/lib/providers/conversation_provider.dart — Both failure branches of deleteConversationOnServer (succeeded == false, and onError) now call _restoreDeletedConversation, which re-adds the row to conversations when missing, re-sorts, regroups, and restores the Siri entry. Previously only _restoreSiriAfterOptimisticDelete ran, so a refused or thrown DELETE left the row hidden until the next refresh while the server still had it. The surrounding invariants hold: the generation != _sessionGeneration guard fires before any restore in both branches, so a DELETE that outlives sign-out cannot mutate the new session's state; and since _filterPendingDeletes blocks refresh reinsertion while the tombstone lives, removing the tombstone inside the helper cannot race into a duplicate row. The undoDeletedConversation refactor is a clean, behavior-preserving extraction of the same steps.
  • app/test/providers/conversation_pending_delete_test.dart — The new rejected/throws loop cases assert the row returns in both conversations and displayedConversations and that memoriesToDelete empties; the active-search test covers the hasActiveSearch regroup branch. They fail without the fix, which is the right regression shape.
  • app/changelog/unreleased/20261015-conversation-failed-delete-restore.json — Accurate user-facing wording for the behavior change.

One pre-existing oddity noticed while reading (not introduced here, no action requested): _restoreSiriAfterOptimisticDelete captures generation and immediately compares it to _sessionGeneration, which is always true at that point.

No changes requested. Since this touches the conversation delete/restore persistence flow, it keeps the security-review label and needs a maintainer's formal sign-off before merge.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Mobile/Flutter bug fix: restores a conversation row when the server delete fails or throws, matching existing memories-delete pattern. Fixes #21572, scoped diff (53+9), CI green (Dart Analyze & Tests pass, Backend Hermetic Merge Gate pass), new dart tests cover the failure/throw/search-active cases. Confidence 5/5.

@kodjima33
kodjima33 merged commit bb5b623 into BasedHardware:main Oct 15, 2026
46 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR flutter flutter work positive-signal Automation verified a genuine fix/quality contribution security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobile: a conversation whose server delete fails stays hidden from the list until the next refresh

3 participants