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.
TypeScript ai-meeting-assistantai-notetakerelectrongranola-alternativelinuxllama-cpplocal-ailocal-firstmacosmcpmeeting-minutesmeeting-notesoffline-firstopen-sourceprivacyspeech-to-texttranscriptionwhisperwhisper-cppwindows
Call names (Teams on Mac): say when a popup hides the rest of the Teams page, take Teams' not-implemented answer to the tree ask as final, and picture every Teams window in the log, minimised ones marked, with how many windows the Mac shows for it (#138)
christianmat2041970fdb55
diff --git a/app/native/yogurt-mac/main.swift b/app/native/yogurt-mac/main.swiftindex 940aafa5..3f56422b 100644--- a/app/native/yogurt-mac/main.swift+++ b/app/native/yogurt-mac/main.swift@@ -234,9 +234,10 @@ func askTree(_ app: AXUIElement, _ r: NSRunningApplication, force: Bool = false)// animations in that app, so it is turned back off when the watch ends (resetTrees).let asked = AXUIElementSetAttributeValue(app, "AXEnhancedUserInterface" as CFString, kCFBooleanTrue)if asked == .success { enhanced.append(r.processIdentifier) }- // a busy app (Teams joining a call) can time out: it is asked again on the next reading until it answers- if manual == .success || asked == .success { askedTree.insert(r.processIdentifier) }- else { lastControlLook = "asking for the tree failed (\(asked.rawValue))" }+ // A busy app (Teams joining a call) can time out: it is asked again on the next reading until it answers. The new Teams+ // answers neither ask (not implemented) and builds its page anyway, so that answer is final and not worth a log (#138).+ if manual == .cannotComplete && asked == .cannotComplete { lastControlLook = "asking for the tree timed out" }+ else { askedTree.insert(r.processIdentifier) }}/// the browsers asked with AXEnhancedUserInterface, to turn it back off when the watch ends@@ -340,6 +341,15 @@ func hasCallControl(_ w: AXUIElement, budget: Int = 1500) -> Bool {let e = queue.removeFirst(); left -= 1let role = axText(axAttr(e, kAXRoleAttribute)) ?? ""if (role == "AXButton" || role == "AXMenuItem" || role == "AXCheckBox") && isCallControl(e) { return true }+ // Chromium hides the rest of a page from accessibility while a modal popup is open in it (aria-modal): a Teams call+ // with a popup open shows only the popup, never its Leave button (#138)+ if role == "AXWebArea", let kids = axAttr(e, kAXChildrenAttribute) as? [AXUIElement], kids.count == 1 {+ let classes = (axAttr(kids[0], "AXDOMClassList") as? [String]) ?? []+ let sub = axText(axAttr(kids[0], kAXSubroleAttribute)) ?? ""+ if sub == "AXApplicationDialog" || sub == "AXDialog" || classes.contains(where: { $0.contains("Popover") || $0.contains("Dialog") }) {+ if !note.contains("page shows only a popup") { note += "; page shows only a popup" }+ }+ }if role == "AXWebArea" && err != .success && pages < 2 {pages += 1let (pageErr, pageButtons) = searchButtons(e)@@ -407,6 +417,30 @@ func owningApp(_ pid: pid_t, ids: [String]) -> NSRunningApplication? {return nil}+/// Every window of an app that showed no call, for the log: the ones accessibility lists, any it lists only as the app's+/// children, minimised ones marked, and how many normal windows the Mac itself has for the app (other Spaces, minimised),+/// so a call in a window accessibility leaves out shows (#138)+func missedWindows(_ app: AXUIElement, _ pid: pid_t) -> (windows: [[String: Any]], mac: Int) {+ var all = (axAttr(app, kAXWindowsAttribute) as? [AXUIElement]) ?? []+ for k in (axAttr(app, kAXChildrenAttribute) as? [AXUIElement]) ?? [] where axText(axAttr(k, kAXRoleAttribute)) == "AXWindow" && !all.contains(where: { CFEqual($0, k) }) {+ all.append(k)+ }+ var budget = 1500+ let windows = all.prefix(6).map { w -> [String: Any] in+ var x: [String: Any] = ["tree": axCopy(w, depth: 0, maxDepth: 40, budget: &budget, zoom: false)]+ if let title = axText(axAttr(w, kAXTitleAttribute)) { x["title"] = title }+ if (axAttr(w, kAXMinimizedAttribute) as? Bool) == true { x["minimized"] = true }+ return x+ }+ let info = (CGWindowListCopyWindowInfo([.optionAll, .excludeDesktopElements], kCGNullWindowID) as? [[String: Any]]) ?? []+ let mac = info.filter { w in+ guard (w[kCGWindowOwnerPID as String] as? Int) == Int(pid), (w[kCGWindowLayer as String] as? Int) == 0 else { return false }+ let b = w[kCGWindowBounds as String] as? [String: Any]+ return ((b?["Width"] as? Double) ?? 0) > 100 && ((b?["Height"] as? Double) ?? 0) > 100+ }.count+ return (windows, mac)+}+func watchCalls(every: Int, ids: [String], pids: [pid_t] = []) {// Yogurt closes stdin to stop the watch (and a crashed Yogurt closes it too)DispatchQueue.global().async { _ = FileHandle.standardInput.readDataToEndOfFile(); DispatchQueue.main.sync { resetTrees() }; exit(0) }@@ -431,14 +465,14 @@ func watchCalls(every: Int, ids: [String], pids: [pid_t] = []) {let running = (pids.isEmpty ? ids.compactMap { NSRunningApplication.runningApplications(withBundleIdentifier: $0).first } : pids.compactMap { owningApp($0, ids: ids) }).sorted { a, _ in a.processIdentifier == front }var found: (NSRunningApplication, AXUIElement, [AXUIElement], String?)?- var teams: (String, AXUIElement)?+ var teams: (String, AXUIElement, pid_t)?for r in running {let app = AXUIElementCreateApplication(r.processIdentifier)AXUIElementSetMessagingTimeout(app, 0.3)askTree(app, r)let (wins, tab) = callWindows(app, r.bundleIdentifier ?? "")if !wins.isEmpty { found = (r, app, wins, tab); break }- if teams == nil, let id = r.bundleIdentifier, id.hasPrefix("com.microsoft.teams") { teams = (id, app) }+ if teams == nil, let id = r.bundleIdentifier, id.hasPrefix("com.microsoft.teams") { teams = (id, app, r.processIdentifier) }}if let (target, app, wins, tab) = found, let id = target.bundleIdentifier {askTree(app, target, force: true)@@ -465,16 +499,11 @@ func watchCalls(every: Int, ids: [String], pids: [pid_t] = []) {} else {// which windows were looked at and how, so a log can say why a call was missed (#111)var o: [String: Any] = ["t": t, "error": running.isEmpty ? "not-running" : lastControlLook.isEmpty ? "no-call-window" : "no-call-window (\(lastControlLook))"]- if let (id, app) = teams {+ if let (id, app, pid) = teams {misses += 1if misses == 10 {- var budget = 1500- o["app"] = id- o["windows"] = ((axAttr(app, kAXWindowsAttribute) as? [AXUIElement]) ?? []).prefix(4).map { w -> [String: Any] in- var x: [String: Any] = ["tree": axCopy(w, depth: 0, maxDepth: 40, budget: &budget, zoom: false)]- if let title = axText(axAttr(w, kAXTitleAttribute)) { x["title"] = title }- return x- }+ let (windows, mac) = missedWindows(app, pid)+ o["app"] = id; o["windows"] = windows; o["macWindows"] = mac}}line(o)diff --git a/app/src/main/callNames/index.ts b/app/src/main/callNames/index.tsindex 865fd9e7..1e089bcc 100644--- a/app/src/main/callNames/index.ts+++ b/app/src/main/callNames/index.ts@@ -12,7 +12,8 @@ import { readCall, summarize, type AxWindow, type CallKind } from './parse'*//** what yogurt-mac call-watch prints each time it reads: the call windows, or why it could not */-export type WatchLine = { t: number; app?: string; windows?: AxWindow[]; error?: string }+/** macWindows: how many normal windows of the app the Mac itself shows, beside the ones accessibility lists (#138) */+export type WatchLine = { t: number; app?: string; windows?: AxWindow[]; error?: string; macWindows?: number }/** pids: read only these processes' windows (the call app's processes on the mic); none known, the app's frontmost with a call */export type Watch = (ids: string[], onLine: (l: WatchLine) => void, pids?: number[]) => { stop(): void }@@ -104,7 +105,7 @@ export function hookCallNames(p: {const why = l.error ?? 'nothing read'if (!s.errors.has(why)) { s.errors.add(why); log(`call names: ${why}${why === 'not-trusted' ? ' (no Accessibility permission): the other side stays Them' : ''}`) }// a call app with no call window sends its windows once, so the log shows what it gives when a call is missed (#138)- if (l.app && l.windows && !s.missPictured) { s.missPictured = true; log(`call names: no call window in ${l.app}, its windows in short:\n${summarize(l.windows)}`) }+ if (l.app && l.windows && !s.missPictured) { s.missPictured = true; log(`call names: no call window in ${l.app}${l.macWindows === undefined ? '' : ` (the Mac shows ${l.macWindows} of its windows)`}, its windows in short:\n${summarize(l.windows)}`) }s.samples.push({ t: l.t, speaking: [], participants: [], me: null, ok: false })return}diff --git a/app/src/main/callNames/parse.ts b/app/src/main/callNames/parse.tsindex bd218959..00596a83 100644--- a/app/src/main/callNames/parse.ts+++ b/app/src/main/callNames/parse.ts@@ -7,7 +7,7 @@/** one element of the tree as the helper copies it: role, subrole, description, title, value, identifier, DOM classes, size */export type AxNode = { r: string; s?: string; d?: string; t?: string; v?: string; i?: string; c?: string[]; w?: number; h?: number; k?: AxNode[] }-export type AxWindow = { title?: string; id?: string; tree: AxNode }+export type AxWindow = { title?: string; id?: string; tree: AxNode; minimized?: boolean }export type CallKind = 'zoom' | 'teams' | 'meet' | 'webex'/** byMute: `speaking` is only the one other person not muted (Teams meetings mark nobody), not a mark of the app */export type CallReading = { speaking: string[]; participants: string[]; me: string | null; byMute?: boolean }@@ -440,7 +440,7 @@ export function summarize(windows: AxWindow[], max = 60): string {const roles = new Map<string, number>()const lines: string[] = []for (const w of windows) {- lines.push(`window "${redact(w.title ?? '')}"${w.id ? ` id=${w.id}` : ''}`)+ lines.push(`window "${redact(w.title ?? '')}"${w.id ? ` id=${w.id}` : ''}${w.minimized ? ' minimized' : ''}`)walk(w.tree, (n, up) => {roles.set(n.r, (roles.get(n.r) ?? 0) + 1)const said = texts(n).map(redact)diff --git a/app/test/callNames.test.ts b/app/test/callNames.test.tsindex 2ee66a80..7184c539 100644--- a/app/test/callNames.test.ts+++ b/app/test/callNames.test.ts@@ -357,12 +357,18 @@ describe('hookCallNames', () => {s.start()const windows = [{ title: 'Chat | Dana Smith | Microsoft Teams', tree: { r: 'AXWindow', k: [{ r: 'AXGroup', k: [{ r: 'AXButton', d: 'Dana Smith' }] }] } }]for (let t = 1_000_000; t < 1_002_000; t += 500) s.emit({ t, error: 'no-call-window (search unavailable)', app: 'com.microsoft.teams2', windows })- const pictured = s.logs.filter((l) => l.startsWith('call names: no call window in com.microsoft.teams2, its windows in short:'))+ const pictured = s.logs.filter((l) => l.startsWith('call names: no call window in com.microsoft.teams2') && l.includes('its windows in short:'))expect(pictured).toHaveLength(1)expect(pictured[0]).toContain('AXButton')expect(s.logs.join('\n')).not.toContain('Dana Smith')expect(s.logs.filter((l) => l === 'call names: no-call-window (search unavailable)')).toHaveLength(1)})+ it('says how many windows the Mac shows for Teams next to the ones it pictures, so a window accessibility leaves out shows (#138)', () => {+ const s = setup({ app: 'Teams' })+ s.start()+ s.emit({ t: 1_000_000, error: 'no-call-window', app: 'com.microsoft.teams2', windows: [{ title: 'Microsoft Teams', tree: { r: 'AXWindow' } }], macWindows: 3 })+ expect(s.logs.some((l) => l.startsWith('call names: no call window in com.microsoft.teams2 (the Mac shows 3 of its windows), its windows in short:'))).toBe(true)+ })it('a meeting in an app it can\'t read starts no watch', async () => {const s = setup({ app: 'FaceTime' })diff --git a/app/test/callParse.test.ts b/app/test/callParse.test.tsindex 66f125ad..5564e781 100644--- a/app/test/callParse.test.ts+++ b/app/test/callParse.test.ts@@ -359,4 +359,9 @@ describe('summarize: a short picture of the tree for the log', () => {expect(s).toContain('window "Meet - ‹12›"')expect(s).not.toContain('abc-defg-hij')})+ it('says which windows are minimised, so a call hidden in one shows in the log (#138)', () => {+ const s = summarize([{ ...win(node('AXWindow', {}), 'Microsoft Teams'), minimized: true }, win(node('AXWindow', {}), 'Microsoft Teams')])+ expect(s).toContain('window "Microsoft Teams" minimized')+ expect(s.split('\n').filter((l) => l.startsWith('window ') && !l.includes('minimized'))).toHaveLength(1)+ })})diff --git a/app/test/macTeamsTree.test.ts b/app/test/macTeamsTree.test.tsindex 972c4974..1cfd317b 100644--- a/app/test/macTeamsTree.test.ts+++ b/app/test/macTeamsTree.test.ts@@ -59,4 +59,19 @@ describe('call-watch on the Teams desktop app (#111)', () => {const loop = swift.slice(swift.indexOf('func watchCalls'))expect(loop).toMatch(/"error": [\s\S]*"windows"/)})+ it("takes Teams' not-implemented answer to the ask as final: only a busy Teams is asked again, so the log is not stuck on it (#138)", () => {+ const ask = swift.slice(swift.indexOf('func askTree'), swift.indexOf('func resetTrees'))+ expect(ask).toContain('.cannotComplete')+ })+ it('pictures every Teams window, minimised ones and ones only listed as children of the app too, and counts what the Mac shows (#138)', () => {+ const dump = swift.slice(swift.indexOf('func missedWindows'), swift.indexOf('func watchCalls'))+ expect(dump).toContain('kAXMinimizedAttribute')+ expect(dump).toContain('kAXChildrenAttribute')+ expect(dump).toContain('CGWindowListCopyWindowInfo')+ expect(swift.slice(swift.indexOf('func watchCalls'))).toContain('missedWindows(')+ })+ it('says when the page shows only a popup, which hides the rest of the page from accessibility (#138)', () => {+ const look = swift.slice(swift.indexOf('func hasCallControl'), swift.indexOf('func isMeetTitle'))+ expect(look).toContain('page shows only a popup')+ })})