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
Calls: one Take notes offer per call. A moment off the mic (a headset change, mute) or the calendar event ending mid-call no longer counts as a new call; only two minutes off the mic ends it
christianmata5238dc6e17b
diff --git a/app/src/main/watch.ts b/app/src/main/watch.tsindex 832fcdca..806511f2 100644--- a/app/src/main/watch.ts+++ b/app/src/main/watch.ts@@ -29,6 +29,9 @@ export type WatchDeps = {const SNOOZE = 5 * 60_000/** Looks at the signals each tick: offers notes when a call starts; when it ends, stops the recording (or asks, with that setting off). Never starts anything itself. */+/** how long a call app must be off the mic before its call is over and the next one is offered again */+export const NEW_CALL_MS = 2 * 60_000+export class Watcher {readonly dismissed = new Set<string>()private shown: string | null = null // key of the start card, or 'stop'@@ -40,6 +43,13 @@ export class Watcher {private idleCall: { app: string; at: number } | null = null/** a recording was going at the last look */private wasRecording = false+ /**+ * The calls already offered, by app, with when the app last held the mic. Zoom lets go of the mic for a moment when a+ * headset changes or someone toggles mute, and the calendar event can end while the call goes on: none of that is a+ * new call. A call is over only after NEW_CALL_MS off the mic, so each call gets one offer, never a stream of them.+ */+ private calls = new Map<string, number>()+ private shownApp: string | null = nullconstructor(private d: WatchDeps) {}@@ -73,18 +83,29 @@ export class Watcher {this.rec = null// the recording just ended while its call app still holds the mic (Finish in Yogurt, then Zoom closes a few seconds// later): that call is done, as if its card were closed. It is forgiven once the app lets go of the mic, as below.- if (justStopped) for (let p = decide(s, now, this.dismissed); p; p = decide(s, now, this.dismissed)) this.dismissed.add(p.key)+ if (justStopped) for (let p = decide(s, now, this.dismissed); p; p = decide(s, now, this.dismissed)) { this.dismissed.add(p.key); this.calls.set(p.app ?? p.key, now) }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- // a call app that let go of the mic is a new call next time+ for (const a of this.idleMic) if (this.calls.has(a)) this.calls.set(a, now)+ for (const [a, last] of this.calls) if (now - last >= NEW_CALL_MS) this.calls.delete(a)+ // a call app whose call is over (off the mic long enough) is a new call next timefor (const k of [...this.dismissed]) {- if (k.startsWith('app:') && !s.micApps.some((m) => callAppName(k.slice(4)) === callAppName(m.bundleId, s.runningApps))) this.dismissed.delete(k)+ const app = k.startsWith('app:') ? callAppName(k.slice(4)) : undefined+ if (app !== undefined && !this.idleMic.has(app ?? '') && !this.calls.has(app ?? '')) this.dismissed.delete(k)+ }+ let p = this.d.ready && !this.d.ready() ? null : decide(s, now, this.dismissed)+ // this call was offered already: under another key (its event ended) or after a moment off the mic+ if (p && this.calls.has(p.app ?? p.key) && this.shown !== p.key) p = null+ if (!p) {+ // a card stays up through a blip; it goes when its call is over+ if (this.shown && !(this.shownApp && this.calls.has(this.shownApp))) { this.shown = null; this.shownApp = null; this.d.hide() }+ return}- const p = this.d.ready && !this.d.ready() ? null : decide(s, now, this.dismissed)- if (!p) { if (this.shown) { this.shown = null; this.d.hide() } return }if (this.shown === p.key) returnthis.shown = p.key+ this.shownApp = p.app ?? p.key+ this.calls.set(p.app ?? p.key, now)console.info(`CALL offer app=${p.app} mic=${s.micApps.filter(m => callAppName(m.bundleId, s.runningApps) === p.app).map(m => m.bundleId).join(',')}`)this.d.offer(p)}diff --git a/app/test/watch.test.ts b/app/test/watch.test.tsindex f3852295..182dda2e 100644--- a/app/test/watch.test.ts+++ b/app/test/watch.test.ts@@ -36,6 +36,44 @@ beforeEach(() => {})describe('start cards', () => {+ // A real call: Zoom lets go of the mic for a few seconds when someone switches headsets or toggles mute, and the+ // calendar event can end while the call goes on. None of that is a new call: one offer per call, never a stream of them.+ it('a mic blip in the middle of a call neither takes the card down nor offers again', async () => {+ reading = { micApps: [zoom], events: [] }+ await w.tick()+ for (const gap of [3_000, 20_000, 90_000]) {+ reading = { micApps: [], events: [] }; clock += gap; await w.tick()+ reading = { micApps: [zoom], events: [] }; clock += 3_000; await w.tick()+ }+ expect(log).toEqual(['offer:app:us.zoom.xos'])+ })+ it('a closed card stays closed through mic blips for the rest of that call', async () => {+ reading = { micApps: [zoom], events: [] }+ await w.tick()+ w.dismiss('app:us.zoom.xos')+ for (let i = 0; i < 4; i++) {+ reading = { micApps: [], events: [] }; clock += 10_000; await w.tick()+ reading = { micApps: [zoom], events: [] }; clock += 3_000; await w.tick()+ }+ expect(log.filter((l) => l.startsWith('offer'))).toHaveLength(1)+ })+ it('the calendar event ending while the call goes on is not a new call', async () => {+ const e = ev({ end: clock + 30 * MIN })+ reading = { micApps: [zoom], events: [e] }+ await w.tick()+ clock += 60 * MIN+ reading = { micApps: [zoom], events: [] }+ await w.tick(); clock += 3_000; await w.tick()+ expect(log.filter((l) => l.startsWith('offer'))).toEqual([`offer:event:e1:${e.start}`])+ })+ it('two minutes off the mic ends the call: the next one gets its own offer', async () => {+ reading = { micApps: [zoom], events: [] }+ await w.tick()+ w.dismiss('app:us.zoom.xos')+ reading = { micApps: [], events: [] }; await w.tick(); clock += 2 * MIN; await w.tick()+ reading = { micApps: [zoom], events: [] }; await w.tick()+ expect(log.filter((l) => l.startsWith('offer'))).toHaveLength(2)+ })it('offers nothing while the first run is still being set up, then offers the call once it is done', async () => {let ready = falseconst x = new Watcher({ read: async () => reading, now: () => clock, active: () => active, bindApp: (_id, app) => (active = { ...active!, app }),@@ -56,7 +94,7 @@ describe('start cards', () => {reading = { micApps: [zoom], events: [] }await w.tick()reading = { micApps: [], events: [] }- await w.tick()+ await w.tick(); clock += 2 * MIN; await w.tick()reading = { micApps: [zoom], events: [] }await w.tick()expect(log).toEqual(['offer:app:us.zoom.xos', 'hide', 'offer:app:us.zoom.xos'])@@ -68,7 +106,7 @@ describe('start cards', () => {await w.tick(); await w.tick()expect(log).toEqual(['offer:app:us.zoom.xos'])reading = { micApps: [], events: [] }- await w.tick()+ await w.tick(); clock += 2 * MIN; await w.tick()expect(w.dismissed.size).toBe(0)reading = { micApps: [zoom], events: [] }await w.tick()@@ -90,7 +128,7 @@ describe('start cards', () => {expect(log.filter((l) => l.startsWith('offer'))).toEqual([])// the call ends, and a new one starts laterreading = { micApps: [], events: [] }- await w.tick()+ await w.tick(); clock += 2 * MIN; await w.tick()reading = { micApps: [zoom], events: [] }await w.tick()expect(log.filter((l) => l.startsWith('offer'))).toEqual(['offer:app:us.zoom.xos'])