From 79e33eccc0e0d3d970f15209c4770c709a9d4acd Mon Sep 17 00:00:00 2001 From: vybe Date: Thu, 21 May 2026 07:04:29 +0000 Subject: [PATCH] fix: capture intended toggle action at click time to avoid stale isConnected in error toast Store _pendingToggleAction before starting toggleProcess. Use it in onExited instead of live root.isConnected. Prevents 'Failed to disconnect' when user actually clicked connect. Fixes #14 --- tailscalectl/TailscaleWidget.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tailscalectl/TailscaleWidget.qml b/tailscalectl/TailscaleWidget.qml index 82d027b..9678cac 100644 --- a/tailscalectl/TailscaleWidget.qml +++ b/tailscalectl/TailscaleWidget.qml @@ -12,6 +12,7 @@ PluginComponent { property bool isConnected: false property string tailscaleIP: "" + property string _pendingToggleAction: "" property string currentExitNode: "" property var peers: [] property string cachedClipboardTool: "" @@ -41,10 +42,11 @@ PluginComponent { onExited: (code, status) => { if (code !== 0) { - var action = root.isConnected ? "disconnect" : "connect" + var action = root._pendingToggleAction || (root.isConnected ? "disconnect" : "connect") var detail = toggleProcess.stderr.text.trim().slice(0, 120) ToastService.showError("tailscalectl", TailscaleLib.errorMessage(action) + (detail ? " — " + detail : "")) } + root._pendingToggleAction = "" statusCheck.running = true } } @@ -112,6 +114,7 @@ PluginComponent { } function toggleTailscale() { + root._pendingToggleAction = root.isConnected ? "disconnect" : "connect" toggleProcess.command = TailscaleLib.buildToggleCommand(root.isConnected) toggleProcess.running = true }