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
Offer Restart Yogurt in the corner when a new version has waited a day
christianmat9aeda86fc0fb
diff --git a/app/e2e/updateToast.spec.ts b/app/e2e/updateToast.spec.tsnew file mode 100644index 00000000..6ee51aba--- /dev/null+++ b/app/e2e/updateToast.spec.ts@@ -0,0 +1,56 @@+import { _electron as electron, expect, test } from '@playwright/test'+import { mkdtempSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'++// a version "downloaded" at launch; the corner waits AFTER_MS (a day in a real install) before offering Restart+const AFTER_MS = 1500+async function launch() {+ const app = await electron.launch({ args: [join(import.meta.dirname, '../out/main/index.js')], env: {+ ...process.env, YOGURT_FAKE: '1', YOGURT_USER_DATA: mkdtempSync(join(tmpdir(), 'yogurt-update-')),+ YOGURT_FAKE_UPDATE: '9.9.9', YOGURT_FAKE_UPDATE_AFTER_MS: String(AFTER_MS),+ } })+ const page = await app.firstWindow()+ await expect(page.getByTestId('home')).toBeVisible()+ return { app, page }+}+const restarts = (app: Awaited<ReturnType<typeof launch>>['app']) =>+ app.evaluate(() => (globalThis as any).__fake__.main().updateRestarts as number)++test('a downloaded version waits, then the corner offers Restart Yogurt, which restarts', async () => {+ const { app, page } = await launch()+ try {+ const toast = page.getByTestId('update-toast')+ await expect(toast).toHaveCount(0)+ await expect(toast).toContainText('Yogurt 9.9.9 is ready', { timeout: 10_000 })+ await toast.getByTestId('update-restart').click()+ await expect.poll(() => restarts(app)).toBe(1)+ await expect(toast).toHaveCount(0)+ } finally { await app.close() }+})++test('closing the offer puts it off, and it comes back later', async () => {+ const { app, page } = await launch()+ try {+ const toast = page.getByTestId('update-toast')+ await expect(toast).toBeVisible({ timeout: 10_000 })+ await toast.locator('.app-toast-close').click()+ await expect(toast).toHaveCount(0)+ await page.waitForTimeout(AFTER_MS / 2)+ await expect(toast).toHaveCount(0)+ await expect(toast).toBeVisible({ timeout: 10_000 })+ expect(await restarts(app)).toBe(0)+ } finally { await app.close() }+})++test('never offered while recording', async () => {+ const { app, page } = await launch()+ try {+ await page.evaluate(() => window.yogurt.meetings.start(null))+ await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', 'recording')+ await page.waitForTimeout(AFTER_MS * 3)+ await expect(page.getByTestId('update-toast')).toHaveCount(0)+ await page.getByTestId('note-stop').click()+ await expect(page.getByTestId('update-toast')).toBeVisible({ timeout: 10_000 })+ } finally { await app.close() }+})diff --git a/app/src/main/index.ts b/app/src/main/index.tsindex 0e906b1e..5d85952b 100644--- a/app/src/main/index.ts+++ b/app/src/main/index.ts@@ -233,6 +233,8 @@ let refreshCalendarConsumers = () => {}const systemSettings: string[] = []/** fake mode: how many times Yogurt would have quit and opened again for a permission */let relaunched = 0+/** fake mode: how many times Yogurt would have restarted to install a new version */+let updateRestarts = 0/** What is still to come today and tomorrow (meetings on now included), soonest first */async function comingUp(): Promise<CalEvent[]> {@@ -399,7 +401,7 @@ function startDetection() {signals: async (r) => { signals.override(r); await watcher.tick() },advance: () => watcher.tick(),widget: () => widget.snapshot(),- main: () => ({ presented, visible: !!win?.isVisible(), route, settingsOpened, systemSettings, mediaCalls, relaunched }),+ main: () => ({ presented, visible: !!win?.isVisible(), route, settingsOpened, systemSettings, mediaCalls, relaunched, updateRestarts }),go: (r) => goTo(r),warn: (code) => tell({ t: 'warn', code: code as WarnCode }),// a long finished meeting: n lines half a second apart, voices taking turns, with quiet low-rate audio to play@@ -936,7 +938,9 @@ app.whenReady().then(() => {const 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(),+ // fake mode: a test pretends a version downloaded, and how long it waits before the corner offers Restart+ fake: isFake() && process.env.YOGURT_FAKE_UPDATE ? { version: process.env.YOGURT_FAKE_UPDATE, afterMs: Number(process.env.YOGURT_FAKE_UPDATE_AFTER_MS ?? 0), restarted: () => { updateRestarts++ } } : undefined }).catch((err) => console.warn("couldn't start looking for new versions", err))// the Dock icon: the main window, even while the widget is upapp.on('activate', showMain)diff --git a/app/src/main/updates.ts b/app/src/main/updates.tsindex 6d747d0e..6585b49f 100644--- a/app/src/main/updates.ts+++ b/app/src/main/updates.ts@@ -21,6 +21,17 @@ export const isPreviewBuild = (packageJson: string): boolean => {try { return JSON.parse(packageJson).yogurtPreview === true } catch { return false }}+/** how long a downloaded version waits for a quit before the corner offers Restart, and how long X puts it off */+export const OFFER_AFTER_MS = 24 * 60 * 60 * 1000++/**+ * The corner offers Restart Yogurt for a downloaded version. Most people quit within a day, and it installs then+ * without a word; only someone who keeps Yogurt open longer is asked. Never during a recording (restarting would end it).+ */+export function offersRestart(o: { readyAt?: number; now: number; snoozedUntil: number; recording: boolean; on: boolean; afterMs?: number }): boolean {+ return o.readyAt !== undefined && o.on && !o.recording && o.now - o.readyAt >= (o.afterMs ?? OFFER_AFTER_MS) && o.now >= o.snoozedUntil+}+let updater: AppUpdater | undefinedlet installOnQuit = false@@ -35,13 +46,19 @@ 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 }): Promise<void> {+export async function hookUpdates(d: { file: string; available: boolean; recording(): boolean; /** fake mode: a version already downloaded */ fake?: { version: string; afterMs: number; restarted(): void } }): Promise<void> {let state: UpdateStatus['state'] = 'idle'let next: string | undefined- const status = (): UpdateStatus => ({ version: app.getVersion(), available: d.available, on: autoUpdateOn(loadSettings(d.file)), state, next })+ let readyAt: number | undefined, snoozedUntil = 0+ const status = (): UpdateStatus => {+ const on = autoUpdateOn(loadSettings(d.file))+ const offer = offersRestart({ readyAt, now: Date.now(), snoozedUntil, recording: d.recording(), on, afterMs: d.fake?.afterMs })+ return { version: app.getVersion(), available: d.available || !!d.fake, on, state, next, offer }+ }const set = (s: UpdateStatus['state'], version?: string) => {state = sif (version) next = version+ if (s === 'ready') readyAt ??= Date.now()for (const w of BrowserWindow.getAllWindows()) if (!w.isDestroyed()) w.webContents.send('updates:status', status())}@@ -57,10 +74,18 @@ export async function hookUpdates(d: { file: string; available: boolean; recordiipcMain.handle('updates:check', () => { check() })ipcMain.handle('updates:restart', () => {if (state !== 'ready' || d.recording()) return false+ // fake mode: as if Yogurt came back on the new version+ if (d.fake) { d.fake.restarted(); readyAt = undefined; set('latest'); return true }installOnQuit = trueapp.quit()return true})+ // the corner's X: ask again tomorrow+ ipcMain.handle('updates:later', () => { snoozedUntil = Date.now() + (d.fake?.afterMs ?? OFFER_AFTER_MS); set(state) })+ // the offer depends on the clock and on recording, so tell the windows again now and then once a version is ready+ setInterval(() => { if (state === 'ready') set(state) }, d.fake ? Math.max(200, d.fake.afterMs / 4) : 10 * 60 * 1000).unref?.()++ if (d.fake) { set('ready', d.fake.version); return }const check = () => { if (updater && autoUpdateOn(loadSettings(d.file)) && state !== 'ready') updater.checkForUpdates().catch(() => {}) }if (!d.available) returndiff --git a/app/src/preload/index.ts b/app/src/preload/index.tsindex d44415bd..ea16ff81 100644--- a/app/src/preload/index.ts+++ b/app/src/preload/index.ts@@ -203,6 +203,7 @@ const api: YogurtApi = {set: (on) => ipcRenderer.invoke('updates:set', on),check: () => ipcRenderer.invoke('updates:check'),restart: () => ipcRenderer.invoke('updates:restart'),+ later: () => ipcRenderer.invoke('updates:later'),onStatus: (fn) => { const f = (_e: unknown, s: UpdateStatus) => fn(s); ipcRenderer.on('updates:status', f); return () => { ipcRenderer.off('updates:status', f) } },},backup: {diff --git a/app/src/renderer/src/components/TrashToast.tsx b/app/src/renderer/src/components/TrashToast.tsxindex e7c7301a..fc4f50ff 100644--- a/app/src/renderer/src/components/TrashToast.tsx+++ b/app/src/renderer/src/components/TrashToast.tsx@@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from 'react'import { Toast } from '@animate-ui/react/primitives/base-ui/toast'import { X } from 'lucide-react'import { t } from '../../../shared/i18n'-import type { SetupState } from '../../../shared/types'+import type { SetupState, UpdateStatus } from '../../../shared/types'import { notesReadyNotice } from '../notesSetup'import { trashMeetings, restoreMeetings } from '../trashMeetings'@@ -67,6 +67,29 @@ export function TrashToast({ go }: { go: (route: string) => void }) {remind()return off}, [])+ useEffect(() => {+ // a downloaded version Yogurt has waited a day to install: Restart Yogurt here; X asks again tomorrow+ let shown: string | undefined, restarting = false+ const offer = (s: UpdateStatus) => {+ if (!s.offer || !s.next) { if (shown) toasts.close(shown); shown = undefined; return }+ if (shown) return+ const id = shown = toasts.add({+ id: 'update-ready', title: t('Yogurt {version} is ready', { version: s.next }), timeout: 0,+ data: { testId: 'update-toast', actionTestId: 'update-restart' },+ onClose: () => { if (shown !== id) return; shown = undefined; if (!restarting) void window.yogurt.updates.later() },+ actionProps: { children: t('Restart Yogurt'), onClick: async () => {+ restarting = true+ const ok = await window.yogurt.updates.restart().catch(() => false)+ if (ok) { toasts.close(id); return }+ restarting = false+ toasts.update(id, { title: t('Stop the recording first, then try again.') })+ } },+ })+ }+ const off = window.yogurt.updates.onStatus(offer)+ void window.yogurt.updates.status().then(offer)+ return off+ }, [])const previous = useRef<string>(undefined)useEffect(() => {show = (s) => {diff --git a/app/src/shared/types.ts b/app/src/shared/types.tsindex e0b19a3d..fb4c0504 100644--- a/app/src/shared/types.ts+++ b/app/src/shared/types.ts@@ -151,6 +151,8 @@ export type YogurtApi = {check(): Promise<void>/** quits, installs the downloaded version and reopens; false while recording or with nothing downloaded */restart(): Promise<boolean>+ /** the corner's offer was closed: it comes back tomorrow */+ later(): Promise<void>onStatus(fn: (s: UpdateStatus) => void): () => void}backup: {@@ -406,4 +408,6 @@ export type ConversationSummary = { id: string; title: string; updatedAt: number/** enabled: in Settings. clients: apps connected now. command: the program to give an AI app */export type McpStatus = { enabled: boolean; clients: string[]; command: string }/** Settings → Updates. available: this build updates itself (not in development or a preview); next: the version found */-export type UpdateStatus = { version: string; available: boolean; on: boolean; state: 'idle' | 'checking' | 'latest' | 'downloading' | 'ready' | 'error'; next?: string }+export type UpdateStatus = { version: string; available: boolean; on: boolean; state: 'idle' | 'checking' | 'latest' | 'downloading' | 'ready' | 'error'; next?: string+ /** the corner should offer Restart Yogurt for the version that downloaded (offersRestart) */+ offer?: boolean }diff --git a/app/test/updates.test.ts b/app/test/updates.test.tsindex eb249932..025b880f 100644--- a/app/test/updates.test.ts+++ b/app/test/updates.test.ts@@ -1,5 +1,5 @@import { expect, it } from 'vitest'-import { isPreviewBuild, updatesOn } from '../src/main/updates'+import { isPreviewBuild, offersRestart, updatesOn } from '../src/main/updates'const installed = { packaged: true, fake: false, profile: false, feed: true }@@ -34,3 +34,19 @@ it('a preview build is told by its package.json; a release build or anything unrexpect(isPreviewBuild(JSON.stringify({ name: 'yogurt' }))).toBe(false)expect(isPreviewBuild('')).toBe(false)})++const HOUR = 60 * 60 * 1000+const ready = { readyAt: 0, now: 25 * HOUR, snoozedUntil: 0, recording: false, on: true }++it('a downloaded version is offered with Restart only after a day, so someone who quits Yogurt meanwhile never sees it', () => {+ expect(offersRestart({ ...ready, now: 23 * HOUR })).toBe(false)+ expect(offersRestart(ready)).toBe(true)+ expect(offersRestart({ ...ready, readyAt: undefined })).toBe(false)+})++it('never during a recording, with updates off, or while put off until tomorrow', () => {+ expect(offersRestart({ ...ready, recording: true })).toBe(false)+ expect(offersRestart({ ...ready, on: false })).toBe(false)+ expect(offersRestart({ ...ready, snoozedUntil: 26 * HOUR })).toBe(false)+ expect(offersRestart({ ...ready, snoozedUntil: 25 * HOUR })).toBe(true)+})