From 2b3b45ccfa7d6d28237d405857a7953e900584e5 Mon Sep 17 00:00:00 2001 From: vybe Date: Fri, 22 May 2026 10:20:27 +0000 Subject: [PATCH] =?UTF-8?q?refactor:=20simplify=20copy=20path=20=E2=80=94?= =?UTF-8?q?=20drop=20caching=20and=20multi-tool=20retry=20state=20machine,?= =?UTF-8?q?=20keep=20simple=20dms=E2=86=92wl-copy=20fallback=20(first-prin?= =?UTF-8?q?ciples=20plan)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tailscalectl/TailscaleWidget.qml | 29 ++++++++++------------------- tailscalectl/lib.js | 3 ++- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/tailscalectl/TailscaleWidget.qml b/tailscalectl/TailscaleWidget.qml index fd77bb4..04b3a7e 100644 --- a/tailscalectl/TailscaleWidget.qml +++ b/tailscalectl/TailscaleWidget.qml @@ -14,10 +14,8 @@ PluginComponent { property string tailscaleIP: "" property string currentExitNode: "" property var peers: [] - property string cachedClipboardTool: "" property string _copyText: "" property string _copyCurrentTool: "" - property int _copyAttempted: 0 property bool _pendingToggle: false // transient one-shot for post-action verification (to be removed in first-principles refactor) layerNamespacePlugin: "tailscalectl" @@ -51,17 +49,14 @@ PluginComponent { onExited: (code, status) => { if (code === 0) { - root.cachedClipboardTool = root._copyCurrentTool - ToastService.showInfo("Copied " + root._copyText + " to clipboard") + ToastService.showInfo(TailscaleLib.getStrings().copied(root._copyText)) + } else if (root._copyCurrentTool === "dms") { + // One simple fallback attempt: try wl-copy. + root._copyCurrentTool = "wl-copy" + root._executeCopy() } else { - root._copyAttempted += 1 - if (root._copyAttempted < TailscaleLib.allClipboardTools().length) { - root._copyCurrentTool = TailscaleLib.nextClipboardTool(root._copyCurrentTool) - root._executeCopy() - } else { - var detail = copyProcess.stderr.text.trim().slice(0, 120) - ToastService.showError("tailscalectl", "No clipboard tool found" + (detail ? " — " + detail : "")) - } + var detail = copyProcess.stderr.text.trim() + ToastService.showError("tailscalectl", TailscaleLib.formatError("clipboard", detail)) } } } @@ -124,19 +119,15 @@ PluginComponent { function copyToClipboard(text) { root._copyText = text - root._copyAttempted = 0 - if (root.cachedClipboardTool) { - root._copyCurrentTool = root.cachedClipboardTool - } else { - root._copyCurrentTool = TailscaleLib.allClipboardTools()[0] - } + // Simple two-tool fallback per first-principles plan: dms first, then wl-copy. + root._copyCurrentTool = "dms" root._executeCopy() } function _executeCopy() { var cmd = TailscaleLib.buildCopyCommand(root._copyText, root._copyCurrentTool) if (!cmd) { - ToastService.showError("tailscalectl", "Invalid clipboard command") + ToastService.showError("tailscalectl", TailscaleLib.formatError("clipboard")) return } copyProcess.command = cmd diff --git a/tailscalectl/lib.js b/tailscalectl/lib.js index b675532..86efe02 100644 --- a/tailscalectl/lib.js +++ b/tailscalectl/lib.js @@ -115,7 +115,8 @@ function errorMessage(cmd) { "down": "Failed to disconnect from Tailscale", "disconnect": "Failed to disconnect from Tailscale", "set": "Failed to set exit node", - "status": "Failed to read Tailscale status" + "status": "Failed to read Tailscale status", + "clipboard": "Error copying to clipboard" }; return messages[cmd] || "Tailscale command failed"; }