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.

2.8 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { createRereads } from '../src/main/asr/reread'

/** meetings by id: still being recorded or finished, with or without a kept recording */
function rig(o: { ready?: boolean } = {}) {
  let list: string[] = []
  const meetings = new Map<string, { busy?: boolean; audio?: boolean }>()
  const started: string[] = []
  const state = { ready: o.ready ?? false }
  const r = createRereads({
    load: () => list, save: (ids) => { list = ids }, ready: () => state.ready,
    meeting: (id) => { const m = meetings.get(id); return m ? { busy: !!m.busy, audio: m.audio !== false } : null },
    start: (id) => { started.push(id); return true },
  })
  return { r, meetings, started, state, list: () => list }
}

describe('meetings the small whisper had to read (the bigger one was not downloaded yet)', () => {
  it('are remembered, once each, and read again from their recording when the bigger whisper is in and they have ended', async () => {
    const t = rig()
    t.meetings.set('a', { busy: true })
    t.r.note('a'); t.r.note('a')
    expect(t.list()).toEqual(['a'])
    // not in yet
    await t.r.run()
    expect(t.started).toEqual([])
    // in, but the meeting still runs
    t.state.ready = true
    await t.r.run()
    expect(t.started).toEqual([])
    expect(t.list()).toEqual(['a'])
    t.meetings.set('a', {})
    await t.r.run()
    expect(t.started).toEqual(['a'])
    expect(t.list()).toEqual([])
    // only once
    await t.r.run()
    expect(t.started).toEqual(['a'])
  })
  it('one that was deleted, or whose recording was not kept, is let go without an error', async () => {
    const t = rig({ ready: true })
    t.meetings.set('kept', {}); t.meetings.set('no-audio', { audio: false })
    for (const id of ['gone', 'no-audio', 'kept']) t.r.note(id)
    await t.r.run()
    expect(t.started).toEqual(['kept'])
    expect(t.list()).toEqual([])
  })
  it('says which meetings it started, so their unedited notes can be written again from the better transcript', async () => {
    const t = rig({ ready: true })
    t.meetings.set('a', {})
    t.r.note('a')
    expect(t.r.reread('a')).toBe(false)
    await t.r.run()
    expect(t.r.reread('a')).toBe(true)
    // asked once
    expect(t.r.reread('a')).toBe(false)
  })
  it('a start that did not take (something else is transcribing it) is tried again later', async () => {
    let list: string[] = []
    let ok = false
    const started: string[] = []
    const r = createRereads({ load: () => list, save: (ids) => { list = ids }, ready: () => true, meeting: () => ({ busy: false, audio: true }), start: (id) => { started.push(id); return ok } })
    r.note('a')
    await r.run()
    expect(list).toEqual(['a'])
    ok = true
    await r.run()
    expect(list).toEqual([])
    expect(started).toEqual(['a', 'a'])
  })
})