From 02da7132e76fe85c2662a7aac42cc6754fbe51e0 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 18:27:39 +0800 Subject: [PATCH] Fix: note dialog not shown when closing session from reconnecting screen (#14528) * Initial plan * Fix: show ask-for-note dialog when user clicks OK on reconnecting screen (#14527) Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com> * fix: don't clear audit_guid during reconnect, clear it after connection established Signed-off-by: 21pages --------- Signed-off-by: 21pages Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com> Co-authored-by: 21pages --- flutter/lib/models/model.dart | 20 ++++++++++++++++---- src/ui_session_interface.rs | 6 ++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index de41a2a78..4533f11fa 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -1016,19 +1016,31 @@ class FfiModel with ChangeNotifier { showMsgBox(SessionID sessionId, String type, String title, String text, String link, bool hasRetry, OverlayDialogManager dialogManager, {bool? hasCancel}) async { - final showNoteEdit = parent.target != null && + final noteAllowed = parent.target != null && allowAskForNoteAtEndOfConnection(parent.target, false) && - (title == "Connection Error" || type == "restarting") && - !hasRetry; + (title == "Connection Error" || type == "restarting"); + final showNoteEdit = noteAllowed && !hasRetry; if (showNoteEdit) { await showConnEndAuditDialogCloseCanceled( ffi: parent.target!, type: type, title: title, text: text); closeConnection(); } else { + VoidCallback? onSubmit; + if (noteAllowed && hasRetry) { + final ffi = parent.target!; + onSubmit = () async { + _timer?.cancel(); + _timer = null; + await showConnEndAuditDialogCloseCanceled( + ffi: ffi, type: type, title: title, text: text); + closeConnection(); + }; + } msgBox(sessionId, type, title, text, link, dialogManager, hasCancel: hasCancel, reconnect: hasRetry ? reconnect : null, - reconnectTimeout: hasRetry ? _reconnects : null); + reconnectTimeout: hasRetry ? _reconnects : null, + onSubmit: onSubmit); } _timer?.cancel(); if (hasRetry) { diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index 9ea0cba5b..be1895e64 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -1289,8 +1289,7 @@ impl Session { drop(connection_round_state_lock); let cloned = self.clone(); - *cloned.audit_guid.lock().unwrap() = String::new(); - *cloned.last_audit_note.lock().unwrap() = String::new(); + // override only if true if true == force_relay { self.lc.write().unwrap().force_relay = true; @@ -1813,6 +1812,9 @@ impl Interface for Session { ); } self.update_privacy_mode(); + // Clear audit_guid when connection is established successfully + *self.audit_guid.lock().unwrap() = String::new(); + *self.last_audit_note.lock().unwrap() = String::new(); // Save recent peers, then push event to flutter. So flutter can refresh peer page. self.lc.write().unwrap().handle_peer_info(&pi); self.set_peer_info(&pi);