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.

Linux: stopping a recording just after it started no longer crashes Yogurt (the recording pill is hidden, and destroyed with the next one)

christianmat50296d5f6b3b
diff --git a/app/src/main/widget.ts b/app/src/main/widget.ts
index e52363fa..37dbb2ea 100644
--- a/app/src/main/widget.ts
+++ b/app/src/main/widget.ts
@@ -58,10 +58,19 @@ const broadcast = (channel: string, v: unknown) => { for (const w of BrowserWind
*/
export function createWidget(d: { open(meetingId: string): void; stop(meetingId: string): void; foreground(): boolean; showRecordingPill?(): boolean; os?: string
/** the computer the windows are made for (a Mac's panel, a tool window elsewhere) */
- windowOs?: string }) {
+ windowOs?: string
+ /** the computer Yogurt really runs on (tests pass one) */
+ platform?: NodeJS.Platform }) {
const model = new WidgetModel(d.os)
let speech = silentSpeech
let win: BrowserWindow | undefined
+ /**
+ * Linux (X11): Electron crashes when a window is destroyed while the X server still answers about its size, as
+ * after stopping a recording a moment after it started. There a stopped pill is only hidden, and destroyed once
+ * the next recording has its own window, long after its last resize.
+ */
+ const retires = (d.platform ?? process.platform) === 'linux'
+ let retired: BrowserWindow | undefined
let pill = { x: 0, y: 0, width: FIRST_W, height: FIRST_H }
let layout: WidgetLayout | null = null
let dragFrame: { layout: WidgetLayout; pill: typeof pill; surface: WidgetSurface } | null = null
@@ -131,7 +140,9 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:
screen.removeListener('display-added', displayChanged)
screen.removeListener('display-removed', displayChanged)
screen.removeListener('display-metrics-changed', displayChanged)
- if (win && !win.isDestroyed()) win.destroy()
+ if (win && !win.isDestroyed()) {
+ if (retires) { win.hide(); win.webContents.setBackgroundThrottling(true); retired = win } else win.destroy()
+ }
win = undefined
}
const open = () => {
@@ -139,10 +150,12 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:
screen.on('display-added', displayChanged)
screen.on('display-removed', displayChanged)
screen.on('display-metrics-changed', displayChanged)
- win = createWindow(d.windowOs); sized = false; ignoring = true; sentPointer = null
+ const w = win = createWindow(d.windowOs); sized = false; ignoring = true; sentPointer = null
pill = { ...lastPosition!, width: lastWidth, height: FIRST_H }
layout = widgetLayout(pill, screen.getDisplayMatching(pill).workArea)
- win.on('closed', () => { clearTimeout(pointerTimer); win = undefined })
+ w.on('closed', () => { if (win === w) { clearTimeout(pointerTimer); win = undefined } })
+ if (retired && !retired.isDestroyed()) retired.destroy()
+ retired = undefined
}
onMeetingStart((m) => {
diff --git a/app/test/widgetWindow.test.ts b/app/test/widgetWindow.test.ts
index 64afcbc0..c96818d1 100644
--- a/app/test/widgetWindow.test.ts
+++ b/app/test/widgetWindow.test.ts
@@ -19,7 +19,7 @@ const state = vi.hoisted(() => ({
vi.mock('electron', () => ({
BrowserWindow: class {
static getAllWindows() { return state.windows }
- bounds: any; options: any; dead = false
+ bounds: any; options: any; dead = false; listeners = new Map<string, () => void>()
webContents = { send: vi.fn(), once: (_name: string, fn: () => void) => fn(), setBackgroundThrottling: vi.fn() }
constructor(options: any) { this.options = options; this.bounds = { x: options.x, y: options.y, width: options.width, height: options.height }; state.windows.push(this) }
getBounds() { return { ...this.bounds } }
@@ -27,10 +27,10 @@ vi.mock('electron', () => ({
setIgnoreMouseEvents = vi.fn()
isDestroyed() { return this.dead }
isVisible() { return false }
- on() {}
- hide() {}
+ on(name: string, fn: () => void) { this.listeners.set(name, fn) }
+ hide = vi.fn()
showInactive() {}
- destroy() { this.dead = true }
+ destroy() { this.dead = true; this.listeners.get('closed')?.() }
loadFile() { return Promise.resolve() }
},
ipcMain: { on: (name: string, fn: (...args: any[]) => unknown) => state.handlers.set(name, fn), handle: vi.fn() },
@@ -70,7 +70,7 @@ beforeEach(async () => {
state.finished.mockReset().mockResolvedValue(); open.mockReset()
const { createWidget } = await import('../src/main/widget')
showRecordingPill = true
- widget = createWidget({ open, stop: vi.fn(), foreground: () => false, showRecordingPill: () => showRecordingPill })
+ widget = createWidget({ open, stop: vi.fn(), foreground: () => false, platform: 'darwin', showRecordingPill: () => showRecordingPill })
state.start!({ id: 'meeting', title: 'Review', startedAt: 0 })
win = state.windows[0]
})
@@ -87,10 +87,32 @@ describe('floating recorder placement', () => {
})
it('uses a tool window on Windows without taking focus', async () => {
const { createWidget } = await import('../src/main/widget')
- createWidget({ open, stop: vi.fn(), foreground: () => false, windowOs: 'win32' })
+ createWidget({ open, stop: vi.fn(), foreground: () => false, windowOs: 'win32', platform: 'win32' })
state.start!({ id: 'meeting2', title: 'Review', startedAt: 0 })
expect(state.windows.at(-1).options).toMatchObject({ type: 'toolbar', focusable: false, skipTaskbar: true })
})
+ it('on Linux, hides a stopped pill and destroys it only once the next recording has its own', async () => {
+ // X11: Electron crashes on a window destroyed while the X server still answers about its size (a quick stop)
+ const { createWidget } = await import('../src/main/widget')
+ const linux = createWidget({ open, stop: vi.fn(), foreground: () => false, platform: 'linux' })
+ state.start!({ id: 'first', title: 'Review', startedAt: 0 })
+ const first = state.windows.at(-1)
+ state.stop!({ id: 'first' })
+ expect(first.dead).toBe(false)
+ expect(first.hide).toHaveBeenCalled()
+ expect(linux.snapshot().bounds).toBeNull()
+ state.start!({ id: 'second', title: 'Next', startedAt: 1 })
+ const second = state.windows.at(-1)
+ expect(second).not.toBe(first)
+ expect(first.dead).toBe(true)
+ expect(second.dead).toBe(false)
+ // the old window's closed event leaves the new one in place
+ expect(linux.snapshot().bounds).not.toBeNull()
+ })
+ it('destroys a stopped pill at once elsewhere', () => {
+ state.stop!({ id: 'meeting' })
+ expect(win.dead).toBe(true)
+ })
it('moves the surface and pill together and remembers the pill for the next meeting', () => {
const before = widget.snapshot().bounds!, frame = win.getBounds()
send('widget:drag', -100, 10); send('widget:drag-end')
@@ -300,7 +322,7 @@ describe('finished meeting notifications', () => {
it('skips the success banner when Yogurt was in front, but still warns', async () => {
vi.resetModules()
const { createWidget } = await import('../src/main/widget')
- widget = createWidget({ open, stop: vi.fn(), foreground: () => true })
+ widget = createWidget({ open, stop: vi.fn(), foreground: () => true, platform: 'darwin' })
state.start!({ id: 'meeting', title: 'Review', startedAt: 0 })
finish(); await Promise.resolve()
expect(widget.snapshot().notice).toMatchObject({ title: 'Meeting captured' })
@@ -339,7 +361,7 @@ describe('finished meeting notifications', () => {
if (mode === 'background') {
vi.stubEnv('YOGURT_BACKGROUND', '1'); vi.resetModules()
const { createWidget } = await import('../src/main/widget')
- widget = createWidget({ open, stop: vi.fn(), foreground: () => false })
+ widget = createWidget({ open, stop: vi.fn(), foreground: () => false, platform: 'darwin' })
state.start!({ id: 'meeting', title: 'Review', startedAt: 0 })
} else if (mode === 'fake') state.fake = true
else state.supported = false
@@ -350,7 +372,7 @@ describe('finished meeting notifications', () => {
it('does not notify for startup/recovery changes without a recording started in this run', async () => {
vi.resetModules()
const { createWidget } = await import('../src/main/widget')
- widget = createWidget({ open, stop: vi.fn(), foreground: () => false })
+ widget = createWidget({ open, stop: vi.fn(), foreground: () => false, platform: 'darwin' })
finish(); await Promise.resolve()
expect(widget.snapshot().notice).toBeNull()
expect(state.notifications).toHaveLength(0)
@@ -361,7 +383,7 @@ describe('hidden, the recorder does no work (the audit: its 4/s clock and meter
it('is throttled like any hidden window while Yogurt is in front, and runs freely while it floats', async () => {
let front = true
const { createWidget } = await import('../src/main/widget')
- const w = createWidget({ open, stop: vi.fn(), foreground: () => front })
+ const w = createWidget({ open, stop: vi.fn(), foreground: () => front, platform: 'darwin' })
state.start!({ id: 'meeting3', title: 'Review', startedAt: 0 })
const win3 = state.windows.at(-1)
send('widget:size', 127, 42)