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
Quitting Yogurt yourself keeps AI apps from starting it again: yogurt-mcp tells them Yogurt is closed until you open it (#147)
christianmat2e35486882e8
diff --git a/app/native/yogurt-mcp-relay/smoke/smoke.mjs b/app/native/yogurt-mcp-relay/smoke/smoke.mjsindex d62a0fa8..b4bb5897 100644--- a/app/native/yogurt-mcp-relay/smoke/smoke.mjs+++ b/app/native/yogurt-mcp-relay/smoke/smoke.mjs@@ -14,6 +14,7 @@ const win = process.platform === 'win32'const launches = process.env.SMOKE_NO_LAUNCH !== '1'const NOT_RUNNING = "Yogurt isn't running, and it couldn't be opened. Open Yogurt, then try again.\n"const TOO_LONG = "Yogurt's folder path is too long for its connection.\n"+const CLOSED = 'Yogurt is closed. Open Yogurt to use your meetings.\n'let failed = 0const check = (ok, what) => { console.log(`${ok ? 'ok ' : 'FAIL'} ${what}`); if (!ok) failed++ }@@ -114,7 +115,7 @@ if (launches) {const r = run(dir)r.send(init)check(await until(() => r.lines.length === 1, 35_000), 'Yogurt is started, then the first message gets its answer')- check(existsSync(join(dir, 'server.args')) && readFileSync(join(dir, 'server.args'), 'utf8') === '["--hidden"]', 'started with --hidden')+ check(existsSync(join(dir, 'server.args')) && readFileSync(join(dir, 'server.args'), 'utf8') === '["--hidden","--started-by=ai-app"]', 'started with --hidden --started-by=ai-app')r.p.stdin.end()check(await exitsWithin(r, 3000) === 0, 'the session ends as usual')const pid = Number(readFileSync(join(dir, 'server.pid'), 'utf8'))@@ -123,7 +124,21 @@ if (launches) {if (alive(pid)) process.kill(pid)}-// 5. Linux: a profile path too long for a Unix socket+// 5. the person quit Yogurt themselves: not started for an AI app, which is told to open it (#147)+if (launches) {+ const dir = profile()+ const launcher = join(dir, win ? 'Yogurt.cmd' : 'Yogurt.AppImage')+ if (win) writeFileSync(launcher, `@"${process.execPath}" "${join(here, 'server.mjs')}" "${dir}" %*\r\n`)+ else { writeFileSync(launcher, `#!/bin/sh\nexec "${process.execPath}" "${join(here, 'server.mjs')}" "${dir}" "$@"\n`); chmodSync(launcher, 0o755) }+ writeFileSync(join(dir, 'mcp-launch'), launcher + '\n')+ writeFileSync(join(dir, 'quit-by-user'), '')+ const r = run(dir)+ check(await exitsWithin(r, 3000) === 1 && r.err === CLOSED, 'quit by the person: exit 1 at once, saying to open Yogurt')+ await sleep(500)+ check(!existsSync(join(dir, 'server.pid')), 'and Yogurt is not started')+}++// 6. Linux: a profile path too long for a Unix socketif (!win) {let dir = profile()while (join(dir, 'mcp.sock').length < 120) { dir = join(dir, 'a'.repeat(40)); mkdirSync(dir) }diff --git a/app/native/yogurt-mcp-relay/src/main.rs b/app/native/yogurt-mcp-relay/src/main.rsindex f78e46fe..40852d3f 100644--- a/app/native/yogurt-mcp-relay/src/main.rs+++ b/app/native/yogurt-mcp-relay/src/main.rs@@ -2,7 +2,7 @@//! The same as native/yogurt-mcp (Swift, Mac): it only passes messages, the AI app's stdin to Yogurt and Yogurt's//! answers to stdout. Linux: the Unix socket in the profile folder. Windows: the named pipe whose name Yogurt//! writes to mcp.pipe in the profile folder. The MCP server itself is in the app (src/main/mcp).-//! Yogurt not open: it is started in the background first.+//! Yogurt not open: it is started in the background first, unless the person quit it themselves (#147).use std::env;use std::ffi::OsString;@@ -14,6 +14,9 @@ use std::thread;use std::time::Duration;const NOT_RUNNING: &str = "Yogurt isn't running, and it couldn't be opened. Open Yogurt, then try again.";+const CLOSED: &str = "Yogurt is closed. Open Yogurt to use your meetings.";+/// Yogurt leaves this in the profile when the person quits it, and removes it when they open it again+const QUIT_MARKER: &str = "quit-by-user";#[cfg_attr(windows, allow(dead_code))]const TOO_LONG: &str = "Yogurt's folder path is too long for its connection.";#[cfg_attr(unix, allow(dead_code))]@@ -250,6 +253,18 @@ use pipe::{connect, start};/// --started-by=ai-app also keeps it from watching for calls until the person opens it (#147)const START_ARGS: [&str; 2] = ["--hidden", "--started-by=ai-app"];+/// Whether to start Yogurt: never when told not to (YOGURT_MCP_NO_LAUNCH), and not after the person quit it+/// themselves, so an AI app can't bring back a Yogurt they closed (#147)+fn may_start(profile: &Path, no_launch: bool) -> Result<bool, &'static str> {+ if no_launch {+ return Ok(false);+ }+ if profile.join(QUIT_MARKER).exists() {+ return Err(CLOSED);+ }+ Ok(true)+}+fn command(target: &Path) -> Command {let mut c = Command::new(target);c.args(START_ARGS).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());@@ -260,7 +275,7 @@ fn main() {let windows = cfg!(windows);let profile = profile(windows, |k| env::var_os(k)).unwrap_or_else(|| fail(NOT_RUNNING));let mut conn = connect(&profile);- if conn.is_none() && env::var_os("YOGURT_MCP_NO_LAUNCH").is_none() {+ if conn.is_none() && may_start(&profile, env::var_os("YOGURT_MCP_NO_LAUNCH").is_some()).unwrap_or_else(|s| fail(s)) {let recorded = std::fs::read_to_string(profile.join("mcp-launch")).ok();if let Some(target) = launch_target(windows, recorded, env::current_exe().ok()) {if start(&target) {@@ -379,6 +394,21 @@ mod tests {assert_eq!(args, ["--hidden", "--started-by=ai-app"]);}+ #[test]+ fn yogurt_is_not_started_after_the_person_quit_it() {+ let dir = env::temp_dir().join(format!("ym-quit-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ let _ = std::fs::remove_file(dir.join(QUIT_MARKER));+ assert_eq!(may_start(&dir, false), Ok(true));+ // told not to start it: not running, as before+ assert_eq!(may_start(&dir, true), Ok(false));+ std::fs::write(dir.join(QUIT_MARKER), "").unwrap();+ assert_eq!(may_start(&dir, false), Err(CLOSED));+ assert_eq!(CLOSED, "Yogurt is closed. Open Yogurt to use your meetings.");+ assert_eq!(may_start(&dir, true), Ok(false));+ std::fs::remove_dir_all(&dir).unwrap();+ }+#[test]fn long_socket_paths_are_caught() {assert!(!socket_too_long(Path::new("/home/sam/.config/Yogurt/mcp.sock")));diff --git a/app/native/yogurt-mcp/main.swift b/app/native/yogurt-mcp/main.swiftindex beac1b4b..e36fd1de 100644--- a/app/native/yogurt-mcp/main.swift+++ b/app/native/yogurt-mcp/main.swift@@ -1,6 +1,7 @@// yogurt-mcp: what an AI app on this Mac (Claude, Cursor, …) starts to read Yogurt's meetings over MCP.// It only passes messages: the AI app's stdin to Yogurt's socket in the profile folder, and Yogurt's answers to stdout.-// The MCP server itself is in the app (src/main/mcp). Yogurt not open: it is opened in the background first.+// The MCP server itself is in the app (src/main/mcp). Yogurt not open: it is opened in the background first, unless+// the person quit it themselves (#147).import Foundationsetvbuf(stdout, nil, _IONBF, 0)@@ -9,6 +10,8 @@ func fail(_ s: String) -> Never { FileHandle.standardError.write((s + "\n").datalet env = ProcessInfo.processInfo.environmentlet profile = env["YOGURT_USER_DATA"] ?? (NSHomeDirectory() + "/Library/Application Support/Yogurt")let path = profile + "/mcp.sock"+/// Yogurt leaves this in the profile when the person quits it, and removes it when they open it again (#147)+let quitMarker = profile + "/" + "quit-by-user"func connectOnce() -> Int32? {let fd = socket(AF_UNIX, SOCK_STREAM, 0)@@ -25,6 +28,8 @@ func connectOnce() -> Int32? {var fd = connectOnce()if fd == nil && env["YOGURT_MCP_NO_LAUNCH"] == nil {+ // the person quit Yogurt: an AI app doesn't bring it back until they open it themselves (#147)+ if FileManager.default.fileExists(atPath: quitMarker) { fail("Yogurt is closed. Open Yogurt to use your meetings.") }// -g: in the background, so starting a chat never pulls Yogurt in front; --hidden: and Yogurt opens no window (#54)// --started-by=ai-app: and it watches for no calls until the person opens it (#147)let open = Process()diff --git a/app/src/main/appMenu.ts b/app/src/main/appMenu.tsindex 5403fc7f..035bd5f6 100644--- a/app/src/main/appMenu.ts+++ b/app/src/main/appMenu.ts@@ -1,9 +1,11 @@import { app, ipcMain, Menu, type BrowserWindow, type MenuItemConstructorOptions } from 'electron'import { onLanguage, t } from '../shared/i18n'+import { quitByUser } from './quitByUser'/*** The Mac's menu bar for Yogurt: Electron's own menu, with every label in the interface language- * (Electron's are English only). The roles keep what each item does and its shortcut.+ * (Electron's are English only). The roles keep what each item does and its shortcut. Quit is the person's own,+ * so an AI app won't start Yogurt again until they open it (#147).*/export function appMenuTemplate(name = app.name, sidebar?: { open: boolean | null; toggle(): void }, reopen?: () => void, os = 'darwin'): MenuItemConstructorOptions[] {if (os !== 'darwin') return pcMenuTemplate(sidebar)@@ -17,7 +19,7 @@ export function appMenuTemplate(name = app.name, sidebar?: { open: boolean | nul{ role: 'hideOthers', label: t('Hide Others') },{ role: 'unhide', label: t('Show All') },{ type: 'separator' },- { role: 'quit', label: t('Quit {app}', { app: name }) },+ { id: 'quit', label: t('Quit {app}', { app: name }), accelerator: 'Command+Q', click: () => quitByUser() },] },{ label: t('File'), submenu: [// With no visible renderer, these app-local shortcuts only bring the retained window back.@@ -65,7 +67,7 @@ function pcMenuTemplate(sidebar?: { open: boolean | null; toggle(): void }): Menreturn [{ label: t('File'), submenu: [{ role: 'close', label: t('Close Window'), accelerator: 'Ctrl+W' },- { role: 'quit', label: t('Quit {app}', { app: 'Yogurt' }), accelerator: 'Ctrl+Q' },+ { id: 'quit', label: t('Quit {app}', { app: 'Yogurt' }), accelerator: 'Ctrl+Q', click: () => quitByUser() },] },{ label: t('Edit'), submenu: [{ role: 'undo', label: t('Undo') },diff --git a/app/src/main/index.ts b/app/src/main/index.tsindex 46d74fd8..3387862f 100644--- a/app/src/main/index.ts+++ b/app/src/main/index.ts@@ -87,6 +87,7 @@ import { hookFolders } from './foldersIpc'import { hookMcp } from './mcp'import { createQuietStart } from './quietStart'import { startArgs, startReason, type StartReason } from './startReason'+import { quitCalledOff, quitting, started as startedAfterQuit } from './quitByUser'import { deleteRecording } from './deleteRecording'import { AUDIO_SCHEME, audioExts, createAudioHandler, trackFile, type AudioExt } from './audio'import { helperDecode, wavDecode } from './asr/backfill'@@ -566,6 +567,9 @@ app.whenReady().then(() => {// #147: which start this was (login, an AI app, an update, the person), so a log says what opened Yogurtconst started = startReason({ argv: process.argv, env: process.env, parent: parentName(), openedAtLogin: openedAtLogin() })console.info('APP', `started by=${started} args=${startArgs(process.argv)}`)+ // #147: the person quit Yogurt, so an AI app (an older yogurt-mcp) doesn't start it until they open it themselves+ if (startedAfterQuit(userDataDir(), started)) { console.info('APP the person quit Yogurt: not starting for an AI app'); app.quit(); return }+ app.on('will-quit', () => quitting(userDataDir()))quietStart = createQuietStart({ reason: started, quit: () => app.quit(), busy: () => busyNow() })// Local Electron launches need the same Dock icon as the packaged application.if (!app.isPackaged && process.platform === 'darwin') app.dock?.setIcon(join(__dirname, '../../build/icon.png'))@@ -1022,6 +1026,8 @@ app.whenReady().then(() => {// Flush the last keystroke and retained drafts before the existing recording/transcription shutdown.const resumeEditing = () => {finishing = false; allowQuit = false; discardUnsaved = false+ // a quit called off: the next one is the person's only if they ask again (#147)+ quitCalledOff()uploads.resume(); savedTranscriptions.resume()win?.webContents.send('notes:flush-request', null)}diff --git a/app/src/main/quitByUser.ts b/app/src/main/quitByUser.tsnew file mode 100644index 00000000..5c61390a--- /dev/null+++ b/app/src/main/quitByUser.ts@@ -0,0 +1,40 @@+import { app } from 'electron'+import { existsSync, rmSync, writeFileSync } from 'node:fs'+import { join } from 'node:path'+import type { StartReason } from './startReason'++/**+ * #147: the person quitting Yogurt (the menu bar's Quit, the app menu, Cmd+Q, Ctrl+Q) leaves this file in the profile,+ * and yogurt-mcp doesn't start Yogurt for an AI app while it's there. Any other quit (an update, logout, a crash, a+ * quiet Yogurt quitting by itself) leaves none, so an AI app can still start it then. The person opening Yogurt again+ * (or a login or update start) removes it.+ */+export const QUIT_MARKER = 'quit-by-user'+/** what yogurt-mcp tells the AI app instead (both helpers have the same words) */+export const CLOSED = 'Yogurt is closed. Open Yogurt to use your meetings.'++let asked = false++/** the person chose Quit */+export function quitByUser() { asked = true; app.quit() }+/** the quit was called off (unsaved notes: Return to notes), so a later quit is not the person's unless they ask again */+export function quitCalledOff() { asked = false }+/** tests */+export function resetQuitByUser() { asked = false }++/** Yogurt is quitting now: marked only when the person asked */+export function quitting(dir: string) {+ if (!asked) return+ try { writeFileSync(join(dir, QUIT_MARKER), '') } catch (e) { console.error('APP could not note the quit', e) }+}++/**+ * At start: any start but an AI app's clears the mark. True: an AI app started Yogurt after the person quit it+ * (a yogurt-mcp from before the mark), so this Yogurt stops at once.+ */+export function started(dir: string, reason: StartReason): boolean {+ const file = join(dir, QUIT_MARKER)+ if (reason === 'ai-app') return existsSync(file)+ try { rmSync(file, { force: true }) } catch (e) { console.error('APP could not clear the quit', e) }+ return false+}diff --git a/app/src/main/tray.ts b/app/src/main/tray.tsindex 5b43001c..6046ea7e 100644--- a/app/src/main/tray.ts+++ b/app/src/main/tray.ts@@ -8,6 +8,7 @@ import { daysAgo } from '../shared/dates'import { onLanguage } from '../shared/i18n'import { onRecordingEvent, recordingPaused } from './capture'import { matchesEvent, type CalEvent } from './calendar'+import { quitByUser } from './quitByUser'function systemTrayTime(start: number, dated: boolean): string {let hour12: boolean | undefined@@ -74,7 +75,7 @@ export function createTray(d: { show: boolean; visible?: boolean; showNextMeetin}else if (id === 'pause' && m) d.pause(m.id, !recordingPaused(m.id))else if (id === 'stop' && m) d.stop(m.id)- else if (id === 'quit') app.quit()+ else if (id === 'quit') quitByUser()}const look = (m: ReturnType<typeof activeMeeting>, next?: CalEvent, at = now()) =>trayLook(os, m ? { paused: recordingPaused(m.id) } : null, m ? d.elapsed() : 0, next, at, systemTrayTime)diff --git a/app/test/appMenu.test.ts b/app/test/appMenu.test.tsindex 10649e3d..67941dab 100644--- a/app/test/appMenu.test.ts+++ b/app/test/appMenu.test.ts@@ -13,6 +13,8 @@ vi.mock('electron', () => ({},ipcMain: { on: (channel: string, handler: (...args: any[]) => void) => state.handlers.set(channel, handler) },}))+const quitByUser = vi.hoisted(() => vi.fn())+vi.mock('../src/main/quitByUser', () => ({ quitByUser }))vi.mock('../src/shared/i18n', () => ({ t: (text: string) => text, onLanguage: vi.fn() }))import { appMenuTemplate, installAppMenu } from '../src/main/appMenu'@@ -70,6 +72,17 @@ it('offers reopen shortcuts only while the main window is hidden, without changiexpect(shortcuts()).toEqual([]) // The renderer keeps its existing shortcuts while visible.})+it('Quit (the menu, Cmd+Q, Ctrl+Q) is the person quitting, so an AI app won\'t start Yogurt again (#147)', () => {+ for (const [os, accelerator] of [['darwin', 'Command+Q'], ['win32', 'Ctrl+Q'], ['linux', 'Ctrl+Q']] as const) {+ const item = appMenuTemplate('Yogurt', undefined, undefined, os).flatMap(i => Array.isArray(i.submenu) ? i.submenu : []).find(i => i.id === 'quit')!+ expect(item).toMatchObject({ accelerator })+ expect(item.role).toBeUndefined()+ quitByUser.mockClear()+ ;(item.click as () => void)()+ expect(quitByUser).toHaveBeenCalledOnce()+ }+})+describe('Windows and Linux', () => {const all = (template: MenuItemConstructorOptions[]) => template.flatMap(item => Array.isArray(item.submenu) ? item.submenu : [])it("have no app menu or the Mac's own items, and use Ctrl", () => {@@ -78,9 +91,9 @@ describe('Windows and Linux', () => {expect(template.map(item => item.label)).toEqual(['File', 'Edit', 'View', 'Window'])const roles = all(template).map(item => item.role).filter(Boolean)for (const mac of ['about', 'services', 'hide', 'hideOthers', 'unhide', 'front', 'zoom']) expect(roles).not.toContain(mac)- expect(roles).toEqual(expect.arrayContaining(['close', 'quit', 'undo', 'copy', 'paste', 'reload', 'toggleDevTools', 'zoomIn', 'togglefullscreen', 'minimize']))+ expect(roles).toEqual(expect.arrayContaining(['close', 'undo', 'copy', 'paste', 'reload', 'toggleDevTools', 'zoomIn', 'togglefullscreen', 'minimize']))expect(sidebarItem(template)).toMatchObject({ accelerator: 'Ctrl+Shift+S' })- expect(all(template).find(item => item.role === 'quit')).toMatchObject({ accelerator: 'Ctrl+Q' })+ expect(all(template).find(item => item.id === 'quit')).toMatchObject({ accelerator: 'Ctrl+Q' })// no window can be focused while it's hidden there, so no hidden reopen shortcutsexpect(all(template).filter(item => item.id?.startsWith('reopen-'))).toEqual([])expect(JSON.stringify(template)).not.toContain('Command')diff --git a/app/test/quitByUser.test.ts b/app/test/quitByUser.test.tsnew file mode 100644index 00000000..6d5cefab--- /dev/null+++ b/app/test/quitByUser.test.ts@@ -0,0 +1,52 @@+import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { beforeEach, describe, expect, it, vi } from 'vitest'++const quit = vi.hoisted(() => vi.fn())+vi.mock('electron', () => ({ app: { quit } }))+import { CLOSED, QUIT_MARKER, quitByUser, quitCalledOff, quitting, resetQuitByUser, started } from '../src/main/quitByUser'++let dir: string+const marked = () => existsSync(join(dir, QUIT_MARKER))+beforeEach(() => { dir = mkdtempSync(join(tmpdir(), 'yq-')); quit.mockClear(); resetQuitByUser() })++describe('the person quitting Yogurt keeps AI apps from starting it again (#147)', () => {+ it('is marked when the person chose Quit', () => {+ quitByUser()+ expect(quit).toHaveBeenCalledOnce()+ quitting(dir)+ expect(marked()).toBe(true)+ })+ it('is not marked for any other quit: an update restart, logout, a quiet Yogurt quitting by itself', () => {+ quitting(dir)+ expect(marked()).toBe(false)+ })+ it('is not marked when the quit was called off (unsaved notes: Return to notes)', () => {+ quitByUser()+ quitCalledOff()+ quitting(dir)+ expect(marked()).toBe(false)+ })+ it('is cleared by any start but an AI app’s', () => {+ for (const reason of ['user', 'login', 'update'] as const) {+ quitByUser(); quitting(dir); resetQuitByUser()+ expect(started(dir, reason)).toBe(false)+ expect(marked()).toBe(false)+ }+ })+ it('is kept by an AI app’s start, which then stops at once', () => {+ quitByUser(); quitting(dir)+ expect(started(dir, 'ai-app')).toBe(true)+ expect(marked()).toBe(true)+ rmSync(join(dir, QUIT_MARKER))+ expect(started(dir, 'ai-app')).toBe(false)+ })+ it('is what both yogurt-mcp helpers look for, with the same words', () => {+ for (const f of ['native/yogurt-mcp-relay/src/main.rs', 'native/yogurt-mcp/main.swift']) {+ const src = readFileSync(join(__dirname, '..', f), 'utf8')+ expect(src).toContain(`"${QUIT_MARKER}"`)+ expect(src).toContain(`"${CLOSED}"`)+ }+ })+})diff --git a/app/test/tray.test.ts b/app/test/tray.test.tsindex 11ec5fba..2c3684b6 100644--- a/app/test/tray.test.ts+++ b/app/test/tray.test.ts@@ -21,6 +21,8 @@ vi.mock('electron', () => ({}))vi.mock('../src/main/meeting', () => ({ activeMeeting: () => state.meeting, onMeetingChange: (fn: () => void) => { state.change = fn } }))vi.mock('../src/main/capture', () => ({ recordingPaused: () => state.paused, onRecordingEvent: (fn: typeof state.recording) => { state.recording = fn } }))+const quitByUser = vi.hoisted(() => vi.fn())+vi.mock('../src/main/quitByUser', () => ({ quitByUser }))vi.mock('../src/shared/i18n', async original => ({ ...await original<typeof import('../src/shared/i18n')>(), onLanguage: (fn: () => void) => { state.language = fn } }))import { app, nativeTheme, powerMonitor, systemPreferences } from 'electron'const basename = (p: string) => p.split(/[\\/]/).at(-1)@@ -46,6 +48,13 @@ it('creates by default, destroys immediately, and recreates with the current recexpect(state.trays[1].setContextMenu).toHaveBeenCalled()})+it('Quit Yogurt is the person quitting, so an AI app won\'t start Yogurt again (#147)', () => {+ const tray = createTray({ show: true, ...actions() })+ tray.click('quit')+ expect(quitByUser).toHaveBeenCalledOnce()+ expect(app.quit).not.toHaveBeenCalled()+})+it('starts hidden and keeps menu hooks working during recording and pause', () => {const d = actions()const tray = createTray({ show: true, visible: false, ...d })