Skip to content

fix(ui): add wallet alias trimming and 64-char length limit#624

Draft
thepastaclaw wants to merge 5 commits intodashpay:v1.0-devfrom
thepastaclaw:fix/wallet-alias-trim
Draft

fix(ui): add wallet alias trimming and 64-char length limit#624
thepastaclaw wants to merge 5 commits intodashpay:v1.0-devfrom
thepastaclaw:fix/wallet-alias-trim

Conversation

@thepastaclaw
Copy link
Collaborator

@thepastaclaw thepastaclaw commented Feb 22, 2026

Issue

Wallet alias input has no length limit and doesn't trim whitespace, which can lead to:

  • Excessively long wallet names that break UI layouts
  • Leading/trailing whitespace in wallet names
  • Wallets named with only spaces getting saved with whitespace instead of using the default name

Changes

src/ui/wallets/add_new_wallet_screen.rs:

  1. Trim whitespace before saving the wallet alias
  2. Enforce 64-character limit on the input field (truncates excess)
  3. Visual character counter appears when approaching the limit (N/64 shown when >50 chars)

Validation

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

Summary by CodeRabbit

Release Notes

  • New Features
    • Wallet names are now limited to 64 characters with dynamic character counter feedback.
    • Added helper message reminding users that blank names default to system-generated wallet names.
    • All wallet name inputs are automatically trimmed of whitespace for consistent formatting.

Trim whitespace from wallet aliases and enforce a 64-character
limit with a visual counter when approaching the limit.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

Warning

Rate limit exceeded

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

⌛ 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.

📥 Commits

Reviewing files that changed from the base of the PR and between b0d1b36 and 7cd3644.

📒 Files selected for processing (2)
  • src/ui/wallets/add_new_wallet_screen.rs
  • src/ui/wallets/wallets_screen/mod.rs
📝 Walkthrough

Walkthrough

This change enhances wallet name input validation and user experience by enforcing a 64-character limit, implementing consistent trimming logic, displaying a dynamic character counter, and adding a helper message about default wallet names.

Changes

Cohort / File(s) Summary
Wallet Name Input Validation
src/ui/wallets/add_new_wallet_screen.rs
Added trimmed\_alias variable for consistent empty validation; enforces hard 64-character limit on custom names via truncation; added UI helper message "Leave blank to use a default wallet name" and character count indicator ("/64") when input exceeds 50 characters.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

Hop along, dear code, with names so neat,
Sixty-four chars make input complete,
A counter ticks as the rabbit types,
No more too-long wallet names tonight,
Default awaits if you leave it bright! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main changes: adding wallet alias trimming and a 64-character length limit.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

🧹 Nitpick comments (1)
src/ui/wallets/add_new_wallet_screen.rs (1)

788-794: Prefer TextEdit::char_limit(64) over post-render truncation.

The current approach truncates alias_input after the widget has already rendered the updated text (line 790 runs first), so the 65th character flashes on screen for one frame before disappearing on the next repaint.

egui::TextEdit has a char_limit: usize field, and char_limit() "Restricts input to maximum number of characters", preventing over-limit characters from being accepted in the first place. This makes the manual check redundant.

♻️ Suggested refactor
-    ui.horizontal(|ui| {
-        ui.label("Wallet Name:");
-        ui.text_edit_singleline(&mut self.alias_input);
-    });
-    if self.alias_input.chars().count() > 64 {
-        self.alias_input = self.alias_input.chars().take(64).collect();
-    }
+    ui.horizontal(|ui| {
+        ui.label("Wallet Name:");
+        ui.add(egui::TextEdit::singleline(&mut self.alias_input).char_limit(64));
+    });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ui/wallets/add_new_wallet_screen.rs` around lines 788 - 794, Replace the
post-render truncation of self.alias_input with egui's built-in char limit: use
ui.add(egui::TextEdit::singleline(&mut self.alias_input).char_limit(64)) (or the
equivalent TextEdit::char_limit(64) builder) in place of
ui.text_edit_singleline(&mut self.alias_input), and remove the manual
check/assignment that trims self.alias_input.chars().take(64).collect(); this
prevents the 65th character flash and centralizes the limit in the TextEdit
widget.
🤖 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/wallets/add_new_wallet_screen.rs`:
- Around line 800-808: The counter visibility currently uses trimmed length
(computed via self.alias_input.trim().chars().count()) while the input is capped
at 64 characters untrimmed, allowing whitespace to fill the field without
triggering the counter; change the threshold check to use the untrimmed
character count (self.alias_input.chars().count()) for deciding when to show the
counter, but continue to display the trimmed count in the UI (so the label still
shows the effective saved length), keeping the 64-character enforcement as-is.
- Line 243: The rename dialog currently truncates the rename_input by bytes
which can panic on UTF-8 boundaries; replace the byte-truncation in the rename
dialog handling (field self.rename_input inside the rename dialog code in
wallets_screen mod) with a char-boundary-safe truncation that builds a new
String from the first 64 chars (use chars().take(64).collect into a new String)
and then assign that new String back to self.rename_input so no truncate() on a
possibly-mid-character byte index is used.

---

Nitpick comments:
In `@src/ui/wallets/add_new_wallet_screen.rs`:
- Around line 788-794: Replace the post-render truncation of self.alias_input
with egui's built-in char limit: use ui.add(egui::TextEdit::singleline(&mut
self.alias_input).char_limit(64)) (or the equivalent TextEdit::char_limit(64)
builder) in place of ui.text_edit_singleline(&mut self.alias_input), and remove
the manual check/assignment that trims
self.alias_input.chars().take(64).collect(); this prevents the 65th character
flash and centralizes the limit in the TextEdit widget.

@PastaPastaPasta
Copy link
Member

Coderabbit has feedback + I don't think we should trim to 64, we should reject above 64

@thepastaclaw
Copy link
Collaborator Author

Addressed in 7cd3644:

  • Switched add-wallet name input to TextEdit::char_limit(64) so over-limit input is rejected at entry.
  • Kept defensive validation in create path to reject >64 (no truncation).
  • Updated counter behavior per CodeRabbit: use raw count for threshold visibility, display trimmed count.

Validation run:

  • cargo test -p dash-evo-tool --lib (259 passed, 0 failed, 1 ignored)
  • pre-commit: cargo fmt --all -- --check, cargo check (both passed)

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

Image

Seems to work fine, limits to 64, trims whitespace

a strange behavior; a user can have two wallets with same name; but that's not related to this I don't think

@thepastaclaw thepastaclaw marked this pull request as draft February 25, 2026 08:22
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.

3 participants