Skip to content

fix(conversations): settle merges and reconcile cached originals without push - #21417

Merged
aryanorastar merged 15 commits into
BasedHardware:mainfrom
Dragonire9:fix/conversation-merge-stuck-watch-19247
Oct 26, 2026
Merged

aryanorastar merged 15 commits into
BasedHardware:mainfrom
Dragonire9:fix/conversation-merge-stuck-watch-19247

Conversation

@Dragonire9

@Dragonire9 Dragonire9 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Closes #19247 and #20603. Manual merge must finish in the running app without depending on push, and a completed result must not retain cached original rows. All manual admissions now use the existing durable merge coordinator regardless of the broader lifecycle canary. The admitted target ID remains stable through partial cleanup/retry; authoritative transfer receipts prevent already-incorporated originals from being merged again, while ordinary semantic duplicate hints retain merge eligibility. Capture/transcription rollout behavior is unchanged.

The client uses typed source absence and target readiness, journals IDs by account/backend, and commits list/search/pagination/cache changes together. Cache transactions, page-cache writes and merge-journal retirement are serialized; concurrent completions retain both targets after offline reopen, failed transactions remain retryable, and queued work rechecks account/backend ownership. Merges still processing after the fast polling window remain observed at a lower bounded rate. A read failure or locked response never proves deletion, and observation never resubmits a merge.

This extends Dragonire9's existing PR, preserving the contributor commits. Main's #21544 already covers the source-deletion propagation proposed by #21525; current-owner tests preserve that guard. No contributor PR is closed and no bounty is accepted or promised.

Verification

  • 129 focused Flutter provider/cache/search/processing/Spotlight tests and 31 adjacent delete/undo, auth retry, date-filter and recap tests passed. Seven new regressions cover concurrent completions with/without refresh, failed cache-read retry, queued account/backend replacement, a stale former target and old-server preservation of unrelated rows pending deletion for Undo. The concurrent offline-cache regression fails at the previous green head 353761f and passes with this fix.
  • 97 focused file-isolated backend tests and all 34 batch-upload storage tests passed, covering route modes off/shadow/serve, atomic admission loss, source receipts, cleanup refusal, same-target retry, worker rereads and validation.
  • 9 integration tests passed against the pinned Firestore emulator (firebase-tools 15.22.0): competing admissions, correction transfer, lease expiry/fencing, partial cleanup failure, restart/retry into the same target without paid processing, and consumed-source refusal.
  • Local HTTP foreground, reopen, delayed completion and simultaneous completion/offline-reopen journeys passed twice: 16 recorded assertions. The offline case shuts down the loopback backend before reopening. Real client decoding/provider/cache/row widgets execute; auth and backend worker/storage effects are synthetic. Backend emulator tests exercise the durable owners separately.
  • Three cache/failed-read regressions fail on byte-exact current-main provider code and pass in this PR. The batch-upload fixture resolves the real pure merge policy while retaining isolated client/IO dependencies; all 34 file tests pass.
  • The nine WAL live-custody tests pass twice. Their gated-index test observes the actual disk/index persistence checkpoint and releases its gate in finally; strict durability assertions and production WAL code are unchanged.
  • Changed-file Flutter analysis is clean. Exact-head CI at f66450e passes: 34 successful checks, 19 conditional skips, one neutral docs preview, no failures or pending checks. Full Dart analysis/tests passed with 7,640 tests and four skips; all six backend shards, aggregate backend suite and seeded journeys passed. Linux packaging passed a same-commit retry after an Ubuntu package-download timeout. Unselected native-compile/far-timezone lanes are not claimed as verified.

Technical readiness and release

Final diff review, local integration evidence and required exact-head CI pass at f66450e. The PR remains draft for maintainer review; it has not been merged or deployed. Customer confirmation is not a technical readiness or GitHub-closure gate.

Deploy the additive backend response before mobile release. No LIFECYCLE_V2_MODE serve-cohort change is needed for manual merge correctness. Existing finalization recovery infrastructure remains required (production runtime manifests already declare the conversation-finalization Cloud Tasks queue). This PR does not change production configuration, deploy, merge, or mutate customer records.

Support separately owns historical-account investigation and post-release customer confirmation; those remain in the support tracker and do not keep a verified technical fix open on GitHub.

Product invariants affected

none

UI-Evidence: none -- No layout/control code changed. The local HTTP journey renders the production row and verifies only the completed target remains without a merging overlay in foreground, reopen, delayed completion and concurrent-completion offline reopen.

Failure-Class: new

Failure-class transition narrative

FC-merge-completion-depends-on-push records the demonstrated contract: a best-effort push is not a completion authority. Its reusable guard is typed target/source observation and a shared provider/cache commit; behavioral provider and HTTP journey tests cover recurrence. Durable manual admission removes the legacy recovery bypass rather than adding another recovery owner.

Line-Count-Exception: app/lib/providers/conversation_provider.dart | 2197 -> 2420 | Keep canonical admission/projection ownership in the established owner; bounded observation and journal serialization live in small separate services.

…asedHardware#19247)

When merging conversations, rows remained stuck in mergingConversationIds
if the FCM push notification was missed or arrived in a background isolate.
Probe involved conversations periodically until the merge settles on the
server, or hand back to a list refresh if bounded time elapses.

Failure-Class: none

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @Dragonire9 — solid, well-tested fix for the stuck "Merging…" rows (#19247). The bounded probe design in watchMerge() (4s interval, 3min limit, push-wins, hand-back-to-refresh fallback) is the right shape, and the five tests in conversation_provider_merge_watch_test.dart cover the important paths (late settle, network hiccup not mistaken for completion, push cancelling the probe, locked result, timeout). The re-check of mergingConversationIds after the awaited fetches correctly handles a push landing mid-probe, and the watcher timers are cleaned up in both clearUserData() and dispose(). The changelog fragment (app/changelog/unreleased/20261013-merge-watch-settle.json) is a nice touch.

Three items before this can merge:

  1. Formatting check fails: app/test/providers/conversation_provider_merge_watch_test.dart is not dart-format clean (and is missing a trailing newline at EOF). Running dart format over it should resolve this.
  2. Hygiene check fails on the product-file line-count ratchet: app/lib/providers/conversation_provider.dart grows 2098 -> 2201 lines against main. Either extract the merge-watch logic (watchMerge and its helpers) into its own file/mixin, or add Line-Count-Exception: app/lib/providers/conversation_provider.dart | 2098 -> 2201 | <reason> to the PR body — the current "Line-Count-Exception: none" line is rejected as malformed for this case.
  3. Housekeeping: this branch is behind main, so the diff carries hunks (the HomeEmptyExplanation wiring from empty_recording_notice.dart, clearEmptyRecordingExplanation, etc.) that already landed in #21398. Rebasing onto current main will drop those duplicated hunks and leave the true delta — the merge watcher — much easier to review.

One non-blocking observation: on the deadline and locked-result paths, handBackToList() clears mergingConversationIds and forces a refresh, but if the server still reports those rows as merging, they may render as merging again from the refreshed list data. Acceptable as a bounded, rare fallback — just worth knowing it is not a guaranteed settled state.

Leaving for human maintainer review once the CI items above are addressed.


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 flutter flutter work label Oct 13, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Progress since my last review: the line-count exception is now well-formed in the PR body and the Hygiene check passes, and conversation_provider_merge_watch_test.dart picked up its missing trailing newline - two of the three items done, thanks.

One blocker remains, and the fix commit missed it slightly: the Formatting check still fails at 38e5a07. CI runs dart format --line-length 120 --set-exit-if-changed, but 38e5a07 reformatted conversation_provider_merge_watch_test.dart at the default 80-column style - e.g. the ticks() helper and several expect(...) calls are wrapped onto multiple lines where 120 columns keeps them on one. Running this from app/ should make it green:

dart format --line-length 120 test/providers/conversation_provider_merge_watch_test.dart

It is only that one test file - the changelog fragment app/changelog/unreleased/20261013-merge-watch-settle.json and the provider changes in conversation_provider.dart are not affected.

Still open but non-blocking: the branch remains behind main, so the diff still carries hunks that already landed via #21398 (the HomeEmptyExplanation wiring, clearEmptyRecordingExplanation, claimDiscardedOnlyExplanation, and the empty_recording_notice.dart import in conversation_provider.dart). The content is identical to main, so this is review noise rather than a correctness risk; rebasing would leave watchMerge() and its timer bookkeeping as the whole diff, which is the part a maintainer will want to eyeball.

Once the formatting fix lands, I do not see anything else blocking on my side.


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

@Dragonire9

Copy link
Copy Markdown
Contributor Author

@Git-on-my-level Thank you for spotting that!

conversation_provider_merge_watch_test.dart has been updated in commit 23423b8:

  • Re-formatted strictly according to dart format --line-length 120 rules (preserving one-line signatures for icks(), test titles, and closures without 80-col splits).
  • Trailing newline verified present with 0 CR bytes (LF-only).

Formatting check should now pass cleanly!

@Git-on-my-level
Git-on-my-level dismissed stale reviews from themself October 16, 2026 01:54

Resolved: the line-count exception is now well-formed in the PR body and the Hygiene check passes at head 23423b8. The formatting item raised later (review 5526940282) was also addressed by that same head.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All three items from my earlier reviews are resolved at 23423b8 — thanks @Dragonire9 for working through them.

  • Formatting is green: conversation_provider_merge_watch_test.dart is now formatted at the repo's 120-column style with the trailing newline restored.
  • The line-count exception in the PR body is well-formed and Hygiene passes.
  • The stale #21398 hunks (the HomeEmptyExplanation wiring, clearEmptyRecordingExplanation, and the empty_recording_notice.dart import in conversation_provider.dart) are identical to what's already on main; the branch merges cleanly into current main, so they're review noise rather than a conflict. A rebase would make watchMerge() the whole diff, but it's not required.

On the substance, conversation_provider.dart holds up well: watchMerge() probes each involved id via _conversationLifecycleFetcher behind a re-entrancy guard, re-checks mergingConversationIds after the awaits so a push landing mid-probe wins, reuses the existing _isActiveProcessingStatus so a merged summary still processing isn't mistaken for completion, settles through onMergeCompleted(..., merged:) without a duplicate fetch, and hands back to forceRefreshConversations() on the 3-minute deadline or an unreadable (402/404) result. Watcher timers are cancelled in both clearUserData() and dispose(). The five tests in conversation_provider_merge_watch_test.dart cover the meaningful paths (late settle, network hiccup, push-first, locked result, timeout), and the changelog fragment 20261013-merge-watch-settle.json matches the shipped behavior.

Nothing blocking on my side — leaving the merge decision to a human maintainer.


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 positive-signal Automation verified a genuine fix/quality contribution label Oct 16, 2026
@aryanorastar
aryanorastar marked this pull request as draft October 26, 2026 11:44
@mintlify

mintlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit f66450e.

Approve preview

@aryanorastar aryanorastar added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 26, 2026
@aryanorastar aryanorastar changed the title fix(conversations): watch merging rows until server finishes merge (#19247) fix(conversations): settle merges and reconcile cached originals without push Oct 26, 2026
@aryanorastar
aryanorastar marked this pull request as ready for review October 26, 2026 17:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T17:48:46.520086Z
We couldn’t complete this review. Comment @codex review to try again.
f66450e Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@aryanorastar
aryanorastar merged commit 2ea1cf8 into BasedHardware:main Oct 26, 2026
61 of 62 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conversations: merged rows stay on 'Merging…' until the app restarts when the push doesn't reach the running app

3 participants