From 9129edb725df4bbcd3359c6feb1669bf61469f22 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 9 Oct 2025 17:57:17 +0000
Subject: [PATCH] Add confirmation dialog for disconnect operation from context
menu
Co-authored-by: Kvarkas <3611964+Kvarkas@users.noreply.github.com>
---
mRemoteNG/Language/Language.Designer.cs | 9 +++++++
mRemoteNG/Language/Language.resx | 3 +++
.../UI/Controls/ConnectionContextMenu.cs | 25 +++++++++++++++++++
3 files changed, 37 insertions(+)
diff --git a/mRemoteNG/Language/Language.Designer.cs b/mRemoteNG/Language/Language.Designer.cs
index cf65e5501..e817c2317 100644
--- a/mRemoteNG/Language/Language.Designer.cs
+++ b/mRemoteNG/Language/Language.Designer.cs
@@ -1041,6 +1041,15 @@ namespace mRemoteNG.Resources.Language {
}
}
+ ///
+ /// Looks up a localized string similar to Are you sure you want to disconnect "{0}"?.
+ ///
+ internal static string ConfirmDisconnectConnection {
+ get {
+ return ResourceManager.GetString("ConfirmDisconnectConnection", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Are you sure you want to delete the credential record, {0}?.
///
diff --git a/mRemoteNG/Language/Language.resx b/mRemoteNG/Language/Language.resx
index 9fd319609..c76d522be 100644
--- a/mRemoteNG/Language/Language.resx
+++ b/mRemoteNG/Language/Language.resx
@@ -348,6 +348,9 @@
Are you sure you want to close the panel, "{0}"? Any connections that it contains will also be closed.
+
+ Are you sure you want to disconnect "{0}"?
+
Are you sure you want to delete the external tool, "{0}"?
diff --git a/mRemoteNG/UI/Controls/ConnectionContextMenu.cs b/mRemoteNG/UI/Controls/ConnectionContextMenu.cs
index 2bbbda36e..a2e5357ce 100644
--- a/mRemoteNG/UI/Controls/ConnectionContextMenu.cs
+++ b/mRemoteNG/UI/Controls/ConnectionContextMenu.cs
@@ -3,9 +3,12 @@ using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using mRemoteNG.App;
+using mRemoteNG.App.Info;
+using mRemoteNG.Config;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Container;
+using mRemoteNG.Properties;
using mRemoteNG.Tools;
using mRemoteNG.Tools.Clipboard;
using mRemoteNG.Tree;
@@ -13,6 +16,7 @@ using mRemoteNG.Tree.Root;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
using mRemoteNG.Security;
+using mRemoteNG.UI.TaskDialog;
// ReSharper disable UnusedParameter.Local
@@ -794,6 +798,27 @@ namespace mRemoteNG.UI.Controls
try
{
if (connectionInfo == null) return;
+
+ // Check if confirmation is needed based on settings
+ if (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All)
+ {
+ string confirmMessage = string.Format(Language.ConfirmDisconnectConnection, connectionInfo.Name);
+ DialogResult result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProductName,
+ confirmMessage, "", "", "",
+ Language.CheckboxDoNotShowThisMessageAgain,
+ ETaskDialogButtons.YesNo, ESysIcons.Question,
+ ESysIcons.Question);
+ if (CTaskDialog.VerificationChecked)
+ {
+ Settings.Default.ConfirmCloseConnection--;
+ }
+
+ if (result == DialogResult.No)
+ {
+ return; // User cancelled the disconnect
+ }
+ }
+
ContainerInfo nodeAsContainer = connectionInfo as ContainerInfo;
if (nodeAsContainer != null)
{