Skip to content

feat(admin): Step3 - inline bond slash UI on dispute finalize popup#78

Merged
arkanoider merged 3 commits into
mainfrom
feat/admin-bond-slash-picker
May 19, 2026
Merged

feat(admin): Step3 - inline bond slash UI on dispute finalize popup#78
arkanoider merged 3 commits into
mainfrom
feat/admin-bond-slash-picker

Conversation

@arkanoider
Copy link
Copy Markdown
Collaborator

@arkanoider arkanoider commented May 19, 2026

Summary

Integrates anti-abuse bond slash into the admin Shift+F finalize flow (builds on PR #77 execute-layer wiring):

  • Single finalize popup: 💰 Pay buyer | ↩️ Refund seller | Bond (←→); Esc exits (no Exit button)
  • Enter on Bond opens overlay submenu (↑/↓, four BondSlashChoice options); default 🔓 no slash
  • Confirm popup shows outcome + Bond: recap before sending admin-settle / admin-cancel
  • Removes separate SelectBondSlash full-screen step

Motivation

Admins choose settle/cancel and bond resolution in one place, with a clear recap before the irreversible confirm step.

Changes

  • ReviewingDisputeForFinalization state: bond, slash_submenu_open, slash_submenu_index
  • New dispute_bond_slash_popup.rs overlay renderer
  • Updated key handlers, confirm popup, emoji labels via BondSlashChoice::label()
  • Docs: FINALIZE_DISPUTES.md, ADMIN_DISPUTES.md, README

Breaking changes

None for end users. Internal: AdminMode::SelectBondSlash removed; finalize popup button indices unchanged (0–2).

Test plan

  • cargo fmt, cargo clippy --all-targets --all-features, cargo test (109 tests)
  • Shift+F → Bond shows 🔓 No bond slash by default
  • Enter Bond → pick slash → label updates on main popup
  • Enter Pay/Refund → confirm shows bond recap → Yes sends wire payload
  • Esc: submenu → main popup → dispute list; confirm No/Esc preserves bond

Follow-up

  • Gate bond UI on instance bond_enabled (kind 38385)

Summary by CodeRabbit

Release Notes

New Features

  • Introduced bond resolution overlay menu within admin dispute finalization workflow
  • Added bond selection recap to finalization confirmation dialog
  • Updated finalization popup button layout with dedicated bond resolution option

Documentation

  • Comprehensive updates to admin dispute finalization documentation covering bond overlay interaction, keyboard navigation (Esc to dismiss), and confirmation flow recap

Review Change Stack

Integrate anti-abuse bond selection into the Shift+F finalize flow instead
of a separate full-screen step. Admins pick slash on a Bond button (default
no slash), open an overlay submenu with Enter, then confirm pay/refund with
a full recap including bond.label().

- ReviewingDisputeForFinalization holds bond + slash_submenu_* state
- Remove SelectBondSlash mode; Esc exits finalize (no Exit button)
- Emoji action buttons (pay buyer, refund seller) and bond labels
- Confirm popup shows outcome and bond choice before execute
- Docs: FINALIZE_DISPUTES, ADMIN_DISPUTES, README

Follows execute-layer BondSlashChoice wiring (PR #77).

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@arkanoider has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 46 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6de6807a-df69-4fab-8917-3dbe27e9b797

📥 Commits

Reviewing files that changed from the base of the PR and between 2ab2c37 and 61154dc.

📒 Files selected for processing (2)
  • docs/FINALIZE_DISPUTES.md
  • src/ui/key_handler/enter_handlers.rs

Walkthrough

Adds a bond-slash submenu overlay to the admin dispute finalization UI, enabling selection of BondSlashChoice (None/SlashSeller/SlashBuyer) with updated state tracking, rendering components, keyboard navigation, and comprehensive documentation reflecting the new inline finalize popup and confirmation flow.

Changes

Admin Dispute Finalization Bond-Slash Submenu

Layer / File(s) Summary
State contract and bond choice utilities
src/ui/admin_state.rs, src/util/order_utils/bond_resolution.rs, src/ui/mod.rs
AdminMode::ReviewingDisputeForFinalization and ConfirmFinalizeDispute variants extended with bond: BondSlashChoice field; slash_submenu_open and slash_submenu_index added for submenu state. BondSlashChoice gains choice_index(), from_choice_index() helpers for TUI index mapping, and label() updated with emoji-prefixed descriptive text. New public module dispute_bond_slash_popup exported.
Bond overlay and confirmation rendering
src/ui/dispute_bond_slash_popup.rs, src/ui/dispute_finalization_confirm.rs, src/ui/dispute_finalization_popup.rs, src/ui/draw.rs
render_bond_slash_overlay renders centered submenu with selectable choices and keyboard hints. render_finalization_confirm updated to accept and display bond recap via bond.label(). render_finalization_popup now renders bond-slash overlay when submenu is open and includes Bond button with dynamic label. ui_draw threads new bond/submenu parameters through to both finalization and confirm renderers.
Keyboard navigation and state transitions
src/ui/key_handler/chat_helpers.rs, src/ui/key_handler/enter_handlers.rs, src/ui/key_handler/esc_handlers.rs, src/ui/key_handler/mod.rs
FinalizeDisputePopupButton changes Exit variant to BondSlash. Enter key opens bond submenu on BondSlash or routes to confirmation via handle_enter_finalize_popup (now accepts bond parameter). Esc key closes submenu or returns to ManagingDispute. Up/Down arrows cycle bond choices when submenu open. State preserved when navigating between reviewing/confirming/submenu via bond.choice_index().
Updated documentation
README.md, docs/ADMIN_DISPUTES.md, docs/CODING_STANDARDS.md, docs/FINALIZE_DISPUTES.md, docs/README.md
Comprehensive updates describing the inline finalize popup with three-button layout (Pay buyer/Refund seller/Bond), bond-resolution submenu overlay, confirmation recap with bond label, keyboard navigation (Esc exit, Left/Right/Up/Down selection), and bond_enabled instance gating behavior. Protocol/execution flow documented to show bond flowing from confirm UI through execute layers.

Sequence Diagram(s)

sequenceDiagram
  participant Admin as Admin User
  participant Finalize as Finalization Popup
  participant Bond as Bond Submenu
  participant Confirm as Confirmation Recap
  participant Execute as Execute Layer
  Admin->>Finalize: Shift+F on dispute
  Finalize->>Finalize: show Pay/Refund/Bond buttons
  Admin->>Finalize: Right arrow to Bond button
  Admin->>Bond: Enter selects Bond button
  Bond->>Bond: show None/SlashSeller/SlashBuyer choices
  Admin->>Bond: Up/Down arrow cycles choice
  Admin->>Bond: Enter to confirm choice
  Bond->>Finalize: Esc or confirm returns to buttons
  Admin->>Finalize: Enter on Pay/Refund
  Finalize->>Confirm: transition with bond stored
  Confirm->>Confirm: show recap with Bond label
  Admin->>Execute: Enter Yes on confirm
  Execute->>Execute: execute_finalize_dispute_action with bond
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • MostroP2P/mostrix#77: Main PR depends on execute-layer bond: BondSlashChoice wiring and execute_finalize_dispute_action payload handling introduced in this PR.
  • MostroP2P/mostrix#76: Main PR extends the BondSlashChoice and bond-resolution payload foundation by adding UI selection helpers (choice_index, from_choice_index) and threading bond through finalize/confirm/execute layers.
  • MostroP2P/mostrix#26: Both PRs modify admin dispute finalization UI and AdminMode state variants; main PR extends the flow with bond-slash submenu and passes BondSlashChoice through confirmation to execution.

Suggested reviewers

  • AndreaDiazCorreia
  • grunch
  • mostronatorcoder

Poem

🐰 A slash so fine, a choice so clear,
Bond or none, the path draws near,
Left and right, up and down we go,
Emoji labels put on a show,
Finalization flows, disputes laid low! ⚔️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(admin): Step3 - inline bond slash UI on dispute finalize popup' clearly and specifically describes the main change: integrating bond slash selection UI inline within the finalize popup, which aligns with the primary objective of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 95.24% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/admin-bond-slash-picker

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/FINALIZE_DISPUTES.md`:
- Line 139: The shortcut docs use inconsistent button naming: replace the phrase
"Enter on Bond slash" with the consistent label "Enter on Bond" so the shortcut
text matches the main action label "Bond" used elsewhere; update the line that
currently reads "Enter on Bond slash: Open bond submenu overlay" to "Enter on
Bond: Open bond submenu overlay" and scan for other occurrences of "Bond slash"
to align them with the "Bond" button name.

In `@src/ui/key_handler/enter_handlers.rs`:
- Around line 673-683: The BondSlash branch currently always reopens the slash
submenu (setting slash_submenu_open and slash_submenu_index) and never
transitions to ConfirmFinalizeDispute, causing finalized disputes to be a
dead-end; update the match arm for FinalizeDisputePopupButton::BondSlash so that
when a finalize-confirm path is appropriate (e.g., dispute is already finalized
or the UI should proceed to confirmation) you set app.mode to
UiMode::AdminMode(AdminMode::ConfirmFinalizeDispute { dispute_id,
selected_button_index, bond }) or otherwise create/choose a bond-only
confirmation variant instead of always reopening the slash submenu; keep or
adjust slash_submenu_open and slash_submenu_index (bond.choice_index()) only
when you actually need the submenu, and ensure selected_button_index, dispute_id
and bond are passed into the ConfirmFinalizeDispute (or new bond-only confirm)
state so the flow can proceed to confirmation.

In `@src/ui/key_handler/mod.rs`:
- Around line 253-260: The cycle_bond_slash_choice function currently clamps the
selected_choice_index at the ends; change it to wrap around using the length of
BondSlashChoice::ALL so Up from 0 goes to len-1 and Down from len-1 goes to 0.
Locate cycle_bond_slash_choice and replace the saturating_sub/min logic with
wrap logic using the len (from
crate::util::order_utils::BondSlashChoice::ALL.len()) — compute the new index by
adding/subtracting 1 then applying modulo len (or equivalent conditional wrap)
so repeated Up/Down presses cycle through options.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a0c9886-1b00-4742-992f-f89491fe3568

📥 Commits

Reviewing files that changed from the base of the PR and between d256204 and 2ab2c37.

📒 Files selected for processing (16)
  • README.md
  • docs/ADMIN_DISPUTES.md
  • docs/CODING_STANDARDS.md
  • docs/FINALIZE_DISPUTES.md
  • docs/README.md
  • src/ui/admin_state.rs
  • src/ui/dispute_bond_slash_popup.rs
  • src/ui/dispute_finalization_confirm.rs
  • src/ui/dispute_finalization_popup.rs
  • src/ui/draw.rs
  • src/ui/key_handler/chat_helpers.rs
  • src/ui/key_handler/enter_handlers.rs
  • src/ui/key_handler/esc_handlers.rs
  • src/ui/key_handler/mod.rs
  • src/ui/mod.rs
  • src/util/order_utils/bond_resolution.rs

Comment thread docs/FINALIZE_DISPUTES.md Outdated
Comment thread src/ui/key_handler/enter_handlers.rs
Comment thread src/ui/key_handler/mod.rs
arkanoider and others added 2 commits May 19, 2026 22:36
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@mostronatorcoder mostronatorcoder Bot left a comment

Choose a reason for hiding this comment

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

I reviewed this carefully and I do not see a blocker.

The UI flow is coherent now:

  • bond choice stays inside the existing finalize popup instead of forcing a separate full-screen mode
  • the selected bond action is preserved into the confirm step and back again on Esc / No
  • the execution path now actually sends the chosen bond resolution instead of always falling back to the legacy default

I also checked the finalized-dispute path and the action layer still rejects invalid finalize attempts, so this does not weaken the existing guardrails.

The follow-up about gating the bond UI on instance bond_enabled still makes sense, but I do not see that as a blocker for this PR itself.

@arkanoider arkanoider merged commit 6cb4481 into main May 19, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant