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
Recording: one calmer wave meter everywhere
Eric Brownroutae21a68b2663
diff --git a/app/e2e/meterGeometry.ts b/app/e2e/meterGeometry.tsnew file mode 100644index 00000000..575c4b21--- /dev/null+++ b/app/e2e/meterGeometry.ts@@ -0,0 +1,6 @@+import type { Locator } from '@playwright/test'++/** Actual visible stroke heights, including the two non-scaling round caps. */+export const meterHeights = (meter: Locator) => meter.locator('line').evaluateAll(lines =>+ lines.map(line => Number(getComputedStyle(line).opacity) > 0+ ? line.getBoundingClientRect().height + parseFloat(getComputedStyle(line).strokeWidth) : 0))diff --git a/app/e2e/meterSleep.spec.ts b/app/e2e/meterSleep.spec.tsindex 198f657b..3ec9b5f5 100644--- a/app/e2e/meterSleep.spec.ts+++ b/app/e2e/meterSleep.spec.ts@@ -1,3 +1,4 @@+import { meterHeights } from './meterGeometry'import { _electron as electron, expect, test } from '@playwright/test'import { mkdtempSync } from 'node:fs'import { tmpdir } from 'node:os'@@ -32,7 +33,7 @@ test('the level meter stops drawing while its window is hidden and once the room// the fake mic falls silent: the meter settles at rest, still drawn, and the loop sleepsawait expect(wave).toHaveAttribute('data-live', '0', { timeout: 30_000 })await expect(wave).toHaveAttribute('data-level', '0.00')- expect(await wave.evaluate((c: HTMLCanvasElement) => c.getContext('2d')!.getImageData(0, 0, c.width, c.height).data.some((v, i) => i % 4 === 3 && v > 0))).toBe(true)+ expect((await meterHeights(wave)).map(Math.round)).toEqual([3, 3, 3, 3, 3])await page.waitForTimeout(500)await expect(wave).toHaveAttribute('data-live', '0')} finally { await app.close() }diff --git a/app/e2e/noteFooter.spec.ts b/app/e2e/noteFooter.spec.tsindex 9d6ea663..4d6b0216 100644--- a/app/e2e/noteFooter.spec.ts+++ b/app/e2e/noteFooter.spec.ts@@ -1,3 +1,4 @@+import { meterHeights } from './meterGeometry'import { _electron as electron, expect, test } from '@playwright/test'import { mkdtempSync } from 'node:fs'import { tmpdir } from 'node:os'@@ -16,7 +17,7 @@ test('recording controls stay in the header and Ask lives in the footer with staconst header = page.locator('.note-header'), controls = header.getByTestId('note-state')await expect(header.getByTestId('note-elapsed')).toHaveAccessibleName('Recorded time')await expect(header.getByTestId('note-elapsed')).toBeVisible()- await expect(controls.locator('time, canvas')).toHaveCount(0)+ await expect(controls.locator('time, [data-testid="note-wave"]')).toHaveCount(0)await expect(controls).toHaveAccessibleName('Recording')await expect(controls.getByTestId('note-pause')).toBeVisible()await expect(controls.getByTestId('note-stop')).toBeVisible()@@ -59,7 +60,7 @@ test('recording controls stay in the header and Ask lives in the footer with staconst gaps = await page.getByTestId('rec-bar').evaluate(bar => {const digits = document.createRange()digits.selectNodeContents(bar.querySelector('time')!)- const [left, middle, right] = [bar.querySelector('canvas')!.getBoundingClientRect(),+ const [left, middle, right] = [bar.querySelector('[data-testid="note-wave"]')!.getBoundingClientRect(),digits.getBoundingClientRect(), bar.querySelector('[data-testid="note-state"]')!.getBoundingClientRect()].sort((a, b) => a.left - b.left)return [Math.round(middle.left - left.right), Math.round(right.left - middle.right)]@@ -98,9 +99,10 @@ test('recording controls stay in the header and Ask lives in the footer with staawait expect(page.getByTestId('note-pause')).toHaveAccessibleName('Resume recording')await expect(controls).toHaveAccessibleName('Paused')expect(Math.abs((await controls.boundingBox())!.width - recordingWidth)).toBeLessThan(1)- const pausedWave = await page.getByTestId('note-wave').evaluate(el => (el as HTMLCanvasElement).toDataURL())+ const pausedWave = await meterHeights(page.getByTestId('note-wave'))+ expect(pausedWave.map(Math.round)).toEqual([3, 3, 3, 3, 3])await page.waitForTimeout(150)- expect(await page.getByTestId('note-wave').evaluate(el => (el as HTMLCanvasElement).toDataURL())).toBe(pausedWave)+ expect(await meterHeights(page.getByTestId('note-wave'))).toEqual(pausedWave)await page.getByTestId('note-pause').focus()await page.keyboard.press('Tab')await expect(page.getByTestId('note-stop')).toBeFocused()diff --git a/app/e2e/recordingReturn.spec.ts b/app/e2e/recordingReturn.spec.tsindex 38b63947..da0fba39 100644--- a/app/e2e/recordingReturn.spec.ts+++ b/app/e2e/recordingReturn.spec.ts@@ -1,3 +1,4 @@+import { meterHeights } from './meterGeometry'import { _electron as electron, expect, test } from '@playwright/test'import { mkdtempSync } from 'node:fs'import { tmpdir } from 'node:os'@@ -58,9 +59,10 @@ test('the header recorder returns from every other page and follows pause, renamawait expect(page.getByTestId('note-pause')).toHaveAccessibleName('Resume recording')await go('/chat')await expect(link).toHaveAttribute('data-paused', 'true')- const pausedWave = await link.getByTestId('recording-return-wave').evaluate((el) => (el as HTMLCanvasElement).toDataURL())+ const pausedWave = await meterHeights(link.getByTestId('recording-return-wave'))+ expect(pausedWave.map(Math.round)).toEqual([3, 3, 3, 3, 3])await page.waitForTimeout(150)- expect(await link.getByTestId('recording-return-wave').evaluate((el) => (el as HTMLCanvasElement).toDataURL())).toBe(pausedWave)+ expect(await meterHeights(link.getByTestId('recording-return-wave'))).toEqual(pausedWave)await page.reload()await expect(link).toHaveAttribute('data-paused', 'true')await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows().find((w) => !w.webContents.getURL().includes('#'))!.setSize(720, 600))diff --git a/app/e2e/widget.spec.ts b/app/e2e/widget.spec.tsindex 255ebdae..4e42c4f0 100644--- a/app/e2e/widget.spec.ts+++ b/app/e2e/widget.spec.ts@@ -1,3 +1,4 @@+import { meterHeights } from './meterGeometry'import { _electron as electron, expect, test, type ElectronApplication, type Page } from '@playwright/test'import { mkdtempSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'@@ -260,11 +261,11 @@ test('hints retain both unavailable recording inputs', async () => {} finally { await app.close() }})-test('with reduced motion the meter stays three static dots', async () => {+test('reduced motion keeps five visible bars without travel', async () => {const { app, page } = await launch()try {const w = await record(app, page)- const drawn = (id: string) => w.getByTestId(id).evaluate((c: HTMLCanvasElement) => c.getContext('2d')!.getImageData(0, 0, c.width, c.height).data.some((v, i) => i % 4 === 3 && v > 0))+ const drawn = async (id: string) => (await meterHeights(w.getByTestId(id))).filter(h => h > 0).length === 5// the setting changing while the widget is up is picked upawait w.emulateMedia({ reducedMotion: 'reduce' })await expect.poll(() => drawn('widget-wave')).toBe(true)diff --git a/app/src/main/widget.ts b/app/src/main/widget.tsindex a4c791bc..e52363fa 100644--- a/app/src/main/widget.ts+++ b/app/src/main/widget.ts@@ -1,3 +1,4 @@+import { silentSpeech, speechSample } from '../shared/speechWave'import { BrowserWindow, ipcMain, Notification, screen } from 'electron'import { join } from 'node:path'import type { Meeting } from './store'@@ -59,6 +60,7 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:/** the computer the windows are made for (a Mac's panel, a tool window elsewhere) */windowOs?: string }) {const model = new WidgetModel(d.os)+ let speech = silentSpeechlet win: BrowserWindow | undefinedlet pill = { x: 0, y: 0, width: FIRST_W, height: FIRST_H }let layout: WidgetLayout | null = null@@ -144,6 +146,7 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:}onMeetingStart((m) => {+ speech = silentSpeechnotifyOnChange = false; notice = null; stopPressed = falsemodel.start({ id: m.id, title: m.title, startedAt: m.resume ? m.resume.startedAt - m.resume.capturedMs : m.startedAt })open(); push()@@ -181,8 +184,10 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:})onRecordingEvent((e) => {if (!model.meetingId) return- if (e.t === 'level') broadcast('widget:level', { me: e.me, them: e.them })- else if (e.t === 'paused' && e.meetingId === model.meetingId) { model.pause(e.paused, e.at); push() }+ if (e.t === 'level') {+ speech = speechSample(speech, e, performance.timeOrigin + performance.now())+ broadcast('widget:level', { me: e.me, them: e.them, speech })+ } else if (e.t === 'paused' && e.meetingId === model.meetingId) { model.pause(e.paused, e.at); push() }else if (e.t === 'warn') { model.warn(e.code); push() }else if (e.t === 'gave-up') model.gaveUp()else if (e.t === 'hiccup') {diff --git a/app/src/preload/index.ts b/app/src/preload/index.tsindex 5886c6d7..55bf9a3d 100644--- a/app/src/preload/index.ts+++ b/app/src/preload/index.ts@@ -1,3 +1,4 @@+import type { MeterPacket } from '../shared/speechWave'import { audioUpload } from './audioUpload'import type { WidgetLayout } from '../shared/widgetMorph'import { contextBridge, ipcRenderer } from 'electron'@@ -34,7 +35,7 @@ const api: YogurtApi = {return () => { ipcRenderer.removeListener('widget:state', on) }},onLevel: (cb) => {- const on = (_e: unknown, lv: { me: number; them: number }) => cb(lv)+ const on = (_e: unknown, lv: MeterPacket) => cb(lv)ipcRenderer.on('widget:level', on)return () => { ipcRenderer.removeListener('widget:level', on) }},diff --git a/app/src/renderer/src/components/LevelBars.tsx b/app/src/renderer/src/components/LevelBars.tsxindex 15106516..3eb64c21 100644--- a/app/src/renderer/src/components/LevelBars.tsx+++ b/app/src/renderer/src/components/LevelBars.tsx@@ -1,82 +1,92 @@import { useEffect, useRef } from 'react'-import { barPlan, frameKey, micLevel, Wave } from '../../../shared/wave'+import { FALL, RISE, SPEECH_PACKET_TIMEOUT, WAVE_PERIOD, silentSpeech, speechAt, speechBars, type SpeechAnchor } from '../../../shared/speechWave'-const BAR_W = 3, GAP = 3+const WIDTH = 15, STROKE = 1.75, STUB = 3+type Props = { height: number; className?: string; testId: string; paused?: boolean; stillBars?: boolean }-const reducedQuery = () => window.matchMedia('(prefers-reduced-motion: reduce)')+// Scale the centreline. Its non-scaling stroke retains the same round caps at every height.+const scale = (value: number, height: number) => `scaleY(${(STUB + value * (height - STUB) - STROKE) / (height - STROKE)})`-/** Shared live microphone meter, drawn without React renders; no simulated movement. */-export function LevelBars({ height, className, testId, paused = false, bars = 5, stillBars = false }: { height: number; bars?: 3 | 5; className?: string; testId: string; paused?: boolean; stillBars?: boolean }) {- const canvas = useRef<HTMLCanvasElement>(null)- const width = bars * BAR_W + (bars - 1) * GAP+export function LevelBars({ height, className = '', testId, paused = false, stillBars = false }: Props) {+ const ref = useRef<SVGSVGElement>(null)+ const recent = useRef(silentSpeech)useEffect(() => {- const c = canvas.current- if (!c) return- const wave = new Wave()- const mq = reducedQuery()- const dpr = window.devicePixelRatio || 1- let reduced = mq.matches- c.width = width * dpr; c.height = height * dpr- // read once (and again when the theme changes), not every frame: getComputedStyle forces a style pass- let color = getComputedStyle(c).color- let drawn = ''- const draw = (force = false) => {- const ctx = c.getContext('2d')- if (!ctx) return- const plan = barPlan({ reduced, paused, level: wave.level, bars, stillBars })- // the same pixels as the last frame: nothing new for the compositor- const key = frameKey(plan, height - BAR_W)- if (!force && key === drawn) return- drawn = key- ctx.setTransform(dpr, 0, 0, dpr, 0, 0)- ctx.clearRect(0, 0, width, height)- ctx.fillStyle = color- plan.heights.forEach((v, i) => {- const h = BAR_W + Math.round(v * (height - BAR_W))- ctx.globalAlpha = plan.alpha[i]- ctx.beginPath()- const inset = (width - plan.heights.length * BAR_W - (plan.heights.length - 1) * GAP) / 2- ctx.roundRect(inset + i * (BAR_W + GAP), (height - h) / 2, BAR_W, h, BAR_W / 2)- ctx.fill()+ const svg = ref.current!+ const bars = [...svg.querySelectorAll('line')]+ const media = window.matchMedia('(prefers-reduced-motion: reduce)')+ const clock = () => performance.timeOrigin + performance.now()+ let playing = false, animations: Animation[] = [], deadline: ReturnType<typeof setTimeout> | undefined+ const cancel = () => { for (const animation of animations) animation.cancel(); animations = [] }++ function sync() {+ clearTimeout(deadline)+ cancel()+ const now = clock(), anchor = recent.current, voice = speechAt(anchor, now)+ const visible = document.visibilityState === 'visible'+ playing = visible && !paused && anchor.speaking && now < anchor.at + SPEECH_PACKET_TIMEOUT+ const marker = stillBars && (paused || media.matches)+ const drive = visible && !paused ? voice.drive : 0+ const duration = playing ? (1 - drive) * RISE : drive * FALL+ const planAt = (ms: number) => speechBars({+ drive: Math.min(1, Math.max(0, drive + ms / (playing ? RISE : -FALL))),+ phase: voice.phase + ms,+ }, media.matches)+ const plan = planAt(0)+ bars.forEach((bar, i) => {+ const value = marker ? [.35, .525, .7, .525, .35][i] : plan.heights[i]+ bar.style.transform = scale(value, height)+ bar.style.opacity = String(marker ? .835 : plan.alpha[i])})- ctx.globalAlpha = 1- c.dataset.level = wave.level.toFixed(2)- }- let levelAt = performance.now()- const off = window.yogurt.widget.onLevel((lv) => {- wave.target = micLevel(lv); levelAt = performance.now()- if (reduced) { wave.level = wave.target; draw() } else if (wave.target > 0) wake()- })- let raf = 0, last = performance.now()- // tests read whether the loop runs; set only when that changes- const live = (on: boolean) => { if (!on) { cancelAnimationFrame(raf); raf = 0 } c.dataset.live = on ? '1' : '0' }- const frame = (now: number) => {- const dt = Math.min(100, now - last); last = now- if (now - levelAt > 300) wave.target = 0- wave.step(dt)- // at rest in silence the loop sleeps until the next level wakes it- if (wave.settled()) { draw(true); live(false); return }- draw()- raf = requestAnimationFrame(frame)+ svg.dataset.level = drive.toFixed(2)+ svg.dataset.live = !media.matches && !marker && (playing || duration > 0) ? '1' : '0'+ if (!visible || paused || marker || (!playing && duration === 0)) return++ // Submit a continuous timeline at gate changes. The display interpolates between samples+ // even when this window's JS frame callbacks run less frequently.+ const timelineStart = now - performance.timeOrigin+ const segment = (at: number, length: number, repeat: boolean) => {+ const count = Math.max(1, Math.ceil(length / (1000 / 60)))+ const samples = Array.from({ length: count + 1 }, (_, i) => planAt(at + length * i / count))+ for (const [i, bar] of bars.entries()) {+ const frames = samples.map(sample => ({ transform: scale(sample.heights[i], height), opacity: sample.alpha[i] }))+ const animation = bar.animate(frames, { duration: length, delay: at, iterations: repeat ? Infinity : 1, fill: 'forwards' })+ animation.startTime = timelineStart+ animations.push(animation)+ }+ }+ if (duration > 0) segment(0, duration, false)+ if (playing && !media.matches) segment(duration, WAVE_PERIOD, true)+ if (playing) armSilence(anchor)+ else deadline = setTimeout(sync, Math.ceil(duration) + 1)}- const start = () => { last = performance.now(); raf = requestAnimationFrame(frame); live(true) }- // nothing runs where it can't be seen: a hidden or covered window, reduced motion, a pause- const wake = () => { if (!raf && !reduced && !paused && document.visibilityState === 'visible') start() }- // either way something is drawn right away- const sync = () => {- live(false)- if (!reduced && !paused && document.visibilityState === 'visible') start()- draw(true)++ function armSilence(anchor: SpeechAnchor) {+ clearTimeout(deadline)+ deadline = setTimeout(sync, Math.max(0, Math.ceil(anchor.at + SPEECH_PACKET_TIMEOUT - clock())))}- const onReduced = () => { reduced = mq.matches; sync() }- const onVisible = () => { if (document.visibilityState === 'visible') wake(); else live(false) }- const onScheme = () => { color = getComputedStyle(c).color; draw(true) }- const scheme = window.matchMedia('(prefers-color-scheme: dark)')- mq.addEventListener('change', onReduced)- scheme.addEventListener('change', onScheme)- document.addEventListener('visibilitychange', onVisible)+ const off = window.yogurt.widget.onLevel(({ speech }) => {+ const previous = recent.current+ recent.current = speech+ if (paused || document.visibilityState !== 'visible') return+ const now = clock(), wasStale = speech.at - previous.at > SPEECH_PACKET_TIMEOUT+ const speaking = speech.speaking && now < speech.at + SPEECH_PACKET_TIMEOUT+ if (previous.speaking !== speech.speaking || speaking !== playing || (wasStale && (speech.drive > 0 || speaking))) sync()+ else if (playing && !(stillBars && media.matches)) armSilence(speech)+ svg.dataset.level = speechAt(speech, now).drive.toFixed(2)+ })+ media.addEventListener('change', sync)+ document.addEventListener('visibilitychange', sync)sync()- return () => { off(); cancelAnimationFrame(raf); mq.removeEventListener('change', onReduced); scheme.removeEventListener('change', onScheme); document.removeEventListener('visibilitychange', onVisible) }- }, [height, width, paused, bars, stillBars])- return <canvas ref={canvas} data-testid={testId} aria-hidden="true" className={className} style={{ width, height }} />+ return () => { off(); clearTimeout(deadline); cancel(); media.removeEventListener('change', sync); document.removeEventListener('visibilitychange', sync) }+ }, [height, paused, stillBars])++ return <svg ref={ref} data-testid={testId} aria-hidden="true" width={WIDTH} height={height} viewBox={`0 0 ${WIDTH} ${height}`} className={`recording-wave ${className}`}>+ <g stroke="currentColor" strokeWidth={STROKE} strokeLinecap="round">+ {Array.from({ length: 5 }, (_, i) => {+ const x = STROKE / 2 + i * (WIDTH - STROKE) / 4+ return <line key={i} x1={x} x2={x} y1={STROKE / 2} y2={height - STROKE / 2}+ vectorEffect="non-scaling-stroke" style={{ transform: scale(0, height), opacity: .45 }} />+ })}+ </g>+ </svg>}diff --git a/app/src/renderer/src/screens/Note.tsx b/app/src/renderer/src/screens/Note.tsxindex 616fd32f..969f6b4a 100644--- a/app/src/renderer/src/screens/Note.tsx+++ b/app/src/renderer/src/screens/Note.tsx@@ -394,7 +394,7 @@ export function Note({ id, onTitleChange, at, folderSuggestion, onSource, onResu<div data-testid={recording ? 'rec-bar' : 'note-bar'} className="note-header-actions"><div className="note-recorder-controls">{recording && !finishing && <>- <LevelBars height={14} bars={3} testId="note-wave" paused={!!m.paused} className="text-muted" />+ <LevelBars height={14} testId="note-wave" paused={!!m.paused} className="text-muted" /><RecordingTime view={recorder} /></>}<div data-testid="note-state" data-state={m.state} data-paused={!!m.paused} className="note-recording-group" data-treatment={RECORDING_CONTROL_TREATMENT} data-recording={recording && !finishing} role="group" aria-label={recording ? m.paused ? t('Paused') : t('Recording') : t('Meeting controls')}>diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.cssindex 442c696d..ba67ec41 100644--- a/app/src/renderer/src/styles.css+++ b/app/src/renderer/src/styles.css@@ -201,7 +201,9 @@ html.widget, .widget-pill[data-illustration] { --pill:#232326;--pill-ink:#F7F7FA/* closed: the transcript stays mounted but unpainted (hidden once the close has played, its live dots paused); the meter repaints only itself */.widget-preview[aria-hidden=true] { visibility:hidden;transition:visibility 0s linear var(--dur-base); }.widget-preview[aria-hidden=true] * { animation-play-state:paused !important; }-[data-testid=widget-wave] { will-change:transform; }+.recording-wave { flex:none;overflow:visible; }+.recording-wave line { transform-origin:center;transform-box:view-box; }+.recording-wave:dir(rtl) > g { transform-origin:center;transform:scaleX(-1); }.widget-preview[aria-hidden=true] { pointer-events:none; }/* the scroll fade sets overflow inline; the reserved thin scrollbar keeps the reading edge still */.widget-preview-conversation { flex:1 1 auto;min-height:0;overflow-x:hidden;overflow-y:scroll !important;overscroll-behavior:contain;padding:8px 4px 4px 0;scrollbar-gutter:stable;scrollbar-width:auto;scrollbar-color:auto; }diff --git a/app/src/renderer/src/windows/widgetMorph.ts b/app/src/renderer/src/windows/widgetMorph.tsindex 8bbb4868..c68f8c1a 100644--- a/app/src/renderer/src/windows/widgetMorph.ts+++ b/app/src/renderer/src/windows/widgetMorph.ts@@ -56,7 +56,7 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warif (!immediate && (!reduced || 'opacity' in to)) animations.current.push(node.animate([from, to] as Keyframe[], { duration: reduced ? motion.micro : ms, easing: ease, delay: reduced ? 0 : delay, fill: 'both' }))}animate(el, { left: `${box.x}px`, top: `${box.y}px`, width: `${box.width}px`, height: `${box.height}px`, borderRadius: opened ? '16px' : '10px' })- const positions = opened ? [[16, 17], [box.width - timerWidth - 55, 18], [box.width - timerWidth - 16, 18.5]] : [[12, 11], [42, 12], [81, 12.5]]+ const positions = opened ? [[16, 17], [box.width - timerWidth - 43, 18], [box.width - timerWidth - 16, 18.5]] : [[12, 11], [42, 12], [69, 12.5]]items.forEach((item, i) => animate(item, { transform: `translate(${positions[i][0]}px,${positions[i][1]}px)` }))body.style.width = `${expanded.width - 2}px`; body.style.height = `${expanded.height - 54}px`animate(body, { transform: opened ? 'translateX(0) scale(1)' : 'translateX(40px) scale(.97)', filter: opened ? 'blur(0px)' : 'blur(2px)' }, duration, motion.ease)@@ -77,7 +77,7 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, waruseLayoutEffect(() => {if (intent.pressed) returnconst timer = card.current?.querySelector<HTMLElement>('[data-testid="widget-time"]')- if (timer) window.yogurt.widget.size(95 + timer.getBoundingClientRect().width, 42)+ if (timer) window.yogurt.widget.size(83 + timer.getBoundingClientRect().width, 42)}, [time, open, layout?.pill.width])useEffect(() => {let frame = 0, lastPoint = { x: -1, y: -1 }, lastSurface = ''@@ -124,7 +124,7 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warwake.current()window.yogurt.widget.pressed(false)const timer = card.current?.querySelector<HTMLElement>('[data-testid="widget-time"]')- if (timer) window.yogurt.widget.size(95 + timer.getBoundingClientRect().width, 42)+ if (timer) window.yogurt.widget.size(83 + timer.getBoundingClientRect().width, 42)},}}diff --git a/app/src/shared/speechWave.ts b/app/src/shared/speechWave.tsnew file mode 100644index 00000000..87bf4361--- /dev/null+++ b/app/src/shared/speechWave.ts@@ -0,0 +1,39 @@+export const WAVE_PERIOD = 900+export const RISE = 300, FALL = 520+export const SPEECH_PACKET_TIMEOUT = 300+export type SpeechAnchor = { at: number; phase: number; drive: number; speaking: boolean }+export type MeterPacket = { me: number; them: number; speech: SpeechAnchor }+export const silentSpeech: SpeechAnchor = { at: 0, phase: 0, drive: 0, speaking: false }++/** Project the last capture packet onto a shared clock, including a missing packet's release. */+export function speechAt(anchor: SpeechAnchor, now: number) {+ const elapsed = Math.max(0, now - anchor.at)+ const rise = anchor.speaking ? Math.min(elapsed, SPEECH_PACKET_TIMEOUT) : 0+ const peak = Math.min(1, anchor.drive + rise / RISE)+ const fall = Math.min(elapsed - rise, peak * FALL)+ const drive = Math.max(0, peak - (elapsed - rise) / FALL)+ // Keep elapsed motion time so each renderer can wrap at its selected period.+ return { drive, phase: anchor.phase + rise + fall }+}++export function speechSample(previous: SpeechAnchor, input: { me: number; them: number }, now: number): SpeechAnchor {+ const db = Number.isFinite(input.me) ? input.me * 60 - 60 : -Infinity+ const held = previous.speaking && now - previous.at <= SPEECH_PACKET_TIMEOUT+ return { ...speechAt(previous, now), at: now, speaking: db >= -44.4 || (held && db > -49.2) }+}++export function speechBars({ drive, phase }: ReturnType<typeof speechAt>, reduced: boolean) {+ const energy = drive * drive * (3 - 2 * drive)+ // The captured crest is 48 px tall and the trough 14 px. Our 3 px resting stub supplies part of that trough.+ const heights = Array.from({ length: 5 }, (_, i) => {+ const angle = reduced ? (i - 2) / 5 : (phase % WAVE_PERIOD) / WAVE_PERIOD + (i - 4) / 5+ const hump = (1 + Math.cos(2 * Math.PI * angle)) / 2+ return .70 * energy * (.11 + .89 * hump)+ })+ return { heights, alpha: heights.map(() => .45 + .55 * energy) }+}++/** Latest possible rest time, for static, reduced-motion renderers if the input stream stops. */+export function speechRestAt(anchor: SpeechAnchor) {+ return anchor.at + (anchor.speaking ? SPEECH_PACKET_TIMEOUT + FALL : anchor.drive * FALL)+}diff --git a/app/src/shared/types.ts b/app/src/shared/types.tsindex 4bd19619..2d5741c9 100644--- a/app/src/shared/types.ts+++ b/app/src/shared/types.ts@@ -1,3 +1,4 @@+import type { MeterPacket } from './speechWave'import type { AudioUploadFile, AudioUploadStatus } from './audioUpload'import type { RendererError } from './rendererError'import type { WidgetLayout, WidgetSurface } from './widgetMorph'@@ -54,7 +55,7 @@ export type YogurtApi = {state(): Promise<WidgetView | null>onState(cb: (v: WidgetView | null) => void): () => void/** sound levels 0..1, about 10 a second */- onLevel(cb: (lv: { me: number; them: number }) => void): () => void+ onLevel(cb: (lv: MeterPacket) => void): () => voidopen(): voidstop(): voidlayout(): Promise<WidgetLayout | null>diff --git a/app/src/shared/wave.ts b/app/src/shared/wave.tsindex 13607a3e..36825dce 100644--- a/app/src/shared/wave.ts+++ b/app/src/shared/wave.ts@@ -5,43 +5,3 @@ export function formatElapsed(ms: number): string {const m = Math.floor(s / 60)return m >= 60 ? `${Math.floor(m / 60)}:${String(m % 60).padStart(2, '0')}:${sec}` : `${m}:${sec}`}--const ATTACK_MS = 60, RELEASE_MS = 220--/** Smooth the 10 Hz capture feed without delaying it behind a scrolling history. */-export class Wave {- target = 0- level = 0- step(dtMs: number) {- const tau = this.target > this.level ? ATTACK_MS : RELEASE_MS- this.level += (this.target - this.level) * (1 - Math.exp(-dtMs / tau))- }- /** back at rest in silence (snapped to 0): nothing moves until the next level */- settled(): boolean {- if (this.target !== 0 || this.level >= 0.002) return false- this.level = 0- return true- }-}--/** Five-bar silhouette; pause and reduced motion default to three still dots. */-export function barPlan(p: { reduced: boolean; paused: boolean; level: number; bars?: 3 | 5; stillBars?: boolean }): { heights: number[]; alpha: number[] } {- const still = p.paused || p.reduced- if (still && !p.stillBars) return { heights: [0, 0, 0], alpha: [0.5, 0.5, 0.5] }- const weights = p.bars === 3 ? [.75, 1, .75] : [.5, .75, 1, .75, .5]- const level = still ? .7 : p.level- return { heights: weights.map(v => v * level), alpha: weights.map(() => .45 + .55 * level) }-}--/** What a frame puts on screen, in whole pixels of growth and 1% steps of alpha: the same key draws the same pixels. */-export const frameKey = (plan: { heights: number[]; alpha: number[] }, span: number): string =>- plan.heights.map((v) => Math.round(v * span)).join() + '|' + Math.round(plan.alpha[0] * 100)--const METER_GAIN = 10--/** Capture already measures dBFS. Give quiet speech more travel while retaining headroom for louder speech. */-export function micLevel({ me }: { me: number; them: number }): number {- if (!Number.isFinite(me)) return 0- const level = Math.max(0, Math.min(1, (me - .15) / .65)) // −51 to −12 dBFS- return METER_GAIN * level / (1 + (METER_GAIN - 1) * level)-}diff --git a/app/test/agendaMarkers.test.ts b/app/test/agendaMarkers.test.tsindex 457aac41..8ce57d96 100644--- a/app/test/agendaMarkers.test.ts+++ b/app/test/agendaMarkers.test.ts@@ -49,7 +49,7 @@ it('replaces the icon with the real meter when recording starts or resumes, inclconst html = render({ event: row, now, recording: active })if (active) {expect(html).toContain('aria-label="Recording"')- expect(html).toContain('<canvas data-testid="agenda-recording-levels"')+ expect(html).toContain('<svg data-testid="agenda-recording-levels"')expect(html).not.toContain('lucide-file-text')expect(html).not.toContain('Has notes')} else if (row.note) {diff --git a/app/test/meterTimeline.test.ts b/app/test/meterTimeline.test.tsnew file mode 100644index 00000000..cc1e178f--- /dev/null+++ b/app/test/meterTimeline.test.ts@@ -0,0 +1,57 @@+import { afterEach, expect, it, vi } from 'vitest'+import { useEffect, useRef } from 'react'+import { silentSpeech, speechAt, speechBars, speechSample, type MeterPacket } from '../src/shared/speechWave'+import { LevelBars } from '../src/renderer/src/components/LevelBars'++vi.mock('react', async original => ({ ...await original<typeof import('react')>(), useEffect: vi.fn(), useRef: vi.fn() }))+afterEach(() => { vi.useRealTimers(); vi.unstubAllGlobals(); vi.clearAllMocks() })++it('interpolates between level packets without renderer frame callbacks and settles when packets stop', () => {+ vi.useFakeTimers(); vi.setSystemTime(0)+ vi.stubGlobal('performance', { now: () => Date.now(), timeOrigin: 0 })+ const doc = Object.assign(new EventTarget(), { visibilityState: 'visible' })+ vi.stubGlobal('document', doc)+ let receive!: (p: MeterPacket) => void+ const media = Object.assign(new EventTarget(), { matches: false })+ vi.stubGlobal('window', { matchMedia: () => media, yogurt: { widget: { onLevel: (cb: typeof receive) => { receive = cb; return vi.fn() } } } })+ const bars = Array.from({ length: 5 }, () => ({+ style: { transform: '', opacity: '' },+ animate: vi.fn((_frames: Keyframe[], _timing: KeyframeAnimationOptions) => ({ startTime: 0, cancel: vi.fn() })),+ }))+ const svg = { querySelectorAll: () => bars, dataset: { live: '', level: '' } }+ vi.mocked(useRef).mockImplementation((value: unknown) => ({ current: value === null ? svg : value }) as never)+ LevelBars({ height: 16, testId: 'widget-wave' })+ const cleanup = vi.mocked(useEffect).mock.calls[0][0]()+ let anchor = silentSpeech+ const packet = () => { anchor = speechSample(anchor, { me: .7, them: 0 }, Date.now()); receive({ me: .7, them: 0, speech: anchor }) }+ packet()+ const line = bars[4]+ const [frames, timing] = line.animate.mock.calls[1]+ expect(timing).toMatchObject({ delay: 300, duration: 900, iterations: Infinity })+ expect(line.animate.mock.results[1].value.startTime).toBe(0)+ // No renderer frame callback is delivered. Sample the submitted display timeline at 120 Hz.+ for (let bin = 0; bin < 12; bin++) {+ vi.advanceTimersByTime(100); packet()+ if (Date.now() < 300) continue+ for (let f = 0; f < 12; f++) {+ const t = Date.now() + f * 1000 / 120+ const index = ((t - 300) % 900) / 900 * (frames.length - 1)+ const scaleAt = (n: number) => Number(String(frames[n].transform).slice(7, -1))+ const a = Math.floor(index), b = Math.min(a + 1, frames.length - 1)+ const scale = scaleAt(a) + (scaleAt(b) - scaleAt(a)) * (index - a)+ const expected = 3 + 13 * speechBars(speechAt(anchor, t), false).heights[4]+ expect(Math.abs(1.75 + scale * (16 - 1.75) - expected)).toBeLessThan(.01)+ }+ }+ expect(line.animate).toHaveBeenCalledTimes(2) // steady packets do not restart travel+ vi.advanceTimersByTime(821)+ expect(svg.dataset).toMatchObject({ level: '0.00', live: '0' })+ expect(line.animate.mock.results.every(result => result.value.cancel.mock.calls.length > 0)).toBe(true)+ media.matches = true; media.dispatchEvent(new Event('change')); packet()+ expect(svg.dataset.live).toBe('0')+ expect(line.animate.mock.calls.at(-1)![1].iterations).toBe(1)+ doc.visibilityState = 'hidden'; doc.dispatchEvent(new Event('visibilitychange'))+ expect(svg.dataset.live).toBe('0')+ if (typeof cleanup === 'function') cleanup()+ expect(vi.getTimerCount()).toBe(0)+})diff --git a/app/test/onboardingMeter.test.ts b/app/test/onboardingMeter.test.tsindex 94cfe4cc..916db923 100644--- a/app/test/onboardingMeter.test.ts+++ b/app/test/onboardingMeter.test.ts@@ -9,7 +9,8 @@ it('holds a single meter frame on the welcome illustration and uses the live metconst sample = render(true)expect(sample).toMatch(/<svg data-testid="widget-wave"/)expect(sample.match(/<rect /g)).toHaveLength(5)- expect(sample).not.toContain('<canvas')+ expect(sample).not.toContain('non-scaling-stroke')const live = renderToStaticMarkup(createElement(LevelBars, { height: 16, testId: 'widget-wave', className: 'text-[var(--pill-accent)]' }))expect(render(false)).toContain(live)+ expect(live.match(/non-scaling-stroke/g)).toHaveLength(5)})diff --git a/app/test/wave.test.ts b/app/test/wave.test.tsindex fd7249c6..4e89c33a 100644--- a/app/test/wave.test.ts+++ b/app/test/wave.test.ts@@ -1,88 +1,59 @@import { describe, expect, it } from 'vitest'-import { barPlan, frameKey, micLevel, Wave } from '../src/shared/wave'+import { silentSpeech, speechAt, speechBars, speechRestAt, speechSample } from '../src/shared/speechWave'-describe('microphone meter', () => {- it('keeps silence quiet and makes ordinary speech visible without using call audio', () => {- expect(micLevel({ me: 0, them: 1 })).toBe(0)- expect(micLevel({ me: .15, them: 1 })).toBe(0)- const speech = [-45, -42, -25, -12].map(db => micLevel({ me: (db + 60) / 60, them: 0 }))- expect(speech[0]).toBeCloseTo(.65, 2)- expect(speech[1]).toBeCloseTo(.75, 2)- expect(speech[2]).toBeCloseTo(.95, 2)- expect(speech[3]).toBe(1)- expect(micLevel({ me: Infinity, them: 0 })).toBe(0)- expect(micLevel({ me: -1, them: 0 })).toBe(0)- expect(micLevel({ me: 2, them: 0 })).toBe(1)- })- it('shows a quiet 100 ms syllable on both meters without lifting silence', () => {- const wave = new Wave()- wave.target = micLevel({ me: .30, them: .79 })- wave.step(100)- for (const [bars, height] of [[3, 14], [5, 16]] as const) {- const plan = barPlan({ bars, level: wave.level, paused: false, reduced: false })- expect(3 + Math.round(Math.max(...plan.heights) * (height - 3))).toBe(bars === 3 ? 10 : 11)- }- expect(micLevel({ me: .1, them: .79 })).toBe(0)- })- it('attacks in 60ms and releases in 220ms without a scrolling delay', () => {- const w = new Wave()- w.target = 1; w.step(60)- expect(w.level).toBeCloseTo(1 - Math.exp(-1))- const peak = w.level- w.target = 0; w.step(60)- expect(w.level).toBeGreaterThan(peak * .75)- w.step(2000)- expect(w.level).toBeLessThan(.001)- })- it('draws five symmetric bars with a tall center, and five quiet dots at rest', () => {- expect(barPlan({ level: 1, reduced: false, paused: false }).heights).toEqual([.5, .75, 1, .75, .5])- const quiet = barPlan({ level: 0, reduced: false, paused: false })- expect(quiet.heights).toEqual([0, 0, 0, 0, 0])- expect(quiet.alpha.every(a => a > 0 && a < .6)).toBe(true)+const input = (db: number) => ({ me: Math.max(0, (db + 60) / 60), them: 0 })+const on = speechSample(silentSpeech, input(-25), 0)+const atStrength = (phase: number, reduced = false) => speechBars({ drive: 1, phase }, reduced).heights++describe('recording speech wave', () => {+ it('uses only the microphone and keeps small fluctuations inside the speech gate from moving it', () => {+ expect(speechSample(silentSpeech, { me: 0, them: 1 }, 0).speaking).toBe(false)+ expect(speechSample(silentSpeech, input(-47), 0).speaking).toBe(false)+ const held = speechSample(on, input(-47), 100)+ expect(held).toEqual(speechSample(on, input(-9), 100))+ expect(held.speaking).toBe(true)+ expect(speechSample(held, input(-52), 200).speaking).toBe(false)+ expect(speechSample(on, input(-47), 1500).speaking).toBe(false)})- it('fits the note control in three bars while preserving the live center and quiet pause', () => {- expect(barPlan({ level: 1, reduced: false, paused: false, bars: 3 }).heights).toEqual([.75, 1, .75])- expect(barPlan({ level: 1, reduced: false, paused: true, bars: 3 }).heights).toEqual([0, 0, 0])++ it('rises in 300 ms and releases in 520 ms; a brief pause reverses from the current energy', () => {+ expect(speechAt(on, 150).drive).toBeCloseTo(.5)+ expect(speechAt(on, 300).drive).toBe(1)+ const off = speechSample(on, input(-60), 300)+ expect(speechAt(off, 560).drive).toBeCloseTo(.5)+ const resumed = speechSample(off, input(-25), 560)+ expect(speechAt(resumed, 560)).toEqual(speechAt(off, 560))+ expect(speechAt(resumed, 710).drive).toBe(1)+ expect(speechRestAt(off)).toBe(820)+ expect(speechAt(off, 820).drive).toBe(0)})- it('reduced motion and pause stay three static dots regardless of live levels', () => {- for (const reduced of [false, true]) for (const paused of [false, true]) {- if (!reduced && !paused) continue- const rest = barPlan({ level: 0, reduced, paused })- expect(rest.heights).toEqual([0, 0, 0])- expect(barPlan({ level: 1, reduced, paused })).toEqual(rest)- }++ it('holds phase throughout silence and resumes from the same position even across a missing stream', () => {+ const resting = speechAt(on, 820)+ expect(resting).toEqual({ drive: 0, phase: 820 })+ expect(speechRestAt(on)).toBe(820)+ expect(speechAt(on, 12000)).toEqual(resting)+ const again = speechSample(on, input(-24), 12000)+ expect(speechAt(again, 12000)).toEqual(resting)+ expect(speechAt(again, 12100).phase).toBe(920)+ expect(speechBars(resting, false).heights).toEqual([0, 0, 0, 0, 0])})- it('can retain still bars during pause or reduced motion without reacting to input levels', () => {- for (const reduced of [false, true]) for (const paused of [false, true]) {- if (!reduced && !paused) continue- const rest = barPlan({ level: 0, reduced, paused, stillBars: true })- expect(rest.heights).toHaveLength(5)- expect(rest.heights.every(h => h > 0)).toBe(true)- expect(rest.heights[2]).toBeGreaterThan(rest.heights[0])- expect(barPlan({ level: 1, reduced, paused, stillBars: true })).toEqual(rest)- }- for (const level of [0, .5, 1]) {- expect(barPlan({ level, reduced: false, paused: false, stillBars: true }))- .toEqual(barPlan({ level, reduced: false, paused: false }))++ it('passes the crest one bar left every 180 ms at every energy and wraps continuously', () => {+ for (const drive of [.25, .7, 1]) {+ for (let i = 0; i <= 5; i++) {+ const { heights } = speechBars({ drive, phase: 180 * i }, false)+ expect(heights.indexOf(Math.max(...heights))).toBe(4 - i % 5)+ }}+ expect(atStrength(900)[4]).toBeCloseTo(atStrength(0)[4], 10)+ expect(atStrength(0)[4]).toBe(.7)+ expect(Math.min(...atStrength(90))).toBeCloseTo(.077)})- it('a frame that would draw the same pixels is the same frame, so it is not drawn again', () => {- const at = (level: number) => frameKey(barPlan({ level, reduced: false, paused: false }), 16)- expect(at(.5)).toBe(at(.5001))- expect(at(0)).toBe(at(.0004))- expect(at(.5)).not.toBe(at(.6))- // the bars fade in with the level even before they grow a pixel- expect(at(0)).not.toBe(at(.02))- })- it('the meter settles at silence, and only then may its loop sleep', () => {- const w = new Wave()- expect(w.settled()).toBe(true)- w.target = 1; w.step(60)- expect(w.settled()).toBe(false)- w.target = 0; w.step(60)- expect(w.settled()).toBe(false)- w.step(2000)- expect(w.settled()).toBe(true)- expect(w.level).toBe(0)++ it('keeps a centred live energy reading without travel in reduced motion', () => {+ expect(atStrength(80, true)).toEqual(atStrength(600, true))+ expect(atStrength(0, true)).toEqual(atStrength(0, true).reverse())+ expect(speechBars({ drive: .5, phase: 135 }, true).heights[2]).toBe(.35)})})