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
A Yogurt an AI app started stays quiet: no window, no call watching and no Take notes? until the person opens it, and it quits by itself once no AI app is connected; the log says what started Yogurt (#147)
christianmat30385b3e8695
diff --git a/app/native/yogurt-mcp-relay/src/main.rs b/app/native/yogurt-mcp-relay/src/main.rsindex 8feaafd4..f78e46fe 100644--- a/app/native/yogurt-mcp-relay/src/main.rs+++ b/app/native/yogurt-mcp-relay/src/main.rs@@ -246,10 +246,13 @@ use sock::{connect, start};#[cfg(windows)]use pipe::{connect, start};-/// Yogurt with --hidden: it opens without a window, so starting a chat never pulls Yogurt in front+/// What Yogurt is started with: --hidden opens no window, so starting a chat never pulls Yogurt in front;+/// --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"];+fn command(target: &Path) -> Command {let mut c = Command::new(target);- c.arg("--hidden").stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());+ c.args(START_ARGS).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());c}@@ -369,6 +372,13 @@ mod tests {assert_eq!(launch_target(true, None, Some(PathBuf::from(r"C:\tools\yogurt-mcp.exe"))), None);}+ #[test]+ fn yogurt_is_told_an_ai_app_started_it() {+ let c = command(Path::new("Yogurt"));+ let args: Vec<_> = c.get_args().collect();+ assert_eq!(args, ["--hidden", "--started-by=ai-app"]);+ }+#[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 8ff6cc15..beac1b4b 100644--- a/app/native/yogurt-mcp/main.swift+++ b/app/native/yogurt-mcp/main.swift@@ -26,9 +26,10 @@ func connectOnce() -> Int32? {var fd = connectOnce()if fd == nil && env["YOGURT_MCP_NO_LAUNCH"] == nil {// -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()open.executableURL = URL(fileURLWithPath: "/usr/bin/open")- open.arguments = ["-g", "-b", "so.yogurt.app", "--args", "--hidden"]+ open.arguments = ["-g", "-b", "so.yogurt.app", "--args", "--hidden", "--started-by=ai-app"]try? open.run(); open.waitUntilExit()for _ in 0..<60 { if let f = connectOnce() { fd = f; break }; usleep(500_000) }}diff --git a/app/src/main/index.ts b/app/src/main/index.tsindex 087d9740..a99fcccc 100644--- a/app/src/main/index.ts+++ b/app/src/main/index.ts@@ -85,7 +85,8 @@ import { hookShare } from './share'import { hookBackup } from './backupIpc'import { hookFolders } from './foldersIpc'import { hookMcp } from './mcp'-import { startedHidden } from './mcp/paths'+import { createQuietStart } from './quietStart'+import { startArgs, startReason, type StartReason } from './startReason'import { deleteRecording } from './deleteRecording'import { AUDIO_SCHEME, audioExts, createAudioHandler, trackFile, type AudioExt } from './audio'import { helperDecode, wavDecode } from './asr/backfill'@@ -127,8 +128,20 @@ let updateMainMenu = () => {}let menuBar: ReturnType<typeof createTray> | undefined/** test runs: no window on screen, never takes focus from what the person is doing */const BACKGROUND = process.env.YOGURT_BACKGROUND === '1'-// an AI app's yogurt-mcp starting Yogurt while it was still opening (--hidden) brings no window forward-app.on('second-instance', (_e, argv) => { if (app.isReady() && !startedHidden(process.platform, argv)) showMain() })+/** how this Yogurt started (#147): an AI app's start waits quietly, with no call watching, until the person opens it */+let quietStart: ReturnType<typeof createQuietStart> | undefined+/** work a quiet Yogurt waits for before quitting by itself (set once notes and setup exist) */+let busyNow = () => !!activeMeeting()+/** Linux: the program that started Yogurt (an older yogurt-mcp passed only --hidden); elsewhere it costs a process to ask */+const parentName = () => { if (process.platform !== 'linux') return undefined; try { return readFileSync(`/proc/${process.ppid}/comm`, 'utf8').trim() } catch { return undefined } }+// an AI app's yogurt-mcp or the login item starting Yogurt while it was still opening (--hidden) brings no window forward+app.on('second-instance', (_e, argv) => {+ if (!app.isReady()) return+ const why: StartReason = startReason({ argv, env: {} })+ console.info('APP', `started again by=${why} args=${startArgs(argv)}`)+ if (why === 'ai-app' || why === 'login') quietStart?.startedAgain(why)+ else showMain()+})/** Links open in the user's browser, never inside the app window. */function openExternally(url: string) {@@ -251,6 +264,7 @@ const permissions = createPermissions({/** Reuse the hidden main window, including its route, scroll, drafts and position. */function showMain() {+ quietStart?.opened()if (!win) { createWindow(); presented++ }presentMain(true)}@@ -265,6 +279,7 @@ function askFromMenu() {win?.webContents.send('nav:ask')}function goTo(next: string, resume = false) {+ quietStart?.opened()route = nextresumeRequested = resumeif (!win) createWindow()@@ -496,7 +511,7 @@ function startDetection() {}// cheap, and only while Yogurt runs; more often while recording, so the end of a quiet call is noticed promptlylet timer: NodeJS.Timeout | undefined- const watchLoop = () => { timer = setTimeout(() => { void watcher.tick().catch((e) => console.error('detect failed', e)).finally(watchLoop) }, watchEveryMs(!!activeMeeting())) }+ const watchLoop = () => { timer = setTimeout(() => { void quietStart!.detect(() => watcher.tick()).catch((e) => console.error('detect failed', e)).finally(watchLoop) }, watchEveryMs(!!activeMeeting())) }watchLoop()app.on('will-quit', () => clearTimeout(timer))if (isFake()) {@@ -538,6 +553,10 @@ function startDetection() {app.whenReady().then(() => {console.info('APP', `trusting ${systemCerts} certificates from the system on top of the built-in ones`)+ // #147: which start this was (login, an AI app, an update, the person), so a log says what opened Yogurt+ const started = startReason({ argv: process.argv, env: process.env, parent: parentName(), openedAtLogin: openedAtLogin() })+ console.info('APP', `started by=${started} args=${startArgs(process.argv)}`)+ 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'))const settings = loadSettings(join(userDataDir(), 'settings.json'))@@ -734,6 +753,7 @@ app.whenReady().then(() => {changed: () => { win?.webContents.send('meetings:changed'); void indexer.schedule() },})let finishing = false, discardUnsaved = false+ busyNow = () => !!activeMeeting() || queue.busy() || setup.state.phase === 'checking' || setup.state.phase === 'downloading'const savedTranscriptions = createSavedTranscriptions({store, ready: () => !!setup.installed()?.asr, recording: () => !!activeMeeting() || !!resumingId || finishing, live: transcriptOpen,tracks: async id => {@@ -925,7 +945,7 @@ app.whenReady().then(() => {await rejoined; await recordingSettled(id)return (['me', 'them'] as const).flatMap((track) => { const path = trackFile(meetingDir(id), track, audioKinds); return path ? [{ track, path }] : [] })},- send: (clients) => win?.webContents.send('mcp:clients', clients),+ send: (clients) => { quietStart?.clients(clients.length); win?.webContents.send('mcp:clients', clients) },})// notes only for a meeting that exists: saving one for an unknown id would throw (its row must exist)const known = (id: unknown): id is string => isId(id) && !!store.meeting(id)@@ -1278,16 +1298,16 @@ app.whenReady().then(() => {})ipcMain.handle('nav:current', () => route)ipcMain.handle('nav:take-ask', () => { const pending = pendingAsk; pendingAsk = false; return pending })- // opened by the Mac at login: just the menu bar, until a call or a click- // opened by an AI app's yogurt-mcp off a Mac (--hidden): the same, so no window jumps in front of it- if (!openedAtLogin() && !startedHidden(process.platform, process.argv)) createWindow()+ // opened at login: just the menu bar, until a call or a click+ // opened by an AI app's yogurt-mcp: the same, so no window jumps in front of it, and no call watching either (#147)+ if (quietStart!.window()) createWindow()startDetection()void setup.start()// new versions from GitHub Releases, downloaded in the background and installed on quitconst updatesAvailable = updatesOn({ packaged: app.isPackaged, fake: isFake(), profile: !!process.env.YOGURT_USER_DATA, platform: process.platform, appImage: !!process.env.APPIMAGE,feed: app.isPackaged && existsSync(join(process.resourcesPath, 'app-update.yml')),preview: app.isPackaged && isPreviewBuild((() => { try { return readFileSync(join(app.getAppPath(), 'package.json'), 'utf8') } catch { return '' } })()) })- hookUpdates({ file: join(userDataDir(), 'settings.json'), available: updatesAvailable, recording: () => !!activeMeeting(),+ hookUpdates({ file: join(userDataDir(), 'settings.json'), available: updatesAvailable, recording: () => !!activeMeeting(), quiet: () => !!quietStart?.quiet(),// fake mode: a test pretends a version downloadedfake: isFake() && process.env.YOGURT_FAKE_UPDATE ? { version: process.env.YOGURT_FAKE_UPDATE, restarted: () => { updateRestarts++ } } : undefined }).catch((err) => console.warn("couldn't start looking for new versions", err))diff --git a/app/src/main/quietStart.ts b/app/src/main/quietStart.tsnew file mode 100644index 00000000..9bf61a7a--- /dev/null+++ b/app/src/main/quietStart.ts@@ -0,0 +1,45 @@+import type { StartReason } from './startReason'++/** how long a Yogurt an AI app started stays once no AI app is connected */+export const QUIT_AFTER_MS = 2 * 60_000++/**+ * A Yogurt an AI app started (yogurt-mcp, while Yogurt was closed) only serves that app: no window, no call watching,+ * so no "Take notes?" for a call the person never asked about (#147: Discord, always on the mic, popped up minutes+ * after every quit). The person opening Yogurt (window, tray, Dock) makes it a normal Yogurt from then on.+ * Until then it quits by itself once no AI app has been connected for QUIT_AFTER_MS, so a quit Yogurt doesn't stay+ * behind in the tray after the AI app is gone. Work in progress (a download, notes being written) is waited for.+ */+export function createQuietStart(o: { reason: StartReason; quit(): void; busy(): boolean }) {+ let quiet = o.reason === 'ai-app'+ let connected = 0+ let timer: NodeJS.Timeout | undefined+ const stop = () => { clearTimeout(timer); timer = undefined }+ const arm = () => {+ stop()+ if (!quiet || connected > 0) return+ timer = setTimeout(() => {+ timer = undefined+ if (!quiet || connected > 0) return+ if (o.busy()) { arm(); return }+ console.info('APP no AI app connected to the Yogurt one started: quitting')+ o.quit()+ }, QUIT_AFTER_MS)+ timer.unref?.()+ }+ const normal = () => { if (quiet) { quiet = false; stop(); console.info('APP opened by the person: watching for calls') } }+ arm()+ return {+ quiet: () => quiet,+ /** a window at start: not for a login or an AI app's start */+ window: () => o.reason === 'user' || o.reason === 'update',+ /** one round of call watching, skipped while quiet */+ detect: async (tick: () => Promise<unknown>) => { if (!quiet) await tick() },+ /** the person opened Yogurt */+ opened: normal,+ /** Yogurt was started again while running (second-instance): a login start makes it normal too */+ startedAgain: (reason: StartReason) => { if (reason === 'login') normal() },+ /** how many AI apps are connected now */+ clients: (n: number) => { connected = n; arm() },+ }+}diff --git a/app/src/main/startReason.ts b/app/src/main/startReason.tsnew file mode 100644index 00000000..0415c149--- /dev/null+++ b/app/src/main/startReason.ts@@ -0,0 +1,24 @@+/** Why this Yogurt is running, so a log says what opened it and an AI app's start can stay out of the way (#147) */+export type StartReason = 'login' | 'ai-app' | 'update' | 'user'++/** what yogurt-mcp passes, next to --hidden, when an AI app starts Yogurt */+export const AI_APP_ARG = '--started-by=ai-app'++/**+ * argv: Yogurt's own. env: YOGURT_STARTED_BY=ai-app also counts. parent: the program that started it, where the+ * computer says cheaply (Linux), so an older yogurt-mcp that passed only --hidden is still known.+ * --hidden alone is the login item (Windows, Linux); a Mac says so itself (openedAtLogin). --updated is the installer.+ */+export function startReason(o: { argv: string[]; env: Record<string, string | undefined>; parent?: string; openedAtLogin?: boolean }): StartReason {+ if (o.argv.includes(AI_APP_ARG) || o.env.YOGURT_STARTED_BY === 'ai-app') return 'ai-app'+ if (o.argv.includes('--hidden') && /^yogurt-mcp(\.exe)?$/i.test(o.parent ?? '')) return 'ai-app'+ if (o.openedAtLogin || o.argv.includes('--hidden')) return 'login'+ if (o.argv.includes('--updated')) return 'update'+ return 'user'+}++/** the switches Yogurt was started with, for the log: names only, so no folder or file name lands there */+export function startArgs(argv: string[]): string {+ const flags = argv.slice(1).filter((a) => a.startsWith('--')).map((a) => (/[\\/:]/.test(a) ? a.split('=')[0] : a))+ return flags.length ? flags.join(' ') : 'none'+}diff --git a/app/src/main/updates.ts b/app/src/main/updates.tsindex 25c03c49..89092194 100644--- a/app/src/main/updates.ts+++ b/app/src/main/updates.ts@@ -35,7 +35,7 @@ export function finishQuit(): void {* available: false in a build that never updates (see updatesOn); Settings then shows only the version.* DOES NOT WORK WHILE RECORDING.*/-export async function hookUpdates(d: { file: string; available: boolean; recording(): boolean; /** fake mode: a version already downloaded */ fake?: { version: string; restarted(): void } }): Promise<void> {+export async function hookUpdates(d: { file: string; available: boolean; recording(): boolean; /** started by an AI app and not opened yet: no notification (#147) */ quiet?(): boolean; /** fake mode: a version already downloaded */ fake?: { version: string; restarted(): void } }): Promise<void> {let runningVersion = app.getVersion()let state: UpdateStatus['state'] = 'idle'let next: string | undefined, dismissedVersion: string | undefined@@ -92,7 +92,7 @@ export async function hookUpdates(d: { file: string; available: boolean; recordiupdater.on('update-available', (info) => set('downloading', info.version))updater.on('update-downloaded', (info) => {set('ready', info.version)- if (!Notification.isSupported()) return+ if (!Notification.isSupported() || d.quiet?.()) returnnew Notification({ title: t('Yogurt {version} is ready', { version: info.version }), body: t('It installs the next time you quit Yogurt.') }).show()})updater.on('error', (err) => {diff --git a/app/test/quietStart.test.ts b/app/test/quietStart.test.tsnew file mode 100644index 00000000..c1669ef8--- /dev/null+++ b/app/test/quietStart.test.ts@@ -0,0 +1,91 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { createQuietStart, QUIT_AFTER_MS } from '../src/main/quietStart'++beforeEach(() => { vi.useFakeTimers() })+afterEach(() => { vi.useRealTimers() })++const make = (reason: Parameters<typeof createQuietStart>[0]['reason'], busy = () => false) => {+ const quit = vi.fn()+ const q = createQuietStart({ reason, quit, busy })+ return { q, quit }+}++describe('a Yogurt an AI app started (#147)', () => {+ it('watches for no calls and offers nothing until the person opens it', async () => {+ const { q } = make('ai-app')+ const tick = vi.fn(async () => {})+ await q.detect(tick)+ expect(q.quiet()).toBe(true)+ expect(tick).not.toHaveBeenCalled()+ q.opened()+ await q.detect(tick)+ expect(q.quiet()).toBe(false)+ expect(tick).toHaveBeenCalledOnce()+ })+ it('opens no window at start', () => {+ expect(make('ai-app').q.window()).toBe(false)+ expect(make('login').q.window()).toBe(false)+ expect(make('user').q.window()).toBe(true)+ expect(make('update').q.window()).toBe(true)+ })+ it('watches for calls right away for any other start', async () => {+ for (const reason of ['login', 'user', 'update'] as const) {+ const tick = vi.fn(async () => {})+ await make(reason).q.detect(tick)+ expect(tick).toHaveBeenCalledOnce()+ }+ })+ it('quits by itself once no AI app has been connected for a while', () => {+ const { q, quit } = make('ai-app')+ q.clients(1)+ vi.advanceTimersByTime(QUIT_AFTER_MS * 3)+ expect(quit).not.toHaveBeenCalled()+ q.clients(0)+ vi.advanceTimersByTime(QUIT_AFTER_MS - 1)+ expect(quit).not.toHaveBeenCalled()+ q.clients(1); q.clients(0)+ vi.advanceTimersByTime(QUIT_AFTER_MS - 1)+ expect(quit).not.toHaveBeenCalled()+ vi.advanceTimersByTime(1)+ expect(quit).toHaveBeenCalledOnce()+ })+ it('quits too when the AI app that started it never connected', () => {+ const { quit } = make('ai-app')+ vi.advanceTimersByTime(QUIT_AFTER_MS)+ expect(quit).toHaveBeenCalledOnce()+ })+ it('waits for work in progress before quitting', () => {+ let busy = true+ const { quit } = make('ai-app', () => busy)+ vi.advanceTimersByTime(QUIT_AFTER_MS * 2)+ expect(quit).not.toHaveBeenCalled()+ busy = false+ vi.advanceTimersByTime(QUIT_AFTER_MS)+ expect(quit).toHaveBeenCalledOnce()+ })+ it('stays once the person opened it, and never quits a Yogurt they started', () => {+ const opened = make('ai-app')+ opened.q.opened()+ opened.q.clients(0)+ vi.advanceTimersByTime(QUIT_AFTER_MS * 5)+ expect(opened.quit).not.toHaveBeenCalled()+ for (const reason of ['login', 'user', 'update'] as const) {+ const other = make(reason)+ other.q.clients(1); other.q.clients(0)+ vi.advanceTimersByTime(QUIT_AFTER_MS * 5)+ expect(other.quit).not.toHaveBeenCalled()+ }+ })+ it('a login start while it waits quietly makes it a normal Yogurt, still without a window', async () => {+ const { q, quit } = make('ai-app')+ q.startedAgain('login')+ expect(q.quiet()).toBe(false)+ vi.advanceTimersByTime(QUIT_AFTER_MS * 2)+ expect(quit).not.toHaveBeenCalled()+ })+ it('another AI app start changes nothing', () => {+ const { q } = make('ai-app')+ q.startedAgain('ai-app')+ expect(q.quiet()).toBe(true)+ })+})diff --git a/app/test/startReason.test.ts b/app/test/startReason.test.tsnew file mode 100644index 00000000..76d281a9--- /dev/null+++ b/app/test/startReason.test.ts@@ -0,0 +1,36 @@+import { readFileSync } from 'node:fs'+import { join } from 'node:path'+import { describe, expect, it } from 'vitest'+import { AI_APP_ARG, startArgs, startReason } from '../src/main/startReason'++const env = {}++describe('why Yogurt started (#147)', () => {+ it('is an AI app when its yogurt-mcp says so', () => {+ expect(startReason({ argv: ['Yogurt.exe', '--hidden', AI_APP_ARG], env })).toBe('ai-app')+ expect(startReason({ argv: ['Yogurt'], env: { YOGURT_STARTED_BY: 'ai-app' } })).toBe('ai-app')+ })+ it('is an AI app when an older yogurt-mcp started it with only --hidden (Linux can see the parent)', () => {+ expect(startReason({ argv: ['yogurt', '--hidden'], env, parent: 'yogurt-mcp' })).toBe('ai-app')+ expect(startReason({ argv: ['Yogurt.exe', '--hidden'], env, parent: 'yogurt-mcp.exe' })).toBe('ai-app')+ })+ it('is login for the login item (--hidden on Windows and Linux, the Mac says so itself)', () => {+ expect(startReason({ argv: ['Yogurt.exe', '--hidden'], env })).toBe('login')+ expect(startReason({ argv: ['Yogurt'], env, openedAtLogin: true })).toBe('login')+ expect(startReason({ argv: ['yogurt', '--hidden'], env, parent: 'systemd' })).toBe('login')+ })+ it('is an update when the installer opens it again', () => {+ expect(startReason({ argv: ['Yogurt.exe', '--updated'], env })).toBe('update')+ })+ it('is the person otherwise (a shortcut, the Start menu, a notification clicked after quitting)', () => {+ expect(startReason({ argv: ['Yogurt.exe'], env })).toBe('user')+ expect(startReason({ argv: ['Yogurt.exe', '--allow-file-access-from-files'], env })).toBe('user')+ })+ it('logs the switches it was given, never a path', () => {+ expect(startArgs(['C:\\Users\\sam\\AppData\\Local\\Programs\\yogurt\\Yogurt.exe', '--hidden', AI_APP_ARG, 'C:\\Users\\sam\\file.txt', '--x=/home/sam/a'])).toBe(`--hidden ${AI_APP_ARG} --x`)+ expect(startArgs(['Yogurt'])).toBe('none')+ })+ it('is what both yogurt-mcp helpers pass when they start Yogurt', () => {+ for (const f of ['native/yogurt-mcp-relay/src/main.rs', 'native/yogurt-mcp/main.swift']) expect(readFileSync(join(__dirname, '..', f), 'utf8')).toContain(`"${AI_APP_ARG}"`)+ })+})