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
Transcript: the player floats as a pill that ducks below the edge while you scroll down and springs back when you scroll up or pause
Eric Brownroutef660ab7ff79
diff --git a/app/e2e/notesSetup.spec.ts b/app/e2e/notesSetup.spec.tsindex 3a5d8eaa..2b3b160b 100644--- a/app/e2e/notesSetup.spec.ts+++ b/app/e2e/notesSetup.spec.ts@@ -60,11 +60,15 @@ async function expectQuietLayout(page: Page, upgrading: boolean, failed: booleanrange.selectNodeContents(line)return range.getClientRects().length === 1 && line.scrollWidth <= line.clientWidth}))).toBe(true)- const line = (await popup.locator('.notes-download-support').boundingBox())!if (upgrading || failed) {- const actions = (await popup.locator('.notes-download-actions').boundingBox())!- if (failed) expect(actions.y).toBeGreaterThanOrEqual(line.y + line.height)- else expect(Math.abs(actions.y + actions.height / 2 - line.y - line.height / 2)).toBeLessThan(1)+ // Both rectangles must come from the same frame while the popover is entering.+ const gap = () => popup.evaluate((el, stacked) => {+ const line = el.querySelector('.notes-download-support')!.getBoundingClientRect()+ const actions = el.querySelector('.notes-download-actions')!.getBoundingClientRect()+ return stacked ? actions.top - line.bottom : Math.abs(actions.y + actions.height / 2 - line.y - line.height / 2)+ }, failed)+ if (failed) await expect.poll(gap).toBeGreaterThanOrEqual(0)+ else await expect.poll(gap).toBeLessThan(1)}if (upgrading) await expect(popup.getByTestId('notes-setup-skip')).toHaveCSS('text-decoration-line', 'none')await expect(popup.locator('.notes-download-next')).toHaveCount(0)diff --git a/app/e2e/transcript.spec.ts b/app/e2e/transcript.spec.tsindex 9f171e56..e37366b2 100644--- a/app/e2e/transcript.spec.ts+++ b/app/e2e/transcript.spec.ts@@ -288,13 +288,15 @@ async function stopped(app: ElectronApplication, page: Page) {return (await page.evaluate(() => window.yogurt.nav.current())).slice('/note/'.length)}-test('the transcript scrolls behind its player and the final line can clear the controls', async () => {+test('the transcript scrolls behind its pill and the final line can clear the controls', async () => {const { app, page } = await launch()try {await stopped(app, page)const list = page.getByTestId('transcript'), player = page.getByTestId('player')const bottom = (await list.boundingBox())!const controls = (await player.boundingBox())!+ expect(controls.width).toBeLessThanOrEqual(412)+ await expect(player).toHaveCSS('border-radius', '22px')expect(bottom.y + bottom.height).toBeGreaterThan(controls.y + controls.height)const footer = (await page.locator('.note-footer').boundingBox())!expect(footer.y - controls.y - controls.height).toBeLessThanOrEqual(12)@@ -569,3 +571,76 @@ test('paused, the mark stays and nothing scrolls; clicking a line follows again;await expect(page.getByTestId('transcript-follow')).toHaveCount(0)} finally { await app.close() }})++for (const colorScheme of ['light', 'dark'] as const) test(`the player pill hides only for reading scrolls in ${colorScheme}`, async ({}, testInfo) => {+ const { app, page } = await launch()+ try {+ await page.context().tracing.start({ screenshots: true, snapshots: true })+ await page.emulateMedia({ colorScheme, reducedMotion: 'no-preference' })+ const id = await fake<string>(app, 'bigMeeting', 400)+ await fake(app, 'go', `/note/${id}`)+ await page.getByTestId('note-transcript-toggle').click()+ const list = page.getByTestId('transcript'), player = page.getByTestId('player')+ const dock = page.locator('.transcript-player-dock')+ await expect(player).toBeVisible()+ await expect(list).toHaveAttribute('data-loaded', 'true')+ await expect(page.getByTestId('transcript-line')).toHaveCount(400)+ await expect.poll(() => list.evaluate(el => el.clientHeight > 0 && el.scrollHeight - el.clientHeight > 600)).toBe(true)+ // Hover waits for the live list to receive input after the tab's view transition.+ await list.hover()+ // Moving the list without user input never hides the controls.+ await list.evaluate(el => { el.scrollTop = 240 })+ await expect.poll(() => list.evaluate(el => el.scrollTop)).toBe(240)+ await expect(dock).toHaveAttribute('data-hidden', 'false')+ await page.mouse.wheel(0, 120)+ await expect(dock).toHaveAttribute('data-hidden', 'true')+ await expect.poll(() => list.evaluate(el => el.scrollTop)).toBeGreaterThanOrEqual(264)+ await expect(player).toHaveCSS('opacity', '0')+ await page.mouse.wheel(0, -40)+ await expect(dock).toHaveAttribute('data-hidden', 'false')+ await expect(player).toHaveCSS('opacity', '1')+ // Opacity finishes before the return spring settles.+ await expect.poll(() => player.evaluate(el => el.getAnimations().length)).toBe(0)+ await page.mouse.wheel(0, 120)+ await expect(dock).toHaveAttribute('data-hidden', 'true')+ await expect(dock).toHaveAttribute('data-hidden', 'false', { timeout: 2000 })+ await expect(player).toHaveCSS('opacity', '1')+ await expect.poll(() => player.evaluate(el => el.getAnimations().length)).toBe(0)++ await page.getByTestId('player-toggle').focus()+ await page.mouse.wheel(0, 120)+ await expect(dock).toHaveAttribute('data-hidden', 'false')+ await page.getByTestId('recording-menu').click()+ await expect(page.getByTestId('recording-delete')).toBeVisible()+ await list.hover()+ await page.mouse.wheel(0, 120)+ await expect(dock).toHaveAttribute('data-hidden', 'false')+ await page.keyboard.press('Escape')+ await page.getByTestId('player-toggle').click()+ await expect(page.getByTestId('player-toggle')).toHaveAttribute('aria-label', 'Pause')+ await list.evaluate(el => { el.tabIndex = -1; el.focus({ preventScroll: true }) })+ await list.hover()+ await page.mouse.wheel(0, 120)+ await expect(dock).toHaveAttribute('data-hidden', 'false')++ await page.getByTestId('player-toggle').click()+ await expect(page.getByTestId('player-toggle')).toHaveAttribute('aria-label', 'Play')+ await page.emulateMedia({ colorScheme, reducedMotion: 'reduce' })+ await list.evaluate(el => { el.focus({ preventScroll: true }); el.scrollTop = 240 })+ await expect.poll(() => list.evaluate(el => el.scrollTop)).toBe(240)+ await list.hover()+ await page.mouse.wheel(0, 120)+ await expect(dock).toHaveAttribute('data-hidden', 'true')+ await expect(player).toHaveCSS('transform', 'none')+ await expect(player).toHaveCSS('transition-property', 'opacity')+ await list.evaluate(el => { el.scrollTop = el.scrollHeight })+ await expect(dock).toHaveAttribute('data-hidden', 'false')+ await expect(player).toHaveCSS('opacity', '1')+ await expect.poll(() => player.evaluate(el => el.getAnimations().length)).toBe(0)+ const last = (await page.getByTestId('transcript-turn').last().boundingBox())!+ const pill = (await player.boundingBox())!+ expect(last.y + last.height).toBeLessThan(pill.y)+ } finally {+ await page.context().tracing.stop({ path: testInfo.outputPath('trace.zip') }).finally(() => app.close())+ }+})diff --git a/app/src/renderer/src/components/Player.tsx b/app/src/renderer/src/components/Player.tsxindex 476e2b9c..9ae10be1 100644--- a/app/src/renderer/src/components/Player.tsx+++ b/app/src/renderer/src/components/Player.tsx@@ -23,10 +23,11 @@ const DRIFT_S = 0.08* `onTime` gets the spot while it plays and when it is moved (paused too, so the line stays marked where it stopped),* with `seek` for an explicit move, and null once the meeting or panel changes; `onPlaying` whether any side is playing.*/-type PlayerProps = { id: string; tracks: Track[]; ref?: Ref<PlayerHandle>; onTime?: (ms: number | null, seek?: boolean) => void; onPlaying?: (on: boolean) => void }+type PlayerProps = { id: string; tracks: Track[]; ref?: Ref<PlayerHandle>; onTime?: (ms: number | null, seek?: boolean) => void; onPlaying?: (on: boolean) => void; onBusy?: (on: boolean) => void }export function Player(props: PlayerProps) { return props.tracks.length ? <MeetingPlayer key={props.id} {...props} /> : null }-function MeetingPlayer({ id, tracks, ref, onTime, onPlaying }: PlayerProps) {+function MeetingPlayer({ id, tracks, ref, onTime, onPlaying, onBusy }: PlayerProps) {const [confirm, setConfirm] = useState(false)+ const [menuOpen, setMenuOpen] = useState(false)const [deleted, setDeleted] = useState(false)const menuButton = useRef<HTMLButtonElement>(null)const els = useRef<Partial<Record<Track, HTMLAudioElement>>>({})@@ -43,6 +44,8 @@ function MeetingPlayer({ id, tracks, ref, onTime, onPlaying }: PlayerProps) {onTimeRef.current = onTimeconst onPlayingRef = useRef(onPlaying)onPlayingRef.current = onPlaying+ const onBusyRef = useRef(onBusy)+ onBusyRef.current = onBusy/** nothing is marked until it has played or been moved */const touched = useRef(false)const rateRef = useRef(rate)@@ -91,6 +94,7 @@ function MeetingPlayer({ id, tracks, ref, onTime, onPlaying }: PlayerProps) {// React lets go of the elements (els) before this cleanup runs, and an audio let go keeps playing: pause every one it haduseEffect(() => () => { for (const a of owned.current) a.pause(); owned.current.clear(); onTimeRef.current?.(null) }, [id])useEffect(() => { onPlayingRef.current?.(playing) }, [playing])+ useEffect(() => { onBusyRef.current?.(playing || menuOpen || confirm) }, [playing, menuOpen, confirm])const changed = () => setPlaying(anyPlaying())const tick = (a: HTMLAudioElement) => {@@ -113,7 +117,7 @@ function MeetingPlayer({ id, tracks, ref, onTime, onPlaying }: PlayerProps) {const note = broken.length === 0 ? null : shown.length === 0 ? t("This recording can't be played.") : t("Part of this recording can't be played.")if (deleted) return nullreturn (- <div data-testid="player" className="mx-4 mb-4 rounded-xl border border-line bg-float p-2 text-xs text-muted shadow-[var(--shadow-soft)]">+ <div data-testid="player" className="transcript-player text-xs text-muted">{shown.map((tr) => (<audio key={tr} data-testid={`player-audio-${tr}`} data-track={tr} preload="metadata" src={`yogurt-audio://${id}/${tr}`}ref={(a) => { if (a) { els.current[tr] = a; owned.current.add(a) } else delete els.current[tr] }}@@ -124,10 +128,10 @@ function MeetingPlayer({ id, tracks, ref, onTime, onPlaying }: PlayerProps) {onError={(e) => { failed(tr, e.currentTarget); changed() }} />))}{note && <p data-testid="player-note" role="status" className={shown.length ? 'px-1.5 pb-1.5' : 'px-1.5 py-1'}>{note}</p>}- <div className="flex items-center gap-2.5">+ <div className="flex items-center gap-2">{shown.length > 0 && <><button data-testid="player-toggle" aria-label={playing ? t('Pause') : t('Play')} onClick={() => (playing ? pause() : play())}- className="player-btn flex size-7 shrink-0 items-center justify-center rounded-md bg-accent text-accent-ink">+ className="player-btn flex size-[26px] shrink-0 items-center justify-center rounded-full bg-accent text-accent-ink"><Swap show={playing ? 'pause' : 'play'} options={{ play: <Play size={13} fill="currentColor" strokeWidth={0} className="ms-0.5" />, pause: <Pause size={13} fill="currentColor" strokeWidth={0} /> }} /></button><span className="w-9 shrink-0 text-end tabular-nums">{clock(time * 1000)}</span>@@ -136,11 +140,11 @@ function MeetingPlayer({ id, tracks, ref, onTime, onPlaying }: PlayerProps) {<span className="w-9 shrink-0 tabular-nums">{clock(duration * 1000)}</span><button data-testid="player-speed" aria-label={t('Playback speed {rate}', { rate: rateText })}onClick={() => setRate((r) => RATES[(RATES.indexOf(r) + 1) % RATES.length])}- className="ghost-btn h-7 w-10 shrink-0 justify-center !px-0 tabular-nums">+ className="ghost-btn h-7 w-[30px] shrink-0 justify-center !px-0 tabular-nums">{rateText}</button></>}- <Menu.Root modal={false}>+ <Menu.Root modal={false} onOpenChange={setMenuOpen}><Menu.Trigger ref={menuButton} data-testid="recording-menu" aria-label={t('More')} title={t('More')}className="bar-btn ms-auto grid size-7 shrink-0 place-items-center rounded-md text-muted"><Ellipsis size={17} aria-hidden="true" /></Menu.Trigger><Menu.Portal>diff --git a/app/src/renderer/src/components/Transcript.tsx b/app/src/renderer/src/components/Transcript.tsxindex 88c71027..b9503000 100644--- a/app/src/renderer/src/components/Transcript.tsx+++ b/app/src/renderer/src/components/Transcript.tsx@@ -12,6 +12,7 @@ import { useLanguage } from '../i18n'import { bubbles, clock, echoRuns, filterLines, lineAt, recentRuns, stableKeys, turns, withLive, type LiveSaid } from '../../../shared/transcript'import { markWords } from '../../../shared/highlight'import { Player, type PlayerHandle } from './Player'+import { attachPlayerVisibility } from '../playerVisibility'import { rememberedScroll, useScrollMemory } from '../useScrollMemory'import { followGlide, scrollBehavior } from '../motion'import { followTarget, inView } from '../../../shared/follow'@@ -186,16 +187,17 @@ export function Transcript({ id, recording, inline = false, active = true, onCloconst playable = tracks.length > 0const playbackDock = useRef<HTMLDivElement>(null)const [playbackInset, setPlaybackInset] = useState(0)+ const visibility = useRef<ReturnType<typeof attachPlayerVisibility> | null>(null)useLayoutEffect(() => {const dock = playbackDock.current- if (!inline || !dock) { setPlaybackInset(0); return }+ if (!dock) { setPlaybackInset(0); return }// Reserve the actual controls height, including playback errors and larger text.- const measure = () => setPlaybackInset(dock.getBoundingClientRect().height + 16)+ const measure = () => setPlaybackInset(dock.getBoundingClientRect().height + 28)measure()const observer = new ResizeObserver(measure)observer.observe(dock)return () => observer.disconnect()- }, [inline, playable, active])+ }, [playable, active])// the line being played: found by a binary search on each tick, drawn only when it changesconst [shownKey, setShownKey] = useState<string>()@@ -213,6 +215,13 @@ export function Transcript({ id, recording, inline = false, active = true, onClo// follow the newest line while recording, unless they scrolled up to readconst scrollKey = `transcript/${id}`const list = useScrollMemory<HTMLOListElement>(scrollKey, active && loaded)+ useLayoutEffect(() => {+ const el = list.current, dock = playbackDock.current+ if (!active || !playable || !el || !dock) return+ const controls = attachPlayerVisibility(el, dock)+ visibility.current = controls+ return () => { controls.dispose(); visibility.current = null }+ }, [id, active, playable])const stick = useRef(rememberedScroll(scrollKey) === undefined)const [behind, setBehind] = useState(false)const onScroll = () => {@@ -225,9 +234,9 @@ export function Transcript({ id, recording, inline = false, active = true, onClo}useLayoutEffect(() => {const el = list.current- if (active && recording && el && stick.current) el.scrollTop = el.scrollHeight+ if (active && recording && el && stick.current) { visibility.current?.programmatic(); el.scrollTop = el.scrollHeight }}, [lines, liveSaid, recording, active])- const toLatest = () => { const el = list.current; if (el) { stick.current = true; setBehind(false); el.scrollTo({ top: el.scrollHeight, behavior: scrollBehavior() }) } }+ const toLatest = () => { const el = list.current; if (el) { visibility.current?.programmatic(); stick.current = true; setBehind(false); el.scrollTo({ top: el.scrollHeight, behavior: scrollBehavior() }) } }// playing follows along: the line being played kept comfortably in view, until they scroll it out of sightconst rowOf = (k?: string) => (k ? list.current?.querySelector<HTMLElement>(`[data-key="${CSS.escape(k)}"]`) ?? null : null)@@ -261,6 +270,7 @@ export function Transcript({ id, recording, inline = false, active = true, onClo}))ours.current = motion}+ visibility.current?.programmatic()ours.current.to(to)}// An explicit seek asks to follow again, even paused or within the same line. Ordinary ticks respect reading elsewhere.@@ -313,7 +323,7 @@ export function Transcript({ id, recording, inline = false, active = true, onClostick.current = falsesetShowAll(true)setFocusedKey(key(l)); setFocusKey(key(l))- requestAnimationFrame(() => rowOf(key(l))?.scrollIntoView({ block: 'center' }))+ requestAnimationFrame(() => { visibility.current?.programmatic(); rowOf(key(l))?.scrollIntoView({ block: 'center' }) })}, [focus?.seq, lines, active])useEffect(() => {if (!focusedKey) return@@ -328,7 +338,7 @@ export function Transcript({ id, recording, inline = false, active = true, onCloif (!playable || !row || row !== e.target) returnconst i = shownLines.findIndex((l) => key(l) === row.dataset.key)if (i < 0) return- const go = (j: number) => { const next = rowOf(key(shownLines[Math.max(0, Math.min(shownLines.length - 1, j))])); next?.focus(); next?.scrollIntoView({ block: 'nearest' }) }+ const go = (j: number) => { const next = rowOf(key(shownLines[Math.max(0, Math.min(shownLines.length - 1, j))])); visibility.current?.programmatic(); next?.focus({ preventScroll: true }); next?.scrollIntoView({ block: 'nearest' }) }if (e.key === 'ArrowDown') { e.preventDefault(); go(i + 1) }else if (e.key === 'ArrowUp') { e.preventDefault(); go(i - 1) }else if (e.key === 'Home') { e.preventDefault(); go(0) }@@ -349,7 +359,7 @@ export function Transcript({ id, recording, inline = false, active = true, onClo<div className="transcript-toolbar"><label className="transcript-search-field"><SearchIcon size={14} strokeWidth={1.75} aria-hidden="true" className="shrink-0 text-muted" />- <input data-testid="transcript-search" value={query} onChange={(e) => setQuery(e.target.value)} placeholder={t('Search')} aria-label={t('Search the transcript')} spellCheck={false} />+ <input data-testid="transcript-search" value={query} onChange={(e) => { visibility.current?.programmatic(); setQuery(e.target.value) }} placeholder={t('Search')} aria-label={t('Search the transcript')} spellCheck={false} /></label>{!inline && onClose && <div className="transcript-actions"><button data-testid="transcript-close" onClick={onClose} aria-label={t('Hide transcript')} title={t('Hide transcript')} className="ghost-btn !p-1.5"><ChevronDown size={15} aria-hidden="true" /></button></div>}</div>@@ -364,7 +374,7 @@ export function Transcript({ id, recording, inline = false, active = true, onClo{loadingPhase !== 'ready' && <li className="loading-placeholder"><Loading layout="transcript" /></li>}{loaded && allLines.length === 0 && liveSaid.length === 0 && <li data-testid="transcript-empty" className="note-empty empty-state"><div className="empty-state-content"><div className="empty-tile"><AudioLines size={28} strokeWidth={1.5} aria-hidden="true" /></div>{t('Nothing heard yet.')}</div></li>}{allLines.length > 0 && grouped.length === 0 && <li data-testid="transcript-none" className="note-empty">{t('Nothing found for “{query}”.', { query: typed })}</li>}- {drawn.earlier > 0 && <li className="flex justify-center"><button data-testid="transcript-earlier" onClick={() => { stick.current = false; setShowAll(true) }} className="ghost-btn !px-2 !py-1 text-xs text-muted">{t('Show earlier lines')}</button></li>}+ {drawn.earlier > 0 && <li className="flex justify-center"><button data-testid="transcript-earlier" onClick={() => { visibility.current?.programmatic(); stick.current = false; setShowAll(true) }} className="ghost-btn !px-2 !py-1 text-xs text-muted">{t('Show earlier lines')}</button></li>}{drawn.runs.map(run => <Fragment key={run.k}>{turns(run.lines).map((turn) => {const me = turn[0].track === 'me', first = turn[0]@@ -407,7 +417,7 @@ export function Transcript({ id, recording, inline = false, active = true, onClo</button>)}</div>- {active && playable && <div ref={playbackDock} className="transcript-player-dock"><Player ref={player} id={id} tracks={tracks} onTime={onTime} onPlaying={setAudioOn} /></div>}+ {active && playable && <div ref={playbackDock} className="transcript-player-dock"><Player ref={player} id={id} tracks={tracks} onTime={onTime} onPlaying={setAudioOn} onBusy={on => visibility.current?.pin(on)} /></div>}</Surface>)}diff --git a/app/src/renderer/src/playerVisibility.ts b/app/src/renderer/src/playerVisibility.tsnew file mode 100644index 00000000..8afaad78--- /dev/null+++ b/app/src/renderer/src/playerVisibility.ts@@ -0,0 +1,103 @@+const RETURN_MS = 900+const DOWN_PX = 24+const UP_PX = 8+const END_PX = 24++/** Only a person's scroll can hide the controls; callers reset before moving the list themselves. */+export function attachPlayerVisibility(list: HTMLElement, dock: HTMLElement) {+ let user = false, dragging = false, busy = false, hovered = false+ let last = list.scrollTop, direction = 0, distance = 0+ let hidden = false+ let idle: ReturnType<typeof setTimeout> | undefined+ const pinned = () => busy || hovered || dock.contains(document.activeElement) ||+ !list.clientHeight || list.scrollHeight - list.clientHeight - list.scrollTop <= END_PX+ const show = (hide: boolean) => {+ const next = hide && !pinned()+ // CSS retargets from the displayed position; repeated input leaves the transition alone.+ if (hidden === next) return+ hidden = next+ dock.dataset.hidden = String(hidden)+ }+ const reset = () => {+ user = false; direction = 0; distance = 0; last = list.scrollTop+ clearTimeout(idle); idle = undefined+ show(false)+ }+ const later = () => { clearTimeout(idle); idle = setTimeout(reset, RETURN_MS) }+ const arm = () => {+ // Passive input can arrive after the offset changes; keep the last scroll-event position.+ if (!user) { direction = 0; distance = 0 }+ user = true; later()+ }+ const scroll = () => {+ const delta = list.scrollTop - last+ last = list.scrollTop+ if (pinned()) { reset(); return }+ if (!user || !delta) return+ const sign = Math.sign(delta)+ distance = sign === direction ? distance + Math.abs(delta) : Math.abs(delta)+ direction = sign+ if (sign > 0 && distance >= DOWN_PX) show(true)+ if (sign < 0 && distance >= UP_PX) show(false)+ later()+ }+ const wheel = (event: WheelEvent) => {+ if (event.isTrusted && !event.ctrlKey && Math.abs(event.deltaY) > Math.abs(event.deltaX)) arm()+ }+ const key = (event: KeyboardEvent) => {+ if (event.isTrusted && !event.defaultPrevented && !event.ctrlKey && !event.metaKey && !event.altKey &&+ ['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(event.key) &&+ !(event.target as HTMLElement).closest('input, textarea, button, [contenteditable="true"]')) arm()+ }+ const touch = (event: TouchEvent) => { if (event.isTrusted) arm() }+ const down = (event: PointerEvent) => {+ if (!event.isTrusted || event.button !== 0 || event.target !== list) return+ const box = list.getBoundingClientRect(), x = event.clientX - box.left+ // Only the scrollbar gutter, including an overlay scrollbar, starts a drag gesture.+ if (x <= Math.max(list.clientLeft, 12) || x >= Math.min(list.clientLeft + list.clientWidth, box.width - 12)) {+ dragging = true; arm()+ }+ }+ const move = (event: PointerEvent) => { if (dragging && event.isTrusted) arm() }+ const up = () => { dragging = false }+ const enter = (event: PointerEvent) => { if (event.pointerType !== 'touch') { hovered = true; reset() } }+ const leave = () => { hovered = false }+ const resize = () => { if (pinned()) reset() }+ const observer = new ResizeObserver(resize)+ observer.observe(list)+ // Text wrapping and filtering can change scrollability without resizing the list itself.+ const content = new MutationObserver(resize)+ content.observe(list, { childList: true, subtree: true })+ list.addEventListener('scroll', scroll, { passive: true })+ list.addEventListener('wheel', wheel, { passive: true })+ list.addEventListener('touchmove', touch, { passive: true })+ list.addEventListener('keydown', key)+ list.addEventListener('pointerdown', down)+ document.addEventListener('pointermove', move, { passive: true })+ document.addEventListener('pointerup', up)+ document.addEventListener('pointercancel', up)+ dock.addEventListener('pointerenter', enter)+ dock.addEventListener('pointerleave', leave)+ dock.addEventListener('focusin', reset)+ dock.dataset.hidden = 'false'+ return {+ programmatic: reset,+ pin(value: boolean) { busy = value; reset() },+ dispose() {+ clearTimeout(idle)+ observer.disconnect(); content.disconnect()+ list.removeEventListener('scroll', scroll)+ list.removeEventListener('wheel', wheel)+ list.removeEventListener('touchmove', touch)+ list.removeEventListener('keydown', key)+ list.removeEventListener('pointerdown', down)+ document.removeEventListener('pointermove', move)+ document.removeEventListener('pointerup', up)+ document.removeEventListener('pointercancel', up)+ dock.removeEventListener('pointerenter', enter)+ dock.removeEventListener('pointerleave', leave)+ dock.removeEventListener('focusin', reset)+ delete dock.dataset.hidden+ },+ }+}diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.cssindex e015d312..e0ef80c9 100644--- a/app/src/renderer/src/styles.css+++ b/app/src/renderer/src/styles.css@@ -16,6 +16,11 @@--ease-out: cubic-bezier(.23,1,.32,1);--ease-in-out: cubic-bezier(.77,0,.175,1);--ease-soft: cubic-bezier(.23,1.15,.32,1);+ --dur-player-duck: 160ms;+ --dur-player-return: 360ms;+ --ease-player-duck: linear(0, 0.00391, 0.01563, 0.03516, 0.0625, 0.09766, 0.14063, 0.19141, 0.25, 0.31641, 0.39063, 0.47266, 0.5625, 0.66016, 0.76563, 0.87891, 1);+ /* Spring samples every 10ms: stiffness 640, damping 32, mass 1. */+ --ease-player-return: linear(0, 0.02869, 0.10244, 0.2049, 0.32261, 0.44499, 0.56409, 0.67433, 0.77212, 0.85554, 0.92399, 0.97783, 1.01814, 1.04642, 1.06443, 1.07399, 1.07691, 1.07484, 1.06925, 1.06143, 1.0524, 1.04299, 1.03381, 1.0253, 1.01775, 1.0113, 1.006, 1.00182, 0.99869, 0.99649, 0.99508, 0.99432, 0.99409, 0.99423, 0.99466, 1, 1);--bg: #FFFFFF;--card: #F6F6F8;--ink: #23242A;@@ -701,12 +706,17 @@ input::selection, textarea::selection, .note-prose ::selection { background: var/* The transcript continues behind the player; its last line can scroll clear of the controls. */[data-testid="transcript-panel"].transcript-inline { position:relative;display:flex;flex:1;flex-direction:column;min-height:0;height:auto;width:100%;border:0;border-radius:0;background:transparent;box-shadow:none; }.transcript-inline>.transcript-toolbar { padding-block:4px 8px;padding-inline:0;border:0; }-.transcript-inline [data-testid="transcript"] { padding-inline:var(--transcript-inset);padding-top:22px;padding-bottom:max(16px,var(--playback-inset));scroll-padding-bottom:var(--playback-inset); }-.transcript-inline .transcript-player-dock { position:absolute;inset-inline:var(--transcript-inset);bottom:4px;z-index:1; }-.transcript-inline [data-testid="player"] { margin:0;background:color-mix(in srgb,var(--float) 88%,transparent);backdrop-filter:blur(12px);box-shadow:0 2px 12px #0000000D; }-.transcript-inline [data-testid="transcript-follow"] { bottom:calc(var(--playback-inset) + 8px); }+.transcript-inline [data-testid="transcript"] { padding-inline:var(--transcript-inset);padding-top:22px; }+[data-testid="transcript-panel"] [data-testid="transcript"] { padding-bottom:max(16px,var(--playback-inset));scroll-padding-bottom:var(--playback-inset); }+.transcript-player-dock { position:absolute;inset-inline:max(16px, calc((100% - 412px)/2));bottom:12px;z-index:1;clip-path:inset(-16px -16px -12px); }+.transcript-player { padding:5px 8px;border:1px solid var(--line);border-radius:22px;background:color-mix(in srgb,var(--float) 96%,transparent);backdrop-filter:blur(12px);box-shadow:0 2px 8px #0000000D;opacity:1;transform:translateY(0);transition:opacity var(--dur-micro) var(--ease-out),transform var(--dur-player-return) var(--ease-player-return); }+.transcript-player-dock[data-hidden=true] .transcript-player { opacity:0;transform:translateY(calc(100% + 12px));pointer-events:none;transition:transform var(--dur-player-duck) var(--ease-player-duck),opacity calc(var(--dur-player-duck)/4) linear calc(var(--dur-player-duck)*.75); }+@media (prefers-reduced-motion: reduce) {+ .transcript-player,.transcript-player-dock[data-hidden=true] .transcript-player { transform:none;transition:opacity var(--dur-micro) var(--ease-out); }+}+[data-testid="transcript-panel"] [data-testid="transcript-follow"] { bottom:calc(var(--playback-inset) + 8px); }@media (prefers-reduced-transparency:reduce),(prefers-contrast:more) {- .transcript-inline [data-testid="player"] { background:var(--float);backdrop-filter:none; }+ .transcript-player { background:var(--float);backdrop-filter:none; }}html:not(.widget) .bg-accent { background-color:var(--primary); }diff --git a/app/test/playerMotion.test.ts b/app/test/playerMotion.test.tsnew file mode 100644index 00000000..3d51d0f9--- /dev/null+++ b/app/test/playerMotion.test.ts@@ -0,0 +1,31 @@+import { readFileSync } from 'node:fs'+import { expect, it } from 'vitest'+import { spring } from 'motion'++const css = readFileSync(new URL('../src/renderer/src/styles.css', import.meta.url), 'utf8')+const points = (name: string) => css.match(new RegExp(`--ease-player-${name}: linear\\(([^)]+)\\)`))![1].split(',').map(Number)++it('returns on a physical spring with fast arrival, a four-pixel overshoot and one small settle', () => {+ const values = points('return')+ const curve = spring({ stiffness: 640, damping: 32, mass: 1, restDelta: .005, restSpeed: .1, keyframes: [0, 1] })+ expect(values).toHaveLength(37)+ values.forEach((value, i) => expect(value).toBeCloseTo(curve.next(i * 10).value, 4))+ expect(css).toContain('--dur-player-return: 360ms')+ expect(values[10]).toBeGreaterThan(.9)+ const overshoot = (Math.max(...values) - 1) * 52+ expect(overshoot).toBeGreaterThan(3.5)+ expect(overshoot).toBeLessThan(4.5)+ expect(Math.min(...values.slice(17))).toBeGreaterThan(.99)+ expect(values.at(-1)).toBe(1)+})++it('ducks in 160ms with increasing speed, no anticipation delay, and the existing final-quarter fade', () => {+ const values = points('duck')+ expect(css).toContain('--dur-player-duck: 160ms')+ expect(values[0]).toBe(0)+ expect(values.at(-1)).toBe(1)+ const steps = values.slice(1).map((value, i) => value - values[i])+ steps.slice(1).forEach((step, i) => expect(step).toBeGreaterThan(steps[i]))+ expect(css).toContain('opacity calc(var(--dur-player-duck)/4) linear calc(var(--dur-player-duck)*.75)')+ expect(css).toContain('transform:none;transition:opacity var(--dur-micro) var(--ease-out)')+})diff --git a/app/test/playerVisibility.test.ts b/app/test/playerVisibility.test.tsnew file mode 100644index 00000000..fb520527--- /dev/null+++ b/app/test/playerVisibility.test.ts@@ -0,0 +1,170 @@+import { afterEach, beforeEach, expect, it, vi } from 'vitest'+import { attachPlayerVisibility } from '../src/renderer/src/playerVisibility'++class Element extends EventTarget {+ scrollHeight = 2000+ clientHeight = 400+ clientWidth = 500+ clientLeft = 0+ scrollTop = 0+ dataset: Record<string, string> = {}+ contains(value: unknown) { return value === this }+ closest() { return null }+ getBoundingClientRect() { return { left: 0, width: 500 } }+}+class Observer {+ static all: Observer[] = []+ observe = vi.fn()+ disconnect = vi.fn()+ constructor(public change: () => void) { Observer.all.push(this) }+}+let doc: EventTarget & { activeElement: Element | null }+beforeEach(() => {+ vi.useFakeTimers()+ doc = Object.assign(new EventTarget(), { activeElement: null })+ Observer.all = []+ vi.stubGlobal('document', doc)+ vi.stubGlobal('ResizeObserver', Observer)+ vi.stubGlobal('MutationObserver', Observer)+})+afterEach(() => { vi.useRealTimers(); vi.unstubAllGlobals() })+function input(target: EventTarget, type: string, props: Record<string, unknown> = {}) {+ const event = Object.assign(new Event(type), props)+ Object.defineProperty(event, 'isTrusted', { value: true })+ target.dispatchEvent(event)+}+function setup() {+ const list = new Element(), dock = new Element()+ const controls = attachPlayerVisibility(list as unknown as HTMLElement, dock as unknown as HTMLElement)+ const scroll = (top: number) => { list.scrollTop = top; list.dispatchEvent(new Event('scroll')) }+ const wheel = (deltaY = 100) => input(list, 'wheel', { deltaY, deltaX: 0 })+ const hide = () => { wheel(); scroll(100); vi.advanceTimersByTime(120); expect(dock.dataset.hidden).toBe('true') }+ return { list, dock, controls, scroll, wheel, hide }+}+it('requires real user input and ignores raw programmatic scrolls and synthetic gestures', () => {+ const { list, dock, controls, scroll } = setup()+ scroll(100)+ list.dispatchEvent(Object.assign(new Event('wheel'), { deltaY: 200, deltaX: 0 }))+ scroll(300)+ expect(dock.dataset.hidden).toBe('false')+ controls.dispose()+})+it('keeps the last scroll-event position when a passive wheel arrives after the offset changes', () => {+ const { list, dock, controls, scroll, wheel } = setup()+ scroll(240)+ list.scrollTop = 360+ wheel(120)+ scroll(360)+ expect(dock.dataset.hidden).toBe('true')+ controls.dispose()+})+it('filters jitter and uses separate down and up thresholds', () => {+ const { dock, controls, scroll, wheel } = setup()+ wheel()+ for (const y of [2, 0, 3, 1, 4, 2, 25]) { scroll(y); expect(dock.dataset.hidden).toBe('false') }+ scroll(26); expect(dock.dataset.hidden).toBe('true')+ vi.advanceTimersByTime(120)+ scroll(19); expect(dock.dataset.hidden).toBe('true')+ scroll(18); expect(dock.dataset.hidden).toBe('false')+ controls.dispose()+})+it('returns after scrolling stops, extending the delay through momentum', () => {+ const { dock, controls, scroll, hide } = setup()+ hide()+ vi.advanceTimersByTime(700); scroll(150)+ vi.advanceTimersByTime(899); expect(dock.dataset.hidden).toBe('true')+ vi.advanceTimersByTime(1); expect(dock.dataset.hidden).toBe('false')+ vi.advanceTimersByTime(180)+ scroll(250); expect(dock.dataset.hidden).toBe('false')+ controls.dispose()+})+it('retargets both directions immediately during motion without a queued animation or restart', () => {+ const { dock, controls, scroll, wheel } = setup()+ wheel(); scroll(100); expect(dock.dataset.hidden).toBe('true')+ vi.advanceTimersByTime(60); scroll(110); scroll(90)+ expect(dock.dataset.hidden).toBe('false')+ scroll(140); expect(dock.dataset.hidden).toBe('true')+ scroll(150); expect(dock.dataset.hidden).toBe('true')+ // Only the reading-pause timer remains; there is no animation lock or deferred reversal.+ expect(vi.getTimerCount()).toBe(1)+ controls.dispose()+})++it('clears a gesture before following playback, citation jumps, search or keyboard navigation', () => {+ const { dock, controls, scroll, hide } = setup()+ hide(); controls.programmatic()+ scroll(500); vi.advanceTimersByTime(400); scroll(900)+ expect(dock.dataset.hidden).toBe('false')+ controls.dispose()+})+it('pins playback and open menus or dialogs, then waits for a fresh user gesture', () => {+ const { dock, controls, scroll, wheel, hide } = setup()+ hide(); controls.pin(true)+ vi.advanceTimersByTime(180)+ wheel(); scroll(600); expect(dock.dataset.hidden).toBe('false')+ controls.pin(false); scroll(900); expect(dock.dataset.hidden).toBe('false')+ wheel(); scroll(1000); expect(dock.dataset.hidden).toBe('true')+ controls.dispose()+})+it('reveals on focus or hover and keeps hidden controls keyboard reachable', () => {+ const { dock, controls, scroll, wheel, hide } = setup()+ hide(); doc.activeElement = dock; dock.dispatchEvent(new Event('focusin'))+ vi.advanceTimersByTime(180)+ wheel(); scroll(600); expect(dock.dataset.hidden).toBe('false')+ doc.activeElement = null+ input(dock, 'pointerenter', { pointerType: 'mouse' })+ wheel(); scroll(900); expect(dock.dataset.hidden).toBe('false')+ dock.dispatchEvent(new Event('pointerleave'))+ wheel(); scroll(1000); expect(dock.dataset.hidden).toBe('true')+ controls.dispose()+})+it('pins short transcripts and the end, including when filtering or resizing makes it unscrollable', () => {+ const { list, dock, controls, scroll, wheel, hide } = setup()+ hide(); scroll(1576); expect(dock.dataset.hidden).toBe('false')+ vi.advanceTimersByTime(180)+ wheel(); scroll(1600); expect(dock.dataset.hidden).toBe('false')+ controls.programmatic(); scroll(0); wheel(); scroll(100)+ vi.advanceTimersByTime(120); expect(dock.dataset.hidden).toBe('true')+ list.scrollHeight = 400; Observer.all[1].change()+ expect(dock.dataset.hidden).toBe('false')+ vi.advanceTimersByTime(180)+ wheel(); scroll(0); expect(dock.dataset.hidden).toBe('false')+ controls.dispose()+})+it('accepts touch scrolling, scroll keys and scrollbar dragging, not horizontal wheel or text clicks', () => {+ const { list, dock, controls, scroll } = setup()+ input(list, 'wheel', { deltaX: 100, deltaY: 1 }); scroll(100)+ input(list, 'wheel', { deltaX: 0, deltaY: 100, ctrlKey: true }); scroll(200)+ input(list, 'pointerdown', { button: 0, clientX: 250 }); scroll(300)+ expect(dock.dataset.hidden).toBe('false')+ input(list, 'touchmove'); scroll(400); expect(dock.dataset.hidden).toBe('true')+ vi.advanceTimersByTime(120); controls.programmatic(); vi.advanceTimersByTime(180)+ input(list, 'keydown', { key: 'PageDown' }); scroll(500); expect(dock.dataset.hidden).toBe('true')+ vi.advanceTimersByTime(120); controls.programmatic(); vi.advanceTimersByTime(180)+ input(list, 'pointerdown', { button: 0, clientX: 498 })+ vi.advanceTimersByTime(1000); input(doc, 'pointermove'); scroll(600)+ expect(dock.dataset.hidden).toBe('true')+ input(doc, 'pointerup'); controls.dispose()+})+it('removes listeners, observers and pending timers on closing, deletion or switching notes', () => {+ const { list, dock, controls, scroll, hide } = setup()+ hide(); controls.dispose()+ expect(vi.getTimerCount()).toBe(0)+ for (const observer of Observer.all) expect(observer.disconnect).toHaveBeenCalledOnce()+ input(list, 'wheel', { deltaY: 200, deltaX: 0 }); scroll(300)+ expect(dock.dataset.hidden).toBeUndefined()+})++it('playback, focus and the end cancel an in-flight exit without waiting for it to hide', () => {+ const { dock, controls, scroll, wheel } = setup()+ wheel(); scroll(100); vi.advanceTimersByTime(60)+ controls.pin(true); expect(dock.dataset.hidden).toBe('false')+ vi.advanceTimersByTime(180); controls.pin(false)+ wheel(); scroll(200); vi.advanceTimersByTime(60)+ doc.activeElement = dock; dock.dispatchEvent(new Event('focusin'))+ expect(dock.dataset.hidden).toBe('false')+ vi.advanceTimersByTime(180); doc.activeElement = null+ wheel(); scroll(300); vi.advanceTimersByTime(60)+ scroll(1600); expect(dock.dataset.hidden).toBe('false')+ controls.dispose()+})