Skip to content

Show hold invoice tui#22

Merged
arkanoider merged 5 commits into
mainfrom
show-hold-invoice-tui
Dec 16, 2025
Merged

Show hold invoice tui#22
arkanoider merged 5 commits into
mainfrom
show-hold-invoice-tui

Conversation

@arkanoider

@arkanoider arkanoider commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator

Merging anothe block of development

Summary by CodeRabbit

  • New Features

    • Added payment invoice handling with copy-to-clipboard functionality for easy payment processing
    • Introduced improved message viewing interface for better order communication display
    • Enabled mouse capture support for enhanced terminal interaction
  • Improvements

    • Enhanced UI with better-centered popup layouts for improved visual organization
    • Improved message notification display and navigation

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This PR refactors order utility functions from a monolithic file into a modular structure (execute_add_invoice, send_new_order, take_order, helper), introduces a new ViewingMessage UI mode with clipboard support for invoices, adds a PaymentRequestRequired order result variant, enhances popup rendering with Flex-based centering across multiple UI files, updates DM message parsing to handle latest messages, and adds project configuration files (rust-toolchain.toml, ARCHITECTURE.md) and the arboard clipboard dependency.

Changes

Cohort / File(s) Summary
Configuration & Documentation
.gitignore, ARCHITECTURE.md, rust-toolchain.toml
Added .cursorrules to .gitignore; introduced comprehensive ARCHITECTURE.md detailing project structure, key management, and dependencies; added Rust toolchain config specifying 1.90.0 with clippy, rustfmt, and wasm32 target.
Dependency Management
Cargo.toml
Added arboard 3.3 dependency for clipboard support.
Main Application Logic
src/main.rs
Added PaymentRequestRequired handling with per-order trade_index tracking; enhanced PayInvoice/AddInvoice popup logic with auto_popup_shown flag; enabled mouse capture on terminal initialization and disabled on exit; introduced commented groundwork for mouse-event handling.
Key Handler & Navigation
src/ui/key_handler.rs
Extended Left/Right navigation to adjust selected_button in ViewingMessage; added ViewingMessage to non-navigable modes for Up/Down; implemented Enter key behavior for NewMessageNotification and ViewingMessage; added clipboard copy for invoices via 'c'/'C' using arboard; updated action matching with wildcard import.
UI State & Data Structures
src/ui/mod.rs
Added ViewingMessage(MessageViewState) UI mode variant; introduced MessageViewState struct with message_content, order_id, action, selected_button; added PaymentRequestRequired OrderResult variant; added auto_popup_shown to OrderMessage; renamed buyer_invoice to invoice in MessageNotification; added copied_to_clipboard to InvoiceInputState; created order_message_to_notification helper function.
Popup Rendering Refactoring
src/ui/order_confirm.rs, src/ui/order_take.rs, src/ui/order_result.rs, src/ui/waiting.rs
Replaced manual Rect positioning with Flex-based Layout centering across all files; added Clear widget rendering to ensure popup opacity; updated imports to include Flex and Clear; preserved existing content rendering logic.
Message Tab Rendering
src/ui/tab_content.rs
Added render_message_view function for dedicated message popup; replaced manual centering with Flex-based layouts; added Clear for popup regions; enhanced invoice rendering with Wrap and white bold styling; added "copied" helper message for clipboard state; updated notification styling with BACKGROUND_COLOR and PRIMARY_COLOR; improved input area rendering with safe saturating arithmetic.
Orders Table Layout
src/ui/orders_tab.rs
Increased column constraint from Max(6) to Max(10) for improved layout spacing.
DM Message Handling
src/util/dm_utils.rs
Refactored to fetch user key once per loop instead of per-order; introduced logic to select only latest incoming message by timestamp; reworked payload extraction for PayInvoice and AddInvoice with derived sat_amount and invoice fields; added auto_popup_shown: false to OrderMessage; extended notification text mapping for additional actions.
Order Utilities Refactoring
src/util/order_utils/ (complete restructure)
Removed monolithic src/util/order_utils.rs; Created modular structure: mod.rs (re-exports), helper.rs (order_from_tags, parse_orders_events, fetch_events_list, create_order_result_success, create_order_result_from_form, handle_mostro_response), execute_add_invoice.rs (invoice validation and AddInvoice DM flow), send_new_order.rs (order creation, validation, and DM submission), take_order.rs (take_order action with payload generation and response handling).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas requiring extra attention:

  • Order utilities refactoring: Verify state preservation and functional equivalence across split modules; ensure all error paths are properly handled in execute_add_invoice, send_new_order, and take_order
  • DM message handling in dm_utils.rs: Confirm the latest-message-only logic correctly selects intended messages and doesn't drop important state; verify payload extraction for PayInvoice and AddInvoice variants
  • UI state transitions: Validate ViewingMessage mode interactions with key handlers and rendering logic; ensure auto_popup_shown flag prevents duplicate popups
  • Clipboard integration: Confirm arboard clipboard operations are stable and properly reset on state changes; verify sleep stabilization doesn't cause UI freezes
  • Popup centering refactoring: Spot-check a few popup renderings (especially PaymentRequestRequired) to ensure visual correctness across different terminal sizes
  • Message notification rendering: Review the new render_message_view function and enhanced tab_content.rs rendering for correct styling and layout handling

Possibly related PRs

  • First merge of a big block of code to star develop #21: Overlapping modifications to src/ui/* and src/util/* with identical function additions (send_new_order, take_order, execute_add_invoice, dm_utils updates), indicating direct code-level connection and possible related refactoring scope.

Poem

🐰 Hop, hop! The code's been split and sorted,
Modular paths where once monoliths courted.
Popups now centered with Flex so divine,
And clipboards click—invoice copy's fine!
Messages view, states align,
A rabbit's refactor—sublime!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch show-hold-invoice-tui

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 201a0b5 and 7a31f7b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (20)
  • .gitignore (1 hunks)
  • ARCHITECTURE.md (1 hunks)
  • Cargo.toml (1 hunks)
  • rust-toolchain.toml (1 hunks)
  • src/main.rs (7 hunks)
  • src/ui/key_handler.rs (12 hunks)
  • src/ui/mod.rs (7 hunks)
  • src/ui/order_confirm.rs (1 hunks)
  • src/ui/order_result.rs (3 hunks)
  • src/ui/order_take.rs (2 hunks)
  • src/ui/orders_tab.rs (1 hunks)
  • src/ui/tab_content.rs (13 hunks)
  • src/ui/waiting.rs (1 hunks)
  • src/util/dm_utils.rs (2 hunks)
  • src/util/order_utils.rs (0 hunks)
  • src/util/order_utils/execute_add_invoice.rs (1 hunks)
  • src/util/order_utils/helper.rs (1 hunks)
  • src/util/order_utils/mod.rs (1 hunks)
  • src/util/order_utils/send_new_order.rs (1 hunks)
  • src/util/order_utils/take_order.rs (1 hunks)

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.

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