@@ -881,6 +881,8 @@ impl App for Skrepka {
881881 }
882882 }
883883 Event::AddContact { input, nickname } => {
884+ // Clear a stale error from a previous failed add.
885+ model.error = None;
884886 // A nickname is stored in the contacts kv blob, which is
885887 // rewritten in full on every change. An unbounded nickname
886888 // bloats the blob and every subsequent write.
@@ -3354,6 +3356,28 @@ mod tests {
33543356 assert!(m.error.is_some());
33553357 }
33563358
3359+ /// A stale error from a previous failed add is cleared on the next attempt,
3360+ /// so the AddContact form does not show an old error after the user fixes
3361+ /// the input and tries again.
3362+ #[test]
3363+ fn add_contact_clears_a_stale_error_on_success() {
3364+ let app = Skrepka;
3365+ let mut m = with_identity();
3366+ m.error = Some("invalid public key".into());
3367+
3368+ let peer = peer_hex(9);
3369+ let _ = app.update(
3370+ Event::AddContact {
3371+ input: peer.clone(),
3372+ nickname: "Bob".into(),
3373+ },
3374+ &mut m,
3375+ );
3376+
3377+ assert!(m.error.is_none(), "a successful add clears the stale error");
3378+ assert!(m.contacts.contains_key(&peer));
3379+ }
3380+
33573381 #[test]
33583382 fn send_text_enqueues_message_profile_and_outbox() {
33593383 let app = Skrepka;