feat: editorApps 白名单 — Sublime/XStudio/VSCode 等 AX 不透编辑器可激活

影响:之前 Sublime Text(AX 树只有 window chrome)、XStudio console 插件
(AXUnknown)、VSCode(Electron,AX 残)长按一律进 skip 分支;现在按 bundle 白名单
走 "AX 不透明" 兜底,与 HexHub 同款 app 级激活。

改动:
- 新增 editorApps: Set<String>(Sublime 4/3、TextEdit、VSCode、Atom、CotEditor、XStudio)
- 长按分支新增一层 let role, let b = bundle, editorApps.contains(b) → startRec()
- 日志加 "allow: editor whitelist <bundle> role=<r> (fallback)"

Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
adminandClaude Code committed 2026-10-07 12:18:06 +08:00
1 parent 63b41c9750
commit 87915bf7e3
1 file changed
+18
+18
View File
@@ -754,6 +754,19 @@ func appAtCursor(_ pt: CGPoint) -> (pid: pid_t, bundle: String?) {
// ---------- 微信过滤 + AX 输入框判定 ----------
let textRoles: Set<String> = ["AXTextField", "AXTextArea", "AXComboBox", "AXSearchField"]
// AX 树暴露不出编辑器(如 Sublime)或只给 AXUnknown(XStudio console 插件)的 app:
// 角色查得到但不是 textRoles 时,本应 skip,这里走白名单按"AX 不透明"兜底放行
// (按 AXWebArea 走不进文本子域、Safari Web 文本输入不在同列,单独处理见下)
let editorApps: Set<String> = [
"com.sublimetext.4", // Sublime Text 4(AX 树只有 window chrome)
"com.sublimetext.3",
"com.apple.TextEdit", // macOS 内置
"com.microsoft.VSCode", // VS Code(Electron,AX 树通常残)
"com.github.atom",
"com.coteditor.CotEditor",
"com.xstudio.ui", // XStudio(AXUnknown,console 插件是 Chromium webview)
]
func frontmostIsWeChat(_ bundle: String?) -> Bool {
bundle?.hasPrefix(weChatPrefix) == true
}
@@ -836,6 +849,11 @@ Thread.detachNewThread {
}
if let role, textRoles.contains(role) {
startRec()
} else if let role, let b = bundle, editorApps.contains(b) {
// AX 树不暴露编辑器小部件(Sublime)或只给 AXUnknown(XStudio console 插件),
// 按白名单当 AX 不透明走 app 级兜底激活
log("allow: editor whitelist \(b) role=\(role) (fallback)")
startRec()
} else if let role {
log("skip: role=\(role)")
state.v = .dead