Commit d422b19
committed
Fix pending invite stuck after navigation (#514)
## Problem
When a joiner scans an invite and navigates away before the inviter approves, the conversation permanently stays as a "pending invite" and never transitions to an active conversation. This was reported by Andy Yang — stuck for 45+ minutes on "Balloon Animals".
## Root Cause
Three gaps in the sync/stream lifecycle:
1. **No post-sync group discovery** — after syncing, the app never checked for XMTP groups that were added while streams were stopped
2. **Resume didn't re-sync** — `handleResume()` only restarted streams without re-syncing, missing groups added during pause
3. **ValueObservation cancelled on navigation** — the DB observation watching for the draft→active transition was tied to the conversation view's lifecycle
## Fix
### 1. Post-sync group discovery (`SyncingManager`)
New `discoverNewConversations()` method lists all XMTP groups after every sync and processes any missing from the local DB. Acts as a safety net for missed stream events.
### 2. Re-sync on resume (`SyncingManager`)
`handleResume()` now calls `syncAllConversations` + `discoverNewConversations` + `processJoinRequestsAfterSync` instead of only restarting streams.
### 3. Restart observation on navigation (`ConversationStateMachine`)
`handleUseExisting()` checks if the conversation is still a draft with an inviteTag and restarts `waitForJoinedConversation` observation in the background.
### 4. Accessibility fix
Added `accessibilityIdentifier("close-new-conversation")` to the close button on `NewConversationView`.
## Testing
- 59 unit tests pass
- QA test 24 (pending invite recovery) passed end-to-end:
- Joiner scans invite → navigates away → inviter approves via CLI → conversation automatically transitions to active → messaging works
## Files Changed
- `ConvosCore/Sources/ConvosCore/Syncing/SyncingManager.swift` — post-sync discovery + resume re-sync
- `ConvosCore/Sources/ConvosCore/Inboxes/ConversationStateMachine.swift` — restart pending invite observation
- `Convos/Conversation Creation/NewConversationView.swift` — close button accessibility ID
- `docs/plans/fix-pending-invite-stuck.md` — plan doc
- `qa/tests/24-pending-invite-recovery.md` — QA test
<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. -->
> [!NOTE]
> ### Recover pending invites after navigation by observing draft `inviteTag` in `ConversationStateMachine.handleUseExisting` and backfilling missed conversations in `SyncingManager`
> Add background observation for draft invites in `ConversationStateMachine` to transition to the joined conversation, and backfill missed conversations on sync and resume in `SyncingManager`; also add a close button accessibility identifier in the new conversation view. Key entry points: [`ConvosCore/Sources/ConvosCore/Inboxes/ConversationStateMachine.swift`](https://github.com/xmtplabs/convos-ios/pull/514/files#diff-a1762ce564035d6cdd7e3b2d3200cfe0db6c3ec5fac03636392780086ba58344), [`ConvosCore/Sources/ConvosCore/Syncing/SyncingManager.swift`](https://github.com/xmtplabs/convos-ios/pull/514/files#diff-ba2362cf646b78283a1af17654ea8d2c18f6b1cb686a78e7761e10f1b0328101), [`Convos/Conversation Creation/NewConversationView.swift`](https://github.com/xmtplabs/convos-ios/pull/514/files#diff-be8eeec29bfb3f245f16cd6258d1ef28ced1aa75bad52187e34243f915b084f6).
>
> #### 📍Where to Start
> Start with `ConversationStateMachine.handleUseExisting` and the new helpers in [ConversationStateMachine.swift](https://github.com/xmtplabs/convos-ios/pull/514/files#diff-a1762ce564035d6cdd7e3b2d3200cfe0db6c3ec5fac03636392780086ba58344), then review `SyncingManager.handleSyncComplete` and `handleResume` plus `discoverNewConversations` in [SyncingManager.swift](https://github.com/xmtplabs/convos-ios/pull/514/files#diff-ba2362cf646b78283a1af17654ea8d2c18f6b1cb686a78e7761e10f1b0328101).
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized e6abb51.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- macroscope-ui-refresh -->
<!-- Macroscope's pull request summary ends here -->1 parent ad10e79 commit d422b19
5 files changed
Lines changed: 276 additions & 9 deletions
File tree
- ConvosCore/Sources/ConvosCore
- Inboxes
- Syncing
- Convos/Conversation Creation
- docs/plans
- qa/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
Lines changed: 60 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
450 | 506 | | |
451 | 507 | | |
452 | 508 | | |
| |||
680 | 736 | | |
681 | 737 | | |
682 | 738 | | |
| 739 | + | |
683 | 740 | | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
684 | 744 | | |
685 | | - | |
686 | | - | |
687 | 745 | | |
688 | 746 | | |
689 | 747 | | |
| |||
693 | 751 | | |
694 | 752 | | |
695 | 753 | | |
696 | | - | |
697 | 754 | | |
698 | 755 | | |
699 | | - | |
700 | | - | |
701 | 756 | | |
702 | 757 | | |
703 | 758 | | |
704 | 759 | | |
705 | 760 | | |
706 | 761 | | |
707 | | - | |
708 | 762 | | |
709 | 763 | | |
710 | 764 | | |
| |||
747 | 801 | | |
748 | 802 | | |
749 | 803 | | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | 804 | | |
754 | 805 | | |
755 | 806 | | |
| |||
Lines changed: 67 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| 140 | + | |
138 | 141 | | |
139 | 142 | | |
140 | 143 | | |
| |||
389 | 392 | | |
390 | 393 | | |
391 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
392 | 400 | | |
393 | 401 | | |
394 | 402 | | |
| |||
403 | 411 | | |
404 | 412 | | |
405 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
406 | 458 | | |
407 | 459 | | |
408 | 460 | | |
| |||
539 | 591 | | |
540 | 592 | | |
541 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
542 | 606 | | |
543 | 607 | | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
544 | 611 | | |
545 | 612 | | |
546 | 613 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
0 commit comments