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
the recorder pill grows into its live transcript on hover, as one window; warnings sit in a card with Open Settings
Eric Brownrout5076e6b4c01d
diff --git a/app/e2e/speakerColors.spec.ts b/app/e2e/speakerColors.spec.tsindex ae5978ae..1f2dae08 100644--- a/app/e2e/speakerColors.spec.ts+++ b/app/e2e/speakerColors.spec.ts@@ -33,9 +33,11 @@ for (const theme of ['light', 'dark'] as const) test(`speaker colours agree acrofor (let i = 0; i < names.length; i++) await expect(noteNames.filter({ hasText: names[i] }).last()).toHaveAttribute('data-color', String(i))await expect(noteNames.filter({ hasText: 'You' }).first()).not.toHaveAttribute('data-color')await page.getByTestId('transcript').evaluate(el => { el.scrollTop = el.scrollHeight })- await page.evaluate(() => window.yogurt.widget.preview(true))- await expect.poll(() => app.windows().some(p => p.url().includes('#widget-preview'))).toBe(true)- const preview = app.windows().find(p => p.url().includes('#widget-preview'))!+ await expect.poll(() => app.windows().some(p => p.url().includes('#widget'))).toBe(true)+ const preview = app.windows().find(p => p.url().includes('#widget'))!+ await preview.reload()+ await preview.getByTestId('widget').hover()+ await expect(preview.getByTestId('widget')).toHaveAttribute('data-open', 'true')await preview.emulateMedia({ colorScheme: theme, reducedMotion: 'reduce' })await expect(preview.getByTestId('widget-preview-loading')).toHaveCount(0)const previewNames = preview.locator('.widget-preview-speaker')@@ -48,6 +50,7 @@ for (const theme of ['light', 'dark'] as const) test(`speaker colours agree acroexpect(noteColour).toBe(theme === 'dark' ? 'rgb(185, 149, 255)' : 'rgb(116, 52, 202)')expect(previewColour).toBe('rgb(185, 149, 255)')await preview.reload()+ await preview.getByTestId('widget').hover()await expect(preview.locator('.widget-preview-speaker').filter({ hasText: names[0] })).toHaveAttribute('data-color', '0')// An earlier unidentified line gaining a name must not shift existing colours.insert.run(id, 'them', 90000, 91000, 'A late attribution.', 'Hal Moss')@@ -72,6 +75,7 @@ for (const theme of ['light', 'dark'] as const) test(`speaker colours agree acroawait page.reload()await page.getByTestId('note-transcript-toggle').click()await preview.reload()+ await preview.getByTestId('widget').hover()await expect(preview.getByText(exchange[0][1], { exact: true })).toBeVisible()for (const [surface, target, scroll, turn] of [['note', page, '[data-testid="transcript"]', '[data-testid="transcript-turn"]'],diff --git a/app/e2e/transcript.spec.ts b/app/e2e/transcript.spec.tsindex 547070ee..9f171e56 100644--- a/app/e2e/transcript.spec.ts+++ b/app/e2e/transcript.spec.ts@@ -153,8 +153,8 @@ test('transcription trouble shows in the widget in plain words', async () => {await page.getByRole('tab', { name: 'Transcript', exact: true }).click()await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', 'recording')await fake(app, 'warn', 'falling-behind')- // the recorder shows a warning sign; the words are on the card beside it- const w = await windowOf(app, '#widget-preview')+ // the recorder shows a warning sign; the words are inside the expanded recorder+ const w = await windowOf(app, '#widget')await expect(w.getByTestId('widget-note')).toHaveText('Yogurt is falling behind. Some lines may be missing.')await fake(app, 'warn', 'transcribe-failed')await expect(w.getByTestId('widget-note')).toHaveText("Some of this meeting couldn't be transcribed.")diff --git a/app/e2e/widget.spec.ts b/app/e2e/widget.spec.tsindex 316d9883..1c767839 100644--- a/app/e2e/widget.spec.ts+++ b/app/e2e/widget.spec.ts@@ -49,7 +49,7 @@ test('the widget is a compact horizontal recorder with one live wave and no exteconst s = await snap(app)expect(s.visible).toBe(true)const style = await w.getByTestId('widget').evaluate((el) => ({ shadow: getComputedStyle(el).boxShadow, width: el.getBoundingClientRect().width, height: el.getBoundingClientRect().height }))- // the pill hugs its content; the window fits the pill exactly+ // The snapshot keeps the resting pill bounds.expect(style.height).toBe(42)expect(style.width).toBeLessThan(127)expect(s.bounds).toMatchObject({ width: Math.ceil(style.width), height: 42 })@@ -66,18 +66,17 @@ test('the widget is a compact horizontal recorder with one live wave and no exte} finally { await app.close() }})-test('Finish closes both floating windows and prepares a completion notification', async () => {+test('Finish closes the floating recorder and prepares a completion notification', async () => {const { app, page } = await launch()try {const w = await record(app, page)await fake(app, 'warn', 'no-system-audio')- const preview = await windowOf(app, '#widget-preview')+ const preview = await windowOf(app, '#widget')await expect(preview.getByTestId('widget-note')).toBeVisible()const before = await fake<{ presented: number }>(app, 'main')await page.getByTestId('note-stop').click()expect((await fake<{ presented: number }>(app, 'main')).presented).toBe(before.presented)await expect.poll(() => w.isClosed()).toBe(true)- await expect.poll(() => preview.isClosed()).toBe(true)await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', /^(stopped|done)$/)expect((await snap(app)).visible).toBe(false)expect((await snap(app)).bounds).toBeNull()@@ -90,13 +89,15 @@ test('Pause hides the recorder and preview; Resume in the meeting restores its ptry {const w = await record(app, page)const bounds = (await snap(app)).bounds!- await w.mouse.move(50, 20)- const preview = await windowOf(app, '#widget-preview')+ const box = (await w.getByTestId('widget').boundingBox())!+ await w.mouse.move(box.x + 50, box.y + 20)+ const preview = await windowOf(app, '#widget')+ await expect(w.getByTestId('widget')).toHaveAttribute('data-open', 'true')await expect(preview.getByTestId('widget-preview')).toBeVisible()await page.getByTestId('note-pause').click()await expect(page.getByTestId('note-state')).toHaveAttribute('data-paused', 'true')await expect(w.getByTestId('widget')).toHaveCount(0)- await expect.poll(() => preview.isClosed()).toBe(true)+ await expect(preview.getByTestId('widget')).toHaveCount(0)expect((await snap(app)).visible).toBe(false)expect((await snap(app)).notice).toBeNull()await page.getByTestId('note-pause').click()@@ -216,7 +217,7 @@ test('a helper that dies once is restarted with a hiccup note; dying again stopstry {const w = await record(app, page)await fake(app, 'crashCapture')- const preview = await windowOf(app, '#widget-preview')+ const preview = await windowOf(app, '#widget')await expect(preview.getByTestId('widget-note')).toHaveText('Recording hiccup. Still going.')await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', 'recording')// The warning leaves after 4 s; the hidden conversation stays mounted for the next hover.@@ -238,18 +239,18 @@ test('hints retain both unavailable recording inputs', async () => {const w = await record(app, page)const before = (await snap(app)).bounds!await fake(app, 'warn', 'no-system-audio')- const preview = await windowOf(app, '#widget-preview')+ const preview = await windowOf(app, '#widget')await expect(preview.getByTestId('widget-note')).toHaveText("Yogurt can't hear the call audio. Allow it in System Settings.")await fake(app, 'warn', 'no-mic')await expect(preview.getByTestId('widget-note')).toContainText("Yogurt can't hear your microphone or the call.")- // Full warnings stay beside the fixed pill even without hover, and remain in the main note too.+ // Warnings expand the recorder without changing its saved pill bounds.expect((await snap(app)).bounds).toEqual(before)- await w.evaluate(() => window.yogurt.widget.preview(false))+ await w.mouse.move(0, 0)await w.waitForTimeout(220)await expect(preview.getByTestId('widget-note')).toBeVisible()await page.getByTestId('note-pause').click()await expect(w.getByTestId('widget')).toHaveCount(0)- await expect.poll(() => preview.isClosed()).toBe(true)+ await expect(preview.getByTestId('widget')).toHaveCount(0)expect((await snap(app)).visible).toBe(false)expect((await snap(app)).bounds).toEqual(before)await expect(page.getByTestId('rec-hint')).toContainText("Yogurt can't hear your microphone or the call.")@@ -307,22 +308,24 @@ test('hover stays stationary and pointer-down movement drags immediately withoutconst w = await record(app, page)const widget = w.getByTestId('widget')// the pill hugs its content: the same space at both ends- const ends = await widget.evaluate(el => { const r = el.getBoundingClientRect(), a = el.firstElementChild!.getBoundingClientRect(), z = el.lastElementChild!.getBoundingClientRect(); return [Math.round(a.left - r.left), Math.round(r.right - z.right)] })+ const ends = await widget.evaluate(el => { const r = el.getBoundingClientRect(), a = el.querySelector('.widget-details > :first-child')!.getBoundingClientRect(), z = el.querySelector('[data-testid=widget-time]')!.getBoundingClientRect(); return [Math.round(a.left - r.left), Math.round(r.right - z.right)] })expect(ends[0]).toBe(ends[1])const before = (await snap(app)).bounds!+ const box = (await w.getByTestId('widget').boundingBox())!const presented = (await fake<{ presented: number }>(app, 'main')).presented- await w.mouse.move(50, 20)- const preview = await windowOf(app, '#widget-preview')+ await w.mouse.move(box.x + 50, box.y + 20)+ const preview = await windowOf(app, '#widget')+ await expect(w.getByTestId('widget')).toHaveAttribute('data-open', 'true')await expect(preview.getByTestId('widget-preview')).toBeVisible()expect((await snap(app)).bounds).toEqual(before)await expect(preview.getByTestId('widget-preview-text')).not.toHaveText('Listening for speech…', { timeout: 30_000 })// Hover movement alone is never a drag.- await w.mouse.move(20, 35)+ await w.mouse.move(box.x + 20, box.y + 35)expect((await snap(app)).bounds).toEqual(before)expect((await fake<{ presented: number }>(app, 'main')).presented).toBe(presented)- await w.mouse.move(50, 20)+ await w.mouse.move(box.x + 50, box.y + 20)await w.mouse.down()- await w.mouse.move(20, 35)+ await w.mouse.move(box.x + 20, box.y + 35)await w.mouse.up()await expect.poll(async () => (await snap(app)).bounds!.x).toBe(before.x - 30)expect((await snap(app)).bounds!.y).toBe(before.y + 15)@@ -335,10 +338,11 @@ test('pointer movement below the drag threshold still opens the note without movtry {const w = await record(app, page)const before = (await snap(app)).bounds!+ const box = (await w.getByTestId('widget').boundingBox())!const presented = (await fake<{ presented: number }>(app, 'main')).presented- await w.mouse.move(50, 20)+ await w.mouse.move(box.x + 50, box.y + 20)await w.mouse.down()- await w.mouse.move(52, 22)+ await w.mouse.move(box.x + 52, box.y + 22)await w.mouse.up()expect((await snap(app)).bounds).toEqual(before)await expect.poll(async () => (await fake<{ presented: number }>(app, 'main')).presented).toBe(presented + 1)@@ -350,8 +354,9 @@ test('holding the pill does not open the note and a held press can still drag',try {const w = await record(app, page)const before = (await snap(app)).bounds!+ const box = (await w.getByTestId('widget').boundingBox())!const presented = (await fake<{ presented: number }>(app, 'main')).presented- await w.mouse.move(50, 20)+ await w.mouse.move(box.x + 50, box.y + 20)await w.mouse.down()await w.waitForTimeout(600)expect((await fake<{ presented: number }>(app, 'main')).presented).toBe(presented)@@ -360,7 +365,7 @@ test('holding the pill does not open the note and a held press can still drag',expect((await snap(app)).bounds).toEqual(before)await w.mouse.down()await w.waitForTimeout(600)- await w.mouse.move(20, 30)+ await w.mouse.move(box.x + 20, box.y + 30)await w.mouse.up()await expect.poll(async () => (await snap(app)).bounds!.x).toBe(before.x - 30)expect((await fake<{ presented: number }>(app, 'main')).presented).toBe(presented)@@ -371,13 +376,14 @@ test('hover transcript shows a readable conversation and keeps your place when nconst { app, page } = await launch()try {const w = await record(app, page)- await w.evaluate(() => window.yogurt.widget.preview(true))- const preview = await windowOf(app, '#widget-preview')- await expect(preview.getByTestId('widget-preview')).toHaveCSS('width', '340px')+ await w.getByTestId('widget').hover()+ await expect(w.getByTestId('widget')).toHaveAttribute('data-open', 'true')+ const preview = await windowOf(app, '#widget')+ await expect(w.getByTestId('widget')).toHaveCSS('width', '340px')await expect(preview.getByTestId('widget-preview-loading')).toHaveCount(0)const id = await page.getByTestId('note').getAttribute('data-meeting-id') || await page.evaluate(() => window.yogurt.widget.state().then(v => v!.meetingId))const send = async (start: number, count: number) => app.evaluate(({ BrowserWindow }, { id, start, count }) => {- const target = BrowserWindow.getAllWindows().find(w => w.webContents.getURL().includes('#widget-preview'))!+ const target = BrowserWindow.getAllWindows().find(w => w.webContents.getURL().includes('#widget'))!for (let i = start; i < start + count; i++) target.webContents.send('transcript:segment', {meetingId: id, track: i % 2 ? 'me' : 'them', startMs: 100000 + i * 3000, endMs: 102000 + i * 3000,speaker: i % 2 ? 'me' : 'Alex', text: `Conversation line ${i + 1}. We should keep the next step clear.`,@@ -386,7 +392,7 @@ test('hover transcript shows a readable conversation and keeps your place when nawait send(0, 24)const log = preview.getByTestId('widget-preview-text')await expect(preview.getByTestId('widget-preview-bubble')).toHaveCount(24)- await expect.poll(() => preview.evaluate(() => innerHeight)).toBe(520)+ await expect(w.getByTestId('widget')).toHaveCSS('height', '390px')if (process.env.YOGURT_UI_REVIEW !== 'before') {await expect(log).toHaveCSS('overflow-y', 'scroll')const scrollbar = () => log.evaluate(el => ({ width: getComputedStyle(el, '::-webkit-scrollbar').width, color: getComputedStyle(el, '::-webkit-scrollbar-thumb').backgroundColor, gutter: el.getBoundingClientRect().width - el.clientWidth }))@@ -402,7 +408,7 @@ test('hover transcript shows a readable conversation and keeps your place when noverflow: el.scrollWidth - el.clientWidth,}})- expect(spacing.edge).toBe(5) // 4px inset plus the border+ expect(spacing.edge).toBe(4) // the body has a 4px insetexpect(spacing.bubbleGap).toBeLessThanOrEqual(8) // 4px scrollbar and 4px breathing roomexpect(spacing.overflow).toBe(0)await log.hover()@@ -416,7 +422,7 @@ test('hover transcript shows a readable conversation and keeps your place when nawait expect(preview.getByTestId('widget-preview-latest')).toBeVisible()for (const colorScheme of ['light', 'dark'] as const) {await preview.emulateMedia({ colorScheme, reducedMotion: 'reduce' })- await preview.mouse.move(0, 0)+ await preview.getByTestId('widget-time').hover()await preview.screenshot({ path: testInfo.outputPath(`preview-${colorScheme}-before-latest.png`) })}const mainState = () => app.evaluate(({ BrowserWindow }) => {@@ -448,13 +454,14 @@ test('hover groups speaker runs and keeps live words stable through updates andconst { app, page } = await launch()try {const w = await record(app, page)- await w.evaluate(() => window.yogurt.widget.preview(true))- const preview = await windowOf(app, '#widget-preview')+ await w.getByTestId('widget').hover()+ await expect(w.getByTestId('widget')).toHaveAttribute('data-open', 'true')+ const preview = await windowOf(app, '#widget')await expect(preview.getByTestId('widget-preview')).toBeVisible()await expect(preview.getByTestId('widget-preview-loading')).toHaveCount(0)const id = await page.evaluate(() => window.yogurt.widget.state().then(v => v!.meetingId))const send = (channel: string, value: object) => app.evaluate(({ BrowserWindow }, { channel, value, id }) => {- BrowserWindow.getAllWindows().find(w => w.webContents.getURL().includes('#widget-preview'))!.webContents.send(channel, { meetingId: id, ...value })+ BrowserWindow.getAllWindows().find(w => w.webContents.getURL().includes('#widget'))!.webContents.send(channel, { meetingId: id, ...value })}, { channel, value, id })await send('transcript:segment', { track: 'them', speaker: 'Alex', startMs: 100000, endMs: 102000, text: 'The launch checklist is ready.' })await send('transcript:segment', { track: 'them', speaker: 'Alex', startMs: 102200, endMs: 104000, text: 'We can share it after this call.' })@@ -482,14 +489,14 @@ test('hover groups speaker runs and keeps live words stable through updates andtrack: i % 2 ? 'me' : 'them', speaker: i % 2 ? 'me' : 'Jamie', startMs: 120000 + i * 4000, endMs: 123000 + i * 4000,text: i % 2 ? 'I can send the draft this afternoon, then we can review it together.' : 'That works. Let us keep the scope clear and check in tomorrow.',})- await expect(preview.getByTestId('widget-preview')).toHaveCSS('height', '520px')+ await expect(w.getByTestId('widget')).toHaveCSS('height', '390px')const log = preview.getByTestId('widget-preview-text')await expect.poll(() => log.evaluate(el => el.scrollHeight - el.scrollTop - el.clientHeight)).toBeLessThan(2)await preview.screenshot({ path: testInfo.outputPath('conversation-tall.png') })await log.evaluate(el => { el.scrollTop = 0; el.dispatchEvent(new Event('scroll')) })- await w.evaluate(() => window.yogurt.widget.preview(false))+ await w.mouse.move(0, 0)await preview.waitForTimeout(220)- await w.evaluate(() => window.yogurt.widget.preview(true))+ await w.getByTestId('widget-time').hover()expect(preview.isClosed()).toBe(false)expect(await log.evaluate(el => el.scrollTop)).toBe(0)await preview.getByTestId('widget-preview-latest').click()diff --git a/app/src/main/widget.ts b/app/src/main/widget.tsindex 95dde3f0..539e393f 100644--- a/app/src/main/widget.ts+++ b/app/src/main/widget.ts@@ -8,12 +8,13 @@ import type { WidgetView } from '../shared/types'import { floatingType, floatOverFullScreen } from './float'import { isFake } from './paths'import { t, onLanguage } from '../shared/i18n'+import { widgetLayout, widgetContains, type WidgetSurface, type WidgetLayout } from '../shared/widgetMorph'const BACKGROUND = process.env.YOGURT_BACKGROUND === '1'const FIRST_W = 127, FIRST_H = 42-const PREVIEW_W = 340, PREVIEW_H = 220, PREVIEW_MAX_H = 520, PREVIEW_GAP = 8/** Remembered while Yogurt runs, including the next meeting and temporary warning cards. */+let lastWidth = FIRST_Wlet lastPosition: { x: number; y: number } | null = nullfunction fit(bounds: Electron.Rectangle): Electron.Rectangle {@@ -25,23 +26,23 @@ function fit(bounds: Electron.Rectangle): Electron.Rectangle {}}-function createWindow(preview = false, os = 'darwin'): BrowserWindow {+function createWindow(os = 'darwin'): BrowserWindow {// the display the person is working on (the mouse is there), not always the main oneconst { workArea } = screen.getDisplayNearestPoint(screen.getCursorScreenPoint())- const bounds = fit({ width: FIRST_W, height: FIRST_H, ...(lastPosition ?? { x: workArea.x + workArea.width - FIRST_W - 12, y: Math.round(workArea.y + workArea.height * 0.38) }) })- if (!preview) lastPosition = { x: bounds.x, y: bounds.y }+ const bounds = fit({ width: lastWidth, height: FIRST_H, ...(lastPosition ?? { x: workArea.x + workArea.width - FIRST_W - 12, y: Math.round(workArea.y + workArea.height * 0.38) }) })+ lastPosition = { x: bounds.x, y: bounds.y }const w = new BrowserWindow({- ...bounds,- // Neither surface may activate Yogurt on mouse-down; only an explicit pill click opens the note.+ ...widgetLayout(bounds, screen.getDisplayMatching(bounds).workArea).bounds,+ // One open-sized window avoids native resizing during the morph; transparent space passes clicks through.type: floatingType(os, 'panel'),- ...(preview ? { width: PREVIEW_W, height: PREVIEW_H } : {}),// CSS owns the outline; macOS corner clipping cuts through its border.frame: false, transparent: true, roundedCorners: false, hasShadow: false, resizable: false, movable: false, minimizable: false, maximizable: false, fullscreenable: false,skipTaskbar: true, focusable: false, acceptFirstMouse: true, show: false,webPreferences: { preload: join(__dirname, '../preload/index.cjs'), sandbox: false, backgroundThrottling: false },})floatOverFullScreen(w)- const hash = preview ? 'widget-preview' : 'widget'+ w.setIgnoreMouseEvents(true, { forward: true })+ const hash = 'widget'if (process.env.ELECTRON_RENDERER_URL) void w.loadURL(`${process.env.ELECTRON_RENDERER_URL}#${hash}`)else void w.loadFile(join(__dirname, '../renderer/index.html'), { hash })return w@@ -51,7 +52,7 @@ function createWindow(preview = false, os = 'darwin'): BrowserWindow {const broadcast = (channel: string, v: unknown) => { for (const w of BrowserWindow.getAllWindows()) if (!w.isDestroyed()) w.webContents.send(channel, v) }/**- * The recording-only pill and its separate hovered transcript/warning. Finished+ * The recording-only pill grows into its transcript and warning. Finished* meetings use a native notification; paused meetings keep no floating surface.*/export function createWidget(d: { open(meetingId: string): void; stop(meetingId: string): void; foreground(): boolean; os?: string@@ -59,9 +60,12 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:windowOs?: string }) {const model = new WidgetModel(d.os)let win: BrowserWindow | undefined- let preview: BrowserWindow | undefined- let previewSized = false, hovered = false- let previewTimer: NodeJS.Timeout | undefined+ let pill = { x: 0, y: 0, width: FIRST_W, height: FIRST_H }+ let layout: WidgetLayout | null = null+ let dragFrame: { layout: WidgetLayout; pill: typeof pill } | null = null+ let surface: WidgetSurface | null = null+ let pressed = false, ignoring = true, sentPointer: string | null = null+ let pointerTimer: NodeJS.Timeout | undefinedlet sized = falselet dragPosition: { x: number; y: number } | null = nulllet noteTimer: NodeJS.Timeout | undefined@@ -73,44 +77,31 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:/** what a test can see: the window itself is hidden in tests */let shown = false- const closePreview = () => {- clearTimeout(previewTimer)- if (preview && !preview.isDestroyed()) preview.destroy()- preview = undefined; previewSized = false- }- const positionPreview = (width = PREVIEW_W, height = PREVIEW_H) => {- if (!win || win.isDestroyed() || !preview || preview.isDestroyed()) return- const pill = win.getBounds()- const { workArea } = screen.getDisplayMatching(pill)- width = Math.min(width, workArea.width); height = Math.min(height, workArea.height)- const below = pill.y + pill.height + PREVIEW_GAP- const above = pill.y - height - PREVIEW_GAP- const left = pill.x - width - PREVIEW_GAP- const right = pill.x + pill.width + PREVIEW_GAP- const beside = left >= workArea.x ? left : right + width <= workArea.x + workArea.width ? right : null- // Reserve room for speech to grow without moving the reading edge of a side-by-side preview.- const besideY = Math.min(workArea.y + workArea.height - Math.min(PREVIEW_MAX_H, workArea.height), Math.round(pill.y + pill.height / 2 - PREVIEW_H * .65))- const y = beside === null ? (above >= workArea.y ? above : below) : besideY- preview.setBounds({ width, height,- x: Math.max(workArea.x, Math.min(workArea.x + workArea.width - width, beside ?? Math.round(pill.x + (pill.width - width) / 2))),- y: Math.max(workArea.y, Math.min(workArea.y + workArea.height - height, y)),- })+ const hitTest = () => {+ if (!win || win.isDestroyed()) return+ const cursor = screen.getCursorScreenPoint(), bounds = win.getBounds()+ const x = cursor.x - bounds.x, y = cursor.y - bounds.y+ const ignore = !shown || (!pressed && (!surface || !widgetContains(surface, x, y)))+ if (ignore !== ignoring) { ignoring = ignore; win.setIgnoreMouseEvents(ignore, { forward: true }) }+ // 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 }) }}- const syncPreview = () => {- const v = model.view(Date.now())- // A recording warning stays visible even when nobody hovers over the recorder.- if (!shown || v?.kind !== 'recording' || dragPosition) { closePreview(); return }- // Keep the reading position and settled text when the pointer briefly leaves the conversation.- if (!hovered && !v.note) { if (preview && !preview.isDestroyed()) preview.hide(); return }- if (!preview || preview.isDestroyed()) { preview = createWindow(true, d.windowOs); previewSized = false; positionPreview() }- if (previewSized && !BACKGROUND && !preview.isVisible()) preview.showInactive()+ const place = () => {+ if (!win || win.isDestroyed()) return+ layout = widgetLayout(pill, screen.getDisplayMatching(pill).workArea)+ win.setBounds(layout.bounds)+ win.webContents.send('widget:layout', layout)+ hitTest()}const visibilityChanged = () => {const view = model.view(Date.now())shown = view?.kind === 'recording' && !view.paused && !d.foreground()- if (!shown) hovered = false- syncPreview()+ clearInterval(pointerTimer)+ if (shown && !BACKGROUND) pointerTimer = setInterval(hitTest, 16)+ if (!shown) { pressed = false; win?.webContents.send('widget:reset') }+ hitTest()if (!win || win.isDestroyed() || BACKGROUND) returnif (!shown) win.hide()else if (sized && !win.isVisible()) win.showInactive()@@ -121,15 +112,23 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:onLanguage(() => { if (win && !win.isDestroyed()) push() })const close = () => {clearTimeout(noteTimer)- shown = false; sized = false; dragPosition = null- hovered = false; closePreview()+ shown = false; sized = false; dragPosition = null; dragFrame = null+ clearInterval(pointerTimer); surface = null; pressed = false+ screen.removeListener('display-added', displayChanged)+ screen.removeListener('display-removed', displayChanged)+ screen.removeListener('display-metrics-changed', displayChanged)if (win && !win.isDestroyed()) win.destroy()win = undefined}const open = () => {if (win && !win.isDestroyed()) return- win = createWindow(false, d.windowOs); sized = false- win.on('closed', () => { win = undefined })+ screen.on('display-added', displayChanged)+ screen.on('display-removed', displayChanged)+ screen.on('display-metrics-changed', displayChanged)+ win = createWindow(d.windowOs); sized = false; ignoring = true; sentPointer = null+ pill = { ...lastPosition!, width: lastWidth, height: FIRST_H }+ layout = widgetLayout(pill, screen.getDisplayMatching(pill).workArea)+ win.on('closed', () => { clearInterval(pointerTimer); win = undefined })}onMeetingStart((m) => {@@ -187,63 +186,79 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:const id = model.meetingIdif (!id) returnshown = false- hovered = false; closePreview()- if (win && !win.isDestroyed()) win.hide()+ clearInterval(pointerTimer); pressed = false+ if (win && !win.isDestroyed()) { win.webContents.send('widget:reset'); hitTest(); win.hide() }d.open(id)})ipcMain.on('widget:stop', () => { const id = model.meetingId; if (id && model.view(Date.now())?.kind === 'recording') { stopPressed = true; d.stop(id) } })- ipcMain.on('widget:preview', (_e, on: unknown) => {- if (typeof on !== 'boolean') return- clearTimeout(previewTimer)- if (on) { hovered = true; syncPreview() }- // The small gap between windows must not close the preview while the pointer crosses it.- else previewTimer = setTimeout(() => { hovered = false; syncPreview() }, 180)+ ipcMain.handle('widget:layout', () => win && !win.isDestroyed() ? layout : null)+ ipcMain.on('widget:surface', (e, value: unknown) => {+ if (!win || win.isDestroyed() || e.sender !== win.webContents || !value || typeof value !== 'object') return+ const r = value as WidgetSurface+ if (![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()+ // The renderer has painted its first surface before the native window appears.+ if (!sized) { sized = true; visibilityChanged() }})- ipcMain.on('widget:drag', (_e, dx: unknown, dy: unknown) => {- if (!win || win.isDestroyed() || typeof dx !== 'number' || typeof dy !== 'number' || !Number.isFinite(dx) || !Number.isFinite(dy)) return- const b = win.getBounds(), from = dragPosition ?? b+ ipcMain.on('widget:pressed', (e, value: unknown) => {+ if (!win || win.isDestroyed() || e.sender !== win.webContents || typeof value !== 'boolean') return+ pressed = value; hitTest()+ })+ 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)) return+ const from = dragPosition ?? pillconst x = from.x + dx, y = from.y + dyif (!Number.isFinite(x) || !Number.isFinite(y)) return// Keep the unclamped gesture position so small deltas can cross a display boundary.dragPosition = { x, y }- closePreview()- win.setBounds(fit({ ...b, x, y }))- })- ipcMain.on('widget:drag-end', () => {- if (dragPosition && win && !win.isDestroyed()) {- const { x, y } = win.getBounds()- lastPosition = { x, y }+ if (!layout) return+ dragFrame ??= { layout, pill: { ...pill } }+ pill = fit({ ...pill, x, y })+ const frame = dragFrame.layout+ if (surface && surface.height > FIRST_H + 1) {+ const area = screen.getDisplayMatching(pill).workArea+ if (frame.open.width > area.width || frame.open.height > area.height) {+ place(); dragFrame = null; return+ }+ // Keep the frozen surface and its remaining travel on the destination display.+ const left = Math.min(surface.x, frame.open.x) - frame.pill.x+ const top = Math.min(surface.y, frame.open.y) - frame.pill.y+ const right = Math.max(surface.x + surface.width, frame.open.x + frame.open.width) - frame.pill.x+ const bottom = Math.max(surface.y + surface.height, frame.open.y + frame.open.height) - frame.pill.y+ pill.x = Math.max(area.x - left, Math.min(area.x + area.width - right, pill.x))+ pill.y = Math.max(area.y - top, Math.min(area.y + area.height - bottom, pill.y))}- dragPosition = null; hovered = false- syncPreview()+ layout = { ...frame, bounds: { ...frame.bounds, x: frame.bounds.x + pill.x - dragFrame.pill.x, y: frame.bounds.y + pill.y - dragFrame.pill.y } }+ win.setBounds(layout.bounds); hitTest()})- ipcMain.on('widget:size', (_e, w: unknown, h: unknown) => {- if (!win || win.isDestroyed() || typeof w !== 'number' || typeof h !== 'number' || !Number.isFinite(w) || !Number.isFinite(h) || w < 0 || h < 0 || w > 600 || h > PREVIEW_MAX_H) return- if (preview && !preview.isDestroyed() && _e.sender === preview.webContents) {- // A paused meeting with no words or warning needs no empty hover window.- if (w === 0 && h === 0) { previewSized = false; preview.hide(); return }- if (!w || !h) return- positionPreview(Math.ceil(w), Math.ceil(h)); previewSized = true; syncPreview(); return- }- // A final ResizeObserver message from a closed preview must never resize the recorder.- if (_e.sender !== win.webContents || h > 400) return- if (w === 0 && h === 0) { sized = false; win.hide(); return }- if (!w || !h) return- const b = win.getBounds()- win.setBounds(fit({ ...(dragPosition ?? lastPosition ?? b), width: Math.ceil(w), height: Math.ceil(h) }))- // Show after the first fit so the recorder never flashes at the wrong size.- if (!sized) { sized = true; visibilityChanged() }+ ipcMain.on('widget:drag-end', (e) => {+ if (!win || win.isDestroyed() || e.sender !== win.webContents) return+ if (dragPosition) lastPosition = { x: pill.x, y: pill.y }+ dragPosition = null; dragFrame = null+ if (!surface || surface.height <= FIRST_H + 1) 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+ const width = Math.ceil(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()+ })+ const displayChanged = () => {+ if (!win || win.isDestroyed()) return+ pill = fit(pill); lastPosition = { x: pill.x, y: pill.y }; place()+ }return {visibilityChanged,elapsed: () => model.view(Date.now())?.elapsedMs ?? 0,/** the recording is about to stop because its call ended: the finished card says so */callEnded: (meetingId: string) => { if (model.meetingId === meetingId) model.callEnded() },- /** The same actual transcript events used by the main note, delivered only to the small preview. */- transcript: (channel: string, value: unknown) => { if (preview && !preview.isDestroyed()) preview.webContents.send(channel, value) },+ /** The same actual transcript events used by the main note, delivered to the recorder. */+ transcript: (channel: string, value: unknown) => { if (win && !win.isDestroyed()) win.webContents.send(channel, value) },/** for tests: what the widget would show, and where it sits */snapshot: (): { visible: boolean; view: WidgetView | null; notice: typeof notice; bounds: Electron.Rectangle | null; workArea: Electron.Rectangle } =>- ({ visible: shown, view: model.view(Date.now()), notice, bounds: win && !win.isDestroyed() ? win.getBounds() : null, workArea: (win && !win.isDestroyed() ? screen.getDisplayMatching(win.getBounds()) : screen.getDisplayNearestPoint(screen.getCursorScreenPoint())).workArea }),+ ({ visible: shown, view: model.view(Date.now()), notice, bounds: win && !win.isDestroyed() ? { ...pill } : null, workArea: (win && !win.isDestroyed() ? screen.getDisplayMatching(pill) : screen.getDisplayNearestPoint(screen.getCursorScreenPoint())).workArea }),}}diff --git a/app/src/preload/index.ts b/app/src/preload/index.tsindex 88756459..4a13207f 100644--- a/app/src/preload/index.ts+++ b/app/src/preload/index.ts@@ -1,3 +1,4 @@+import type { WidgetLayout } from '../shared/widgetMorph'import { contextBridge, ipcRenderer } from 'electron'import { capabilities, platformOf } from '../shared/platform'import type { ChatView, ConversationSummary, ConversationView, NoteView, PromptAction, SetupState, WidgetView, YogurtApi } from '../shared/types'@@ -34,7 +35,23 @@ const api: YogurtApi = {},open: () => { ipcRenderer.send('widget:open') },stop: () => { ipcRenderer.send('widget:stop') },- preview: (on) => { ipcRenderer.send('widget:preview', on) },+ layout: () => ipcRenderer.invoke('widget:layout'),+ onLayout: (cb) => {+ const on = (_e: unknown, layout: WidgetLayout) => cb(layout)+ ipcRenderer.on('widget:layout', on)+ return () => { ipcRenderer.removeListener('widget:layout', on) }+ },+ onPointer: (cb) => {+ const on = (_e: unknown, point: { x: number; y: number }) => cb(point)+ ipcRenderer.on('widget:pointer', on)+ return () => { ipcRenderer.removeListener('widget:pointer', on) }+ },+ onReset: (cb) => {+ ipcRenderer.on('widget:reset', cb)+ return () => { ipcRenderer.removeListener('widget:reset', cb) }+ },+ surface: (rect) => { ipcRenderer.send('widget:surface', rect) },+ pressed: (value) => { ipcRenderer.send('widget:pressed', value) },drag: (dx, dy) => { ipcRenderer.send('widget:drag', dx, dy) },endDrag: () => { ipcRenderer.send('widget:drag-end') },size: (w, h) => { ipcRenderer.send('widget:size', w, h) },diff --git a/app/src/renderer/src/main.tsx b/app/src/renderer/src/main.tsxindex 5696799e..1e560994 100644--- a/app/src/renderer/src/main.tsx+++ b/app/src/renderer/src/main.tsx@@ -6,11 +6,11 @@ import './workspace.css'import './setup.css'import { App } from './App'import { Prompt } from './windows/Prompt'-import { Widget, WidgetPreview } from './windows/Widget'+import { Widget } from './windows/Widget'import { applyLanguage, useLanguage } from './i18n'// The small prompt card and the recording widget are the same page with #prompt and #widget-const Which = location.hash === '#prompt' ? Prompt : location.hash === '#widget' ? Widget : location.hash === '#widget-preview' ? WidgetPreview : App+const Which = location.hash === '#prompt' ? Prompt : location.hash === '#widget' ? Widget : Appdocument.documentElement.classList.toggle('main-window', Which === App)// Windows and Linux: the system's window buttons over the top right, no traffic lights (workspace.css)if (window.yogurt.platform !== 'darwin') document.documentElement.dataset.chrome = 'overlay'diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.cssindex 792473e6..7e54c1d1 100644--- a/app/src/renderer/src/styles.css+++ b/app/src/renderer/src/styles.css@@ -165,7 +165,7 @@ body {.drag { -webkit-app-region: drag; }.no-drag { -webkit-app-region: no-drag; }-/* The recorder fills its transparent native window; no outside shadow or halo. */+/* The recorder floats inside a transparent native window. */html.widget, html.widget body, html.widget #root { background: transparent; }html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:var(--accent);--widget-line:#48484D; }.widget-pill {@@ -174,8 +174,6 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:vbox-shadow:none;touch-action: none;}-/* the pill hugs its content: 12px at each end and between items; tabular figures keep it still as seconds tick, and it grows only when the timer gains a digit */-.widget-strip { grid-template-columns:18px 27px max-content; }.widget-pill:focus-visible { outline: 2px solid var(--pill-accent); outline-offset: -3px; }.widget-btn { color:#fff;background:#6F00FF;transition: transform 120ms ease, background-color 120ms ease; }.widget-btn-secondary { color:var(--pill-ink);background:#39393E; }@@ -187,8 +185,14 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:v.widget-btn:not(:disabled):hover { background:#8120FF; }.widget-btn-secondary:not(:disabled):hover { background:#48484F; }}-.widget-preview { position:relative;display:flex;flex-direction:column;width:340px;min-height:min(220px,var(--preview-max-height,520px));max-height:var(--preview-max-height,520px);padding:12px 4px 12px 12px;border:1px solid var(--widget-line);border-radius:16px;background:rgb(35 35 38 / .96);color:var(--pill-ink);font-size:14px;line-height:21px; }-.widget-preview-conversation { flex:1 1 auto;min-height:0;overflow-x:hidden;overflow-y:scroll;overscroll-behavior:contain;padding:8px 4px 4px 0;scrollbar-gutter:stable;scrollbar-width:auto;scrollbar-color:auto;mask-image:linear-gradient(to bottom,transparent,#000 8px,#000); }+.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-details>* { position:absolute;left:0;top:0;margin:0; }+.widget-time { white-space:nowrap;font-size:10px;font-weight:500;font-variant-numeric:tabular-nums;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; }+.widget-preview[aria-hidden=true] { pointer-events:none; }+.widget-preview-conversation { flex:1 1 auto;min-height:0;overflow-x:hidden;overflow-y:scroll;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. */.widget-preview-conversation::-webkit-scrollbar { width:4px; }.widget-preview-conversation::-webkit-scrollbar-thumb { border-radius:3px;background:#FFFFFF50; }@@ -202,8 +206,9 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:v.widget-preview-empty { padding:12px 6px;color:#B8B8C0;font-size:13px; }.widget-preview-latest { position:absolute;bottom:12px;inset-inline-start:50%;translate:-50% 0;display:flex;align-items:center;gap:4px;padding:4px 9px;border:1px solid var(--widget-line);border-radius:8px;background:var(--pill);font-size:11px;box-shadow:0 3px 10px #0003; }[dir=rtl] .widget-preview-latest { translate:50% 0; }-.widget-preview-warning { flex:none;display:flex;align-items:flex-start;gap:7px;padding:4px 4px 10px;margin-bottom:4px;border-bottom:1px solid var(--widget-line);font-size:12px;line-height:18px; }-.widget-preview-warning>svg { flex:none;margin-top:2px;color:var(--pill-accent); }+.widget-preview-warning { flex:none;margin:0 8px 12px 0;padding:10px 12px;border-radius:10px;background:#FFFFFF06;font-size:12px;line-height:18px; }+.widget-settings { display:block;margin-top:10px;padding:4px 9px;min-height:28px;border:1px solid #FFFFFF20;border-radius:6px;background:#FFFFFF08;font-size:11px;font-weight:500;cursor:pointer; }+.widget-settings:hover { background:#FFFFFF14; }.widget-preview button:focus-visible { outline:2px solid var(--pill-accent);outline-offset:1px; }.widget-preview .page-loading { --control:#FFFFFF14; }@media (prefers-reduced-motion: reduce) { .widget-btn { transition: none; } }diff --git a/app/src/renderer/src/windows/Widget.tsx b/app/src/renderer/src/windows/Widget.tsxindex fd592de9..9f740d4f 100644--- a/app/src/renderer/src/windows/Widget.tsx+++ b/app/src/renderer/src/windows/Widget.tsx@@ -3,7 +3,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, RotateCw, TriangleAlert } from 'lucide-react'+import { ArrowDown, TriangleAlert } from 'lucide-react'import type { Segment, TranscriptPartial, WidgetView } from '../../../shared/types'import { formatElapsed } from '../../../shared/wave'import { t } from '../../../shared/i18n'@@ -12,7 +12,9 @@ import { LevelBars } from '../components/LevelBars'import { LiveWords } from '../components/Transcript'import { glide } from '../motion'import { afterFinal, joinWords } from '../../../shared/liveWords'-import { Swap } from '../components/Swap'+import { ScrollFade } from '../components/ScrollFade'+import { useWidgetMorph } from './widgetMorph'+import { widgetSettings } from '../../../shared/widgetMorph'function useElapsed(v: WidgetView | null): string {const [text, setText] = useState('0:00')@@ -27,45 +29,35 @@ function useElapsed(v: WidgetView | null): string {return text}-/** The live transcript opens once the pointer settles on the recorder, never on the way to grabbing it, and not- * straight after a drag: it waits for the pointer to rest there a moment longer. */-const SETTLE_MS = 220, AFTER_DRAG_MS = 650-function useHoverPreview() {- const over = useRef(false), timer = useRef<ReturnType<typeof setTimeout>>(undefined), quietUntil = useRef(0)- const wait = () => {- clearTimeout(timer.current)- timer.current = setTimeout(() => { if (over.current) window.yogurt.widget.preview(true) }, Math.max(SETTLE_MS, quietUntil.current - performance.now()))- }- useEffect(() => () => clearTimeout(timer.current), [])- return {- enter: () => { over.current = true; wait() },- // still moving across it, or about to press: keep waiting- move: (pressed: boolean) => { if (over.current && !pressed) wait() },- press: () => clearTimeout(timer.current),- leave: () => { over.current = false; clearTimeout(timer.current); window.yogurt.widget.preview(false) },- dropped: () => { quietUntil.current = performance.now() + AFTER_DRAG_MS; wait() },- }-}-/** A click opens the note; a drag moves the recorder without opening it on release. */-function useDragOrClick(onClick: () => void, hover: ReturnType<typeof useHoverPreview>) {+function useDragOrClick(onClick: () => void, hover: ReturnType<typeof useWidgetMorph>) {const s = useRef<WidgetPress | null>(null)const cancel = () => {- if (s.current?.moved) window.yogurt.widget.endDrag()+ if (!s.current) return+ window.yogurt.widget.endDrag()+ hover.release(s.current.moved)s.current = null}- useEffect(() => () => { if (s.current?.moved) window.yogurt.widget.endDrag() }, [])+ useEffect(() => {+ const release = () => hover.release(false)+ window.addEventListener('pointerup', release)+ window.addEventListener('pointercancel', release)+ return () => { window.removeEventListener('pointerup', release); window.removeEventListener('pointercancel', release); window.yogurt.widget.endDrag(); window.yogurt.widget.pressed(false) }+ }, [])return {onPointerDown: (e: React.PointerEvent) => {- if (e.button !== 0 || s.current || (e.target as HTMLElement).closest('button')) return- e.preventDefault()+ if (e.button !== 0 || s.current) returnhover.press()+ if ((e.target as HTMLElement).closest('button')) return+ const scroll = (e.target as HTMLElement).closest<HTMLElement>('.widget-preview-conversation')+ if (scroll && e.clientX >= scroll.getBoundingClientRect().left + scroll.clientWidth) return+ e.preventDefault()e.currentTarget.setPointerCapture(e.pointerId)s.current = { x: e.screenX, y: e.screenY, pointerId: e.pointerId, at: e.timeStamp, moved: false }},onPointerMove: (e: React.PointerEvent) => {const d = s.current- hover.move(!!d)+ hover.pointer(e.clientX, e.clientY)if (!d || e.pointerId !== d.pointerId) returnconst delta = widgetDragDelta(d, e.screenX, e.screenY)if (delta) window.yogurt.widget.drag(delta.dx, delta.dy)@@ -77,7 +69,6 @@ function useDragOrClick(onClick: () => void, hover: ReturnType<typeof useHoverPrcancel()e.currentTarget.releasePointerCapture(e.pointerId)if (click) onClick()- else if (d.moved) hover.dropped()},onPointerCancel: cancel,onLostPointerCapture: cancel,@@ -99,64 +90,34 @@ function useWidgetView() {return view}-function useSize(card: React.RefObject<HTMLDivElement | null>, shape: string) {- useEffect(() => {- const el = card.current- if (!el) return- const ro = new ResizeObserver(() => { const r = el.getBoundingClientRect(); window.yogurt.widget.size(Math.ceil(r.width), Math.ceil(r.height)) })- ro.observe(el)- return () => ro.disconnect()- }, [shape])-}--/**- * The recording-only strip: mark, one wave and time. A click opens the note's controls.- * A separate card shows warnings and hovered live words without moving the recorder.- */+/** One recording surface, with the transcript kept mounted between hovers. */export function Widget() {const view = useWidgetView()- const card = useRef<HTMLDivElement>(null)- const recording = view?.kind === 'recording' && !view.paused- useSize(card, recording ? 'recording' : 'none')-- if (!recording) return null- return (- <div className="flex h-full items-start">- <Recording view={view} cardRef={card} />- </div>- )+ return view?.kind === 'recording' && !view.paused ? <Recording key={view.meetingId} view={view} /> : null}-function Recording({ view, cardRef }: { view: WidgetView; cardRef: React.RefObject<HTMLDivElement | null> }) {+function Recording({ view }: { view: WidgetView }) {const time = useElapsed(view)- const hover = useHoverPreview()- const press = useDragOrClick(() => window.yogurt.widget.open(), hover)- const note = view.note- return (- <div ref={cardRef} data-testid="widget" data-kind="recording" role="button" tabIndex={0} className="widget-pill widget-strip grid h-[42px] w-max shrink-0 cursor-pointer select-none items-center gap-3 rounded-[10px] px-3 text-[var(--pill-ink)]"- {...press} onPointerEnter={hover.enter} onPointerLeave={hover.leave}- aria-label={t('Open {title}', { title: view.title })} title={note?.text ?? t('Recording {title}', { title: view.title })}>- <Swap show={note ? 'warning' : 'logo'} className="text-[var(--pill-accent)]" options={{ logo: <Logo size={18} />, warning: <TriangleAlert data-testid="widget-warning" size={18} /> }} />- <LevelBars testId="widget-wave" height={16} className="justify-self-center text-[var(--pill-accent)]" />- <span data-testid="widget-time" className="shrink-0 whitespace-nowrap text-[10px] font-medium tabular-nums opacity-80">- {time}- </span>- </div>- )-}--/** Separate, tightly fitted native window: showing words never moves the recorder itself. */-export function WidgetPreview() {- const view = useWidgetView()const card = useRef<HTMLDivElement>(null)- const recording = view?.kind === 'recording' && !view.paused- useSize(card, recording ? 'recording' : 'none')- return recording ? <Preview key={view.meetingId} view={view} cardRef={card} /> : null+ const hover = useWidgetMorph(card, !!view.note, time)+ const press = useDragOrClick(() => window.yogurt.widget.open(), hover)+ return <div ref={card} data-testid="widget" data-kind="recording" data-open={hover.open} role="group" tabIndex={0}+ className="widget-pill widget-morph" {...press}+ onMouseMove={e => hover.pointer(e.clientX, e.clientY)}+ onMouseLeave={() => hover.pointer(-1, -1)}+ aria-label={t('Open {title}', { title: view.title })} title={view.note?.text ?? t('Recording {title}', { title: view.title })}>+ <div className="widget-details" aria-hidden="true">+ <span className="text-[var(--pill-accent)]">{view.note ? <TriangleAlert data-testid="widget-warning" size={18} /> : <Logo size={18} />}</span>+ <LevelBars testId="widget-wave" height={16} className="text-[var(--pill-accent)]" />+ <span data-testid="widget-time" className="widget-time">{time}</span>+ </div>+ <Preview view={view} open={hover.open} />+ </div>}const RECENT_LINES = 80-function Preview({ view, cardRef }: { view: WidgetView; cardRef: React.RefObject<HTMLDivElement | null> }) {+function Preview({ view, open }: { view: WidgetView; open: boolean }) {const [lines, setLines] = useState<Array<Omit<Segment, 'id'>>>([])const [parts, setParts] = useState<Record<string, TranscriptPartial>>({})const [loaded, setLoaded] = useState(false)@@ -213,19 +174,13 @@ function Preview({ view, cardRef }: { view: WidgetView; cardRef: React.RefObjectif (content.current) observer.observe(content.current)return () => observer.disconnect()}, [])- useEffect(() => {- const card = cardRef.current- if (!card) return- // screen.availHeight is independent of this window's measured height, so it can grow again after shrinking.- const fit = () => card.style.setProperty('--preview-max-height', `${Math.min(520, window.screen.availHeight)}px`)- const appear = () => {- if (!document.hidden && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) card.animate([{opacity:0},{opacity:1}],{duration:120,easing:'ease-out'})- }- fit(); appear()- window.addEventListener('resize', fit)- document.addEventListener('visibilitychange', appear)- return () => { window.removeEventListener('resize', fit); document.removeEventListener('visibilitychange', appear); gliding.current?.() }- }, [cardRef])+ useLayoutEffect(() => {+ if (!open) return+ gliding.current?.(); gliding.current = null+ stick.current = true; setBehind(false)+ if (scroll.current) scroll.current.scrollTop = scroll.current.scrollHeight+ }, [open])+ useEffect(() => () => gliding.current?.(), [])const manual = () => { gliding.current?.(); gliding.current = null; stick.current = false }const latest = () => {const el = scroll.current@@ -240,12 +195,13 @@ function Preview({ view, cardRef }: { view: WidgetView; cardRef: React.RefObject})}const note = view.note- return <div ref={cardRef} data-testid="widget-preview" className="widget-preview" role="region" aria-label={t('Live transcript')}- onPointerEnter={() => window.yogurt.widget.preview(true)} onPointerLeave={() => window.yogurt.widget.preview(false)}>- {note && <p data-testid="widget-note" data-tone={note.tone} className="widget-preview-warning" role="status">- {note.tone === 'hiccup' ? <RotateCw size={13} aria-hidden="true" /> : note.code === 'no-mic' ? <MicOff size={13} aria-hidden="true" /> : <TriangleAlert size={13} aria-hidden="true" />}- <span>{note.text}</span>- </p>}+ const permission = widgetSettings(note)+ return <div data-testid="widget-preview" className="widget-preview" role="region" aria-label={t('Live transcript')} inert={!open} aria-hidden={!open}>+ {note && <div className="widget-preview-warning" role="status">+ <p data-testid="widget-note" data-tone={note.tone}>{note.text}</p>+ {permission && <button className="widget-settings" onClick={() => { void window.yogurt.permissions.open(permission) }}>{t('Open Settings')}</button>}+ </div>}+ <ScrollFade><div ref={scroll} data-testid="widget-preview-text" className="widget-preview-conversation" role="log" aria-live="off" aria-label={t('Transcript')}onWheel={manual} onTouchStart={manual} onPointerDown={manual} onKeyDown={manual} onScroll={e => {if (gliding.current) return@@ -268,6 +224,7 @@ function Preview({ view, cardRef }: { view: WidgetView; cardRef: React.RefObject})}</div></div>+ </ScrollFade>{behind && <button data-testid="widget-preview-latest" className="widget-preview-latest" onClick={latest}><ArrowDown size={12} aria-hidden="true" />{t('Latest')}</button>}</div>}diff --git a/app/src/renderer/src/windows/widgetMorph.ts b/app/src/renderer/src/windows/widgetMorph.tsnew file mode 100644index 00000000..b3dbc109--- /dev/null+++ b/app/src/renderer/src/windows/widgetMorph.ts@@ -0,0 +1,122 @@+import { useEffect, useLayoutEffect, useRef, useState } from 'react'+import { WidgetIntent, widgetContains, type WidgetLayout } 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) {+ const intent = useRef(new WidgetIntent()).current+ const [open, setOpen] = useState(false)+ const [layout, setLayout] = useState<WidgetLayout | null>(null)+ const pointer = useRef({ x: -1, y: -1 })+ const animations = useRef<Animation[]>([])+ const resumeAt = useRef<number | null>(null)+ const morph = useRef((immediate = false) => { void immediate })+ 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) })+ const offPointer = window.yogurt.widget.onPointer(p => { pointer.current = p })+ 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)+ })+ return () => { alive = false; off(); offPointer(); offReset(); freeze() }+ }, [])+ useLayoutEffect(() => {+ const was = intent.warning+ intent.warning = warning+ if (was && !warning && !intent.over) intent.leave(performance.now())+ }, [warning])+ const previous = useRef<WidgetLayout | null>(null)+ useLayoutEffect(() => {+ const el = card.current+ if (!el || !layout) return+ const items = [...el.querySelectorAll<HTMLElement>('.widget-details > *')]+ const body = el.querySelector<HTMLElement>('.widget-preview')!+ const timerWidth = items[2].getBoundingClientRect().width+ const height = Math.min(warning ? 446 : 390, layout.open.height)+ const up = layout.pill.y + layout.pill.height > layout.open.y + layout.open.height / 2+ const expanded = { ...layout.open, height, y: layout.open.y + (up ? layout.open.height - height : 0) }+ 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 ? 350 : 250, easing = opened ? 'cubic-bezier(.34,1.25,.64,1)' : 'cubic-bezier(.22,1,.36,1)'+ const animate = (node: HTMLElement, to: Record<string, string>, ms = 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) animations.current.push(node.animate([from, to] as Keyframe[], { duration: ms, easing: ease, delay, fill: 'both' }))+ }+ animate(el, { left: `${box.x}px`, top: `${box.y}px`, width: `${box.width}px`, height: `${box.height}px`, borderRadius: opened ? '16px' : '10px' })+ const positions = opened ? [[16, 17], [box.width - timerWidth - 55, 18], [box.width - timerWidth - 16, 18.5]] : [[12, 11], [42, 12], [81, 12.5]]+ items.forEach((item, i) => animate(item, { transform: `translate(${positions[i][0]}px,${positions[i][1]}px)` }))+ body.style.width = `${expanded.width - 2}px`; body.style.height = `${expanded.height - 54}px`+ animate(body, { transform: opened ? 'translateX(0) scale(1)' : 'translateX(40px) scale(.97)', filter: opened ? 'blur(0px)' : 'blur(2px)' }, duration, 'cubic-bezier(.22,1,.36,1)')+ animate(body, { opacity: opened ? '1' : '0' }, opened ? 200 : 120, 'ease-out', opened ? 50 : 0)+ el.style.visibility = 'visible'+ }+ 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.open.width)}px`+ el.style.height = `${Math.min(parseFloat(el.style.height), layout.open.height)}px`+ } else morph.current(true)+ previous.current = layout+ }, [layout, warning])+ useLayoutEffect(() => {+ if (intent.pressed) return+ const timer = card.current?.querySelector<HTMLElement>('[data-testid="widget-time"]')+ if (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 = ''+ const tick = (now: number) => {+ 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 = widgetContains(surface, 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 = p+ const 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) }+ }+ frame = requestAnimationFrame(tick)+ }+ frame = requestAnimationFrame(tick)+ const reduced = window.matchMedia('(prefers-reduced-motion: reduce)')+ const swap = () => morph.current(true)+ reduced.addEventListener('change', swap)+ return () => { cancelAnimationFrame(frame); reduced.removeEventListener('change', swap) }+ }, [])+ return {+ open,+ pointer: (x: number, y: number) => {+ pointer.current = { x, y }+ 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) })+ },+ press: () => { freeze(); intent.press(); resumeAt.current = null; window.yogurt.widget.pressed(true) },+ release: (dragged: boolean) => {+ if (!intent.pressed) return+ intent.release(performance.now(), dragged)+ resumeAt.current = performance.now() + (dragged ? 650 : 0)+ 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/src/shared/types.ts b/app/src/shared/types.tsindex 03491b9a..8248271b 100644--- a/app/src/shared/types.ts+++ b/app/src/shared/types.ts@@ -1,3 +1,4 @@+import type { WidgetLayout, WidgetSurface } from './widgetMorph'import type { ContextChip, ContextTarget } from './askContext'import type { FolderAppearance } from './folderAppearance'import type { LiveWord } from './liveWords'@@ -45,13 +46,17 @@ export type YogurtApi = {onLevel(cb: (lv: { me: number; them: number }) => void): () => voidopen(): voidstop(): void- /** hover over the recorder or its adjacent live transcript */- preview(on: boolean): void+ layout(): Promise<WidgetLayout | null>+ onLayout(cb: (layout: WidgetLayout) => void): () => void+ onPointer(cb: (point: { x: number; y: number }) => void): () => void+ onReset(cb: () => void): () => void+ surface(rect: WidgetSurface): void+ pressed(value: boolean): void/** moves the widget by screen-space deltas during a pointer drag */drag(dx: number, dy: number): void/** commits the clamped position after the pointer is released or cancelled */endDrag(): void- /** the recorder or card size, keeping its chosen screen position */+ /** the resting pill size, keeping its right edge fixed */size(w: number, h: number): void}meetings: {diff --git a/app/src/shared/widgetMorph.ts b/app/src/shared/widgetMorph.tsnew file mode 100644index 00000000..b95f8e94--- /dev/null+++ b/app/src/shared/widgetMorph.ts@@ -0,0 +1,55 @@+import type { WidgetView } from './types'++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 }++const 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 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.height+ const 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.+ 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.x+ bounds.height = Math.min(area.y + area.height, y + height + 8) - bounds.y+ return { bounds, pill: { ...pill, x: pill.x - bounds.x, y: pill.y - bounds.y }, open: { x: x - bounds.x, y: y - bounds.y, width, height } }+}++export function widgetContains(rect: WidgetSurface, x: number, y: number): boolean {+ if (x < rect.x || y < rect.y || x > rect.x + rect.width || y > rect.y + rect.height) return false+ const radius = Math.min(rect.radius, rect.width / 2, rect.height / 2)+ const dx = x - clamp(x, rect.x + radius, rect.x + rect.width - radius)+ const dy = y - clamp(y, rect.y + radius, rect.y + rect.height - radius)+ return dx * dx + dy * dy <= radius * radius+}++export const widgetSettings = (note: WidgetView['note']) => note?.code === 'no-mic' ? 'mic' : note?.code === 'no-system-audio' ? 'systemAudio' : null++/** Hover deadlines stop during a press and wait for quiet after a drag. */+export class WidgetIntent {+ open = false+ over = false+ pressed = false+ warning = false+ quiet = 0+ due: { at: number; open: boolean } | null = null+ enter(now: number) { this.over = true; this.due = !this.pressed && !this.open ? { at: Math.max(now + 220, this.quiet), open: true } : null }+ move(now: number) { if (!this.open && !this.pressed) this.enter(now) }+ leave(now: number) { this.over = false; this.due = !this.pressed && this.open && !this.warning ? { at: Math.max(now + 480, this.quiet), open: false } : null }+ press() { this.pressed = true; this.due = null }+ release(now: number, dragged: boolean) { this.pressed = false; if (dragged) this.quiet = now + 650; this.over ? this.enter(now) : this.leave(now) }+ tick(now: number) {+ if (this.pressed) return null+ if (this.warning && !this.open) { this.open = true; this.due = null; return true }+ if (!this.due || now < this.due.at) return null+ const next = this.warning || this.due.open+ this.due = null+ if (next === this.open) return null+ this.open = next+ return next+ }+}diff --git a/app/test/widgetMorph.test.ts b/app/test/widgetMorph.test.tsnew file mode 100644index 00000000..8410ec5a--- /dev/null+++ b/app/test/widgetMorph.test.ts@@ -0,0 +1,89 @@+import { describe, expect, it } from 'vitest'+import { WidgetIntent, widgetContains, widgetLayout, widgetSettings } from '../src/shared/widgetMorph'+import { WidgetModel } from '../src/main/widgetModel'++describe('recorder hover intent', () => {+ it('opens after 220ms of rest and closes 480ms after leaving', () => {+ const intent = new WidgetIntent()+ intent.enter(0)+ expect(intent.tick(219)).toBeNull()+ intent.move(100)+ expect(intent.tick(319)).toBeNull()+ expect(intent.tick(320)).toBe(true)+ intent.leave(400)+ expect(intent.tick(879)).toBeNull()+ expect(intent.tick(880)).toBe(false)+ })+ it('cancels leaving on reentry and waits 650ms after a drag', () => {+ const intent = new WidgetIntent()+ intent.enter(0); intent.tick(220); intent.leave(300); intent.enter(400)+ expect(intent.tick(1000)).toBeNull()+ intent.leave(1000); intent.tick(1480)+ intent.enter(1500); intent.press()+ expect(intent.tick(2000)).toBeNull()+ intent.release(2000, true)+ expect(intent.tick(2649)).toBeNull()+ expect(intent.tick(2650)).toBe(true)+ })+ it('blocks closing during a press and post-drag quiet, including cancellation outside', () => {+ const intent = new WidgetIntent()+ intent.enter(0); intent.tick(220); intent.press(); intent.leave(300)+ expect(intent.tick(1000)).toBeNull()+ intent.release(1000, true)+ expect(intent.tick(1649)).toBeNull()+ expect(intent.tick(1650)).toBe(false)+ })+ it('shows a warning without hover and keeps it open until the warning clears', () => {+ const intent = new WidgetIntent()+ intent.warning = true+ expect(intent.tick(0)).toBe(true)+ intent.leave(100)+ expect(intent.tick(1000)).toBeNull()+ intent.warning = false; intent.leave(1000)+ expect(intent.tick(1480)).toBe(false)+ })+})++describe('recorder geometry', () => {+ const area = { x: -1200, y: -100, width: 1200, height: 900 }+ 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) => {+ const pill = { x, y, width: 127, height: 42 }, result = widgetLayout(pill, area)+ expect(result.bounds.x + result.pill.x).toBe(x)+ expect(result.bounds.y + result.pill.y).toBe(y)+ expect(result.bounds.x + result.open.x).toBe(openX)+ expect(result.bounds.y + result.open.y).toBe(openY)+ expect(result.bounds.x).toBeGreaterThanOrEqual(area.x)+ expect(result.bounds.y).toBeGreaterThanOrEqual(area.y)+ expect(result.bounds.x + result.bounds.width).toBeLessThanOrEqual(0)+ expect(result.bounds.y + result.bounds.height).toBeLessThanOrEqual(800)+ })+ 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(result.pill).toMatchObject({ x: 80, y: 130 })+ })+ it('excludes transparent corners and includes the full animated surface', () => {+ const surface = { x: 200, y: 10, width: 118, height: 42, radius: 10 }+ expect(widgetContains(surface, 200, 10)).toBe(false)+ expect(widgetContains(surface, 205, 15)).toBe(true)+ expect(widgetContains(surface, 190, 30)).toBe(false)+ expect(widgetContains({ ...surface, x: 0, width: 340, height: 390, radius: 16 }, 190, 300)).toBe(true)+ })+})++it('offers Settings only for missing microphone or call audio', () => {+ const model = new WidgetModel()+ model.start({ id: 'meeting', title: 'Review', startedAt: 0 })+ expect(widgetSettings(model.view(0)!.note)).toBeNull()+ model.warn('falling-behind')+ expect(widgetSettings(model.view(0)!.note)).toBeNull()+ model.warn('no-system-audio')+ expect(widgetSettings(model.view(0)!.note)).toBe('systemAudio')+ model.warn('no-mic')+ expect(widgetSettings(model.view(0)!.note)).toBe('mic')+ model.hiccup(0)+ expect(widgetSettings(model.view(1)!.note)).toBeNull()+ expect(widgetSettings(model.view(4001)!.note)).toBe('mic')+})diff --git a/app/test/widgetWindow.test.ts b/app/test/widgetWindow.test.tsindex 33604488..5d064604 100644--- a/app/test/widgetWindow.test.ts+++ b/app/test/widgetWindow.test.ts@@ -1,6 +1,8 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'const state = vi.hoisted(() => ({+ cursor: { x: 500, y: 400 },+ displayEvents: new Map<string, () => void>(),handlers: new Map<string, (...args: any[]) => unknown>(),start: null as null | ((meeting: any) => void),stop: null as null | ((meeting: any) => void),@@ -22,6 +24,7 @@ vi.mock('electron', () => ({constructor(options: any) { this.options = options; this.bounds = { x: options.x, y: options.y, width: options.width, height: options.height }; state.windows.push(this) }getBounds() { return { ...this.bounds } }setBounds(bounds: any) { this.bounds = bounds }+ setIgnoreMouseEvents = vi.fn()isDestroyed() { return this.dead }isVisible() { return false }on() {}@@ -38,7 +41,9 @@ vi.mock('electron', () => ({constructor(options: any) { this.options = options; state.notifications.push(this) }},screen: {- getCursorScreenPoint: () => ({ x: 500, y: 400 }),+ getCursorScreenPoint: () => state.cursor,+ on: (name: string, fn: () => void) => state.displayEvents.set(name, fn),+ removeListener: (name: string) => state.displayEvents.delete(name),getDisplayNearestPoint: (p: { x: number; y: number }) => ({ workArea: state.displays[p.x < 0 ? 1 : 0] }),getDisplayMatching: (b: { x: number }) => ({ workArea: state.displays[b.x < 0 ? 1 : 0] }),},@@ -56,6 +61,8 @@ let win: anyconst open = vi.fn()let widget: ReturnType<typeof import('../src/main/widget').createWidget>beforeEach(async () => {+ vi.useFakeTimers()+ state.cursor = { x: 500, y: 400 }vi.stubEnv('YOGURT_BACKGROUND', '0')vi.resetModules(); state.handlers.clear(); state.windows.length = 0state.notifications.length = 0; state.fake = false; state.stopPending = false; state.supported = true@@ -65,171 +72,129 @@ beforeEach(async () => {state.start!({ id: 'meeting', title: 'Review', startedAt: 0 })win = state.windows[0]})-afterEach(() => vi.unstubAllEnvs())+afterEach(() => { vi.clearAllTimers(); vi.useRealTimers(); vi.unstubAllEnvs() })describe('floating recorder placement', () => {- it('starts as a non-activating panel, accepts the first mouse click, and has no native shadow', () => {- expect(win.options).toMatchObject({ type: 'panel', width: 127, height: 42, acceptFirstMouse: true, hasShadow: false, roundedCorners: false, focusable: false })+ it('uses one transparent, non-activating window with clicks initially passing through', () => {+ expect(state.windows).toHaveLength(1)+ expect(win.options).toMatchObject({ type: 'panel', transparent: true, frame: false, acceptFirstMouse: true, hasShadow: false, roundedCorners: false, focusable: false })+ expect(win.options.width).toBeGreaterThanOrEqual(340)+ expect(win.options.height).toBeGreaterThanOrEqual(446)+ expect(win.setIgnoreMouseEvents).toHaveBeenCalledWith(true, { forward: true })+ expect(widget.snapshot().bounds).toMatchObject({ width: 127, height: 42 })})- it('Windows and Linux: a tool window that never takes focus, as there are no panels there', async () => {+ it('uses a tool window on Windows without taking focus', async () => {const { createWidget } = await import('../src/main/widget')- state.windows.length = 0createWidget({ open, stop: vi.fn(), foreground: () => false, windowOs: 'win32' })state.start!({ id: 'meeting2', title: 'Review', startedAt: 0 })expect(state.windows.at(-1).options).toMatchObject({ type: 'toolbar', focusable: false, skipTaskbar: true })})- it('moves in both axes and keeps the chosen location through card resizing and the next meeting', () => {- const before = win.getBounds()- send('widget:drag', -300, 70); send('widget:drag-end')- expect(win.getBounds()).toMatchObject({ x: before.x - 300, y: before.y + 70 })- const chosen = win.getBounds()- send('widget:size', 300, 100)- expect(win.getBounds()).toEqual({ ...chosen, width: 300, height: 100 })- send('widget:size', 127, 42)- expect(win.getBounds()).toEqual(chosen)- win.destroy()+ it('moves the surface and pill together and remembers the pill for the next meeting', () => {+ const before = widget.snapshot().bounds!, frame = win.getBounds()+ send('widget:drag', -100, 10); send('widget:drag-end')+ const chosen = widget.snapshot().bounds!+ expect(chosen).toEqual({ ...before, x: before.x - 100, y: before.y + 10 })+ expect(win.getBounds()).toEqual({ ...frame, x: frame.x - 100, y: frame.y + 10 })+ send('widget:size', 118, 42)+ expect(widget.snapshot().bounds).toEqual({ ...chosen, x: chosen.x + 9, width: 118 })+ const resized = widget.snapshot().bounds+ state.stop!({ id: 'meeting' })state.start!({ id: 'next', title: 'Next meeting', startedAt: 1 })- expect(state.windows[1].getBounds()).toEqual(chosen)+ expect(widget.snapshot().bounds).toEqual(resized)+ })+ it('drags an expanded surface as one window and clamps all of it at the edge', async () => {+ const { widgetLayout } = await import('../src/shared/widgetMorph')+ const before = widget.snapshot().bounds!, layout = widgetLayout(before, state.displays[0])+ send('widget:surface', { ...layout.open, height: 390, radius: 16 })+ send('widget:pressed', true)+ const frame = win.getBounds()+ send('widget:drag', -100, 10)+ expect(win.getBounds()).toEqual({ ...frame, x: frame.x - 100, y: frame.y + 10 })+ expect(widget.snapshot().bounds).toEqual({ ...before, x: before.x - 100, y: before.y + 10 })+ send('widget:drag', 9999, 9999)+ const edge = win.getBounds()+ expect(edge.x + layout.open.x + layout.open.width).toBe(1200)+ expect(edge.y + layout.open.y + layout.open.height).toBe(800)+ send('widget:drag-end'); send('widget:pressed', false)+ expect(win.getBounds()).toEqual(edge)+ expect(state.windows).toHaveLength(1)+ })+ it('defers timer sizing while pressed and keeps the right edge fixed afterward', () => {+ const before = widget.snapshot().bounds!+ send('widget:pressed', true); send('widget:size', 134, 42)+ expect(widget.snapshot().bounds).toEqual(before)+ send('widget:pressed', false); send('widget:size', 134, 42)+ expect(widget.snapshot().bounds).toEqual({ ...before, x: before.x - 7, width: 134 })})- it('can cross to a display with negative coordinates using successive small deltas', () => {- const before = win.getBounds()+ it('crosses to a negative-coordinate display with successive small deltas', () => {+ const before = widget.snapshot().bounds!send('widget:drag', -before.x, 0)for (let n = 0; n < 45; n++) send('widget:drag', -4, -2)send('widget:drag-end')- expect(win.getBounds()).toMatchObject({ x: -180, y: before.y - 90 })+ expect(widget.snapshot().bounds).toMatchObject({ x: -180, y: before.y - 90 })+ expect(win.getBounds().x).toBeGreaterThanOrEqual(-1000)})- it('clamps the whole widget to the destination work area and restores its anchor after a card shrinks', () => {+ it('turns inward at both screen edges without changing the pill anchor', () => {send('widget:drag', 9999, 9999); send('widget:drag-end')- expect(win.getBounds()).toEqual({ x: 1073, y: 758, width: 127, height: 42 })- send('widget:size', 300, 100)- expect(win.getBounds()).toEqual({ x: 900, y: 700, width: 300, height: 100 })- send('widget:size', 127, 42)- expect(win.getBounds()).toEqual({ x: 1073, y: 758, width: 127, height: 42 })+ expect(widget.snapshot().bounds).toEqual({ x: 1073, y: 758, width: 127, height: 42 })+ expect(win.getBounds().x + win.getBounds().width).toBe(1200)+ expect(win.getBounds().y + win.getBounds().height).toBe(800)send('widget:drag', -9999, -9999); send('widget:drag-end')- expect(win.getBounds()).toEqual({ x: -1000, y: -200, width: 127, height: 42 })+ expect(widget.snapshot().bounds).toEqual({ x: -1000, y: -200, width: 127, height: 42 })+ expect(win.getBounds()).toMatchObject({ x: -1000, y: -200 })})- it('ignores malformed coordinates and dimensions at the IPC boundary', () => {- const before = win.getBounds()- for (const pair of [[NaN, 1], [1, Infinity], ['2', 3], [1, undefined]]) send('widget:drag', ...pair)- for (const pair of [[NaN, 1], [1, Infinity], [0, 0], [601, 400], [100, 401]]) send('widget:size', ...pair)- expect(win.getBounds()).toEqual(before)- })- it('opens a separate hover preview without moving the placed pill at either screen edge', () => {+ it('refits after display changes and removes its display listeners on stop', () => {send('widget:drag', 9999, 9999); send('widget:drag-end')- const chosen = win.getBounds()- send('widget:preview', true)- const preview = state.windows[1]- expect(preview).toBeDefined()- expect(win.getBounds()).toEqual(chosen)- expect(preview.options).toMatchObject({ type: 'panel', width: 340, hasShadow: false, roundedCorners: false, focusable: false, acceptFirstMouse: true })- expect(preview.getBounds().x + preview.getBounds().width).toBeLessThanOrEqual(chosen.x)- expect(preview.getBounds().x + preview.getBounds().width).toBeLessThanOrEqual(1200)- // Finish removes both floating windows immediately.- state.stop!({ id: 'meeting' })- expect(preview.dead).toBe(true)- expect(win.dead).toBe(true)- state.handlers.get('widget:size')!({ sender: preview.webContents }, 280, 150)- expect(win.getBounds()).toEqual(chosen)- })- it('fits the preview beside a top-edge pill and sizes only the preview window', () => {- send('widget:drag', -9999, -9999); send('widget:drag-end')- const chosen = win.getBounds()- send('widget:preview', true)- const preview = state.windows[1]- state.handlers.get('widget:size')!({ sender: preview.webContents }, 280, 150)- expect(win.getBounds()).toEqual(chosen)- expect(preview.getBounds()).toEqual({ x: chosen.x + chosen.width + 8, y: -200, width: 280, height: 150 })- widget.transcript('transcript:partial', { meetingId: 'meeting', track: 'me', startMs: 12, text: 'Actual incoming words' })- expect(preview.webContents.send).toHaveBeenCalledWith('transcript:partial', { meetingId: 'meeting', track: 'me', startMs: 12, text: 'Actual incoming words' })- })- it('keeps the same preview between hovers so its transcript and reading position stay mounted', () => {- vi.useFakeTimers()+ const height = state.displays[0].heighttry {- send('widget:preview', true)- const preview = state.windows[1], hide = vi.spyOn(preview, 'hide')- send('widget:preview', false)- vi.advanceTimersByTime(180)- expect(hide).toHaveBeenCalled()- expect(preview.dead).toBe(false)- send('widget:preview', true)- expect(state.windows).toHaveLength(2)- expect(preview.dead).toBe(false)- } finally { vi.useRealTimers() }+ state.displays[0].height = 300+ state.displayEvents.get('display-metrics-changed')!()+ expect(widget.snapshot().bounds!.y).toBe(258)+ expect(win.getBounds()).toMatchObject({ y: 0, height: 300 })+ state.stop!({ id: 'meeting' })+ expect(state.displayEvents.size).toBe(0)+ } finally { state.displays[0].height = height }})- it('lets the preview grow to 520px and clamps it to a short display without moving the pill', () => {- send('widget:drag', 9999, 9999); send('widget:drag-end')- const chosen = win.getBounds()- send('widget:preview', true)- const preview = state.windows[1]- const size = (height: number) => state.handlers.get('widget:size')!({ sender: preview.webContents }, 340, height)- size(220)- const top = preview.getBounds().y- size(520)- expect(preview.getBounds().y).toBe(top)- expect(preview.getBounds().height).toBe(520)- expect(preview.getBounds().y + 520).toBeLessThanOrEqual(800)- expect(win.getBounds()).toEqual(chosen)- size(521)- expect(preview.getBounds().height).toBe(520)- const previous = state.displays[0].height- try {- state.displays[0].height = 460- size(520)- expect(preview.getBounds().height).toBe(460)- expect(preview.getBounds().y).toBe(0)- expect(win.getBounds()).toEqual(chosen)- } finally { state.displays[0].height = previous }+ it('rejects malformed sizing, hit regions and foreign senders', () => {+ const before = widget.snapshot().bounds+ for (const pair of [[NaN, 1], [1, Infinity], ['2', 3], [1, undefined]]) send('widget:drag', ...pair)+ for (const pair of [[NaN, 42], [601, 42], [0, 0], [118, 400]]) send('widget:size', ...pair)+ state.handlers.get('widget:drag')!({ sender: {} }, 20, 20)+ for (const shape of [null, {}, { x: 0, y: 0, width: 340, height: 400, radius: NaN }]) send('widget:surface', shape)+ expect(widget.snapshot().bounds).toEqual(before)+ expect(win.setIgnoreMouseEvents).toHaveBeenCalledTimes(1)})- it('hides an empty preview without changing the pill and restores it when useful content arrives', () => {- const chosen = win.getBounds()- send('widget:preview', true)- const preview = state.windows[1]- const hide = vi.spyOn(preview, 'hide'), show = vi.spyOn(preview, 'showInactive')- const size = (width: number, height: number) => state.handlers.get('widget:size')!({ sender: preview.webContents }, width, height)- size(280, 70)- expect(show).toHaveBeenCalledTimes(1)- size(0, 0)- expect(hide).toHaveBeenCalledOnce()- expect(show).toHaveBeenCalledTimes(1)- // A real warning or transcript gives the existing preview its measured size again.- state.recording!({ t: 'warn', code: 'no-mic' })- size(280, 92)- expect(show).toHaveBeenCalledTimes(2)- expect(win.getBounds()).toEqual(chosen)+ it('passes clicks outside the actual rounded surface and keeps pointer capture during a drag', () => {+ const b = win.getBounds(), surface = { x: 20, y: 20, width: 118, height: 42, radius: 10 }+ state.cursor = { x: b.x + 30, y: b.y + 35 }+ send('widget:surface', surface)+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(false, { forward: true })+ state.cursor = { x: b.x + 20, y: b.y + 20 }+ vi.advanceTimersByTime(16)+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(true, { forward: true })+ send('widget:pressed', true)+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(false, { forward: true })+ send('widget:pressed', false)+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(true, { forward: true })+ state.cursor = { x: b.x + 30, y: b.y + 35 }+ vi.advanceTimersByTime(16)+ expect(win.setIgnoreMouseEvents).toHaveBeenLastCalledWith(false, { forward: true })})- it('hides the pill and preview on Pause, keeps warnings in app state, and resumes in the same place', () => {- send('widget:size', 127, 42)- send('widget:drag', -100, 40); send('widget:drag-end')- const chosen = win.getBounds(), hide = vi.spyOn(win, 'hide'), show = vi.spyOn(win, 'showInactive')- send('widget:preview', true)- const preview = state.windows[1]- state.recording!({ t: 'paused', meetingId: 'meeting', paused: true, at: 100 })- expect(widget.snapshot().visible).toBe(false)- expect(hide).toHaveBeenCalled()- expect(preview.dead).toBe(true)- send('widget:size', 0, 0)+ 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' })- widget.visibilityChanged()- expect(state.windows).toHaveLength(2)expect(widget.snapshot().view?.note?.code).toBe('no-mic')- expect(state.notifications).toHaveLength(0)+ expect(state.windows).toHaveLength(1)+ state.recording!({ t: 'paused', meetingId: 'meeting', paused: true, at: 100 })+ expect(widget.snapshot().visible).toBe(false)+ expect(win.dead).toBe(false)state.recording!({ t: 'paused', meetingId: 'meeting', paused: false, at: 200 })- send('widget:size', 127, 42)expect(widget.snapshot().visible).toBe(true)- expect(show).toHaveBeenCalled()- expect(win.getBounds()).toEqual(chosen)- })- it('keeps warnings visible without hover, but does not resurrect stale hover after a drag ends', () => {- const chosen = win.getBounds()- send('widget:preview', true)- const preview = state.windows[1]- send('widget:drag', -20, 10); send('widget:drag-end')- expect(preview.dead).toBe(true)- expect(state.windows).toHaveLength(2)- state.recording!({ t: 'warn', code: 'no-mic' })- expect(state.windows).toHaveLength(3)- expect(state.windows[2].dead).toBe(false)- expect(win.getBounds()).toEqual({ ...chosen, x: chosen.x - 20, y: chosen.y + 10 })+ expect(widget.snapshot().bounds).toEqual(chosen)+ widget.transcript('transcript:partial', { text: 'Actual incoming words' })+ expect(win.webContents.send).toHaveBeenCalledWith('transcript:partial', { text: 'Actual incoming words' })+ state.stop!({ id: 'meeting' })+ expect(win.dead).toBe(true)})})