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
A Teams popup over the call no longer ends the recording, a call that goes on is offered again, and a network badge is never a name (#138)
christianmat97d92b3e6033
diff --git a/app/src/main/callNames/index.ts b/app/src/main/callNames/index.tsindex e423d89c..9cd1730d 100644--- a/app/src/main/callNames/index.ts+++ b/app/src/main/callNames/index.ts@@ -63,6 +63,8 @@ const RECENT_MS = 60_000const MAX_RESTARTS = 20/** changes of who talks written to the log, per meeting (enough to check a real call, never a flood) */const LOGGED_CHANGES = 30+/** how long after a stop by the call window a call coming back is still that call */+const LOOK_BACK_MS = 2 * 60_000type Sample = Omit<CallSample, 'ms'> & { t: number }type Session = { app: string | null; ids: string[]; pids?: number[]; heardAt: number; quietMs: number; restarts: number; samples: Sample[]; priorLines: Set<number>; watch?: { stop(): void }; everyApp: boolean; offset?: number; startedAt: number; pictured: boolean; missPictured?: boolean; picturedPeople?: boolean; picturedTalking?: boolean; errors: Set<string>; last: string; logged: number; /** a call window with people was read (Zoom, Teams) */ windowSeen?: CallKind; /** since when the readings say that window is gone, and the last one that said so */ goneSince?: number; goneAt?: number }@@ -113,8 +115,12 @@ export function hookCallNames(p: {// the call window gone: the reader looked and found none (or the app quit). Anything else (no permission, a slow// window) says nothing either way.const gone = !!l.error && (l.error.startsWith('no-call-window') || l.error === 'not-running')- if (gone && l.hidden) {- if (!s.errors.has('hidden')) { s.errors.add('hidden'); log('call names: the call window is out of sight (another desktop or full screen), not closed') }+ // A popup in the page (Teams' poor-network suggestion, #138) makes Chromium show only the popup, so no Leave button+ // is found, though the call window is still there. With the app still on the mic that is the call hidden, not over.+ const popup = gone && !!s.app && l.error!.includes('page shows only a popup') && (p.micPids?.(s.app).length ?? 0) > 0+ if (gone && (l.hidden || popup)) {+ const why = popup ? 'popup' : 'hidden'+ if (!s.errors.has(why)) { s.errors.add(why); log(popup ? 'call names: a popup covers the call window while the app holds the mic, not closed' : 'call names: the call window is out of sight (another desktop or full screen), not closed') }windowBack(s)}else if (gone && s.windowSeen) {@@ -172,7 +178,11 @@ export function hookCallNames(p: {try { s.watch = p.watch(s.ids, (l) => onLine(id, s, l), s.pids) } catch (e) { console.error('call names: the watch did not start', e) }}+ /** readers looking for a call that came back after its recording stopped (lookForCall) */+ const looks = new Set<() => void>()+p.onStart((m) => {+ for (const end of [...looks]) end()const ids = watchIds(m.app)const s: Session = { app: m.app, ids, heardAt: now(), quietMs: QUIET_MS, restarts: 0, everyApp: !m.app, samples: [], priorLines: new Set(p.store.segments(m.id, { hidden: true }).map((line) => line.id)), startedAt: m.resume ? m.resume.startedAt - m.resume.startMs : m.startedAt, pictured: false, errors: new Set(), last: '', logged: 0 }sessions.set(m.id, s)@@ -274,6 +284,32 @@ export function hookCallNames(p: {const fresh = s.goneSince !== undefined && s.goneAt !== undefined && now() - s.goneAt <= s.quietMsreturn { goneMs: fresh ? now() - s.goneSince! : 0 }},+ /**+ * After a recording stopped because its call window looked gone while the app still held the mic: the window read+ * again with people in it within `ms` means the call went on (#138), so `back` runs, once.+ */+ lookForCall(app: string, back: () => void, ms = LOOK_BACK_MS) {+ const ids = watchIds(app)+ if (!ids.length) return+ const since = now()+ let w: { stop(): void } | undefined, done = false+ const end = () => { if (done) return; done = true; looks.delete(end); clearTimeout(timer); w?.stop() }+ const timer = setTimeout(end, ms); timer.unref?.()+ looks.add(end)+ const pids = p.micPids?.(app)+ try {+ w = p.watch(ids, (l) => {+ if (done) return+ if (now() - since > ms) return end()+ if (l.error || !l.app || !l.windows) return+ const kind = kindFor(l.app, l.windows, app)+ if (!kind || !readCall(kind, l.windows).participants.length) return+ log(`call names: the ${kind} call window is back after the recording stopped`)+ end(); back()+ }, pids?.length ? pids : undefined)+ } catch (e) { console.error('call names: the watch did not start', e); end() }+ if (done) w?.stop()+ },/** resolves when the names after the meeting are in */finished: (id: string): Promise<void> => finals.get(id) ?? Promise.resolve(),}diff --git a/app/src/main/callNames/parse.ts b/app/src/main/callNames/parse.tsindex 190ec978..6074ad9d 100644--- a/app/src/main/callNames/parse.ts+++ b/app/src/main/callNames/parse.ts@@ -316,6 +316,8 @@ const TEAMS_UNMUTED = /^(?:unmuted|stummschaltung aufgehoben|nicht stummgeschaltconst TEAMS_HINT = /^(?:context menu is available|has context menu|kontextmenü ist verfügbar)$/i/** my own tile on a Mac starts with these words: "Myself video, Name, ..., Unmuted, Has context menu" (#138) */const TEAMS_MYSELF = /^myself video,\s*/i+/** status badges Teams puts before the name: "Myself video, Bad network connection indicator, Name, ..." (#138). Never a name. */+const TEAMS_BADGE = /^(?:[^,]*\b(?:network|connection|netzwerk|verbindung)\b[^,]*|[^,]*\bindicator|(?:raised hand|hand raised|pinned|spotlighted))\s*(?:,\s*|$)/i/** my own tile's label adds a short word after the name: "Christa, Ich" */const OWN_LABEL = /^(.+?),\s*(\p{L}{1,5})$/u@@ -323,7 +325,8 @@ const OWN_LABEL = /^(.+?),\s*(\p{L}{1,5})$/ufunction teamsTile(n: AxNode, alone: boolean): { name: string; speaking: boolean; me: boolean; muted: boolean | null } | null {const full = (n.t ?? n.d ?? '').normalize('NFKC').trim()const myself = TEAMS_MYSELF.test(full)- const label = full.replace(TEAMS_MYSELF, '')+ let label = full.replace(TEAMS_MYSELF, '')+ while (TEAMS_BADGE.test(label)) label = label.replace(TEAMS_BADGE, '')const inner: string[] = [], heads: string[] = []walk(n, (x) => {if (x === n) returndiff --git a/app/src/main/index.ts b/app/src/main/index.tsindex 783878b9..22894b26 100644--- a/app/src/main/index.ts+++ b/app/src/main/index.ts@@ -345,6 +345,7 @@ let micPidsNow: (app: string) => number[] = () => []* readers also say when the call window is just minimised or on another desktop, so that is never taken for the call* ending (#83: on Windows a recording started from the agenda never ended by itself) */let callWindowOf: (meetingId: string) => { goneMs: number } | null = () => null+let lookForCallOf: (app: string, back: () => void) => void = () => {}/** fake mode's hooks reach the store and the notes through these */let storeRef: Store | undefined@@ -377,6 +378,7 @@ function startDetection() {// fake mode: tests can shorten the gracegraceMs: isFake() && process.env.YOGURT_FAKE_CALL_GONE_MS ? Number(process.env.YOGURT_FAKE_CALL_GONE_MS) : CALL_GONE_MS,callWindow: (id) => callWindowOf(id),+ lookForCall: (m, back) => { if (m.app) lookForCallOf(m.app, back) },})onMeetingStop(() => { watcher.cleared() })const prompts = createPrompts({@@ -662,7 +664,10 @@ app.whenReady().then(() => {changed: (id) => { win?.webContents.send('transcript:speakers', id); sendWidgetTranscript('transcript:speakers', id); win?.webContents.send('meetings:changed'); notes.applyPeople(id) },onStart: onMeetingStart, onStop: onMeetingStop, onCapture: onCaptureStart, onBind: onMeetingBound, micPids: (app) => micPidsNow(app),})- if (process.platform === 'darwin' || process.platform === 'win32') callWindowOf = (id) => callNames.callWindow(id)+ if (process.platform === 'darwin' || process.platform === 'win32') {+ callWindowOf = (id) => callNames.callWindow(id)+ lookForCallOf = (app, back) => callNames.lookForCall(app, back)+ }// Windows and Linux: whisper left the graphics card in a meeting, so the speed check (timed with it) runs again next startonWhisperGpuOff(() => speedStore(speedFile()).forget())hookTranscription({ store, modelPath: () => setup.installed()?.asr, smallerModels: () => setup.installed()?.smallerAsr ?? [],diff --git a/app/src/main/watch.ts b/app/src/main/watch.tsindex 76845df3..371bda53 100644--- a/app/src/main/watch.ts+++ b/app/src/main/watch.ts@@ -26,6 +26,8 @@ export type WatchDeps = {graceMs?: number/** the call names reader's view of the meeting's call window: null before a call window with people was seen */callWindow?(meetingId: string): { goneMs: number } | null+ /** after a stop by the call window while the app still held the mic: `back` runs if that window shows the call again */+ lookForCall?(m: Meeting, back: () => void): void}const SNOOZE = 5 * 60_000@@ -52,6 +54,10 @@ export class Watcher {*/private calls = new Map<string, { last: number; key: string; at: number }>()private shownApp: string | null = null+ /** the offers a recording's stop closed, by app, so a call that turns out to go on can be offered again (#138) */+ private stopKeys = new Map<string, string[]>()+ /** apps whose call came back after its recording stopped as ended */+ private back = new Set<string>()constructor(private d: WatchDeps) {}@@ -91,7 +97,20 @@ export class Watcher {// later): that call is done, as if its card were closed. It is forgiven once the app lets go of the mic, as below.// A recording ending closes its call: once the app lets go of the mic, the next call is new (back-to-back meetings)if (justStopped) this.calls.clear()- if (justStopped) for (let p = decide(s, now, this.dismissed); p; p = decide(s, now, this.dismissed)) this.dismissed.add(p.key)+ if (justStopped) {+ this.stopKeys.clear()+ for (let p = decide(s, now, this.dismissed); p; p = decide(s, now, this.dismissed)) {+ this.dismissed.add(p.key)+ const app = p.app ?? p.key+ this.stopKeys.set(app, [...(this.stopKeys.get(app) ?? []), p.key])+ }+ }+ // the call window came back after a stop by it (a popup hid it, #138): that call goes on, so it is offered again+ for (const app of this.back) {+ for (const k of this.stopKeys.get(app) ?? []) this.dismissed.delete(k)+ this.stopKeys.delete(app); this.calls.delete(app)+ }+ this.back.clear()this.idleMic = new Set(s.micApps.flatMap((m) => callAppName(m.bundleId, s.runningApps) ?? []))const call = decide(s, now, new Set())this.idleCall = call?.app ? { app: call.app, at: now } : null@@ -162,6 +181,8 @@ export class Watcher {r.stopped = trueif (this.shown === 'stop') { this.shown = null; this.d.hide() }this.d.autoStop(m)+ // the app still on the mic: the window may only have looked gone, so watch a while for it to show the call again+ if (byWindow && onMic && m.app) { const app = m.app; this.d.lookForCall?.(m, () => this.back.add(app)) }return}const over = byWindow || ended(now - r.lastMic, silentMs)diff --git a/app/test/callNames.test.ts b/app/test/callNames.test.tsindex 16c6765c..380183f6 100644--- a/app/test/callNames.test.ts+++ b/app/test/callNames.test.ts@@ -490,6 +490,47 @@ describe('callWindow: the call window seen, then gone', () => {expect(s.hook.callWindow(s.m.id)?.goneMs).toBe(8_000)expect(s.logs).toContain('call names: the teams call window went away')})+ // #138 11-25: Teams' poor-network suggestion covered the page for 10 s; Chromium then shows only the popup, so no Leave+ // button is found. The window kept its call title and Teams kept the mic: that is the call hidden, not ended.+ const popup = 'no-call-window (search unavailable (-25213); walk saw the whole window, no page in it | search unavailable (-25213); page shows only a popup; page search saw buttons, none a call control; walk saw the whole window)'+ const teamsCall = (t: number): WatchLine => ({ t, app: 'com.microsoft.teams2', windows: [{ title: 'Weekly review | Microsoft Teams', tree: { r: 'frame', k: [{ r: 'section', t: 'Dana Smith, speaking' }, { r: 'tree', t: 'Participants', k: [{ r: 'tree item', t: 'Dana Smith, unmuted' }, { r: 'tree item', t: 'Alex Morgan (You)' }] }] } }] })+ it('a Teams popup covering the call while Teams holds the mic is the window hidden, not gone', () => {+ const s = setup({ app: 'Teams' })+ s.start(); s.setMic('Teams', [701])+ s.at(1_000_000); s.emit(teamsCall(1_000_000))+ for (let t = 1_000_500; t <= 1_030_000; t += 500) { s.at(t); s.emit({ t, app: 'com.microsoft.teams2', error: popup }) }+ expect(s.hook.callWindow(s.m.id)).toEqual({ goneMs: 0 })+ expect(s.logs).not.toContain('call names: the teams call window went away')+ expect(s.logs.filter((l) => l.includes('popup covers'))).toHaveLength(1)+ })+ it('a popup-only page with Teams off the mic still counts as gone (the call is over)', () => {+ const s = setup({ app: 'Teams' })+ s.start()+ s.at(1_000_000); s.emit(teamsCall(1_000_000))+ for (let t = 1_000_500; t <= 1_008_500; t += 500) { s.at(t); s.emit({ t, app: 'com.microsoft.teams2', error: popup }) }+ expect(s.hook.callWindow(s.m.id)?.goneMs).toBe(8_000)+ })+ it('after a stop, lookForCall says once when the call window with people is back, then stops reading', () => {+ const s = setup({ app: 'Teams' })+ s.start(); s.at(1_000_000); s.emit(teamsCall(1_000_000)); s.stop()+ const back = vi.fn()+ s.hook.lookForCall('Teams', back)+ expect(s.watched.at(-1)).toEqual(watchIds('Teams'))+ const stopped = s.stopped()+ s.at(1_001_000); s.emit({ t: 1_001_000, app: 'com.microsoft.teams2', error: popup })+ expect(back).not.toHaveBeenCalled()+ s.at(1_001_500); s.emit(teamsCall(1_001_500)); s.emit(teamsCall(1_002_000))+ expect(back).toHaveBeenCalledTimes(1)+ expect(s.stopped()).toBe(stopped + 1)+ })+ it('lookForCall gives up after a while', () => {+ const s = setup({ app: 'Teams' })+ s.start(); s.stop()+ const back = vi.fn()+ s.hook.lookForCall('Teams', back)+ s.at(1_000_000 + 3 * 60_000); s.emit(teamsCall(1_000_000 + 3 * 60_000))+ expect(back).not.toHaveBeenCalled()+ })it('Zoom quitting is the window gone too', () => {const s = setup()s.start()diff --git a/app/test/callParse.test.ts b/app/test/callParse.test.tsindex f60b5497..771c37ed 100644--- a/app/test/callParse.test.ts+++ b/app/test/callParse.test.ts@@ -489,6 +489,18 @@ describe("Teams' talking mark on a Mac (#138)", () => {const samples = [0, 500, 1000, 1500].map((ms) => ({ ms, ...readCall('teams', [macStage([macOwnTile('Alex Morgan'), macTile('Dana Smith', ms < 1500), macTile('Ann Lee', false)])]) }))expect(nameFor({ startMs: 0, endMs: 2000 }, samples)).toBe('Dana Smith')})+ it("never takes the poor-network badge on my own tile for my name (#138 11-25)", () => {+ const badge = (name: string, label: boolean): AxNode => node('AXMenuItem', { d: `Myself video, Bad network connection indicator, ${name}, ${PRODUCTION}, Muted, Has context menu` },+ node('AXGroup', { c: ['fui-Primitive', '___19sw0rl'] }), ...(label ? [node('AXStaticText', { v: name })] : []))+ for (const label of [true, false]) {+ const r = readCall('teams', [macStage([badge('Alex Morgan', label), macTile('Dana Smith', true)])])+ expect(r.me).toBe('Alex Morgan')+ expect(r.participants).toEqual(['Alex Morgan', 'Dana Smith'])+ }+ // a remote tile with a badge first is no person named for it either+ const remote = node('AXMenuItem', { d: `Poor network connection indicator, Dana Smith, ${PRODUCTION}, muted, Context menu is available` })+ expect(readCall('teams', [macStage([remote])]).participants).toEqual(['Dana Smith'])+ })})describe('summarize: a short picture of the tree for the log', () => {diff --git a/app/test/watch.test.ts b/app/test/watch.test.tsindex c29b01c3..9ccc6813 100644--- a/app/test/watch.test.ts+++ b/app/test/watch.test.ts@@ -566,6 +566,43 @@ describe('the call window going away ends the call', () => {win = { goneMs: 0 }; clock += 1_500; await w.tick()expect(log).toEqual([])})+ // #138 11-25: a Teams popup hid the call for 10 s, the recording stopped as call-ended, and the call went on 7 more+ // minutes with Teams on the mic. A recording ending dismisses its call until the app lets go of the mic, so no offer came.+ it('a call that ended by its window but comes back while the app still holds the mic is offered again', async () => {+ const looks: Array<{ app: string | null; back: () => void }> = []+ w = new Watcher({+ read: async () => reading, now: () => clock, active: () => active,+ bindApp: (_id, app) => (active = { ...active!, app }),+ offer: (p) => log.push('offer:' + p.key), askStop: () => log.push('stop'), hide: () => log.push('hide'),+ silentMs: () => silent, callWindow: () => win,+ autoStop: (m) => { log.push('auto:' + m.id); active = null; w.cleared() }, autoStopOn: () => auto,+ lookForCall: (m, back) => looks.push({ app: m.app, back }),+ })+ active = meeting(); reading = { micApps: [zoom], events: [] }; win = { goneMs: 0 }; await w.tick()+ clock += 8_000; win = { goneMs: 8_000 }; await w.tick()+ expect(log).toEqual(['auto:m1'])+ expect(looks.map((l) => l.app)).toEqual(['Zoom'])+ // still on the mic, the window not back yet: no offer (a call that ended while the app keeps the mic stays quiet)+ for (let i = 0; i < 5; i++) { clock += 1_500; await w.tick() }+ expect(log).toEqual(['auto:m1'])+ // the window with people is back+ looks[0].back(); clock += 1_500; await w.tick()+ expect(log).toEqual(['auto:m1', 'offer:app:us.zoom.xos'])+ // one offer, not a stream+ for (let i = 0; i < 5; i++) { clock += 1_500; await w.tick() }+ expect(log.filter((l) => l.startsWith('offer'))).toHaveLength(1)+ })+ it('no look for the call coming back when the app let go of the mic (that call is over)', async () => {+ const looks: string[] = []+ w = new Watcher({+ read: async () => reading, now: () => clock, active: () => active, bindApp: (_id, app) => (active = { ...active!, app }),+ offer: () => {}, askStop: () => {}, hide: () => {}, silentMs: () => silent, callWindow: () => win,+ autoStop: () => {}, autoStopOn: () => true, lookForCall: (m) => looks.push(m.id),+ })+ active = meeting(); reading = { micApps: [zoom], events: [] }; win = { goneMs: 0 }; await w.tick()+ reading = { micApps: [], events: [] }; clock += 8_000; win = { goneMs: 8_000 }; await w.tick()+ expect(looks).toEqual([])+ })it('a card start still ends by the mic as before', async () => {active = meeting()reading = { micApps: [zoom], events: [] }; await w.tick()