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
Dev on Linux: pnpm dev stays up on Wayland, and says what to fix instead of crashing (#119)
Mohammad Ibrahim.3f06350772bf
diff --git a/app/package.json b/app/package.jsonindex 5000bca0..5c62adaf 100644--- a/app/package.json+++ b/app/package.json@@ -5,7 +5,7 @@"type": "module","main": "out/main/index.js","scripts": {- "dev": "electron-vite dev",+ "dev": "node scripts/dev.mjs","build": "node scripts/native.mjs && electron-vite build","test": "vitest run","e2e": "node scripts/native.mjs && electron-vite build && playwright test",diff --git a/app/scripts/dev.mjs b/app/scripts/dev.mjsnew file mode 100644index 00000000..ebb6b73d--- /dev/null+++ b/app/scripts/dev.mjs@@ -0,0 +1,56 @@+// pnpm dev: electron-vite's dev server and Electron, after the checks that otherwise end in an unclear crash.+// - Electron's own download is there: a skipped postinstall leaves only "Error: Electron uninstall".+// - Linux on Wayland: Electron starts on X11 straight away, like the AppImage's launcher (build/linux-launcher.sh).+// The app's own relaunch (src/main/display.ts) ends the first Electron, and electron-vite stops the dev server with it.+// - Linux where unprivileged user namespaces are off (Ubuntu 24.04): Electron's chrome-sandbox has to be root's with+// mode 4755, and the folder can't have a space in its path (Chromium splits the helper's command at spaces).+import { spawnSync } from 'node:child_process'+import { existsSync, readFileSync, statSync } from 'node:fs'+import { createRequire } from 'node:module'+import { dirname, join } from 'node:path'+import { fileURLToPath } from 'node:url'++/** the switches Electron starts with: X11 through XWayland on a Wayland desktop, unless a switch was given by hand */+export function electronArgs(platform, env, args) {+ if (platform !== 'linux' || env.YOGURT_FAKE === '1') return args+ if (!env.WAYLAND_DISPLAY || !env.DISPLAY || args.some((a) => a.startsWith('--ozone-platform'))) return args+ return ['--ozone-platform=x11', ...args]+}++/** what stops Chromium's setuid sandbox from starting, each with its fix; empty when it will start */+export function sandboxProblems({ platform, env, usernsRestricted, sandbox, electronDir }) {+ if (platform !== 'linux' || !usernsRestricted || env.ELECTRON_DISABLE_SANDBOX) return []+ const problems = []+ if (sandbox && !(sandbox.uid === 0 && (sandbox.mode & 0o7777) === 0o4755)) {+ const file = join(electronDir, 'dist', 'chrome-sandbox')+ problems.push(`Electron's sandbox helper must be owned by root with mode 4755 (again after each reinstall of node_modules):\n sudo chown root:root "${file}"\n sudo chmod 4755 "${file}"`)+ }+ if (electronDir.includes(' ')) problems.push(`Electron's sandbox can't start from a folder with a space in its path:\n ${electronDir}\nMove the repository to a path without spaces.`)+ return problems+}++if (process.argv[1] === fileURLToPath(import.meta.url)) {+ const app = join(dirname(fileURLToPath(import.meta.url)), '..')+ const resolve = createRequire(join(app, 'package.json')).resolve+ const electronDir = dirname(resolve('electron/package.json'))+ const run = (cmd, args) => spawnSync(cmd, args, { cwd: app, stdio: 'inherit' }).status ?? 1++ if (!existsSync(join(electronDir, 'path.txt'))) {+ console.log("Electron's download is missing: fetching it")+ if (run(process.execPath, [join(electronDir, 'install.js')]) !== 0) process.exit(1)+ }++ let usernsRestricted = false+ try { usernsRestricted = readFileSync('/proc/sys/kernel/apparmor_restrict_unprivileged_userns', 'utf8').trim() === '1' } catch {}+ const sandboxFile = join(electronDir, 'dist', 'chrome-sandbox')+ const sandbox = existsSync(sandboxFile) ? statSync(sandboxFile) : null+ const problems = sandboxProblems({ platform: process.platform, env: process.env, usernsRestricted, sandbox, electronDir })+ if (problems.length) {+ console.error(`${problems.join('\n\n')}\n\nOr skip Electron's sandbox for this run: ELECTRON_DISABLE_SANDBOX=1 pnpm dev`)+ process.exit(1)+ }++ const args = electronArgs(process.platform, process.env, process.argv.slice(2))+ const electronVite = join(dirname(resolve('electron-vite/package.json')), 'bin', 'electron-vite.js')+ process.exit(run(process.execPath, [electronVite, 'dev', ...(args.length ? ['--', ...args] : [])]))+}diff --git a/app/test/devScript.test.ts b/app/test/devScript.test.tsnew file mode 100644index 00000000..db4501af--- /dev/null+++ b/app/test/devScript.test.ts@@ -0,0 +1,35 @@+import { expect, it } from 'vitest'+// @ts-expect-error plain script, no types+import { electronArgs, sandboxProblems } from '../scripts/dev.mjs'++const wayland = { WAYLAND_DISPLAY: 'wayland-0', DISPLAY: ':0' }++it('pnpm dev on Wayland starts Electron on X11 itself: the app relaunching would end the dev server', () => {+ expect(electronArgs('linux', wayland, [])).toEqual(['--ozone-platform=x11'])+ expect(electronArgs('linux', wayland, ['--inspect'])).toEqual(['--ozone-platform=x11', '--inspect'])+})++it('never on X11, without XWayland, on a Mac or Windows, in fake mode, or over a switch given by hand', () => {+ expect(electronArgs('linux', { DISPLAY: ':0' }, [])).toEqual([])+ expect(electronArgs('linux', { WAYLAND_DISPLAY: 'wayland-0' }, [])).toEqual([])+ expect(electronArgs('darwin', wayland, [])).toEqual([])+ expect(electronArgs('win32', wayland, [])).toEqual([])+ expect(electronArgs('linux', { ...wayland, YOGURT_FAKE: '1' }, [])).toEqual([])+ expect(electronArgs('linux', wayland, ['--ozone-platform=wayland'])).toEqual(['--ozone-platform=wayland'])+})++const restricted = { platform: 'linux', env: {}, usernsRestricted: true, electronDir: '/home/sam/code/yogurt/node_modules/electron' }+const setuid = { uid: 0, mode: 0o104755 }++it("where the sandbox needs its setuid helper, pnpm dev says how to set it up instead of Electron's crash", () => {+ expect(sandboxProblems({ ...restricted, sandbox: { uid: 1000, mode: 0o100755 } })).toEqual([expect.stringContaining('sudo chmod 4755')])+ expect(sandboxProblems({ ...restricted, sandbox: setuid, electronDir: '/home/sam/Personal Docs/yogurt/node_modules/electron' })).toEqual([expect.stringContaining('space')])+ expect(sandboxProblems({ ...restricted, sandbox: setuid })).toEqual([])+})++it('nothing to say when user namespaces are allowed, off Linux, or with the sandbox turned off', () => {+ const broken = { ...restricted, sandbox: { uid: 1000, mode: 0o100755 }, electronDir: '/a b/electron' }+ expect(sandboxProblems({ ...broken, usernsRestricted: false })).toEqual([])+ expect(sandboxProblems({ ...broken, platform: 'darwin' })).toEqual([])+ expect(sandboxProblems({ ...broken, env: { ELECTRON_DISABLE_SANDBOX: '1' } })).toEqual([])+})diff --git a/docs/building.md b/docs/building.mdindex 723f1847..2e553b6d 100644--- a/docs/building.md+++ b/docs/building.md@@ -6,7 +6,13 @@- CMake- **Mac:** Xcode Command Line Tools- **Windows:** Rust, the Vulkan SDK, Visual Studio C++ Build Tools-- **Linux:** Rust, the Vulkan SDK, `libpulse-dev`, `pkg-config`+- **Linux:** Rust, the Vulkan SDK, `libpulse-dev`, `pkg-config`. On Ubuntu 24.04 or newer, these packages can stand in for the Vulkan SDK:++ ```sh+ sudo apt install libpulse-dev pkg-config libvulkan-dev glslc spirv-headers+ ```++On Linux, clone into a folder whose path has no spaces: Electron's sandbox can't start from one.## Run it@@ -22,6 +28,7 @@ The first run downloads the AI models, like the installed app.- **Separate profile:** `YOGURT_USER_DATA=/tmp/yogurt-dev pnpm dev` keeps your real meetings out of it.- **Without models:** `YOGURT_FAKE=1 pnpm dev` swaps in a fake transcriber, notes model and call audio, so the whole app runs in seconds.+- **Linux sandbox:** on Ubuntu 24.04 and other systems that turn off unprivileged user namespaces, Electron's sandbox helper must be owned by root. `pnpm dev` prints the two `sudo` commands when it isn't, and they're needed again after `node_modules` is reinstalled.## Test