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 pill and the expanded card resize in the same frame as their contents, so the mute badge never covers the timer, unmuting leaves no gap, and the card opens at full width; the mic sits on the same line as the timer
Eric Brownrout54ccba6fc134
diff --git a/app/e2e/widget.spec.ts b/app/e2e/widget.spec.tsindex c3807ee9..64064098 100644--- a/app/e2e/widget.spec.ts+++ b/app/e2e/widget.spec.ts@@ -78,17 +78,22 @@ test('the widget is a compact horizontal recorder with one live wave and no exteasync function captureCenteredReadout(app: ElectronApplication, pill: Locator, path: string) {const png = await pill.screenshot({ path, scale: 'device' })- const { boxes, center, width } = await pill.evaluate(el => {+ const { boxes, controls, center, width } = await pill.evaluate(el => {const bounds = el.getBoundingClientRect()const boxes = ['widget-wave', 'widget-time'].map(id => {const b = el.querySelector(`[data-testid="${id}"]`)!.getBoundingClientRect()return { left: b.left - bounds.left, right: b.right - bounds.left, mid: b.top - bounds.top + b.height / 2 }})const center = el.getAttribute('data-open') === 'true' ? 27 : bounds.height / 2- return { boxes, center, width: bounds.width }+ const controls = [...el.querySelectorAll('[data-testid="logo"], .widget-mic, .widget-mic svg, .widget-mic-off, .widget-mic-off svg')].map(node => {+ const b = node.getBoundingClientRect()+ return b.top - bounds.top + b.height / 2+ })+ return { boxes, controls, center, width: bounds.width }})expect(Math.abs(boxes[0].mid - boxes[1].mid)).toBeLessThanOrEqual(0.5)for (const box of boxes) expect(Math.abs(box.mid - center)).toBeLessThanOrEqual(0.5)+ for (const mid of controls) expect(Math.abs(mid - center)).toBeLessThanOrEqual(0.5)expect(png.readUInt32BE(16)).toBe(Math.round(width) * 2)// The old line boxes already lined up. Check the painted digits and strokes at Retina scale too.const ink = await app.evaluate(({ nativeImage }, { data, boxes, center }) => {@@ -114,6 +119,60 @@ async function captureCenteredReadout(app: ElectronApplication, pill: Locator, pexpect(Math.abs(ink[0] - ink[1])).toBeLessThanOrEqual(0.5)}+test('each visible recorder frame fits its contents across hover, mute and unmute', async () => {+ const { app, page } = await launch()+ try {+ const w = await record(app, page), pill = w.getByTestId('widget')+ const header = page.getByTestId('note-mic'), mic = w.getByTestId('widget-mic')+ const badge = w.getByTestId('widget-mic-off')+ const watch = await pill.evaluateHandle(el => {+ const errors = new Set<string>(), seen = new Set<string>()+ const sample = () => {+ const open = el.dataset.open === 'true', bounds = el.getBoundingClientRect()+ const timer = el.querySelector('.widget-time')!.getBoundingClientRect()+ const divider = el.querySelector('.widget-mic-status')?.getBoundingClientRect()+ const label = open ? 'expanded' : divider ? 'muted pill' : 'unmuted pill'+ seen.add(label)+ const width = open ? 340 : Math.round(53 + timer.width + (divider ? 49 : 0))+ if (Math.abs(bounds.width - width) > 0.01) errors.add(`${label} width ${bounds.width}, expected ${width}`)+ if (bounds.left < 0 || bounds.top < 0 || bounds.right > innerWidth || bounds.bottom > innerHeight) errors.add('surface outside native window')+ if (divider && Math.abs(divider.left - timer.right - 12) > 0.01) errors.add('badge gap')+ const preview = el.querySelector<HTMLElement>('.widget-preview')!+ const visible = getComputedStyle(preview).visibility === 'visible'+ const content = preview.getBoundingClientRect()+ if (visible !== open || (visible && (content.left < bounds.left || content.right > bounds.right || content.bottom > bounds.bottom))) errors.add('transcript clipped or visible in the pill')+ const brand = el.querySelector('.widget-brand')+ if (open !== !!brand || (brand && getComputedStyle(brand).opacity !== '1')) errors.add('logo missing on open')+ }+ // Sample state commits as well as animation frames: an eventual width assertion misses the first bad paint.+ const observer = new MutationObserver(sample)+ observer.observe(el, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-open'] })+ let frame = 0+ const tick = () => { sample(); frame = requestAnimationFrame(tick) }+ tick()+ return { stop: () => { observer.disconnect(); cancelAnimationFrame(frame); return { errors: [...errors], seen: [...seen] } } }+ })+ // First change mute in the compact pill, then collapse directly from each expanded mic state.+ await header.click()+ await expect(badge).toBeVisible()+ await header.click()+ await expect(badge).toHaveCount(0)+ await pill.hover()+ await mic.click()+ await expect(mic).toHaveAttribute('aria-pressed', 'true')+ await w.mouse.move(0, 0)+ await expect(badge).toBeVisible()+ await pill.hover()+ await mic.click()+ await expect(mic).toHaveAttribute('aria-pressed', 'false')+ await w.mouse.move(0, 0)+ await expect(pill).toHaveAttribute('data-open', 'false')+ const result = await watch.evaluate(watch => watch.stop())+ expect(result.seen.sort()).toEqual(['expanded', 'muted pill', 'unmuted pill'])+ expect(result.errors).toEqual([])+ } finally { await app.close() }+})+test('the header and expanded card share confirmed mute, across collapse, reload and pause', async ({}, testInfo) => {const { app, page } = await launch(undefined, 'slow', '--force-device-scale-factor=2')try {diff --git a/app/src/main/widget.ts b/app/src/main/widget.tsindex f2813234..74f05cba 100644--- a/app/src/main/widget.ts+++ b/app/src/main/widget.ts@@ -9,7 +9,7 @@ import { micIsOff, type WidgetView } from '../shared/types'import { floatingType, floatOverFullScreen } from './float'import { isFake } from './paths'import { t, onLanguage } from '../shared/i18n'-import { widgetLayout, widgetDragLayout, widgetRestLayout, widgetContains, type WidgetSurface, type WidgetLayout } from '../shared/widgetMorph'+import { widgetLayout, widgetDragLayout, widgetRestLayout, widgetSizedPill, widgetContains, type WidgetSurface, type WidgetLayout } from '../shared/widgetMorph'const BACKGROUND = process.env.YOGURT_BACKGROUND === '1'const FIRST_W = 127, FIRST_H = 42@@ -261,24 +261,22 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:hitTest()})ipcMain.on('widget:drag-end', (e) => {- if (!win || win.isDestroyed() || e.sender !== win.webContents) return- if (dragPosition) {- lastPosition = { x: pill.x, y: pill.y }- if (layout && surface && surface.height > FIRST_H + 1) place(widgetRestLayout(layout, screen.getDisplayMatching(pill).workArea, model.view(Date.now())?.note ? 446 : 390))- }+ if (!win || win.isDestroyed() || e.sender !== win.webContents || !dragPosition) return+ lastPosition = { x: pill.x, y: pill.y }dragPosition = null; dragFrame = null- if (!surface || surface.height <= FIRST_H + 1) place()+ if (layout && surface && surface.height > FIRST_H + 1) place(widgetRestLayout(layout, screen.getDisplayMatching(pill).workArea, surface.height))+ else place()})ipcMain.on('widget:size', (e, w: unknown, h: unknown) => {- if (!win || win.isDestroyed() || e.sender !== win.webContents || typeof w !== 'number' || !Number.isFinite(w) || w < 60 || w > 340 || h !== FIRST_H || pressed) return- // Apply timer width changes once collapsed, so they cannot re-anchor a dropped card.- if (surface && surface.height > FIRST_H + 1) return- // rounded, not up: the timer is a fractional width, and rounding up left the right end a pixel wider than the left- const width = Math.round(w)- if (width === pill.width) return- lastWidth = width- pill = fit({ ...pill, x: pill.x + pill.width - width, width })- lastPosition = { x: pill.x, y: pill.y }; place()+ if (!win || win.isDestroyed() || !layout || e.sender !== win.webContents || typeof w !== 'number' || !Number.isFinite(w) || w < 60 || w > 340 || h !== FIRST_H || pressed) return+ const next = widgetSizedPill(layout, w)+ if (next.width === pill.width) return+ // Remember the measured pill without moving the native window that contains both shapes.+ layout = { ...layout, pill: next }+ lastWidth = next.width+ pill = { ...next, x: layout.bounds.x + next.x, y: layout.bounds.y + next.y }+ lastPosition = { x: pill.x, y: pill.y }+ win.webContents.send('widget:layout', layout)})const displayChanged = () => {if (!win || win.isDestroyed()) returndiff --git a/app/src/renderer/src/components/RecordingPill.tsx b/app/src/renderer/src/components/RecordingPill.tsxindex b570174e..7e665b7e 100644--- a/app/src/renderer/src/components/RecordingPill.tsx+++ b/app/src/renderer/src/components/RecordingPill.tsx@@ -1,8 +1,9 @@import type { ComponentPropsWithRef } from 'react'import { LevelBars } from './LevelBars'import { Logo } from './Logo'+import { MicOff } from './Icons'-type Props = ComponentPropsWithRef<'div'> & { time: string; expanded?: boolean; illustration?: boolean }+type Props = ComponentPropsWithRef<'div'> & { time: string; expanded?: boolean; muted?: boolean; illustration?: boolean }function StillMeter() {return <svg data-testid="widget-wave" width="27" height="16" aria-hidden="true" fill="var(--pill-accent)" opacity=".835">@@ -11,13 +12,16 @@ function StillMeter() {</svg>}-export function RecordingPill({ time, expanded, illustration, className = '', children, ...props }: Props) {+export function RecordingPill({ time, expanded, muted, illustration, className = '', children, ...props }: Props) {return <div {...props} data-open={expanded} data-illustration={illustration || undefined} className={`widget-pill ${className}`}><div className="widget-details" aria-hidden="true">{expanded && <span className="widget-brand"><Logo size={18} className="text-white" /></span>}<div className="widget-readout">{illustration ? <StillMeter /> : <LevelBars testId="widget-wave" height={16} className="text-[var(--pill-accent)]" />}<span data-testid="widget-time" className="widget-time">{time}</span>+ {muted && !expanded && <span className="widget-mic-status">+ <span className="widget-mic-off" data-testid="widget-mic-off"><MicOff size={14} /></span>+ </span>}</div></div>{children}diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.cssindex 7cc23092..ac44e12b 100644--- a/app/src/renderer/src/styles.css+++ b/app/src/renderer/src/styles.css@@ -168,36 +168,41 @@ html.widget, .widget-pill[data-illustration] { --pill:#232326;--pill-ink:#F7F7FA}.widget-pill:focus-visible { outline: 2px solid var(--pill-accent); outline-offset: -3px; }.widget-retry { color:#FFB0BD; }-.widget-morph { position:absolute;visibility:hidden;overflow:hidden;isolation:isolate;user-select:none;color:var(--pill-ink);cursor:default; }-.widget-morph[data-open=true] { cursor:grab; }-.widget-details { position:absolute;left:0;top:0;z-index:2; }+.widget-morph { --row-center:20px;position:absolute;visibility:hidden;overflow:hidden;isolation:isolate;user-select:none;color:var(--pill-ink);cursor:default;border-radius:10px; }+.widget-morph[data-open=true] { --row-center:26px;cursor:grab;border-radius:16px; }+.widget-details { position:absolute;left:0;right:0;top:0;z-index:2; }.widget-details>* { position:absolute;left:0;top:0;margin:0; }-.widget-details>.widget-brand { left:16px;top:17px;animation:motion-fade var(--dur-micro) var(--ease-out) 40ms both; }+.widget-morph .widget-details>* { top:var(--row-center);transform:translateY(-50%); }+.widget-details>.widget-brand { left:16px; }+.widget-morph .widget-readout { left:12px; }+.widget-morph[data-open=true] .widget-readout { left:auto;right:46px; }.widget-readout { display:flex;align-items:center;gap:12px;width:max-content;direction:ltr; }/* The resting recorder in the first-run call. Only the native window morphs on hover. */.widget-pill[data-illustration] { width:max-content;border-radius:10px;color:var(--pill-ink);direction:ltr; }.widget-pill[data-illustration] .widget-details { position:static;display:flex;align-items:center;gap:12px;height:40px;padding:0 12px; }.widget-pill[data-illustration] .widget-details>* { position:static; }-.widget-mic { position:absolute;z-index:2;right:9px;top:10px;display:grid;place-items:center;width:28px;height:28px;border-radius:5px;color:var(--pill-ink); }+.widget-mic { position:absolute;z-index:2;right:9px;top:var(--row-center);transform:translateY(-50%);display:grid;place-items:center;width:28px;height:28px;border-radius:5px;color:var(--pill-ink); }.widget-mic[aria-busy=true] { opacity:.55; }.widget-mic:hover { background:#FFFFFF14; }.widget-mic:focus-visible { outline:2px solid var(--pill-accent); }.widget-mic[aria-pressed=true] { color:#FF797C;background:#FF5E661A; }-.widget-mic-status { position:absolute;right:12px;top:8px;height:24px;display:flex;align-items:center;border-left:1px solid var(--widget-line);padding-left:12px; }+.widget-mic-status { height:24px;display:flex;align-items:center;border-left:1px solid var(--widget-line);padding-left:12px; }.widget-mic-off { display:grid;place-items:center;width:24px;height:24px;border-radius:7px;color:#E5484D;background:rgba(229,72,77,.14); }.mic-feedback { margin:6px auto;font-size:13px;text-align:center; }.mic-pending-status { position:absolute;z-index:2;margin:0;font-size:12px;line-height:18px;pointer-events:none; }.widget-preview > .mic-pending-status { top:-36px;left:44px;right:125px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }.note-footer > .mic-pending-status { bottom:100%;inset-inline:0;width:fit-content;max-width:100%;margin:auto;padding:2px 8px;border-radius:4px;background:var(--bg); }.widget-time { white-space:nowrap;font-size:10px;font-weight:500;font-variant-numeric:tabular-nums;text-box:trim-both cap alphabetic;line-height:15px;opacity:.8; }-.widget-preview { position:absolute;left:0;top:52px;display:flex;flex-direction:column;padding:0 4px 12px 12px;color:var(--pill-ink);font-size:14px;line-height:21px;transform-origin:50% 0;cursor:default; }-/* 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 { position:absolute;inset:52px 0 0;display:flex;flex-direction:column;padding:0 4px 12px 12px;color:var(--pill-ink);font-size:14px;line-height:21px;cursor:default; }+/* Keep the transcript mounted, but hide it on the same frame as the compact pill. */+.widget-preview[aria-hidden=true] { visibility:hidden;pointer-events:none; }.widget-preview[aria-hidden=true] * { animation-play-state:paused !important; }+@media (prefers-reduced-motion:no-preference) {+ .widget-preview[aria-hidden=false] { animation:motion-fade var(--dur-micro) var(--ease-out); }+}.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; }/* Custom scrollbars stay visible even when macOS uses automatic overlay scrollbars. */@@ -924,7 +929,6 @@ html:not(.widget) button:focus-visible, html:not(.widget) input:focus-visible {.player-btn { transition:opacity var(--dur-micro) var(--ease-out); }.scrubber::-webkit-slider-thumb,.scrubber:hover::-webkit-slider-thumb,.scrubber:active::-webkit-slider-thumb { transition:none;transform:none; }.notes-download-trigger>svg { transition:none; }- .widget-preview[aria-hidden=true] { transition-delay:var(--dur-micro); }}.search-panel.dialog-motion,.search-panel.dialog-motion[data-ending-style] { transition:opacity var(--dur-micro) var(--ease-out),transform var(--dur-micro) var(--ease-out); }diff --git a/app/src/renderer/src/windows/Widget.tsx b/app/src/renderer/src/windows/Widget.tsxindex a11aaf7c..68b078ff 100644--- a/app/src/renderer/src/windows/Widget.tsx+++ b/app/src/renderer/src/windows/Widget.tsx@@ -4,7 +4,7 @@ import { widgetDragDelta, isWidgetClick, type WidgetPress } from '../../../shareimport { Loading } from '../components/Loading'import { bubbles, turns, withLive } from '../../../shared/transcript'import { Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'-import { ArrowDown, MicOff, TriangleAlert } from '../components/Icons'+import { ArrowDown, TriangleAlert } from '../components/Icons'import type { Segment, TranscriptPartial, WidgetView } from '../../../shared/types'import { formatElapsed } from '../../../shared/wave'import { t } from '../../../shared/i18n'@@ -107,17 +107,14 @@ function Recording({ view }: { view: WidgetView }) {const showFeedback = view.micState === 'unconfirmed' || view.micState === 'still-off'const hover = useWidgetMorph(card, !!view.note || showFeedback, time, muted)const press = useDragOrClick(() => window.yogurt.widget.open(), hover)- return <RecordingPill ref={card} time={time} expanded={hover.open} data-testid="widget" data-kind="recording" role={hover.open ? 'group' : 'button'} tabIndex={0}+ return <RecordingPill ref={card} time={time} expanded={hover.open} muted={muted} data-testid="widget" data-kind="recording" role={hover.open ? 'group' : 'button'} tabIndex={0}className="widget-morph" {...press}onFocus={e => { if (e.target.matches(':focus-visible')) hover.focus(true) }}onBlur={e => { if (!e.currentTarget.contains(e.relatedTarget)) hover.focus(false) }}onMouseMove={e => hover.pointer(e.clientX, e.clientY)}onMouseLeave={() => hover.pointer(-1, -1)}aria-label={[t('Open {title}', { title: view.title }), muted && t('Mic off in Yogurt')].filter(Boolean).join('. ')} title={view.note?.text ?? t('Recording {title}', { title: view.title })}>- {hover.open ? <MicToggle pill id={view.meetingId} state={view.micState} />- : muted && <span className="widget-mic-status" aria-hidden="true">- <span className="widget-mic-off" data-testid="widget-mic-off"><MicOff size={14} /></span>- </span>}+ {hover.open && <MicToggle pill id={view.meetingId} state={view.micState} />}<Preview view={view} open={hover.open} /></RecordingPill>}diff --git a/app/src/renderer/src/windows/widgetMorph.ts b/app/src/renderer/src/windows/widgetMorph.tsindex e84dc964..721030c9 100644--- a/app/src/renderer/src/windows/widgetMorph.ts+++ b/app/src/renderer/src/windows/widgetMorph.ts@@ -1,38 +1,27 @@import { useEffect, useLayoutEffect, useRef, useState } from 'react'-import { motion } from '../motion'-import { WidgetIntent, widgetContains, widgetExpanded, type WidgetLayout } from '../../../shared/widgetMorph'+import { WidgetIntent, widgetContains, widgetExpanded, widgetSizedPill, type WidgetLayout, type WidgetSurface } from '../../../shared/widgetMorph'-/** The same surface and details travel between the two shapes. */export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warning: boolean, time: string, muted: boolean) {const intent = useRef(new WidgetIntent()).currentconst [open, setOpen] = useState(false)const [layout, setLayout] = useState<WidgetLayout | null>(null)const pointer = useRef({ x: -1, y: -1 })const keyboardFocus = useRef(false)+ const surface = useRef<WidgetSurface | null>(null)const collapsedWidth = useRef(0)- const 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()- a.cancel()- }- animations.current = []- }+useEffect(() => {- let alive = true- const off = window.yogurt.widget.onLayout(setLayout)- void window.yogurt.widget.layout().then(v => { if (alive) setLayout(v) })+ let initial = true+ const off = window.yogurt.widget.onLayout(next => { initial = false; setLayout(next) })+ void window.yogurt.widget.layout().then(next => { if (initial) setLayout(next) })const offPointer = window.yogurt.widget.onPointer(p => { pointer.current = p; wake.current() })const offReset = window.yogurt.widget.onReset(() => {keyboardFocus.current = falseintent.open = false; intent.over = false; intent.pressed = false; intent.due = null- resumeAt.current = null; setOpen(false); morph.current(true); wake.current()+ setOpen(false); wake.current()})- return () => { alive = false; off(); offPointer(); offReset(); freeze() }+ return () => { initial = false; off(); offPointer(); offReset() }}, [])useLayoutEffect(() => {const was = intent.warning@@ -40,77 +29,40 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warif (was && !warning && !intent.over) intent.leave(performance.now())wake.current()}, [warning])- const previous = useRef<WidgetLayout | null>(null)+useLayoutEffect(() => {const el = card.currentif (!el || !layout) return- const readout = el.querySelector<HTMLElement>('.widget-readout')!- const body = el.querySelector<HTMLElement>('.widget-preview')!- const expanded = widgetExpanded(layout, warning)- morph.current = (immediate = false) => {- freeze()- const opened = intent.open, box = opened ? expanded : layout.pill- const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches- const duration = opened ? motion.surface : motion.base, easing = opened ? motion.soft : motion.ease- const animate = (node: HTMLElement, to: Record<string, string>, ms: number = duration, ease = easing, delay = 0) => {- const computed = getComputedStyle(node), from = Object.fromEntries(Object.keys(to).map(k => [k, computed[k as keyof CSSStyleDeclaration]]))- Object.assign(node.style, to)- if (!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 readoutX = opened ? box.width - readout.getBoundingClientRect().width - 48 : 12- animate(readout, { transform: `translate(${readoutX}px,${opened ? 18 : 12}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)- animate(body, { opacity: opened ? '1' : '0' }, opened ? motion.base : motion.micro, motion.ease, opened ? 40 : 0)- el.style.visibility = 'visible'+ // Measure the mounted row, including its badge, before the same React commit paints.+ const box = open ? widgetExpanded(layout, warning)+ : widgetSizedPill(layout, 26 + el.querySelector<HTMLElement>('.widget-readout')!.getBoundingClientRect().width)+ Object.assign(el.style, { left: `${box.x}px`, top: `${box.y}px`, width: `${box.width}px`, height: `${box.height}px`, visibility: 'visible' })+ if (!open) {+ collapsedWidth.current = box.width+ if (!intent.pressed && box.width !== layout.pill.width) window.yogurt.widget.size(box.width, 42)}- const before = previous.current- if (before && (intent.pressed || (resumeAt.current !== null && performance.now() < resumeAt.current))) {- freeze()- el.style.left = `${parseFloat(el.style.left) + layout.pill.x - before.pill.x}px`- el.style.top = `${parseFloat(el.style.top) + layout.pill.y - before.pill.y}px`- el.style.width = `${Math.min(parseFloat(el.style.width), layout.bounds.width)}px`- el.style.height = `${Math.min(parseFloat(el.style.height), layout.bounds.height)}px`- } else morph.current(true)- previous.current = layout+ surface.current = { ...box, radius: open ? 16 : 10 }+ window.yogurt.widget.surface(surface.current)wake.current()- }, [layout, warning])- useLayoutEffect(() => {- const readout = card.current?.querySelector<HTMLElement>('.widget-readout')- if (!readout) return- collapsedWidth.current = 26 + readout.getBoundingClientRect().width + (muted ? 12 + 1 + 12 + 24 : 0)- if (!intent.pressed) window.yogurt.widget.size(collapsedWidth.current, 42)- }, [time, open, layout?.pill.width, muted])+ }, [layout, open, warning, muted, time.length]) // Tabular digits only change width when the clock gains a character.+useEffect(() => {- let frame = 0, lastPoint = { x: -1, y: -1 }, lastSurface = ''+ let frame = 0, lastPoint = { x: -1, y: -1 }const tick = (now: number) => {frame = 0- const el = card.current- if (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) }- const p = pointer.current, inside = keyboardFocus.current || widgetContains(surface, p.x, p.y)+ if (surface.current) {+ const p = pointer.current, inside = keyboardFocus.current || widgetContains(surface.current, p.x, p.y)if (inside !== intent.over) inside ? intent.enter(now) : intent.leave(now)else if (inside && (p.x !== lastPoint.x || p.y !== lastPoint.y)) intent.move(now)lastPoint = pconst next = intent.tick(now)- if (next !== null) { setOpen(next); morph.current(); resumeAt.current = null }- else if (!intent.pressed && resumeAt.current !== null && now >= resumeAt.current) { resumeAt.current = null; morph.current() }- const key = JSON.stringify(surface)- if (key !== lastSurface) {- lastSurface = key; window.yogurt.widget.surface(surface)- if (!intent.open && !intent.pressed && surface.height === 42 && collapsedWidth.current) window.yogurt.widget.size(collapsedWidth.current, 42)- }+ if (next !== null) setOpen(next)}- // 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)+ if (intent.due) 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); wake.current() }- reduced.addEventListener('change', swap)- return () => { wake.current = () => {}; cancelAnimationFrame(frame); reduced.removeEventListener('change', swap) }+ return () => { wake.current = () => {}; cancelAnimationFrame(frame) }}, [])return {open,@@ -118,19 +70,15 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, warpointer: (x: number, y: number) => {pointer.current = { x, y }wake.current()- const el = card.current- if (!el || el.style.visibility !== 'visible') return- const r = el.getBoundingClientRect()- window.yogurt.widget.surface({ x: r.x, y: r.y, width: r.width, height: r.height, radius: parseFloat(getComputedStyle(el).borderRadius) })+ if (surface.current) window.yogurt.widget.surface(surface.current)},- press: () => { freeze(); intent.press(); resumeAt.current = null; window.yogurt.widget.pressed(true); wake.current() },+ press: () => { intent.press(); 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)- if (collapsedWidth.current) window.yogurt.widget.size(collapsedWidth.current, 42)+ if (!intent.open && collapsedWidth.current) window.yogurt.widget.size(collapsedWidth.current, 42)+ wake.current()},}}diff --git a/app/src/shared/widgetMorph.ts b/app/src/shared/widgetMorph.tsindex 37e6a6e3..2093dbd9 100644--- a/app/src/shared/widgetMorph.ts+++ b/app/src/shared/widgetMorph.ts@@ -4,33 +4,39 @@ export type WidgetRect = { x: number; y: number; width: number; height: number }export type WidgetSurface = WidgetRect & { radius: number }export type WidgetLayout = { bounds: WidgetRect; pill: WidgetRect; open: WidgetRect; up: boolean }+const CARD_WIDTH = 340, MAX_CARD_HEIGHT = 446const clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n))/** Keep the pill's corner fixed; turn inward at the display edges. */export function widgetLayout(pill: WidgetRect, area: WidgetRect): WidgetLayout {- const width = Math.min(340, area.width), height = Math.min(446, area.height)+ const width = Math.min(CARD_WIDTH, area.width), height = Math.min(MAX_CARD_HEIGHT, area.height)const x = clamp(pill.x + pill.width - width < area.x ? pill.x : pill.x + pill.width - width, area.x, area.x + area.width - width)const up = pill.y + height > area.y + area.heightconst y = clamp(up ? pill.y + pill.height - height : pill.y, area.y, area.y + area.height - height)- // Leave room for the spring without extending beyond the display.+ // Keep a small transparent margin inside the display.const bounds = { x: Math.max(area.x, x - 8), y: Math.max(area.y, y - 8), width: 0, height: 0 }bounds.width = Math.min(area.x + area.width, x + width + 8) - bounds.xbounds.height = Math.min(area.y + area.height, y + height + 8) - bounds.yreturn { bounds, pill: { ...pill, x: pill.x - bounds.x, y: pill.y - bounds.y }, open: { x: x - bounds.x, y: y - bounds.y, width, height }, up }}-/** Move the frozen visible surface; trim unused native space at the work area's edges. */+/** Resize the pill inside the existing window, keeping the edge it shares with the card. */+export function widgetSizedPill({ pill, open, bounds }: WidgetLayout, measured: number): WidgetRect {+ const width = Math.min(Math.round(measured), bounds.width)+ const x = pill.x === open.x ? pill.x : pill.x + pill.width - width+ return { ...pill, x: clamp(x, 0, bounds.width - width), width }+}++/** Keep the dragged surface under the pointer and enough native space for the card to reopen. */export function widgetDragLayout(frame: WidgetLayout, surface: WidgetRect, dx: number, dy: number, area: WidgetRect): WidgetLayout {const x = clamp(frame.bounds.x + Math.round(dx), area.x - surface.x, area.x + area.width - surface.x - surface.width)const y = clamp(frame.bounds.y + Math.round(dy), area.y - surface.y, area.y + area.height - surface.y - surface.height)- const clip = (r: WidgetRect): WidgetRect => {- const left = Math.max(area.x, r.x), top = Math.max(area.y, r.y)- return { x: left, y: top, width: Math.min(area.x + area.width, r.x + r.width) - left, height: Math.min(area.y + area.height, r.y + r.height) - top }+ const width = Math.min(area.width, Math.max(CARD_WIDTH, Math.ceil(x + frame.bounds.width) - Math.floor(x)))+ const height = Math.min(area.height, Math.max(MAX_CARD_HEIGHT, Math.ceil(y + frame.bounds.height) - Math.floor(y)))+ const bounds = {+ x: clamp(Math.floor(x), area.x, area.x + area.width - width),+ y: clamp(Math.floor(y), area.y, area.y + area.height - height), width, height,}- const bounds = clip({- x: Math.floor(x), y: Math.floor(y),- width: Math.ceil(x + frame.bounds.width) - Math.floor(x), height: Math.ceil(y + frame.bounds.height) - Math.floor(y),- })const local = (r: WidgetRect) => ({ ...r, x: r.x - bounds.x, y: r.y - bounds.y })return {bounds, up: frame.up,@@ -41,7 +47,7 @@ export function widgetDragLayout(frame: WidgetLayout, surface: WidgetRect, dx: n/** Restore room for the normal card without moving the frozen surface on release. */export function widgetRestLayout(frame: WidgetLayout, area: WidgetRect, height: number): WidgetLayout {- const width = Math.min(340, area.width), fullHeight = Math.min(446, area.height)+ const width = Math.min(CARD_WIDTH, area.width), fullHeight = Math.min(MAX_CARD_HEIGHT, area.height)height = Math.min(height, fullHeight)const x = clamp(frame.bounds.x + frame.open.x, area.x, area.x + area.width - width)const y = clamp(frame.bounds.y + frame.open.y + (frame.up ? frame.open.height - height : 0), area.y, area.y + area.height - height)@@ -63,7 +69,7 @@ export function widgetRestLayout(frame: WidgetLayout, area: WidgetRect, height:export function widgetExpanded(layout: WidgetLayout, warning: boolean): WidgetRect {const width = Math.min(layout.open.width, layout.bounds.width)- const height = Math.min(warning ? 446 : 390, layout.open.height, layout.bounds.height)+ const height = Math.min(warning ? MAX_CARD_HEIGHT : 390, layout.open.height, layout.bounds.height)return {x: clamp(layout.open.x, 0, layout.bounds.width - width),y: clamp(layout.open.y + (layout.up ? layout.open.height - height : 0), 0, layout.bounds.height - height),diff --git a/app/test/widgetMorph.test.ts b/app/test/widgetMorph.test.tsindex 4c73a3b0..e5184d7d 100644--- a/app/test/widgetMorph.test.ts+++ b/app/test/widgetMorph.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { WidgetIntent, widgetContains, widgetDragLayout, widgetExpanded, widgetLayout, widgetRestLayout, widgetSettings } from '../src/shared/widgetMorph'+import { WidgetIntent, widgetContains, widgetDragLayout, widgetExpanded, widgetLayout, widgetRestLayout, widgetSettings, widgetSizedPill } from '../src/shared/widgetMorph'import { WidgetModel } from '../src/main/widgetModel'describe('recorder hover intent', () => {@@ -56,6 +56,18 @@ describe('recorder hover intent', () => {describe('recorder geometry', () => {const area = { x: -1200, y: -100, width: 1200, height: 900 }+ it.each([-1200, -200])('keeps the card and its shared edge fixed through mute, timer growth and unmute at x=%s', x => {+ const initial = widgetLayout({ x, y: 0, width: 75, height: 42 }, area)+ const left = x === area.x+ const edge = left ? initial.pill.x : initial.pill.x + initial.pill.width+ let frame = initial+ for (const width of [124, 75, 82, 131, 82, 75]) {+ const pill = widgetSizedPill(frame, width + 0.2)+ expect(pill).toEqual({ ...initial.pill, width, x: left ? edge : edge - width })+ frame = { ...frame, pill }+ expect(widgetExpanded(frame, false)).toEqual(widgetExpanded(initial, false))+ }+ })it.each([[-200, 0, -413, 0], [-1200, 0, -1200, 0], [-200, 750, -413, 346], [-1200, 750, -1200, 346],])('keeps the pill at %s,%s and grows inward', (x, y, openX, openY) => {@@ -72,9 +84,10 @@ describe('recorder geometry', () => {it('fits a small work area while preserving the pill location', () => {const result = widgetLayout({ x: 80, y: 130, width: 118, height: 42 }, { x: 0, y: 0, width: 250, height: 200 })expect(result.bounds).toEqual({ x: 0, y: 0, width: 250, height: 200 })+ expect(widgetExpanded(result, false)).toEqual(result.bounds)expect(result.pill).toMatchObject({ x: 80, y: 130 })})- it.each([42, 180, 390, 446])('clamps the visible %spt surface at every edge without reserving invisible space', height => {+ it.each([42, 180, 390, 446])('clamps the visible %spt surface at every edge and keeps room to open', height => {for (const y of [0, 700]) {const frame = widgetLayout({ x: -600, y, width: 127, height: 42 }, area)const up = frame.pill.y > frame.open.y@@ -89,6 +102,7 @@ describe('recorder geometry', () => {expect(moved.bounds.y).toBeGreaterThanOrEqual(area.y)expect(moved.bounds.x + moved.bounds.width).toBeLessThanOrEqual(area.x + area.width)expect(moved.bounds.y + moved.bounds.height).toBeLessThanOrEqual(area.y + area.height)+ expect(widgetExpanded(moved, false)).toMatchObject({ width: 340, height: 390 })if (height === 390 || height === 446) {const resumedHeight = Math.min(height, moved.open.height)const resumedUp = moved.pill.y + moved.pill.height > moved.open.y + moved.open.height / 2diff --git a/app/test/widgetWindow.test.ts b/app/test/widgetWindow.test.tsindex c96818d1..5cc9e7d5 100644--- a/app/test/widgetWindow.test.ts+++ b/app/test/widgetWindow.test.ts@@ -165,7 +165,7 @@ describe('floating recorder placement', () => {if (height > 42) {send('widget:size', 134, 42)expect(win.getBounds()).toEqual(dropped)- expect(widget.snapshot().bounds).toEqual({ ...before, ...previous })+ expect(widget.snapshot().bounds).toEqual({ ...before, ...previous, x: previous.x - 7, width: 134 })}else expect(win.getBounds()).toEqual(widgetLayout({ ...before, ...previous }, area).bounds)expect(state.windows).toHaveLength(1)@@ -178,6 +178,16 @@ describe('floating recorder placement', () => {send('widget:pressed', false); send('widget:size', 134, 42)expect(widget.snapshot().bounds).toEqual({ ...before, x: before.x - 7, width: 134 })})+ it('accepts the new compact width even when the last reported surface was expanded', () => {+ const native = win.getBounds(), initial = widget.snapshot().bounds!+ const right = initial.x + initial.width+ send('widget:surface', { x: 8, y: 8, width: 340, height: 390, radius: 16 })+ for (const width of [75, 124, 75]) {+ send('widget:size', width, 42)+ expect(widget.snapshot().bounds).toEqual({ ...initial, width, x: right - width })+ expect(win.getBounds()).toEqual(native)+ }+ })it('restores the normal card after dragging during opening, dropping, closing and reopening', async () => {const { widgetLayout, widgetExpanded, WidgetIntent } = await import('../src/shared/widgetMorph')const intent = new WidgetIntent()@@ -187,8 +197,7 @@ describe('floating recorder placement', () => {send('widget:surface', partial); send('widget:pressed', true)send('widget:drag', -frame.bounds.x - partial.x, -frame.bounds.y - partial.y)const latest = () => win.webContents.send.mock.calls.filter(([channel]: [string]) => channel === 'widget:layout').at(-1)[1]- const clipped = latest()- expect(clipped.bounds.width).toBeLessThan(340)+ expect(widgetExpanded(latest(), false)).toMatchObject({ width: 340, height: 390 })send('widget:drag-end'); send('widget:pressed', false)intent.release(300, true)expect(intent.open).toBe(true)