feat(ui): role-aware waiting-phase trade status popups#73
Conversation
Show invoice/payment modals only when the local user must act; otherwise present a waiting-phase popup with phase-specific copy. Suppress auto-popups for non-acting parties and add unit tests for maker/taker role rules. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
WalkthroughThis PR introduces role-based invoice popup gating and waiting-phase UI rendering for ChangesInvoice Popup Role Gating and Waiting-Phase UI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
I reviewed this strictly and I do see a blocker in the new role-aware popup gating.
Blocker
local_user_must_act_on_invoice_popup() now decides whether to show an actionable invoice/payment popup or a passive waiting popup based on msg.is_mine.
But in this codebase, is_mine is not always a strong/fully-hydrated signal yet:
- timeline code already documents that takers often see
is_mine: Noneuntil the local row hydrates - DM-only upserts can also preserve / infer role imperfectly before the local row is fully established
The new helper currently does:
let is_maker = msg.is_mine.unwrap_or(false);So an unknown role (None) is silently treated as taker.
That was relatively harmless for timeline highlighting, but in this PR it directly controls whether the user:
- gets the real actionable popup, or
- gets a waiting-only popup / suppressed auto-popup instead
This creates a real risk that the correct acting party is misclassified during early hydration and does not get the action they are supposed to see.
In other words, this PR is using a field that is still known to be temporarily ambiguous as if it were authoritative enough to gate the invoice/payment UX.
I think this needs a safer fallback strategy for the unknown-role case, plus tests that explicitly cover is_mine: None for the invoice-popup decision path.
Because this can hide or downgrade an action-required popup for the actual local actor, I am marking this as request changes.
There was a problem hiding this comment.
Re-reviewed the latest changes.
The blocker I raised is addressed now.
The important fix is that OrderMessage.is_mine is no longer derived only from the pre-upsert snapshot in the trade-DM path. The listener now re-reads SQLite after upsert, but only trusts that post-upsert role when a local row already existed before the DM path. That avoids promoting the DM-upsert maker default to authoritative role information for the early taker race.
So the popup gating is now on much safer ground:
- persisted maker/taker rows hydrate into
Some(true/false)correctly - the brief unknown-role window still falls back to taker intentionally
- tests now cover both the hydration helper and the
is_mine: Nonepopup behavior
With that fix in place, I do not see a remaining blocker in this PR.
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
Summary
Invoice and payment popups were shown to both maker and taker even when only one party must act (e.g. buy maker seeing a Pay Invoice modal while waiting for the seller). This PR gates popups on who must act and adds a waiting-phase modal when the local user only needs to wait.
local_user_must_act_on_invoice_popupwith buy/sell maker/taker rules forAddInvoice,PayInvoice, andPayBondInvoiceWaitingSellerToPay/WaitingBuyerInvoice) with phase-specific title and body text instead of an invoice input formMotivation
Early trade phases assign different actions to maker vs taker. Showing payment/invoice forms to the wrong party is confusing and can imply action is required when the user should only wait for the counterparty.
Summary by CodeRabbit