fix: profile bio guideline text and unsaved changes dialog#554
Conversation
The PROFILE_GUIDELINES_INFO_TEXT said bios were limited to 250 characters, but the actual validation enforces 140 characters, the error message says 140, and the character counter shows /140. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When canceling profile editing with unsaved changes, show a ConfirmationDialog asking the user to confirm discarding changes instead of silently discarding them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdded a confirmation dialog to ProfileScreen to prevent discarding unsaved profile edits; pressing Cancel with unsaved changes now shows a Discard/Keep Editing prompt. Also reduced the bio guideline length from 250 to 140 characters. Changes
Sequence DiagramsequenceDiagram
actor User
participant ProfileScreen
participant ConfirmationDialog
User->>ProfileScreen: Press Cancel (with unsaved changes)
ProfileScreen->>ProfileScreen: Detect unsaved changes
ProfileScreen->>ConfirmationDialog: Create dialog ("Discard"/"Keep Editing")
ProfileScreen->>User: Render confirmation dialog
alt User selects Discard
User->>ConfirmationDialog: Click "Discard"
ConfirmationDialog->>ProfileScreen: Return Confirm
ProfileScreen->>ProfileScreen: cancel_editing()
ProfileScreen->>ProfileScreen: Clear confirmation_dialog
else User selects Keep Editing
User->>ConfirmationDialog: Click "Keep Editing"
ConfirmationDialog->>ProfileScreen: Return Cancel
ProfileScreen->>ProfileScreen: Clear confirmation_dialog
ProfileScreen->>User: Resume editing
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/ui/dashpay/profile_screen.rs (1)
900-909:⚠️ Potential issue | 🟡 MinorCancel button in wallet-locked branch bypasses the unsaved changes confirmation.
The Cancel button here calls
self.cancel_editing()directly, while the Cancel button in the normal (unlocked) branch at Line 950 shows the confirmation dialog whenhas_unsaved_changesis true. A user could have unsaved edits and then encounter the locked-wallet state, losing changes without confirmation.Proposed fix: apply the same guard
ui.horizontal(|ui| { if ui.button("Cancel").clicked() { - self.cancel_editing(); + if self.has_unsaved_changes { + self.confirmation_dialog = Some( + ConfirmationDialog::new( + "Discard Changes?", + "You have unsaved profile changes. Are you sure you want to discard them?", + ) + .confirm_text(Some("Discard")) + .cancel_text(Some("Keep Editing")) + .danger_mode(true), + ); + } else { + self.cancel_editing(); + } }Alternatively, extract the cancel-with-guard logic into a helper to avoid duplication.
🧹 Nitpick comments (1)
src/ui/dashpay/profile_screen.rs (1)
1355-1369: Nit: simplify withif letto avoid theunwrap.Line 1357 uses
.is_some()+.as_mut().unwrap(). While safe,if letis more idiomatic.Suggested refactor
- if self.confirmation_dialog.is_some() { - let dialog = self.confirmation_dialog.as_mut().unwrap(); - let response = dialog.show(ui); - match response.inner.dialog_response { - Some(ConfirmationStatus::Confirmed) => { - self.confirmation_dialog = None; - self.cancel_editing(); - } - Some(ConfirmationStatus::Canceled) => { - self.confirmation_dialog = None; - } - None => {} + if let Some(dialog) = self.confirmation_dialog.as_mut() { + let response = dialog.show(ui); + match response.inner.dialog_response { + Some(ConfirmationStatus::Confirmed) => { + self.confirmation_dialog = None; + self.cancel_editing(); + } + Some(ConfirmationStatus::Canceled) => { + self.confirmation_dialog = None; + } + None => {} } }
There was a problem hiding this comment.
Pull request overview
This PR updates the DashPay profile editing UI to (1) align the “Profile Guidelines” bio limit text with the already-enforced 140-character validation, and (2) prevent accidental loss of edits by adding a discard-changes confirmation dialog when canceling with unsaved changes.
Changes:
- Update
PROFILE_GUIDELINES_INFO_TEXTto state bios are limited to 140 characters. - Add
ConfirmationDialogflow when canceling profile edits with unsaved changes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…atic if-let - The Cancel button in the wallet_locked branch now shows the same confirmation dialog as the normal Cancel path when there are unsaved profile changes, preventing silent data loss. - Replace is_some() + unwrap() pattern with idiomatic if let Some(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
PROFILE_GUIDELINES_INFO_TEXTsaid bios were limited to 250 characters, but the actual validation enforces 140 characters, the error message says 140, and the character counter shows/140. Fixed the guideline text to match.ConfirmationDialognow asks the user to confirm discarding changes instead of silently discarding them (resolves a TODO that was in the code).Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Changes