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 second Yogurt that hands off to the running one quits without starting up, and never writes its own pipe name to mcp.pipe, so AI apps on Windows keep reaching Yogurt (#156)
christianmat9e8ae0644f6e
diff --git a/app/src/main/index.ts b/app/src/main/index.tsindex a62d0b5d..dcf5f614 100644--- a/app/src/main/index.ts+++ b/app/src/main/index.ts@@ -116,9 +116,13 @@ process.on('uncaughtException', (err) => console.error('uncaught exception', err// Linux on Wayland: once more through XWayland, so the widget and the card can float (display.ts)const x11 = x11Relaunch(process.platform, process.argv, process.env, process.execPath)+/**+ * One Yogurt at a time: a second launch hands its arguments to the running one (second-instance) and quits. It does+ * nothing else on the way out (#156: an AI app's --hidden start ran the whole start-up, and wrote its own mcp.pipe).+ */+const primary = !x11 && app.requestSingleInstanceLock()if (x11) { stripAppImageEnv(); app.relaunch(x11); app.exit(0) }-// One Yogurt at a time: a second launch focuses the existing window-else if (!app.requestSingleInstanceLock()) app.quit()+else if (!primary) app.quit()let win: BrowserWindow | undefined/** the iPhone companion once it has started (Settings → Phone pairs and unpairs through it) */let companion: Companion | undefined@@ -557,6 +561,7 @@ function startDetection() {}app.whenReady().then(() => {+ if (!primary) returnconsole.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 Yogurtconst started = startReason({ argv: process.argv, env: process.env, parent: parentName(), openedAtLogin: openedAtLogin() })diff --git a/app/src/main/mcp/index.ts b/app/src/main/mcp/index.tsindex f7442ea1..c05b8caa 100644--- a/app/src/main/mcp/index.ts+++ b/app/src/main/mcp/index.ts@@ -1,11 +1,11 @@import { app, ipcMain } from 'electron'import { randomBytes } from 'node:crypto'-import { existsSync, renameSync, writeFileSync } from 'node:fs'+import { existsSync } from 'node:fs'import { join } from 'node:path'import { helperFile } from '../../shared/platform'import type { Store } from '../store'import { createMcp, type McpApp } from './server'-import { helperCopyPath, installHelper, LAUNCH_FILE, launchCommand, mcpAddress, PIPE_FILE } from './paths'+import { helperCopyPath, installHelper, LAUNCH_FILE, launchCommand, mcpAddress, publishPipe, writeWhole } from './paths'import { serveMcp } from './socket'/** yogurt-mcp, the program an AI app starts: it passes messages between that app and Yogurt */@@ -18,12 +18,6 @@ export function mcpHelperPath(): string {return candidates.find((c) => existsSync(c)) ?? candidates.at(-1)!}-/** small files the helper reads, written whole so it never reads half of one */-function writeWhole(path: string, text: string) {- writeFileSync(`${path}.part`, text)- renameSync(`${path}.part`, path)-}-/** Linux: AI apps are given a copy in the profile folder, because the AppImage's own path moves each launch */function copyHelper(profile: string): string | undefined {const dest = helperCopyPath(process.platform, profile)@@ -52,7 +46,8 @@ export async function hookMcp(d: {const address = mcpAddress(process.platform, d.profile, randomBytes(16).toString('hex'))try {server = await serveMcp(address, mcp, d.send)- if (process.platform === 'win32') writeWhole(join(d.profile, PIPE_FILE), address)+ // a second Yogurt handing off to the running one never gets this far (index.ts), and never writes it if it did+ publishPipe(process.platform, d.profile, address, app.hasSingleInstanceLock())} catch (e) { console.error('mcp: could not open its socket', e) }// what the helper starts when Yogurt is closed (Windows, Linux): recorded each launch, as an AppImage can moveconst launch = launchCommand(process.platform, app.isPackaged, process.execPath, process.env)diff --git a/app/src/main/mcp/paths.ts b/app/src/main/mcp/paths.tsindex 951aac41..c413e02d 100644--- a/app/src/main/mcp/paths.ts+++ b/app/src/main/mcp/paths.ts@@ -1,5 +1,5 @@-import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync } from 'node:fs'-import { dirname, posix } from 'node:path'+import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'+import { dirname, join, posix } from 'node:path'/** Windows: the pipe's name is in this file in the profile folder, where the helper reads it */export const PIPE_FILE = 'mcp.pipe'@@ -17,6 +17,23 @@ export function mcpAddress(platform: string, profile: string, id: string): strinreturn platform === 'win32' ? `\\\\.\\pipe\\yogurt-mcp-${id}` : posix.join(profile, 'mcp.sock')}+/** small files the helper reads, written whole so it never reads half of one */+export function writeWhole(path: string, text: string) {+ writeFileSync(`${path}.part`, text)+ renameSync(`${path}.part`, path)+}++/**+ * Windows: tells the helper the pipe's name. Only the Yogurt that holds the single-instance lock writes it: a second+ * launch hands off to that one and quits, and its own pipe, gone a moment later, must never replace the running one's+ * (#156: an AI app's --hidden start left the helper pointed at a pipe that no longer existed). true: written.+ */+export function publishPipe(platform: string, profile: string, address: string, primary: boolean): boolean {+ if (platform !== 'win32' || !primary) return false+ writeWhole(join(profile, PIPE_FILE), address)+ return true+}+/*** What the helper starts when Yogurt is closed. Windows: the installed Yogurt.exe. Linux: the AppImage, wherever* it was started from this time. A Mac opens Yogurt by its bundle id, and a dev or test run would start a bare Electron.diff --git a/app/test/mcpPaths.test.ts b/app/test/mcpPaths.test.tsindex 375e3d20..aa0ece44 100644--- a/app/test/mcpPaths.test.ts+++ b/app/test/mcpPaths.test.ts@@ -2,7 +2,8 @@ import { afterEach, describe, expect, it } from 'vitest'import { mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'-import { helperCopyPath, installHelper, launchCommand, mcpAddress, startedHidden } from '../src/main/mcp/paths'+import { existsSync } from 'node:fs'+import { helperCopyPath, installHelper, launchCommand, mcpAddress, PIPE_FILE, publishPipe, startedHidden } from '../src/main/mcp/paths'const dirs: string[] = []afterEach(() => { dirs.splice(0).forEach((d) => rmSync(d, { recursive: true, force: true })) })@@ -20,6 +21,27 @@ describe('where AI apps reach Yogurt', () => {})})+// #156: each AI-app start of a second Yogurt wrote its own pipe's name, then quit, leaving the helper a pipe that was gone+describe('the pipe name file (Windows)', () => {+ it('is written by the Yogurt that holds the single-instance lock', () => {+ const d = tmp()+ expect(publishPipe('win32', d, '\\\\.\\pipe\\yogurt-mcp-first', true)).toBe(true)+ expect(readFileSync(join(d, PIPE_FILE), 'utf8')).toBe('\\\\.\\pipe\\yogurt-mcp-first')+ })+ it('is never overwritten by a second Yogurt that is handing off to the running one', () => {+ const d = tmp()+ publishPipe('win32', d, '\\\\.\\pipe\\yogurt-mcp-first', true)+ expect(publishPipe('win32', d, '\\\\.\\pipe\\yogurt-mcp-second', false)).toBe(false)+ expect(readFileSync(join(d, PIPE_FILE), 'utf8')).toBe('\\\\.\\pipe\\yogurt-mcp-first')+ })+ it('is not written on a Mac or Linux (they use the socket)', () => {+ const d = tmp()+ expect(publishPipe('darwin', d, '/x/mcp.sock', true)).toBe(false)+ expect(publishPipe('linux', d, '/x/mcp.sock', true)).toBe(false)+ expect(existsSync(join(d, PIPE_FILE))).toBe(false)+ })+})+describe('what the helper opens when Yogurt is closed', () => {it('is nothing to record on a Mac (it opens Yogurt by its bundle id)', () => {expect(launchCommand('darwin', true, '/Applications/Yogurt.app/Contents/MacOS/Yogurt', {})).toBeUndefined()