Skip to content

Fix(ui): Keep My Trades input visible while typing - #112

Merged
arkanoider merged 2 commits into
MostroP2P:mainfrom
ca-ruz:fix/my-trades-message-input-scroll
Aug 13, 2026
Merged

Fix(ui): Keep My Trades input visible while typing#112
arkanoider merged 2 commits into
MostroP2P:mainfrom
ca-ruz:fix/my-trades-message-input-scroll

Conversation

@ca-ruz

@ca-ruz ca-ruz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the My Trades order chat message input when typed text exceeds the visible field width.

  • Keeps the latest typed text visible by rendering the trailing input that fits the field.
  • Prevents long messages from disappearing behind the left side of the input box.
  • Preserves the existing input height and layout.
  • Adds unit coverage for fitting text, overflowing text, and Unicode-width text.

Testing

  • cargo fmt --all -- --check
  • cargo check --all-targets --all-features
  • cargo test --all-features
  • cargo clippy --all-targets --all-features -- -D warnings

All checks passed successfully.

Summary by CodeRabbit

  • Bug Fixes

    • Improved message box rendering to show the latest text that fits within the visible input area.
    • Preserved complete Unicode characters, including decomposed characters and emoji sequences.
    • Added truncation for text that exceeds the available space.
  • Tests

    • Added coverage for ASCII overflow, Unicode widths, complex emoji, and end-to-end rendering.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e193e3a-06c6-4af0-81eb-55ee5fc62732

📥 Commits

Reviewing files that changed from the base of the PR and between 5fc4368 and b5fd811.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml
  • src/ui/tabs/order_in_progress_tab.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/ui/tabs/order_in_progress_tab.rs

Walkthrough

The message input now shows the latest grapheme-aligned text that fits its visible width. The truncation logic handles Unicode display widths, combining characters, and ZWJ emoji sequences. Tests cover calculation and rendered output.

Changes

Chat input rendering

Layer / File(s) Summary
Trailing input calculation and rendering
Cargo.toml, src/ui/tabs/order_in_progress_tab.rs
The input keeps fitting text unchanged and otherwise renders the rightmost grapheme-aligned suffix. The widget preserves its block styling. Tests cover ASCII overflow, Unicode widths, decomposed characters, ZWJ emoji sequences, and rendered visibility.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: 🔵 Low · up to b5fd8

The input now keeps trailing text visible while typing, but some decomposed characters or joined emoji sequences may render partially or incorrectly at the left edge when text overflows. The PR is mergeable with owner awareness and follow-up for Unicode grapheme-safe truncation.

Suggested reviewers: arkanoider

Poem

A rabbit trims the input line,
Graphemes stay whole and bright.
Wide symbols keep their space,
Newest words remain in sight,
Tests hop through the rendered light.

🚥 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 clearly summarizes the main UI change: keeping the My Trades input visible while typing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ca-ruz

ca-ruz commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 2

🤖 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 `@src/ui/tabs/order_in_progress_tab.rs`:
- Around line 160-169: Update the truncation logic around order_chat_input to
iterate with UnicodeSegmentation::grapheme_indices(true) instead of
char_indices(), ensuring the selected suffix always begins on a grapheme
boundary, including decomposed characters and ZWJ emoji sequences. Add
unicode-segmentation as a direct dependency and add regression tests covering
both cases.
- Around line 703-732: Add a deterministic TestBackend integration test
alongside the existing trailing input tests, initializing my_trades_maker_book
with one row and setting app.order_chat_input to text exceeding main_chunks[2]’s
inner width. Render render_order_in_progress to a fixed-size terminal and assert
the terminal buffer contains the expected trailing suffix, covering the
Block::inner and Paragraph rendering path.
🪄 Autofix

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 Plus

Run ID: d9ec61e1-c53e-462d-a9d7-2b161ef9972a

📥 Commits

Reviewing files that changed from the base of the PR and between 8f312ee and 5fc4368.

📒 Files selected for processing (1)
  • src/ui/tabs/order_in_progress_tab.rs

Comment thread src/ui/tabs/order_in_progress_tab.rs
Comment thread src/ui/tabs/order_in_progress_tab.rs
@ca-ruz

ca-ruz commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Addressed review feedback in the latest commit.

  • Preserved grapheme boundaries when truncating input text.
  • Added regression coverage for decomposed characters and ZWJ emoji.
  • Added a TestBackend render test for the overflowing input field.
  • All standard checks pass locally.

@ca-ruz

ca-ruz commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ermeme ermeme Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: approved

The current head addresses the previous feedback: input truncation now walks grapheme boundaries, adds unicode-segmentation as a direct dependency, and includes focused helper tests plus a TestBackend render regression for the overflowing My Trades input.

I did not find blocking issues in the diff.

Verified locally on b5fd811e3243c3cd74adb7ecf37c40b1b1f3bc65:

  • cargo fmt --all -- --check
  • cargo test order_in_progress_tab::tests --all-features
  • cargo check --all-targets --all-features
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all-features

@arkanoider
arkanoider merged commit e90b980 into MostroP2P:main Aug 13, 2026
7 checks passed
amuntri added a commit to amuntri/mostrix that referenced this pull request Aug 13, 2026
Review findings on MostroP2P#114, all three verified against the code before fixing:

1. Security (CodeRabbit): the restore response sender was discarded. Unlike
   the order flows there is no random request_id an attacker cannot know —
   new_restore sends none — so on GiftWrap, where the subscription cannot
   filter by author (ephemeral wrap signers), a forged identity-encrypted
   RestoreData could seed attacker-controlled orders and advance
   last_trade_index. The response is now rejected unless the unwrapped
   sender is the configured Mostro pubkey.

2. Maker/taker (ermeme): restored rows all claimed taker. The exact
   inference suggested (trade pubkey vs buyer/seller pubkey) is not
   possible from public data — kind-38383 tags stop at the order terms —
   but the protocol allows a partial one: Pending / WaitingMakerBond
   orders exist only for their maker, so those now restore as maker.
   Genuinely ambiguous rows still fall back to taker, but are counted in
   the summary ("N order(s) restored with unknown maker/taker role") so
   the fallback is never silent.

3. UI projections (ermeme): the restore task rewrote SQLite but sent a
   plain Info result, which does not re-run the DB-to-UI sync — recovered
   orders stayed invisible until restart. The task now sends a dedicated
   OperationResult::SessionRestored, and apply_order_result runs the same
   startup sync pair (refresh_my_trades_maker_book_cache +
   sync_user_order_history_messages_from_db) before showing the popup.
   handle_operation_result normalizes the variant to Info for display.

Also rebased onto main (mergeable_state was dirty after MostroP2P#106/MostroP2P#112 landed).

Tests: role inference (maker-exclusive statuses vs ambiguous ones), the
resync trigger matrix, and summary wording for unknown roles.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

2 participants