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
recorder: the pointer is checked at frame rate only while it's over the recorder, and its frame loop sleeps between hovers
Eric Brownrout63b7967ffed3
diff --git a/app/src/main/widget.ts b/app/src/main/widget.tsindex 539e393f..8d1c0bd4 100644--- a/app/src/main/widget.ts+++ b/app/src/main/widget.ts@@ -78,7 +78,7 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:let shown = falseconst hitTest = () => {- if (!win || win.isDestroyed()) return+ if (!win || win.isDestroyed()) return falseconst cursor = screen.getCursorScreenPoint(), bounds = win.getBounds()const x = cursor.x - bounds.x, y = cursor.y - bounds.yconst ignore = !shown || (!pressed && (!surface || !widgetContains(surface, x, y)))@@ -86,6 +86,14 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:// Only a pointer over the window matters; a still or distant pointer sends nothing.const over = x >= 0 && y >= 0 && x < bounds.width && y < bounds.height, key = over ? `${x},${y}` : ''if (!BACKGROUND && key !== sentPointer) { sentPointer = key; win.webContents.send('widget:pointer', over ? { x, y } : { x: -1, y: -1 }) }+ return over+ }+ // Frame-rate checks only while the pointer is over the window; elsewhere a slow check, and none while hidden.+ // The renderer's own mouse events (forwarded through the click-through area) speed it up at once.+ const poll = () => {+ clearTimeout(pointerTimer)+ if (!shown || BACKGROUND || !win || win.isDestroyed()) return+ pointerTimer = setTimeout(poll, hitTest() || pressed ? 16 : 250)}const place = () => {if (!win || win.isDestroyed()) return@@ -98,10 +106,8 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:const visibilityChanged = () => {const view = model.view(Date.now())shown = view?.kind === 'recording' && !view.paused && !d.foreground()- clearInterval(pointerTimer)- if (shown && !BACKGROUND) pointerTimer = setInterval(hitTest, 16)- if (!shown) { pressed = false; win?.webContents.send('widget:reset') }- hitTest()+ if (!shown) { clearTimeout(pointerTimer); pressed = false; win?.webContents.send('widget:reset') }+ hitTest(); poll()if (!win || win.isDestroyed() || BACKGROUND) returnif (!shown) win.hide()else if (sized && !win.isVisible()) win.showInactive()@@ -113,7 +119,7 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:const close = () => {clearTimeout(noteTimer)shown = false; sized = false; dragPosition = null; dragFrame = null- clearInterval(pointerTimer); surface = null; pressed = false+ clearTimeout(pointerTimer); surface = null; pressed = falsescreen.removeListener('display-added', displayChanged)screen.removeListener('display-removed', displayChanged)screen.removeListener('display-metrics-changed', displayChanged)@@ -128,7 +134,7 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:win = createWindow(d.windowOs); sized = false; ignoring = true; sentPointer = nullpill = { ...lastPosition!, width: lastWidth, height: FIRST_H }layout = widgetLayout(pill, screen.getDisplayMatching(pill).workArea)- win.on('closed', () => { clearInterval(pointerTimer); win = undefined })+ win.on('closed', () => { clearTimeout(pointerTimer); win = undefined })}onMeetingStart((m) => {@@ -186,7 +192,7 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:const id = model.meetingIdif (!id) returnshown = false- clearInterval(pointerTimer); pressed = false+ clearTimeout(pointerTimer); pressed = falseif (win && !win.isDestroyed()) { win.webContents.send('widget:reset'); hitTest(); win.hide() }d.open(id)})@@ -196,13 +202,13 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:if (!win || win.isDestroyed() || e.sender !== win.webContents || !value || typeof value !== 'object') returnconst r = value as WidgetSurfaceif (![r.x, r.y, r.width, r.height, r.radius].every(n => typeof n === 'number' && Number.isFinite(n)) || r.width <= 0 || r.height <= 0 || r.width > 600 || r.height > 600 || r.radius < 0 || r.radius > 100 || Math.abs(r.x) > 600 || Math.abs(r.y) > 600) return- surface = r; hitTest()+ surface = r; poll()// The renderer has painted its first surface before the native window appears.if (!sized) { sized = true; visibilityChanged() }})ipcMain.on('widget:pressed', (e, value: unknown) => {if (!win || win.isDestroyed() || e.sender !== win.webContents || typeof value !== 'boolean') return- pressed = value; hitTest()+ pressed = value; poll()})ipcMain.on('widget:drag', (e, dx: unknown, dy: unknown) => {if (!win || win.isDestroyed() || e.sender !== win.webContents || typeof dx !== 'number' || typeof dy !== 'number' || !Number.isFinite(dx) || !Number.isFinite(dy)) returndiff --git a/app/src/renderer/src/windows/widgetMorph.ts b/app/src/renderer/src/windows/widgetMorph.tsindex b3dbc109..cac26471 100644--- a/app/src/renderer/src/windows/widgetMorph.ts+++ b/app/src/renderer/src/windows/widgetMorph.ts@@ -10,6 +10,8 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warconst animations = useRef<Animation[]>([])const resumeAt = useRef<number | null>(null)const morph = useRef((immediate = false) => { void immediate })+ /** the frame loop sleeps while nothing can change; anything that might change wakes it */+ const wake = useRef(() => {})const freeze = () => {for (const a of animations.current) {if (card.current?.isConnected) a.commitStyles()@@ -21,10 +23,10 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warlet alive = trueconst off = window.yogurt.widget.onLayout(setLayout)void window.yogurt.widget.layout().then(v => { if (alive) setLayout(v) })- const offPointer = window.yogurt.widget.onPointer(p => { pointer.current = p })+ const offPointer = window.yogurt.widget.onPointer(p => { pointer.current = p; wake.current() })const offReset = window.yogurt.widget.onReset(() => {intent.open = false; intent.over = false; intent.pressed = false; intent.due = null- resumeAt.current = null; setOpen(false); morph.current(true)+ resumeAt.current = null; setOpen(false); morph.current(true); wake.current()})return () => { alive = false; off(); offPointer(); offReset(); freeze() }}, [])@@ -32,6 +34,7 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warconst was = intent.warningintent.warning = warningif (was && !warning && !intent.over) intent.leave(performance.now())+ wake.current()}, [warning])const previous = useRef<WidgetLayout | null>(null)useLayoutEffect(() => {@@ -70,6 +73,7 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warel.style.height = `${Math.min(parseFloat(el.style.height), layout.open.height)}px`} else morph.current(true)previous.current = layout+ wake.current()}, [layout, warning])useLayoutEffect(() => {if (intent.pressed) return@@ -77,8 +81,9 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warif (timer) window.yogurt.widget.size(95 + timer.getBoundingClientRect().width, 42)}, [time, open, layout?.pill.width])useEffect(() => {- let frame: number, lastPoint = { x: -1, y: -1 }, lastSurface = ''+ let frame = 0, lastPoint = { x: -1, y: -1 }, lastSurface = ''const tick = (now: number) => {+ frame = 0const el = card.currentif (el && el.style.visibility === 'visible') {const r = el.getBoundingClientRect(), surface = { x: r.x, y: r.y, width: r.width, height: r.height, radius: parseFloat(getComputedStyle(el).borderRadius) }@@ -92,28 +97,32 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warconst key = JSON.stringify(surface)if (key !== lastSurface) { lastSurface = key; window.yogurt.widget.surface(surface) }}- frame = requestAnimationFrame(tick)+ // Keep running only while a hover deadline is pending or the shape is moving.+ if (intent.due || resumeAt.current !== null || animations.current.some(a => a.playState === 'running')) frame = requestAnimationFrame(tick)}- frame = requestAnimationFrame(tick)+ wake.current = () => { if (!frame) frame = requestAnimationFrame(tick) }+ wake.current()const reduced = window.matchMedia('(prefers-reduced-motion: reduce)')- const swap = () => morph.current(true)+ const swap = () => { morph.current(true); wake.current() }reduced.addEventListener('change', swap)- return () => { cancelAnimationFrame(frame); reduced.removeEventListener('change', swap) }+ return () => { wake.current = () => {}; cancelAnimationFrame(frame); reduced.removeEventListener('change', swap) }}, [])return {open,pointer: (x: number, y: number) => {pointer.current = { x, y }+ wake.current()const el = card.currentif (!el || el.style.visibility !== 'visible') returnconst r = el.getBoundingClientRect()window.yogurt.widget.surface({ x: r.x, y: r.y, width: r.width, height: r.height, radius: parseFloat(getComputedStyle(el).borderRadius) })},- press: () => { freeze(); intent.press(); resumeAt.current = null; window.yogurt.widget.pressed(true) },+ press: () => { freeze(); intent.press(); resumeAt.current = null; window.yogurt.widget.pressed(true); wake.current() },release: (dragged: boolean) => {if (!intent.pressed) returnintent.release(performance.now(), dragged)resumeAt.current = performance.now() + (dragged ? 650 : 0)+ wake.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)diff --git a/app/test/widgetWindow.test.ts b/app/test/widgetWindow.test.tsindex 5d064604..3fed996f 100644--- a/app/test/widgetWindow.test.ts+++ b/app/test/widgetWindow.test.ts@@ -180,6 +180,22 @@ describe('floating recorder placement', () => {vi.advanceTimersByTime(16)expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(false, { forward: true })})+ it('checks the pointer at frame rate only over the window, slowly elsewhere, and not at all while hidden', () => {+ const b = win.getBounds(), surface = { x: 20, y: 20, width: 118, height: 42, radius: 10 }+ state.cursor = { x: b.x - 400, y: b.y - 400 }+ send('widget:surface', surface)+ state.cursor = { x: b.x + 30, y: b.y + 35 }+ vi.advanceTimersByTime(16)+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(true, { forward: true })+ vi.advanceTimersByTime(250)+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(false, { forward: true })+ state.recording!({ t: 'paused', meetingId: 'meeting', paused: true, at: 100 })+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(true, { forward: true })+ const calls = win.setIgnoreMouseEvents.mock.calls.length, sent = win.webContents.send.mock.calls.length+ vi.advanceTimersByTime(5000)+ expect(win.setIgnoreMouseEvents.mock.calls.length).toBe(calls)+ expect(win.webContents.send.mock.calls.length).toBe(sent)+ })it('keeps the window and anchor through warnings, pause and resume, and forwards live words there', () => {const chosen = widget.snapshot().boundsstate.recording!({ t: 'warn', code: 'no-mic' })