Skip to content

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.

Notes: the Summarizing button fits its label and reads as a live button

Eric Brownroutead5a038ea84
diff --git a/app/e2e/resumeRecording.spec.ts b/app/e2e/resumeRecording.spec.ts
index 660646f5..59673fc4 100644
--- a/app/e2e/resumeRecording.spec.ts
+++ b/app/e2e/resumeRecording.spec.ts
@@ -22,6 +22,8 @@ test('Stop summary preserves a saved rewrite and the header label stays still on
await page.evaluate(id => window.yogurt.notes.writeAgain(id), id)
const button = page.getByTestId('note-resume')
await expect(button).toHaveText('Summarizing…')
+ // the button eases to its label's width first; measure once the label's box has reached the words' own width
+ await expect.poll(() => button.locator('.swap-text').evaluate(el => Math.abs(el.getBoundingClientRect().width - el.firstElementChild!.getBoundingClientRect().width) < 0.5)).toBe(true)
const width = (await button.boundingBox())!.width
await button.hover()
await expect(button).toHaveAccessibleName('Stop summary')
diff --git a/app/src/renderer/src/components/Swap.tsx b/app/src/renderer/src/components/Swap.tsx
index eca63b3b..bdda2ccc 100644
--- a/app/src/renderer/src/components/Swap.tsx
+++ b/app/src/renderer/src/components/Swap.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, type ReactNode } from 'react'
+import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
/**
* Icons that change in place: every option shares one grid cell, so nothing around it moves, and only the current
@@ -11,9 +11,21 @@ export function Swap<K extends string>({ show, options, className }: { show: K;
</span>
}
-/** A label that changes in place: the new words soften in, and `widest` holds the width so the label never shifts. */
+/** `widest` reserves a fixed label width; without it, fit the current words and ease between widths. */
export function SwapText({ text, widest }: { text: string; widest?: string }) {
- const mounted = useRef(false)
+ const mounted = useRef(false), label = useRef<HTMLSpanElement>(null)
+ const [width, setWidth] = useState<number>()
useEffect(() => { mounted.current = true }, [])
- return <span className="swap-text" data-widest={widest}><span key={text} className={mounted.current ? 'swap-in' : undefined}>{text}</span></span>
+ useLayoutEffect(() => {
+ const el = label.current
+ if (widest != null || !el) return
+ const measure = () => setWidth(el.getBoundingClientRect().width)
+ measure()
+ const observer = new ResizeObserver(measure)
+ observer.observe(el)
+ return () => observer.disconnect()
+ }, [text, widest])
+ return <span className="swap-text" data-widest={widest} data-resize={widest == null || undefined} style={widest == null && width != null ? { width } : undefined}>
+ <span ref={label} key={text} className={mounted.current ? 'swap-in' : undefined}>{text}</span>
+ </span>
}
diff --git a/app/src/renderer/src/screens/Note.tsx b/app/src/renderer/src/screens/Note.tsx
index ed06eb1d..3db73ced 100644
--- a/app/src/renderer/src/screens/Note.tsx
+++ b/app/src/renderer/src/screens/Note.tsx
@@ -371,7 +371,7 @@ export function Note({ id, onTitleChange, at, folderSuggestion, onSource, onResu
{!finishing && (m.state === 'stopped' || m.state === 'done') && !m.stopSavePending && !trashed && <button data-testid="note-resume" disabled={starting} aria-busy={summarizing} data-processing={summarizing} onClick={() => { if (summarizing) void window.yogurt.notes.stop(id).catch(console.error); else void resumeRecording() }}
aria-label={summarizing ? t('Stop summary') : t('Resume recording')} className="note-record-action note-resume-action" title={summarizing ? t('Stop summary') : t('Resume recording in this note')}>
<Swap show={summarizing ? 'busy' : 'mic'} options={{ mic: <Mic size={14} />, busy: <span className="summary-stop-icon"><Loader size={14} /><span className="summary-stop-square" /></span> }} />
- <SwapText text={summarizing ? t('Summarizing…') : starting ? t('Preparing…') : t('Resume recording')} widest={t('Resume recording')} />
+ <SwapText text={summarizing ? t('Summarizing…') : starting ? t('Preparing…') : t('Resume recording')} />
</button>}
{m.state === 'prepared' && !trashed && <button data-testid="note-start" disabled={starting} onClick={() => { void startPrepared() }} className="note-record-action primary">
<Mic size={14} strokeWidth={1.75} aria-hidden="true" />{starting ? t('Starting…') : t('Start recording')}
diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.css
index 31cb2333..c4a36120 100644
--- a/app/src/renderer/src/styles.css
+++ b/app/src/renderer/src/styles.css
@@ -331,6 +331,10 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:v
.swap-text { display:inline-grid; }
.swap-text>*,.swap-text::after { grid-area:1/1; }
.swap-text[data-widest]::after { content:attr(data-widest);visibility:hidden;height:0;overflow:hidden; }
+.swap-text[data-resize] { display:inline-block;overflow:hidden;transition:width var(--dur-base) var(--ease-out); }
+.swap-text[data-resize]>span { display:block;width:max-content;white-space:nowrap; }
+.swap-text[data-resize] .swap-in { animation-name:motion-fade; }
+@media(prefers-reduced-motion:reduce) { .swap-text[data-resize] { transition:none; } }
.swap-in { animation:swap-in var(--dur-base) var(--ease-out) both; }
@keyframes swap-in { from { opacity:0;filter:blur(2px); } }
.follow-arrow { transition:transform var(--dur-base) var(--ease-soft); }
@@ -612,7 +616,6 @@ input::selection, textarea::selection, .note-prose ::selection { background: var
.chat-morph-surface { position:absolute;inset:-1px auto auto -1px;width:calc(100% + 2px);height:calc(100% + 2px);pointer-events:none;border:1px solid var(--line);border-radius:inherit;background:var(--float);box-shadow:0 16px 48px rgb(0 0 0 / .18),0 4px 12px rgb(0 0 0 / .08); }
.chat-panel-contents { position:relative;display:flex;flex-direction:column;flex:1;min-height:0;min-width:0; }
.chat-trigger[aria-expanded=true] { opacity:0; }
-.note-resume-action { min-width:160px; }
[data-icon] { flex:none; }
[data-icon=Loader] { animation:icon-spin 1s linear infinite; }
[data-icon] path { transform-box:fill-box;transform-origin:center; }
@@ -952,7 +955,7 @@ html:not(.widget) button:focus-visible, html:not(.widget) input:focus-visible {
.summary-stop-icon { display:inline-grid;place-items:center;width:14px;height:14px; }
.summary-stop-icon>* { grid-area:1/1;transition:opacity var(--dur-base) var(--ease-out); }
.summary-stop-square { width:10px;height:10px;border-radius:2px;background:currentColor;opacity:0; }
-.note-resume-action[data-processing=true] { color:var(--muted);cursor:pointer; }
+.note-resume-action[data-processing=true] { cursor:pointer; }
.note-resume-action[data-processing=true]:hover { background:var(--float); }
.note-resume-action:is(:hover,:focus-visible) .summary-stop-icon>svg { opacity:0; }
.note-resume-action:is(:hover,:focus-visible) .summary-stop-square { opacity:1; }
diff --git a/app/test/swapText.test.ts b/app/test/swapText.test.ts
new file mode 100644
index 00000000..3bbfe2fa
--- /dev/null
+++ b/app/test/swapText.test.ts
@@ -0,0 +1,39 @@
+import { afterEach, beforeEach, expect, it, vi } from 'vitest'
+import { useLayoutEffect, useRef, useState } from 'react'
+import { SwapText } from '../src/renderer/src/components/Swap'
+
+vi.mock('react', async original => ({ ...await original<typeof import('react')>(), useRef: vi.fn(), useState: vi.fn(), useEffect: vi.fn(), useLayoutEffect: vi.fn() }))
+const setWidth = vi.fn(), observe = vi.fn(), disconnect = vi.fn()
+let resized: () => void, measured = 90, width: number | undefined
+const label = { getBoundingClientRect: () => ({ width: measured }) }
+beforeEach(() => {
+ vi.clearAllMocks(); width = undefined; measured = 90
+ vi.mocked(useRef).mockImplementation(((value: unknown) => ({ current: value === null ? label : value })) as typeof useRef)
+ vi.mocked(useState).mockImplementation((() => [width, setWidth]) as typeof useState)
+ vi.stubGlobal('ResizeObserver', class { constructor(fn: () => void) { resized = fn } observe = observe; disconnect = disconnect })
+})
+afterEach(() => vi.unstubAllGlobals())
+
+it('measures the current words, follows font changes and disconnects when the label is replaced', () => {
+ const initial = SwapText({ text: 'Summarizing…' })
+ expect(initial.props['data-resize']).toBe(true)
+ expect(initial.props.style).toBeUndefined()
+ const cleanup = vi.mocked(useLayoutEffect).mock.calls.at(-1)![0]()
+ expect(observe).toHaveBeenCalledWith(label); expect(setWidth).toHaveBeenLastCalledWith(90)
+ measured = 126; resized(); expect(setWidth).toHaveBeenLastCalledWith(126)
+ width = 126
+ const next = SwapText({ text: 'Resume recording' })
+ expect(next.props.style).toEqual({ width: 126 })
+ expect(next.props.children.props.children).toBe('Resume recording')
+ expect(vi.mocked(useLayoutEffect).mock.calls.at(-1)![1]).toEqual(['Resume recording', undefined])
+ cleanup?.(); expect(disconnect).toHaveBeenCalledOnce()
+})
+
+it('keeps reserved-width labels unchanged and never observes them', () => {
+ width = 90
+ const tree = SwapText({ text: 'Copy', widest: 'Copied' })
+ expect(tree.props['data-widest']).toBe('Copied')
+ expect(tree.props['data-resize']).toBeUndefined(); expect(tree.props.style).toBeUndefined()
+ expect(vi.mocked(useLayoutEffect).mock.calls.at(-1)![0]()).toBeUndefined()
+ expect(observe).not.toHaveBeenCalled(); expect(setWidth).not.toHaveBeenCalled()
+})