Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Call names (Teams on Mac): ask Teams for its accessibility tree before looking for its call window, since its Leave and Mute buttons only show once asked (#111: no-call-window, no names)

christianmat9bc89bdf211f
diff --git a/app/native/yogurt-mac/main.swift b/app/native/yogurt-mac/main.swift
index 6b94bd68..dd307e32 100644
--- a/app/native/yogurt-mac/main.swift
+++ b/app/native/yogurt-mac/main.swift
@@ -213,12 +213,22 @@ func browserTitle(_ id: String) -> String? {
* Who is in a call and who is talking, as the call app shows it: its meeting windows copied out of the accessibility
* tree, read-only (nothing is clicked or changed in the app). Only the call app Yogurt was told about, the frontmost
* one first. Yogurt reads the tree (src/main/callNames/parse.ts). Chromium and Electron build a page's tree only when
- * an assistive app asks, so they are asked the way screen readers do (AXManualAccessibility), and only for a call window.
+ * an assistive app asks, so they are asked the way screen readers do (AXManualAccessibility): see askTree.
*/
let axKeys = [kAXRoleAttribute, kAXSubroleAttribute, kAXDescriptionAttribute, kAXTitleAttribute, kAXValueAttribute, kAXIdentifierAttribute, "AXDOMClassList", kAXChildrenAttribute, kAXSizeAttribute] as [String]
let chromium: Set<String> = ["com.google.Chrome", "company.thebrowser.Browser", "com.brave.Browser", "com.microsoft.edgemac", "com.microsoft.teams", "com.microsoft.teams2"]
var askedTree = Set<pid_t>()
+/// Asks a Chromium or Electron app to build its page's accessibility tree, once per process. A browser is asked only
+/// once a window is a Meet call. Teams is asked before looking: a Teams window counts as a call only by its Leave or
+/// Mute button, and Teams shows those only once asked, so asking afterwards never finds a call (#111).
+func askTree(_ app: AXUIElement, _ r: NSRunningApplication, force: Bool = false) {
+ guard let id = r.bundleIdentifier, chromium.contains(id), !askedTree.contains(r.processIdentifier) else { return }
+ guard force || id.hasPrefix("com.microsoft.teams") else { return }
+ AXUIElementSetAttributeValue(app, "AXManualAccessibility" as CFString, kCFBooleanTrue)
+ askedTree.insert(r.processIdentifier)
+}
+
func axAttr(_ e: AXUIElement, _ name: String) -> AnyObject? {
var v: AnyObject?
return AXUIElementCopyAttributeValue(e, name as CFString, &v) == .success ? v : nil
@@ -337,14 +347,12 @@ func watchCalls(every: Int, ids: [String]) {
for r in running {
let app = AXUIElementCreateApplication(r.processIdentifier)
AXUIElementSetMessagingTimeout(app, 0.3)
+ askTree(app, r)
let wins = callWindows(app, r.bundleIdentifier ?? "")
if !wins.isEmpty { found = (r, app, wins); break }
}
if let (target, app, wins) = found, let id = target.bundleIdentifier {
- if chromium.contains(id) && !askedTree.contains(target.processIdentifier) {
- AXUIElementSetAttributeValue(app, "AXManualAccessibility" as CFString, kCFBooleanTrue)
- askedTree.insert(target.processIdentifier)
- }
+ askTree(app, target, force: true)
let zoom = id == "us.zoom.xos"
var budget = zoom ? 1500 : 4000
let out = wins.prefix(4).map { w -> [String: Any] in
diff --git a/app/test/macTeamsTree.test.ts b/app/test/macTeamsTree.test.ts
new file mode 100644
index 00000000..9e3e4c18
--- /dev/null
+++ b/app/test/macTeamsTree.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+
+// The Mac helper is Swift; this pins the order that matters (#111). Teams shows its Leave and Mute buttons to
+// accessibility only once asked, and a Teams window counts as a call only when it has one of them, so the helper must
+// ask Teams for its tree before it looks for a call window there, not after it found one.
+const swift = readFileSync(join(__dirname, '../native/yogurt-mac/main.swift'), 'utf8')
+
+describe('call-watch on the Teams desktop app (#111)', () => {
+ it('asks Teams for its tree before looking for call controls', () => {
+ const loop = swift.slice(swift.indexOf('func watchCalls'))
+ const ask = loop.indexOf('askTree(')
+ const look = loop.indexOf('callWindows(app')
+ expect(ask).toBeGreaterThan(-1)
+ expect(ask).toBeLessThan(look)
+ expect(swift).toMatch(/func askTree[\s\S]*?hasPrefix\("com\.microsoft\.teams"\)/)
+ })
+})