Skip to content

feat(ui): Settings mode switch, Shift+H help, My Trades UX#53

Merged
arkanoider merged 3 commits into
mainfrom
feat/settings-mode-and-my-trades-ux
Apr 19, 2026
Merged

feat(ui): Settings mode switch, Shift+H help, My Trades UX#53
arkanoider merged 3 commits into
mainfrom
feat/settings-mode-and-my-trades-ux

Conversation

@arkanoider

@arkanoider arkanoider commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Settings: Replace the non-obvious M shortcut with an explicit Switch Mode (User ↔ Admin) list item; Enter toggles mode and persists user_mode as before.
  • Settings: Shift+H opens a dedicated Settings instructions overlay (different copy for User vs Admin), with clearer typography (title + indented body + spacing). Short Ctrl+H help on Settings updated accordingly.
  • My Trades: Footer uses a single Paragraph over up to three reserved rows so wrapped hints have space; layout chooses 1/2/3 lines from available height and width.
  • Order chat sidebar: Active orders are sorted by trade index (higher / newer first), with stable tie-break on order_id.

Motivation

  • Mode switching should be discoverable from the Settings UI, not a hidden key.
  • Full option reference should be readable and role-specific.
  • My Trades had many shortcuts; the previous footer could starve wrapped text of height.
  • Newer trades are easier to find when ordered by allocation index.

Breaking / behavior changes

  • M no longer switches User/Admin anywhere; use Settings → Switch Mode (or the flow you document for users).

Summary by CodeRabbit

  • New Features

    • Added Shift+H hotkey to view detailed explanations of all settings options in a dedicated popup.
    • Changed mode switching from "M" keyboard shortcut to "Switch Mode (User ↔ Admin)" menu option in Settings.
    • Improved order chat list sorting to prioritize newest trades first.
  • Documentation

    • Updated Admin mode instructions to reflect new menu-based mode switching workflow.

- Add Switch Mode as first Settings action; remove M key shortcut
- SettingsInstructionsPopup (Shift+H) with styled admin/user option reference
- Wire Enter, Esc, navigation; update README and short Ctrl+H copy
- My Trades: reserve up to 3 footer rows; single Paragraph for wrapped hints
- Order chat list: sort by trade_index descending (newest trades first)

Made-with: Cursor
@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 13 seconds.

⌛ 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: 1cce5d0d-5437-415b-8a55-083de5f1adec

📥 Commits

Reviewing files that changed from the base of the PR and between 93e6550 and 25b86d7.

📒 Files selected for processing (3)
  • src/ui/help_popup.rs
  • src/ui/tabs/disputes_in_progress_tab.rs
  • src/ui/tabs/order_in_progress_tab.rs

Walkthrough

This PR introduces a new settings instructions popup accessible via Shift+H on the Settings tab, replacing the previous M-key mode switch with a menu-driven "Switch Mode" option that persists settings. The change adds comprehensive help documentation for all settings options and updates the UI navigation accordingly, while also sorting order chats by trade_index descending.

Changes

Cohort / File(s) Summary
Settings UI Structure
src/ui/tabs/settings_tab.rs, src/ui/constants.rs
Added "Switch Mode (User ↔ Admin)" as top-level menu item; increased option counts (Admin: 8→9, User: 6→7); replaced M-key help constant with Enter-on-menu and Shift+H help text; updated footer hint.
UI State & Rendering
src/ui/app_state.rs, src/ui/draw.rs
Added UiMode::SettingsInstructionsPopup(UserRole, Box<UiMode>) variant with cloning support; added conditional rendering path for settings instructions popup.
Input Handling
src/ui/key_handler/mod.rs, src/ui/key_handler/enter_handlers.rs, src/ui/key_handler/esc_handlers.rs, src/ui/key_handler/navigation.rs
Added Shift+H trigger for settings instructions popup on Settings tabs; updated Enter dispatcher to call handle_mode_switch at index 0 (shifting subsequent indices); ESC/Enter/Shift+H/Ctrl+H now close popup; Up/Down keys disabled in popup.
Help Popup Implementation
src/ui/help_popup.rs
Added render_settings_instructions_popup(f, user_role) renderer with role-specific instruction blocks and close hints; added internal helpers for formatting and wrapping instruction entries.
Documentation
README.md, src/ui/key_handler/settings.rs
Updated README and function doc comment to reflect Enter-on-menu mode switch behavior instead of M-key toggle.
Order Chat Sorting
src/ui/helpers/order_chat_projection.rs
Changed build_active_order_chat_list sorting from order_id to prioritize trade_index descending (newest first) with order_id tie-breaker.
Footer Layout Refactor
src/ui/tabs/order_in_progress_tab.rs
Replaced dual-paragraph footer rendering with single-paragraph wrapping text; computed dynamic footer height (1–3 rows) based on available space; added "My Trades" shortcuts row when space permits.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant KeyHandler as Key Handler
    participant AppState as App State
    participant DrawEngine as Draw Engine
    participant HelpPopup as Help Popup

    User->>KeyHandler: Press Shift+H on Settings tab
    KeyHandler->>AppState: Set mode to SettingsInstructionsPopup(role, previous_mode)
    AppState->>DrawEngine: Update app.mode
    DrawEngine->>HelpPopup: Call render_settings_instructions_popup(f, role)
    HelpPopup-->>DrawEngine: Render popup with role-specific help entries
    DrawEngine-->>User: Display settings instructions overlay
    User->>KeyHandler: Press Esc/Enter/Shift+H/Ctrl+H
    KeyHandler->>AppState: Restore previous_mode
    AppState-->>User: Dismiss popup, return to Settings tab
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Catrya
  • grunch
  • AndreaDiazCorreia

Poem

🐰 With Shift+H, help blooms bright,
Settings dance in pixel light,
Switch modes smooth, no M-key fight,
Trade chats sorted, newest right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the three main changes: Settings mode switch, Shift+H help, and My Trades UX improvements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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/settings-mode-and-my-trades-ux

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/ui/tabs/order_in_progress_tab.rs (2)

335-350: Footer height heuristic looks reasonable, but worth noting the chat area can collapse to 0.

footer_height is chosen from spare_below_header_input (= main_area.height − header_height − input_height). When that spare is exactly 3 and the 3-line footer is selected, the Min(0) chat constraint at Line 356 collapses to 0 rows and the chat becomes invisible (only header + input + footer remain). On very small terminals this is probably acceptable, but you may want to bias toward leaving at least 1 row for chat — e.g. require spare_below_header_input >= 4 for the 3-line footer and >= 3 for the 2-line footer.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ui/tabs/order_in_progress_tab.rs` around lines 335 - 350, The
footer_height selection can consume the last available chat row when
spare_below_header_input equals the footer size; update the heuristic in the
block that computes spare_below_header_input/footer_height (variables:
spare_below_header_input, footer_height, main_area, header_height, input_height)
to bias leaving at least one chat row by raising thresholds — e.g. require
spare_below_header_input >= 4 to pick a 3-line footer and >= 3 to pick a 2-line
footer (so the chat's Min(0) constraint does not collapse the chat to 0 height).

424-534: Footer refactor LGTM.

Collapsing the per-line Paragraphs into a single Paragraph::new(footer_text).wrap(Wrap { trim: true }) over the full footer rect correctly addresses the “wrapped hints have nowhere to go” problem described in the PR objectives. The 3/2/1-line content variants are consistent across the input-enabled / disabled branches and use the same separator style.

One small nit: in the 3-line input-enabled variant (Lines 439-442), middle line only contains SHIFT_C | SHIFT_F while the surrounding lines pack four hints each — feels a bit lopsided. Consider rebalancing (e.g. moving SHIFT_R_RELEASE or SHIFT_V_RATE up to line 2) for visual symmetry. Non-blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ui/tabs/order_in_progress_tab.rs` around lines 424 - 534, The 3-line
footer variant when app.order_chat_input_enabled (in the footer_height >= 3
branch) has an unbalanced middle line containing only
FOOTER_MYTRADES_SHIFT_C_CANCEL and FOOTER_MYTRADES_SHIFT_F_FIAT_SENT; move one
of FOOTER_MYTRADES_SHIFT_R_RELEASE or FOOTER_MYTRADES_SHIFT_V_RATE from the
third line up into that middle Line (the block that constructs Text::from(vec![
Line::from(format!(...)), Line::from(format!(...)), Line::from(format!(...)) ])
under the app.order_chat_input_enabled branch) so the three lines are more
visually balanced while keeping the same separators and overall content.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/ui/help_popup.rs`:
- Around line 80-109: The popup currently builds content as multiple lines and
passes them to Paragraph::new(lines), which causes height overflow on 24-row
terminals; change the content construction so each option is a single Spans line
combining a bold Span for the title and one or more Spans for the description
(instead of separate title+description+blank lines), reduce or remove extra
blank spacer lines, and pass a Vec<Spans> (or Text) into Paragraph::new(...) so
the Paragraph renders compactly with existing Wrap { trim: true }; update where
"lines" is built and keep using Span::styled, Paragraph::new(lines), Wrap, and
the same block/inner layout variables (block, inner, popup) so the popup fits on
constrained terminals without clipping.

---

Nitpick comments:
In `@src/ui/tabs/order_in_progress_tab.rs`:
- Around line 335-350: The footer_height selection can consume the last
available chat row when spare_below_header_input equals the footer size; update
the heuristic in the block that computes spare_below_header_input/footer_height
(variables: spare_below_header_input, footer_height, main_area, header_height,
input_height) to bias leaving at least one chat row by raising thresholds — e.g.
require spare_below_header_input >= 4 to pick a 3-line footer and >= 3 to pick a
2-line footer (so the chat's Min(0) constraint does not collapse the chat to 0
height).
- Around line 424-534: The 3-line footer variant when
app.order_chat_input_enabled (in the footer_height >= 3 branch) has an
unbalanced middle line containing only FOOTER_MYTRADES_SHIFT_C_CANCEL and
FOOTER_MYTRADES_SHIFT_F_FIAT_SENT; move one of FOOTER_MYTRADES_SHIFT_R_RELEASE
or FOOTER_MYTRADES_SHIFT_V_RATE from the third line up into that middle Line
(the block that constructs Text::from(vec![ Line::from(format!(...)),
Line::from(format!(...)), Line::from(format!(...)) ]) under the
app.order_chat_input_enabled branch) so the three lines are more visually
balanced while keeping the same separators and overall content.
🪄 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: c51b4cba-be88-49e4-aae5-96892eccd5e1

📥 Commits

Reviewing files that changed from the base of the PR and between 126ca55 and 93e6550.

📒 Files selected for processing (13)
  • README.md
  • src/ui/app_state.rs
  • src/ui/constants.rs
  • src/ui/draw.rs
  • src/ui/help_popup.rs
  • src/ui/helpers/order_chat_projection.rs
  • src/ui/key_handler/enter_handlers.rs
  • src/ui/key_handler/esc_handlers.rs
  • src/ui/key_handler/mod.rs
  • src/ui/key_handler/navigation.rs
  • src/ui/key_handler/settings.rs
  • src/ui/tabs/order_in_progress_tab.rs
  • src/ui/tabs/settings_tab.rs

Comment thread src/ui/help_popup.rs Outdated

@mostronatorcoder mostronatorcoder Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me overall.

I re-checked the main risk in this PR, which was the My Trades selection/action coupling. Moving both the sidebar rendering and the Enter/action target resolution onto build_active_order_chat_list fixes the previous desync class properly, and the trade-index ordering is deterministic.

The Settings changes also look coherent: the explicit mode switch is much more discoverable than the old hidden shortcut, the new Shift+H overlay is wired consistently, and the footer/help layout changes are a net UX improvement.

I still think the full Settings instructions popup could benefit from scroll support in a future follow-up on very small terminals, but I do not see that as a blocker for this PR.

Approving.

@arkanoider arkanoider merged commit 89786e6 into main Apr 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