From a5bd4c699e4d577f40014c871e846a209978d8e4 Mon Sep 17 00:00:00 2001 From: IQBAL HASAN Date: Sun, 6 Sep 2026 09:14:52 +0600 Subject: [PATCH] fix: paste into terminals that expose no accessibility element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Terminals like Warp and Ghostty expose no AX tree, so neither the system-wide nor the app-level AXFocusedUIElement lookup returns anything and dictation kept diverting to the clipboard. When no focused element can be resolved, paste into the frontmost app instead of copying — unless that app is EchoType itself or the Finder (desktop), which are never text targets. Log the frontmost app name for diagnosis. Bump to 1.0.6. --- CHANGELOG.md | 6 ++++++ Resources/Info.plist | 4 ++-- Sources/EchoType/Paster.swift | 20 ++++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 230e257..4c4f93c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.6] - 2026-09-06 + +### Fixed + +- Dictation not pasting into terminals that expose no accessibility tree (e.g. Warp, Ghostty), where no focused element can be resolved at all. The transcript is now pasted into the frontmost app in that case, instead of being diverted to the clipboard — unless the frontmost app is EchoType itself or the Finder/desktop. The frontmost app name is logged. + ## [1.0.5] - 2026-09-06 ### Fixed diff --git a/Resources/Info.plist b/Resources/Info.plist index 7755bd5..f189d17 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleVersion - 1.0.5 + 1.0.6 LSMinimumSystemVersion 14.0 LSUIElement diff --git a/Sources/EchoType/Paster.swift b/Sources/EchoType/Paster.swift index 33725bc..83acbe6 100644 --- a/Sources/EchoType/Paster.swift +++ b/Sources/EchoType/Paster.swift @@ -75,10 +75,26 @@ enum Paster { /// fall through to the clipboard. Poorly-accessible apps (terminals like /// Warp/Ghostty) expose an opaque focused view — treat that as a text target /// rather than losing the paste, matching pre-1.0.3 behavior. + // Apps whose "focus" is never a text target; dictating here goes to the + // clipboard rather than pasting into nothing. + private static let nonTextBundleIDs: Set = [ + "com.apple.finder", + ] + private static func hasTextTarget() -> Bool { guard let axElement = focusedElement() else { - Log.write("paste: no focused element — copying to clipboard") - return false + // Some terminals (Warp, Ghostty) expose no accessibility element at + // all. Rather than lose the paste, type into the frontmost app unless + // it is our own app or a known non-text app (the desktop/Finder). + let front = NSWorkspace.shared.frontmostApplication + let bundleID = front?.bundleIdentifier ?? "?" + let name = front?.localizedName ?? "?" + if bundleID == Bundle.main.bundleIdentifier || nonTextBundleIDs.contains(bundleID) { + Log.write("paste: no focused element, frontmost=\(name) — copying to clipboard") + return false + } + Log.write("paste: no focused element, frontmost=\(name) — pasting anyway") + return true } var role = ""