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.

Recorder: drag it to any edge of the screen, open or closed

Eric Brownrout3b1a80292b47
diff --git a/app/src/main/widget.ts b/app/src/main/widget.ts
index e00b0e6a..c2f9a4fd 100644
--- a/app/src/main/widget.ts
+++ b/app/src/main/widget.ts
@@ -8,7 +8,7 @@ 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'
+import { widgetLayout, widgetDragLayout, widgetRestLayout, widgetContains, type WidgetSurface, type WidgetLayout } from '../shared/widgetMorph'
const BACKGROUND = process.env.YOGURT_BACKGROUND === '1'
const FIRST_W = 127, FIRST_H = 42
@@ -62,7 +62,7 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:
let win: BrowserWindow | 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 dragFrame: { layout: WidgetLayout; pill: typeof pill; surface: WidgetSurface } | null = null
let surface: WidgetSurface | null = null
let pressed = false, ignoring = true, sentPointer: string | null = null
let pointerTimer: NodeJS.Timeout | undefined
@@ -95,9 +95,11 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:
if (!shown || BACKGROUND || !win || win.isDestroyed()) return
pointerTimer = setTimeout(poll, hitTest() || pressed ? 16 : 250)
}
- const place = () => {
+ const place = (next?: WidgetLayout) => {
if (!win || win.isDestroyed()) return
- layout = widgetLayout(pill, screen.getDisplayMatching(pill).workArea)
+ const previous = layout
+ layout = next ?? widgetLayout(pill, screen.getDisplayMatching(pill).workArea)
+ if (surface && previous) surface = { ...surface, x: surface.x + layout.pill.x - previous.pill.x, y: surface.y + layout.pill.y - previous.pill.y }
win.setBounds(layout.bounds)
win.webContents.send('widget:layout', layout)
hitTest()
@@ -218,33 +220,31 @@ export function createWidget(d: { open(meetingId: string): void; stop(meetingId:
// Keep the unclamped gesture position so small deltas can cross a display boundary.
dragPosition = { 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))
+ dragFrame ??= { layout, pill: { ...pill }, surface: surface ?? { ...layout.pill, radius: 10 } }
+ const { workArea } = screen.getDisplayNearestPoint({ x: Math.round(x + pill.width / 2), y: Math.round(y + pill.height / 2) })
+ if (dragFrame.surface.width > workArea.width || dragFrame.surface.height > workArea.height) {
+ pill = fit({ ...pill, x, y }); place(); dragFrame = null; return
}
- 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()
+ layout = widgetDragLayout(dragFrame.layout, dragFrame.surface, x - dragFrame.pill.x, y - dragFrame.pill.y, workArea)
+ pill = { ...layout.pill, x: layout.bounds.x + layout.pill.x, y: layout.bounds.y + layout.pill.y }
+ surface = { ...dragFrame.surface, x: dragFrame.surface.x + layout.pill.x - dragFrame.layout.pill.x, y: dragFrame.surface.y + layout.pill.y - dragFrame.layout.pill.y }
+ win.setBounds(layout.bounds)
+ win.webContents.send('widget:layout', layout)
+ hitTest()
})
ipcMain.on('widget:drag-end', (e) => {
if (!win || win.isDestroyed() || e.sender !== win.webContents) return
- if (dragPosition) lastPosition = { x: pill.x, y: pill.y }
+ if (dragPosition) {
+ lastPosition = { x: pill.x, y: pill.y }
+ if (layout && surface && surface.height > FIRST_H + 1) place(widgetRestLayout(layout, screen.getDisplayMatching(pill).workArea, model.view(Date.now())?.note ? 446 : 390))
+ }
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
+ // Apply timer width changes once collapsed, so they cannot re-anchor a dropped card.
+ if (surface && surface.height > FIRST_H + 1) return
// rounded, not up: the timer is a fractional width, and rounding up left the right end a pixel wider than the left
const width = Math.round(w)
if (width === pill.width) return
diff --git a/app/src/renderer/src/windows/widgetMorph.ts b/app/src/renderer/src/windows/widgetMorph.ts
index cac26471..0e27f161 100644
--- a/app/src/renderer/src/windows/widgetMorph.ts
+++ b/app/src/renderer/src/windows/widgetMorph.ts
@@ -1,5 +1,5 @@
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
-import { WidgetIntent, widgetContains, type WidgetLayout } from '../../../shared/widgetMorph'
+import { WidgetIntent, widgetContains, widgetExpanded, 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) {
@@ -43,9 +43,7 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, war
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) }
+ const expanded = widgetExpanded(layout, warning)
morph.current = (immediate = false) => {
freeze()
const opened = intent.open, box = opened ? expanded : layout.pill
@@ -69,8 +67,8 @@ export function useWidgetMorph(card: React.RefObject<HTMLDivElement | null>, war
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`
+ el.style.width = `${Math.min(parseFloat(el.style.width), layout.bounds.width)}px`
+ el.style.height = `${Math.min(parseFloat(el.style.height), layout.bounds.height)}px`
} else morph.current(true)
previous.current = layout
wake.current()
diff --git a/app/src/shared/widgetMorph.ts b/app/src/shared/widgetMorph.ts
index b95f8e94..37e6a6e3 100644
--- a/app/src/shared/widgetMorph.ts
+++ b/app/src/shared/widgetMorph.ts
@@ -2,7 +2,7 @@ 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 }
+export type WidgetLayout = { bounds: WidgetRect; pill: WidgetRect; open: WidgetRect; up: boolean }
const clamp = (n: number, min: number, max: number) => Math.max(min, Math.min(max, n))
@@ -16,7 +16,59 @@ export function widgetLayout(pill: WidgetRect, area: WidgetRect): WidgetLayout {
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 } }
+ 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 }, up }
+}
+
+/** Move the frozen visible surface; trim unused native space at the work area's edges. */
+export function widgetDragLayout(frame: WidgetLayout, surface: WidgetRect, dx: number, dy: number, area: WidgetRect): WidgetLayout {
+ const x = clamp(frame.bounds.x + Math.round(dx), area.x - surface.x, area.x + area.width - surface.x - surface.width)
+ const y = clamp(frame.bounds.y + Math.round(dy), area.y - surface.y, area.y + area.height - surface.y - surface.height)
+ const clip = (r: WidgetRect): WidgetRect => {
+ const left = Math.max(area.x, r.x), top = Math.max(area.y, r.y)
+ return { x: left, y: top, width: Math.min(area.x + area.width, r.x + r.width) - left, height: Math.min(area.y + area.height, r.y + r.height) - top }
+ }
+ const bounds = clip({
+ x: Math.floor(x), y: Math.floor(y),
+ width: Math.ceil(x + frame.bounds.width) - Math.floor(x), height: Math.ceil(y + frame.bounds.height) - Math.floor(y),
+ })
+ const local = (r: WidgetRect) => ({ ...r, x: r.x - bounds.x, y: r.y - bounds.y })
+ return {
+ bounds, up: frame.up,
+ pill: local({ ...frame.pill, x: x + frame.pill.x, y: y + frame.pill.y }),
+ open: local({ ...frame.open, x: x + frame.open.x, y: y + frame.open.y }),
+ }
+}
+
+/** Restore room for the normal card without moving the frozen surface on release. */
+export function widgetRestLayout(frame: WidgetLayout, area: WidgetRect, height: number): WidgetLayout {
+ const width = Math.min(340, area.width), fullHeight = Math.min(446, area.height)
+ height = Math.min(height, fullHeight)
+ const x = clamp(frame.bounds.x + frame.open.x, area.x, area.x + area.width - width)
+ const y = clamp(frame.bounds.y + frame.open.y + (frame.up ? frame.open.height - height : 0), area.y, area.y + area.height - height)
+ const openY = y - (frame.up ? fullHeight - height : 0)
+ const fullY = clamp(openY, area.y, area.y + area.height - fullHeight)
+ const left = Math.max(area.x, Math.floor(Math.min(frame.bounds.x, x - 8)))
+ const top = Math.max(area.y, Math.floor(Math.min(frame.bounds.y, fullY - 8)))
+ const bounds = {
+ x: left, y: top,
+ width: Math.min(area.x + area.width, Math.ceil(Math.max(frame.bounds.x + frame.bounds.width, x + width + 8))) - left,
+ height: Math.min(area.y + area.height, Math.ceil(Math.max(frame.bounds.y + frame.bounds.height, fullY + fullHeight + 8))) - top,
+ }
+ return {
+ bounds, up: frame.up,
+ pill: { ...frame.pill, x: frame.bounds.x + frame.pill.x - left, y: frame.bounds.y + frame.pill.y - top },
+ open: { x: x - left, y: openY - top, width, height: fullHeight },
+ }
+}
+
+export function widgetExpanded(layout: WidgetLayout, warning: boolean): WidgetRect {
+ const width = Math.min(layout.open.width, layout.bounds.width)
+ const height = Math.min(warning ? 446 : 390, layout.open.height, layout.bounds.height)
+ return {
+ x: clamp(layout.open.x, 0, layout.bounds.width - width),
+ y: clamp(layout.open.y + (layout.up ? layout.open.height - height : 0), 0, layout.bounds.height - height),
+ width, height,
+ }
}
export function widgetContains(rect: WidgetSurface, x: number, y: number): boolean {
diff --git a/app/test/widgetMorph.test.ts b/app/test/widgetMorph.test.ts
index 8410ec5a..4c73a3b0 100644
--- a/app/test/widgetMorph.test.ts
+++ b/app/test/widgetMorph.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
-import { WidgetIntent, widgetContains, widgetLayout, widgetSettings } from '../src/shared/widgetMorph'
+import { WidgetIntent, widgetContains, widgetDragLayout, widgetExpanded, widgetLayout, widgetRestLayout, widgetSettings } from '../src/shared/widgetMorph'
import { WidgetModel } from '../src/main/widgetModel'
describe('recorder hover intent', () => {
@@ -33,6 +33,16 @@ describe('recorder hover intent', () => {
expect(intent.tick(1649)).toBeNull()
expect(intent.tick(1650)).toBe(false)
})
+ it.each([false, true])('keeps an open card open through dragging and release, warning=%s', warning => {
+ const intent = new WidgetIntent()
+ intent.warning = warning
+ intent.enter(0); intent.tick(220); intent.press(); intent.leave(300)
+ expect(intent.tick(1000)).toBeNull()
+ expect(intent.open).toBe(true)
+ intent.enter(1100); intent.release(1200, true)
+ expect(intent.tick(2000)).toBeNull()
+ expect(intent.open).toBe(true)
+ })
it('shows a warning without hover and keeps it open until the warning clears', () => {
const intent = new WidgetIntent()
intent.warning = true
@@ -64,6 +74,76 @@ describe('recorder geometry', () => {
expect(result.bounds).toEqual({ x: 0, y: 0, width: 250, height: 200 })
expect(result.pill).toMatchObject({ x: 80, y: 130 })
})
+ it.each([42, 180, 390, 446])('clamps the visible %spt surface at every edge without reserving invisible space', height => {
+ for (const y of [0, 700]) {
+ const frame = widgetLayout({ x: -600, y, width: 127, height: 42 }, area)
+ const up = frame.pill.y > frame.open.y
+ const surface = height === 42 ? frame.pill : { ...frame.open, height, y: frame.open.y + (up ? frame.open.height - height : 0) }
+ for (const dx of [-9999, 9999]) for (const dy of [-9999, 9999]) {
+ const moved = widgetDragLayout(frame, surface, dx, dy, area)
+ const left = moved.bounds.x + surface.x + moved.pill.x - frame.pill.x
+ const top = moved.bounds.y + surface.y + moved.pill.y - frame.pill.y
+ expect(left).toBe(dx < 0 ? area.x : area.x + area.width - surface.width)
+ expect(top).toBe(dy < 0 ? area.y : area.y + area.height - surface.height)
+ expect(moved.bounds.x).toBeGreaterThanOrEqual(area.x)
+ expect(moved.bounds.y).toBeGreaterThanOrEqual(area.y)
+ expect(moved.bounds.x + moved.bounds.width).toBeLessThanOrEqual(area.x + area.width)
+ expect(moved.bounds.y + moved.bounds.height).toBeLessThanOrEqual(area.y + area.height)
+ if (height === 390 || height === 446) {
+ const resumedHeight = Math.min(height, moved.open.height)
+ const resumedUp = moved.pill.y + moved.pill.height > moved.open.y + moved.open.height / 2
+ expect(moved.bounds.x + moved.open.x).toBe(left)
+ expect(moved.bounds.y + moved.open.y + (resumedUp ? moved.open.height - resumedHeight : 0)).toBe(top)
+ expect(resumedHeight).toBe(height)
+ }
+ }
+ }
+ })
+ it('keeps a fractional spring surface intact inside integer native bounds', () => {
+ const frame = widgetLayout({ x: -600, y: 0, width: 127, height: 42 }, area)
+ const surface = { ...frame.open, x: frame.open.x - 0.5, y: frame.open.y - 0.5, width: 341, height: 391 }
+ for (const delta of [-9999, 9999]) {
+ const moved = widgetDragLayout(frame, surface, delta, delta, area)
+ expect(Object.values(moved.bounds).every(Number.isInteger)).toBe(true)
+ expect(moved.bounds.width).toBeGreaterThanOrEqual(surface.width)
+ expect(moved.bounds.height).toBeGreaterThanOrEqual(surface.height)
+ const left = moved.bounds.x + surface.x + moved.pill.x - frame.pill.x
+ const top = moved.bounds.y + surface.y + moved.pill.y - frame.pill.y
+ expect(left).toBe(delta < 0 ? area.x : area.x + area.width - surface.width)
+ expect(top).toBe(delta < 0 ? area.y : area.y + area.height - surface.height)
+ }
+ })
+ it.each([false, true])('restores normal dimensions across repeated edge drags and reopen, warning=%s', warning => {
+ const height = warning ? 446 : 390
+ for (const y of [0, 700]) {
+ let frame = widgetLayout({ x: -600, y, width: 127, height: 42 }, area)
+ const expanded = widgetExpanded(frame, warning)
+ let surface = { ...expanded, x: expanded.x + 100, y: expanded.y + (frame.up ? height - 180 : 0), width: 240, height: 180 }
+ for (const [dx, dy] of [[-9999, -9999], [9999, 9999], [-9999, 9999], [9999, -9999], [-100, 100]]) {
+ const dragged = widgetDragLayout(frame, surface, dx, dy, area)
+ const visible = {
+ ...surface,
+ x: dragged.bounds.x + surface.x + dragged.pill.x - frame.pill.x,
+ y: dragged.bounds.y + surface.y + dragged.pill.y - frame.pill.y,
+ }
+ const restored = widgetRestLayout(dragged, area, height)
+ const reopened = widgetExpanded(restored, warning)
+ expect(reopened).toMatchObject({ width: 340, height })
+ expect(restored.bounds.x + reopened.x).toBeGreaterThanOrEqual(area.x)
+ expect(restored.bounds.y + reopened.y).toBeGreaterThanOrEqual(area.y)
+ expect(restored.bounds.x + reopened.x + reopened.width).toBeLessThanOrEqual(area.x + area.width)
+ expect(restored.bounds.y + reopened.y + reopened.height).toBeLessThanOrEqual(area.y + area.height)
+ // Growing the native frame does not move the frozen surface; a settled card stays at its drop point.
+ expect(restored.bounds.x + surface.x + restored.pill.x - frame.pill.x).toBe(visible.x)
+ expect(restored.bounds.y + surface.y + restored.pill.y - frame.pill.y).toBe(visible.y)
+ if (surface.width === 340) {
+ expect(restored.bounds.x + reopened.x).toBe(visible.x)
+ expect(restored.bounds.y + reopened.y).toBe(visible.y)
+ }
+ frame = restored; surface = reopened
+ }
+ }
+ })
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)
diff --git a/app/test/widgetWindow.test.ts b/app/test/widgetWindow.test.ts
index 3fed996f..ca632dec 100644
--- a/app/test/widgetWindow.test.ts
+++ b/app/test/widgetWindow.test.ts
@@ -102,22 +102,50 @@ describe('floating recorder placement', () => {
state.start!({ id: 'next', title: 'Next meeting', startedAt: 1 })
expect(widget.snapshot().bounds).toEqual(resized)
})
- it('drags an expanded surface as one window and clamps all of it at the edge', async () => {
+ it.each([42, 180, 390, 446])('drags a %spt surface to every work area edge without moving it on release', async height => {
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 })
+ const area = state.displays[0]
+ area.y = 24; area.height = 776
+ state.displayEvents.get('display-metrics-changed')!()
+ const before = widget.snapshot().bounds!, layout = widgetLayout(before, area)
+ const surface = { ...(height === 42 ? layout.pill : layout.open), height, radius: 16 }
+ send('widget:surface', surface)
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)
+ let previous = { x: before.x - 100, y: before.y + 10 }
+ const offset = { x: surface.x - layout.pill.x, y: surface.y - layout.pill.y }
+ try {
+ for (const target of [
+ { x: 500, y: 24 }, { x: 0, y: 24 }, { x: 0, y: 800 - height },
+ { x: 1200 - surface.width, y: 800 - height }, { x: 1200 - surface.width, y: 24 },
+ ]) {
+ const anchor = { x: target.x - offset.x, y: target.y - offset.y }
+ send('widget:drag', anchor.x - previous.x, anchor.y - previous.y)
+ const next = win.webContents.send.mock.calls.filter(([channel]: [string]) => channel === 'widget:layout').at(-1)[1]
+ const visible = { ...surface, x: surface.x + next.pill.x - layout.pill.x, y: surface.y + next.pill.y - layout.pill.y }
+ expect(next.bounds.x + visible.x).toBe(target.x)
+ expect(next.bounds.y + visible.y).toBe(target.y)
+ expect(win.getBounds().x).toBeGreaterThanOrEqual(0)
+ expect(win.getBounds().y).toBeGreaterThanOrEqual(24)
+ expect(win.getBounds().x + win.getBounds().width).toBeLessThanOrEqual(1200)
+ expect(win.getBounds().y + win.getBounds().height).toBeLessThanOrEqual(800)
+ send('widget:surface', visible)
+ previous = anchor
+ }
+ const dropped = win.getBounds()
+ send('widget:drag-end'); send('widget:pressed', false)
+ expect(widget.snapshot().bounds).toEqual({ ...before, ...previous })
+ if (height > 42) {
+ send('widget:size', 134, 42)
+ expect(win.getBounds()).toEqual(dropped)
+ expect(widget.snapshot().bounds).toEqual({ ...before, ...previous })
+ }
+ else expect(win.getBounds()).toEqual(widgetLayout({ ...before, ...previous }, area).bounds)
+ expect(state.windows).toHaveLength(1)
+ } finally { area.y = 0; area.height = 800 }
})
it('defers timer sizing while pressed and keeps the right edge fixed afterward', () => {
const before = widget.snapshot().bounds!
@@ -126,6 +154,32 @@ describe('floating recorder placement', () => {
send('widget:pressed', false); send('widget:size', 134, 42)
expect(widget.snapshot().bounds).toEqual({ ...before, x: before.x - 7, width: 134 })
})
+ it('restores the normal card after dragging during opening, dropping, closing and reopening', async () => {
+ const { widgetLayout, widgetExpanded, WidgetIntent } = await import('../src/shared/widgetMorph')
+ const intent = new WidgetIntent()
+ intent.enter(0); expect(intent.tick(220)).toBe(true); intent.press()
+ const frame = widgetLayout(widget.snapshot().bounds!, state.displays[0])
+ const partial = { ...frame.open, x: frame.open.x + 100, width: 240, height: 180, radius: 16 }
+ send('widget:surface', partial); send('widget:pressed', true)
+ send('widget:drag', -frame.bounds.x - partial.x, -frame.bounds.y - partial.y)
+ const latest = () => win.webContents.send.mock.calls.filter(([channel]: [string]) => channel === 'widget:layout').at(-1)[1]
+ const clipped = latest()
+ expect(clipped.bounds.width).toBeLessThan(340)
+ send('widget:drag-end'); send('widget:pressed', false)
+ intent.release(300, true)
+ expect(intent.open).toBe(true)
+ expect(widgetExpanded(latest(), false)).toMatchObject({ width: 340, height: 390 })
+ // Finish closing, with an unchanged timer width, then use the same target on reopen.
+ intent.leave(1000); expect(intent.tick(1480)).toBe(false)
+ send('widget:surface', { ...latest().pill, radius: 10 })
+ send('widget:size', frame.pill.width, 42)
+ intent.enter(1500); expect(intent.tick(1720)).toBe(true)
+ expect(widgetExpanded(latest(), false)).toMatchObject({ width: 340, height: 390 })
+ expect(latest().open.width).toBe(340)
+ expect(Math.min(390, latest().open.height)).toBe(390)
+ expect(latest().bounds.width).toBeGreaterThanOrEqual(340)
+ expect(latest().bounds.height).toBeGreaterThanOrEqual(390)
+ })
it('crosses to a negative-coordinate display with successive small deltas', () => {
const before = widget.snapshot().bounds!
send('widget:drag', -before.x, 0)