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.

Recording: the "Stop recording?" card closes when the recording ends, however it ends

Eric Brownrout47c90a44104d
diff --git a/app/src/main/prompts.ts b/app/src/main/prompts.ts
index 05ddf4dd..b63c69ad 100644
--- a/app/src/main/prompts.ts
+++ b/app/src/main/prompts.ts
@@ -5,6 +5,7 @@ import type { Meeting } from './store'
import type { PromptAction, PromptView } from '../shared/types'
import { t } from '../shared/i18n'
import { floatingType, floatOverFullScreen } from './float'
+import { activeMeeting, onMeetingStop } from './meeting'
const BACKGROUND = process.env.YOGURT_BACKGROUND === '1'
const ACTIONS: readonly string[] = ['take-notes', 'close', 'stop', 'keep-going'] satisfies PromptAction[]
@@ -60,6 +61,9 @@ export function createPrompts(d: {
card = undefined
notice?.n?.close(); notice = null
}
+ onMeetingStop((m) => {
+ if (view?.kind === 'stop' && view.meetingId === m.id) close()
+ })
/** a button on the card, or a click on its notification (the card's yes: take notes, or stop) */
const act = (action: PromptAction) => {
const v = view, p = prompt
@@ -68,8 +72,10 @@ export function createPrompts(d: {
if (v.kind === 'start') {
if (action === 'take-notes' && p) d.takeNotes(p)
else d.dismissed(v.key)
- } else if (action === 'stop') d.stop(v.meetingId)
- else d.keepGoing()
+ } else if (activeMeeting()?.id === v.meetingId) {
+ if (action === 'stop') d.stop(v.meetingId)
+ else d.keepGoing()
+ }
}
const show = (v: PromptView) => {
view = v
diff --git a/app/test/promptWindow.test.ts b/app/test/promptWindow.test.ts
index 9b1f7b2f..c9786782 100644
--- a/app/test/promptWindow.test.ts
+++ b/app/test/promptWindow.test.ts
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
-const state = vi.hoisted(() => ({ windows: [] as any[], dark: false, theme: new Set<() => void>() }))
+const state = vi.hoisted(() => ({ windows: [] as any[], notices: [] as any[], handlers: new Map<string, Function>(), dark: false, theme: new Set<() => void>() }))
vi.mock('electron', () => ({
BrowserWindow: class {
options: any; dead = false; listeners = new Map<string, Array<() => void>>()
@@ -12,8 +12,13 @@ vi.mock('electron', () => ({
isDestroyed() { return this.dead }
loadFile() { return Promise.resolve() }
},
- ipcMain: { handle: vi.fn() },
- Notification: { isSupported: () => false },
+ ipcMain: { handle: (name: string, fn: Function) => state.handlers.set(name, fn) },
+ Notification: class {
+ static isSupported() { return true }
+ close = vi.fn(); show = vi.fn(); listeners = new Map<string, () => void>()
+ constructor() { state.notices.push(this) }
+ on(event: string, fn: () => void) { this.listeners.set(event, fn) }
+ },
nativeTheme: {
get shouldUseDarkColors() { return state.dark },
on: (_name: string, fn: () => void) => state.theme.add(fn),
@@ -24,8 +29,8 @@ vi.mock('electron', () => ({
vi.mock('../src/main/float', async (real) => ({ ...(await real<typeof import('../src/main/float')>()), floatOverFullScreen: vi.fn() }))
let prompts: ReturnType<typeof import('../src/main/prompts').createPrompts>
beforeEach(async () => {
- vi.stubEnv('YOGURT_BACKGROUND', '1'); vi.resetModules()
- state.windows.length = 0; state.theme.clear(); state.dark = false
+ vi.stubEnv('YOGURT_BACKGROUND', '0'); vi.resetModules()
+ state.windows.length = 0; state.notices.length = 0; state.handlers.clear(); state.theme.clear(); state.dark = false
const { createPrompts } = await import('../src/main/prompts')
prompts = createPrompts({windowVisible:()=>true,takeNotes:vi.fn(),stop:vi.fn(),dismissed:vi.fn(),keepGoing:vi.fn(),open:vi.fn()})
})
@@ -56,3 +61,116 @@ it('uses the current app appearance and updates the native background without le
prompts.hide()
expect(state.theme.size).toBe(0)
})
+
+
+/** Real meeting lifecycle, with only the native windows and notifications replaced. */
+async function recording() {
+ const meeting = await import('../src/main/meeting')
+ const { openStore } = await import('../src/main/store')
+ const store = openStore(':memory:')
+ meeting.initMeetings(store)
+ const m = meeting.startMeeting({ title: 'Review fixture', event: null, app: null })
+ const stop = vi.fn(meeting.stopMeeting), keepGoing = vi.fn(), open = vi.fn()
+ const { createPrompts } = await import('../src/main/prompts')
+ prompts.hide()
+ prompts = createPrompts({ windowVisible: () => false, takeNotes: vi.fn(), stop, dismissed: vi.fn(), keepGoing, open })
+ prompts.askStop(m)
+ return { ...meeting, store, m, stop, keepGoing, open, card: state.windows.at(-1), notice: state.notices.at(-1) }
+}
+
+it('stopping by hand immediately closes the stop card and its native notification', async () => {
+ const r = await recording()
+ try {
+ r.stopMeeting(r.m.id)
+ expect(r.card.isDestroyed()).toBe(true)
+ expect(r.notice.close).toHaveBeenCalledOnce()
+ expect(prompts.notice()).toBeNull()
+ expect(state.handlers.get('prompt:state')!()).toBeNull()
+ r.notice.listeners.get('click')!()
+ expect(r.stop).not.toHaveBeenCalled()
+ } finally { r.store.close() }
+})
+
+it('closes at capture stop even when saving the stopped state fails', async () => {
+ const r = await recording()
+ const save = vi.spyOn(r.store, 'updateMeeting').mockImplementation(() => { throw new Error('Disk full') })
+ try {
+ expect(r.stopMeeting(r.m.id)?.stopSavePending).toBe(true)
+ expect(r.card.isDestroyed()).toBe(true)
+ expect(r.notice.close).toHaveBeenCalledOnce()
+ } finally { save.mockRestore(); r.store.close() }
+})
+
+it('stopping a different stored recording leaves the active meeting card and notification alone', async () => {
+ const r = await recording()
+ try {
+ const other = r.store.createMeeting({ ...r.m, title: 'Other fixture' })
+ r.stopMeeting(other.id)
+ expect(r.activeMeeting()?.id).toBe(r.m.id)
+ expect(r.card.isDestroyed()).toBe(false)
+ expect(r.notice.close).not.toHaveBeenCalled()
+ expect(state.handlers.get('prompt:state')!()).toMatchObject({ meetingId: r.m.id })
+ } finally { r.store.close() }
+})
+
+it.each(['stop', 'keep-going', 'notification'] as const)('a stale %s action just closes without stopping or snoozing another recording', async action => {
+ const r = await recording()
+ try {
+ r.stopMeeting(r.m.id)
+ const next = r.startMeeting({ title: 'Next fixture', event: null, app: null })
+ // A late/stale presentation must remain harmless even after the lifecycle event was missed.
+ prompts.askStop(r.m)
+ const card = state.windows.at(-1), notice = state.notices.at(-1)
+ if (action === 'notification') notice.listeners.get('click')!()
+ else state.handlers.get('prompt:act')!({}, action)
+ expect(card.isDestroyed()).toBe(true)
+ expect(notice.close).toHaveBeenCalledOnce()
+ expect(prompts.notice()).toBeNull()
+ expect(r.stop).not.toHaveBeenCalled()
+ expect(r.keepGoing).not.toHaveBeenCalled()
+ expect(r.activeMeeting()?.id).toBe(next.id)
+ expect(r.store.meeting(r.m.id)?.state).toBe('stopped')
+ } finally { r.store.close() }
+})
+
+it('Stop on an already-ended meeting closes the stale card and leaves its summary alone', async () => {
+ const r = await recording()
+ try {
+ r.stopMeeting(r.m.id)
+ r.store.setNotes(r.m.id, { mine: 'Original notes', enhanced: 'Existing summary' })
+ prompts.askStop(r.m)
+ const card = state.windows.at(-1), notice = state.notices.at(-1)
+ state.handlers.get('prompt:act')!({}, 'stop')
+ expect(card.isDestroyed()).toBe(true)
+ expect(notice.close).toHaveBeenCalledOnce()
+ expect(r.stop).not.toHaveBeenCalled()
+ expect(r.keepGoing).not.toHaveBeenCalled()
+ expect(r.activeMeeting()).toBeNull()
+ expect(r.store.notes(r.m.id)).toMatchObject({ mine: 'Original notes', enhanced: 'Existing summary' })
+ } finally { r.store.close() }
+})
+
+it.each(['stop', 'keep-going'] as const)('the live %s action still works and closes both surfaces', async action => {
+ const r = await recording()
+ try {
+ state.handlers.get('prompt:act')!({}, action)
+ expect(r.card.isDestroyed()).toBe(true)
+ expect(r.notice.close).toHaveBeenCalledOnce()
+ if (action === 'stop') expect(r.stop).toHaveBeenCalledWith(r.m.id)
+ else { expect(r.keepGoing).toHaveBeenCalledOnce(); expect(r.activeMeeting()?.id).toBe(r.m.id) }
+ } finally { r.store.close() }
+})
+
+it('preserves the informational call-ended notice after closing the obsolete stop question', async () => {
+ const r = await recording()
+ try {
+ r.stopMeeting(r.m.id)
+ prompts.stopped(r.m)
+ expect(r.card.isDestroyed()).toBe(true)
+ expect(r.notice.close).toHaveBeenCalledOnce()
+ expect(prompts.notice()?.title).toBe('Recording stopped when the call ended.')
+ prompts.clickNotice()
+ expect(r.open).toHaveBeenCalledWith(r.m.id)
+ expect(r.stop).not.toHaveBeenCalled()
+ } finally { r.store.close() }
+})