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.

Ask: the panel keeps its suggestions and box inside it while it opens

Eric Brownrout745e45cafd31
diff --git a/app/e2e/chat.spec.ts b/app/e2e/chat.spec.ts
index 4adaee11..dbac3c2c 100644
--- a/app/e2e/chat.spec.ts
+++ b/app/e2e/chat.spec.ts
@@ -381,6 +381,21 @@ test('Ask grows from its button identically for either trigger and keeps typing
expect(parseFloat(String(motion[0].frames[0].width))).toBeCloseTo((await trigger.boundingBox())!.width)
expect(String(motion[0].frames.at(-1)!.width)).toContain('100%')
expect(motion[0].frames.every(frame => !frame.transform)).toBe(true)
+ // Sample the opening itself, including the frame where the shell is still on the button.
+ const insets = await surface.evaluate(el => {
+ const shape = el.getAnimations().find(a => (a.effect as KeyframeEffect).getKeyframes().some(f => f.width))!
+ const dialog = el.closest('dialog')!.getBoundingClientRect()
+ const body = el.querySelector('.chat-panel-contents')!, composer = body.querySelector('.chat-composer')!
+ shape.pause()
+ const samples = [0, 45, 90, 180].map(ms => {
+ shape.currentTime = ms
+ const bounds = body.getBoundingClientRect()
+ return [bounds.left - dialog.left, bounds.top - dialog.top, dialog.right - bounds.right, dialog.bottom - composer.getBoundingClientRect().bottom]
+ })
+ shape.finish()
+ return samples
+ })
+ for (const sample of insets) for (const inset of sample) expect(inset).toBeCloseTo(1, 1)
await expect(page.getByTestId('chat-input')).toBeFocused()
await expect(page.locator('.chat-panel-contents')).toHaveCSS('transform', 'none')
await expect(page.locator('.chat-panel-contents')).toHaveCSS('filter', 'none')
diff --git a/app/src/renderer/src/components/Chat.tsx b/app/src/renderer/src/components/Chat.tsx
index 245f46f7..2cac1519 100644
--- a/app/src/renderer/src/components/Chat.tsx
+++ b/app/src/renderer/src/components/Chat.tsx
@@ -39,16 +39,17 @@ export function Ask({ id, recording, anchor, onSource }: { id: string; recording
void window.yogurt.conversations.current([{ kind: 'meeting', id }]).then(cid => { if (active) setConversationId(cid) }).catch(() => { if (active) setError(true) })
return () => { active = false }
}, [open, id, conversationId, attempt])
- // Ask grows out of its button and folds back into it. Only the empty surface resizes; the chat stays at its final size,
- // cropped to the surface so none of it shows outside, and the button and the surface trade places where they meet.
+ // Ask grows out of its button and folds back into it. The surface clips its own full-size conversation as its border moves.
const morph = (expand: boolean, animate = true) => {
const shell = surface.current, body = contents.current, dialog = panel.current, button = trigger.current
if (!shell || !body || !dialog || !button) return
const running = animations.current.some(animation => animation.playState === 'running')
const style = getComputedStyle(shell)
- const was = { left: style.left, top: style.top, width: style.width, height: style.height, borderRadius: style.borderRadius, shell: style.opacity,
- dialog: getComputedStyle(dialog).opacity, body: getComputedStyle(body).opacity, clip: getComputedStyle(body).clipPath, button: getComputedStyle(button).opacity }
+ const interrupted = running ? { '--ask-left': style.left, '--ask-top': style.top, width: style.width, height: style.height, borderRadius: style.borderRadius } : undefined
+ const was = { shell: style.opacity,
+ dialog: getComputedStyle(dialog).opacity, body: getComputedStyle(body).opacity, button: getComputedStyle(button).opacity }
animations.current.forEach(animation => animation.cancel()); animations.current = []
+ shell.style.overflow = ''
if (!animate) return
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
const fade = dialog.animate([{ opacity: running ? was.dialog : expand ? 0 : 1 }, { opacity: expand ? 1 : 0 }],
@@ -56,27 +57,26 @@ export function Ask({ id, recording, anchor, onSource }: { id: string; recording
animations.current = [fade]
return fade
}
- const from = button.getBoundingClientRect(), to = dialog.getBoundingClientRect(), box = body.getBoundingClientRect()
+ const from = button.getBoundingClientRect(), to = dialog.getBoundingClientRect()
const buttonRadius = parseFloat(getComputedStyle(button).borderRadius)
- const collapsed = { left: `${from.x - to.x - 1}px`, top: `${from.y - to.y - 1}px`, width: `${from.width}px`, height: `${from.height}px`, borderRadius: `${buttonRadius}px` }
- const expanded = { left: '-1px', top: '-1px', width: 'calc(100% + 2px)', height: 'calc(100% + 2px)', borderRadius: '12px' }
- const cropped = `inset(${from.top + 1 - box.top}px ${box.right - from.right + 1}px ${box.bottom - from.bottom + 1}px ${from.left + 1 - box.left}px round ${Math.max(0, buttonRadius - 1)}px)`
- const uncropped = 'inset(0px round 11px)'
- // Equal bounds/radius interpolation keeps the clip one border pixel inside the surface at every frame.
+ const collapsed = { '--ask-left': `${from.x - to.x - 1}px`, '--ask-top': `${from.y - to.y - 1}px`, width: `${from.width}px`, height: `${from.height}px`, borderRadius: `${buttonRadius}px` }
+ const expanded = { '--ask-left': '-1px', '--ask-top': '-1px', width: 'calc(100% + 2px)', height: 'calc(100% + 2px)', borderRadius: '12px' }
+ shell.style.overflow = 'clip'
const duration = expand ? timing.base : timing.askExit, easing = timing.ease, handoff = timing.micro
const shape = shell.animate([
- running ? { left: was.left, top: was.top, width: was.width, height: was.height, borderRadius: was.borderRadius } : expand ? collapsed : expanded,
+ interrupted ?? (expand ? collapsed : expanded),
expand ? expanded : collapsed,
], { duration, easing, fill: 'both' })
- const crop = body.animate([{ clipPath: running && was.clip !== 'none' ? was.clip : expand ? cropped : uncropped }, { clipPath: expand ? uncropped : cropped }],
- { duration, easing, fill: expand ? 'backwards' : 'forwards' })
const content = body.animate([{ opacity: running ? was.body : expand ? 0 : 1 }, { opacity: expand ? 1 : 0 }],
{ duration: timing.micro, easing, fill: 'both' })
// opening: the button fades as the surface appears over it; closing: the surface fades as it lands on the button
const trade = { duration: handoff, delay: expand ? 0 : duration - handoff, easing, fill: 'both' as const }
const cover = shell.animate([{ opacity: running ? was.shell : expand ? 0 : 1 }, { opacity: expand ? 1 : 0 }], trade)
const label = button.animate([{ opacity: running ? was.button : expand ? 1 : 0 }, { opacity: expand ? 0 : 1 }], trade)
- animations.current = [shape, crop, content, cover, label]
+ animations.current = [shape, content, cover, label]
+ if (expand) void shape.finished.then(() => {
+ if (animations.current.includes(shape)) shell.style.overflow = ''
+ }, () => {})
return shape
}
useEffect(() => () => animations.current.forEach((animation) => animation.cancel()), [])
@@ -119,15 +119,18 @@ export function Ask({ id, recording, anchor, onSource }: { id: string; recording
aria-labelledby="meeting-chat-title" aria-modal={narrow || undefined}
onKeyDown={event => { if (event.key === 'Escape' && !event.defaultPrevented && !panel.current?.querySelector('.citation-card:not([data-ending-style])') && !(event.target as HTMLElement).closest('[role="alertdialog"], [role="dialog"], [role="menu"]')) { event.preventDefault(); event.stopPropagation(); close() } }}
onCancel={event => { event.preventDefault(); close() }}>
- <div ref={surface} className="chat-morph-surface" aria-hidden="true" />
- <div ref={contents} className="chat-panel-contents">
- {error && <InlineError testId="chat-open-error"><span>{t("Couldn't load this conversation.")}</span>
- <button className="workspace-button" onClick={() => setAttempt(n => n + 1)}>{t('Try again')}</button>
- </InlineError>}
- <AskConversation key={`${id}/${conversationVersion}`} id={conversationId ?? ''} pendingDraftKey={`meeting/${id}`} loadError={error} panel recording={recording} onSelect={next => { setConversationId(next); setConversationVersion(version => version + 1) }} onClose={() => close()}
- onExpand={conversationId ? () => { rememberScrollPositions(); close(false); window.yogurt.nav.go(`/chat/${conversationId}`) } : undefined}
- onDeleted={() => { close(false); setConversationId(undefined); window.yogurt.nav.go('/chat') }}
- onSource={(source, match) => { close(false); onSource(source, match) }} />
+ <div className="chat-panel-viewport">
+ <div ref={surface} className="chat-morph-surface">
+ <div ref={contents} className="chat-panel-contents">
+ {error && <InlineError testId="chat-open-error"><span>{t("Couldn't load this conversation.")}</span>
+ <button className="workspace-button" onClick={() => setAttempt(n => n + 1)}>{t('Try again')}</button>
+ </InlineError>}
+ <AskConversation key={`${id}/${conversationVersion}`} id={conversationId ?? ''} pendingDraftKey={`meeting/${id}`} loadError={error} panel recording={recording} onSelect={next => { setConversationId(next); setConversationVersion(version => version + 1) }} onClose={() => close()}
+ onExpand={conversationId ? () => { rememberScrollPositions(); close(false); window.yogurt.nav.go(`/chat/${conversationId}`) } : undefined}
+ onDeleted={() => { close(false); setConversationId(undefined); window.yogurt.nav.go('/chat') }}
+ onSource={(source, match) => { close(false); onSource(source, match) }} />
+ </div>
+ </div>
</div>
</dialog>
return <>
diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.css
index 9efe431c..442c696d 100644
--- a/app/src/renderer/src/styles.css
+++ b/app/src/renderer/src/styles.css
@@ -606,8 +606,12 @@ input::selection, textarea::selection, .note-prose ::selection { background: var
.chat-panel { position:fixed;z-index:70;inset-block:auto var(--chat-bottom,72px);inset-inline:auto 24px;width:420px;max-width:calc(100% - 32px);height:min(440px,var(--chat-height,440px),calc(100dvh - var(--chat-bottom,72px) - 68px));min-height:0;max-height:none;margin:0;padding:0;overflow:visible;border:1px solid var(--line);border-radius:12px;background:var(--float);color:var(--ink);box-shadow:0 16px 48px rgb(0 0 0 / .18),0 4px 12px rgb(0 0 0 / .08); }
.chat-panel[open] { display:flex;flex-direction:column; }
.chat-panel { background:transparent;border-color:transparent;box-shadow:none; }
-.chat-morph-surface { position:absolute;inset:-1px auto auto -1px;width:calc(100% + 2px);height:calc(100% + 2px);pointer-events:none;border:1px solid var(--line);border-radius:inherit;background:var(--float);box-shadow:0 16px 48px rgb(0 0 0 / .18),0 4px 12px rgb(0 0 0 / .08); }
-.chat-panel-contents { position:relative;display:flex;flex-direction:column;flex:1;min-height:0;min-width:0; }
+/* Keep the full-size contents at the dialog origin while their parent moves and clips them. */
+@property --ask-left { syntax:"<length>";inherits:true;initial-value:-1px; }
+@property --ask-top { syntax:"<length>";inherits:true;initial-value:-1px; }
+.chat-panel-viewport { position:absolute;inset:0;container-type:size;border-radius:inherit; }
+.chat-morph-surface { position:absolute;inset:var(--ask-top) auto auto var(--ask-left);width:calc(100% + 2px);height:calc(100% + 2px);border:1px solid var(--line);border-radius:inherit;background:var(--float);box-shadow:0 16px 48px rgb(0 0 0 / .18),0 4px 12px rgb(0 0 0 / .08); }
+.chat-panel-contents { position:absolute;left:calc(-1px - var(--ask-left));top:calc(-1px - var(--ask-top));width:100cqw;height:100cqh;display:flex;flex-direction:column; }
.chat-trigger[aria-expanded=true] { opacity:0; }
[data-icon] { flex:none; }
[data-icon=Loader] { animation:icon-spin 1s linear infinite; }
diff --git a/app/test/motion.test.ts b/app/test/motion.test.ts
index 548aa73a..193c31d4 100644
--- a/app/test/motion.test.ts
+++ b/app/test/motion.test.ts
@@ -123,9 +123,17 @@ it('keeps the anchored panel curve monotonic with a shorter close', () => {
const styles = readFileSync(new URL('../src/renderer/src/styles.css', import.meta.url), 'utf8')
const surface = styles.match(/\.chat-morph-surface \{([^}]+)\}/)![1]
// Animated left/top and width/height must not be overconstrained by right/bottom in RTL.
- expect(surface).toContain('inset:-1px auto auto -1px')
+ expect(surface).toContain('inset:var(--ask-top) auto auto var(--ask-left)')
expect(surface).toContain('width:calc(100% + 2px);height:calc(100% + 2px)')
expect(surface).not.toContain('transform')
+ expect(surface).not.toContain('pointer-events:none')
+ expect(styles).toMatch(/\.chat-panel-viewport \{[^}]*container-type:size/)
+ const contents = styles.match(/\.chat-panel-contents \{([^}]+)\}/)![1]
+ expect(contents).toContain('width:100cqw;height:100cqh')
+ for (const edge of ['left', 'top']) {
+ expect(styles).toContain(`@property --ask-${edge} { syntax:"<length>";inherits:true;initial-value:-1px; }`)
+ expect(contents).toContain(`${edge}:calc(-1px - var(--ask-${edge}))`)
+ }
})
it('moves the sidebar and page together with the original timing and child layout', () => {
diff --git a/app/test/motionInteractions.test.ts b/app/test/motionInteractions.test.ts
index b8f46bf0..606334ad 100644
--- a/app/test/motionInteractions.test.ts
+++ b/app/test/motionInteractions.test.ts
@@ -496,25 +496,26 @@ it.each(['darwin', 'win32'])('toggles the meeting panel once per shortcut press
expect(click).toHaveBeenCalledTimes(3)
})
-it.each([false, true])('keeps the composer clip inside the growing shape through open, close and reversal (narrow: %s)', narrow => {
+it.each([[false, false], [true, false], [false, true], [true, true]])('clips the suggestions and composer with the moving surface (narrow %s, reduced motion %s)', async (narrow, reduced) => {
const rect = (x: number, y: number, width: number, height: number) => ({ x, y, width, height, top: y, left: x, right: x + width, bottom: y + height })
const to = narrow ? rect(16, 16, 328, 640) : rect(760, 200, 420, 440)
// Exercise a button outside the final panel, anchored on either side.
const from = narrow ? rect(20, 700, 140, 30) : rect(1040, 670, 140, 30)
- const box = rect(to.x + 1, to.y + 1, to.width - 2, to.height - 2)
const node = (bounds: ReturnType<typeof rect>, computed: Record<string, string>) => ({
- getBoundingClientRect: () => bounds, computed,
- animate: vi.fn((_frames: Keyframe[], _options: KeyframeAnimationOptions) => ({
- playState: 'running', cancel() { this.playState = 'idle' }, finished: new Promise<void>(() => {}),
- })),
+ getBoundingClientRect: () => bounds, computed, style: { overflow: '' },
+ animate: vi.fn((_frames: Keyframe[], _options: KeyframeAnimationOptions) => {
+ let finish!: () => void
+ const finished = new Promise<void>(resolve => { finish = resolve })
+ return { playState: 'running', cancel() { this.playState = 'idle' }, finished, finish }
+ }),
})
const button = { ...node(from, { opacity: '1', borderRadius: '6px' }), focus: vi.fn() }
const shell = node(to, { left: '-1px', top: '-1px', width: `${to.width}px`, height: `${to.height}px`, borderRadius: '12px', opacity: '1' })
- const body = node(box, { clipPath: 'none', opacity: '1' })
+ const body = node(to, { opacity: '1' })
const input = { focus: vi.fn() }
const dialog = { ...node(to, { opacity: '1' }), style: { setProperty() {} }, show() {}, showModal() {}, close() {}, querySelector: () => input }
const anchor = { getBoundingClientRect: () => to } as HTMLElement
- vi.stubGlobal('window', { matchMedia: (query: string) => ({ matches: query.includes('max-width') && narrow }), addEventListener() {}, removeEventListener() {} })
+ vi.stubGlobal('window', { matchMedia: (query: string) => ({ matches: query.includes('max-width') ? narrow : reduced }), addEventListener() {}, removeEventListener() {} })
vi.stubGlobal('innerHeight', 800)
vi.stubGlobal('ResizeObserver', class { observe() {} disconnect() {} })
vi.stubGlobal('getComputedStyle', (element: { computed: Record<string, string> }) => element.computed)
@@ -525,60 +526,58 @@ it.each([false, true])('keeps the composer clip inside the growing shape through
tree = render()
const panel = find(tree, 'chat-panel')
panel.props.ref.current = dialog
- panel.props.children[0].props.ref.current = shell
- panel.props.children[1].props.ref.current = body
- // The conversation mounts before its ID resolves; clipping must not postpone the editable composer.
- expect(panel.props.children[1].props.children[1].props).toMatchObject({ id: '', panel: true, pendingDraftKey: 'meeting/morph' })
+ const surface = find(panel, 'chat-morph-surface')
+ surface.props.ref.current = shell
+ find(surface, 'chat-panel-contents').props.ref.current = body
+ const conversation = find(surface, 'AskConversation')
+ expect(surface.props['aria-hidden']).toBeUndefined()
+ expect(conversation.props).toMatchObject({ id: '', panel: true, pendingDraftKey: 'meeting/morph' })
vi.mocked(useLayoutEffect).mock.lastCall![0]()
expect(input.focus).toHaveBeenCalledWith({ preventScroll: true })
+ const view = renderer(() => AskConversation(conversation.props))()
+ expect(find(view, 'chat-suggestions')).toBeDefined()
+ expect(find(view, 'chat-box').type).toBe('form')
- const lerp = (a: string, b: string, p: number) => parseFloat(a) + (parseFloat(b) - parseFloat(a)) * p
- const clip = (value: string) => {
- const n = value.match(/-?\d+(?:\.\d+)?/g)!.map(Number)
- return n.length === 2 ? [n[0], n[0], n[0], n[0], n[1]] : n
+ const toggle = () => find(tree, 'chat-open').props.onClick()
+ if (reduced) {
+ expect(dialog.animate.mock.lastCall?.[0]).toEqual([{ opacity: 0 }, { opacity: 1 }])
+ toggle()
+ expect(dialog.animate.mock.lastCall?.[0].at(-1)).toEqual({ opacity: 0 })
+ expect(dialog.animate.mock.lastCall?.[1].duration).toBe(120)
+ expect(shell.animate).not.toHaveBeenCalled()
+ expect(shell.style.overflow).toBe('')
+ return
}
- const check = (expand: boolean) => {
- const [shape, shapeTiming] = shell.animate.mock.calls.at(-2)!
- const [crop, cropTiming] = body.animate.mock.calls.at(-2)!
- expect(shapeTiming.duration).toBe(cropTiming.duration)
- expect(shapeTiming.easing).toBe(cropTiming.easing)
- expect(cropTiming.fill).toBe(expand ? 'backwards' : 'forwards')
- expect(shapeTiming.fill).toBe('both')
- expect(shape[1].width).toBe(expand ? 'calc(100% + 2px)' : `${from.width}px`)
- expect(shape.every(frame => !frame.transform)).toBe(true)
- const at = (p: number) => {
- const used = (frame: Keyframe, key: string) => String(frame[key]).includes('100%') ? `${to[key as 'width' | 'height']}px` : String(frame[key])
- const bounds = Object.fromEntries(['left', 'top', 'width', 'height', 'borderRadius'].map(key => [key, lerp(used(shape[0], key), used(shape[1], key), p)]))
- const start = clip(String(crop[0].clipPath)), end = clip(String(crop[1].clipPath))
- const inset = start.map((value, i) => value + (end[i] - value) * p)
- return { bounds, inset }
- }
- // All intermediate rectangles AND rounded corners agree, not just the two endpoints.
- for (let frame = 0; frame <= 100; frame++) {
- const { bounds, inset: [top, right, bottom, left, radius] } = at(frame / 100)
- expect(box.left + left).toBeCloseTo(to.left + 1 + bounds.left + 1)
- expect(box.top + top).toBeCloseTo(to.top + 1 + bounds.top + 1)
- expect(box.right - right).toBeCloseTo(to.left + 1 + bounds.left + bounds.width - 1)
- expect(box.bottom - bottom).toBeCloseTo(to.top + 1 + bounds.top + bounds.height - 1)
- expect(radius).toBeCloseTo(bounds.borderRadius - 1)
- }
- // A fast toggle resumes from the same on-screen bounds and radius.
- const { bounds, inset } = at(.4)
- Object.assign(shell.computed, Object.fromEntries(Object.entries(bounds).map(([key, value]) => [key, `${value}px`])))
- body.computed.clipPath = `inset(${inset.slice(0, 4).map(n => `${n}px`).join(' ')} round ${inset[4]}px)`
- }
- check(true)
- find(tree, 'chat-open').props.onClick()
- check(false)
- find(tree, 'chat-open').props.onClick()
- check(true)
- for (const element of [shell, body, button, dialog]) {
- for (const result of element.animate.mock.results) result.value.playState = 'finished'
+ const collapsed = { '--ask-left': `${from.left - to.left - 1}px`, '--ask-top': `${from.top - to.top - 1}px`, width: `${from.width}px`, height: `${from.height}px`, borderRadius: '6px' }
+ const expanded = { '--ask-left': '-1px', '--ask-top': '-1px', width: 'calc(100% + 2px)', height: 'calc(100% + 2px)', borderRadius: '12px' }
+ const shape = () => shell.animate.mock.calls.at(-2)!
+ expect(shape()[0]).toEqual([collapsed, expanded])
+ expect(shape()[1].duration).toBe(180)
+ expect(shell.style.overflow).toBe('clip')
+ expect(body.animate.mock.calls.flatMap(([frames]) => frames).every(frame => Object.keys(frame).every(k => k === 'opacity'))).toBe(true)
+ const first = shell.animate.mock.results.at(-2)!.value
+
+ // Reverse from the painted bounds. A late completion from the first opening cannot release the new clip.
+ const midway = { left: '40px', top: '80px', width: '210px', height: '140px', borderRadius: '8px' }
+ Object.assign(shell.computed, midway)
+ toggle()
+ const resumed = { '--ask-left': midway.left, '--ask-top': midway.top, width: midway.width, height: midway.height, borderRadius: midway.borderRadius }
+ expect(shape()[0]).toEqual([resumed, collapsed])
+ expect(shape()[1].duration).toBe(150)
+ toggle()
+ expect(shape()[0]).toEqual([resumed, expanded])
+ first.finish()
+ await Promise.resolve()
+ expect(shell.style.overflow).toBe('clip')
+ shell.animate.mock.results.at(-2)!.value.finish()
+ await Promise.resolve()
+ expect(shell.style.overflow).toBe('')
+ for (const el of [shell, body, button]) {
+ for (const result of el.animate.mock.results) result.value.playState = 'finished'
}
- Object.assign(shell.computed, { left: '-1px', top: '-1px', width: `${to.width}px`, height: `${to.height}px`, borderRadius: '12px' })
- body.computed.clipPath = 'none'
- find(tree, 'chat-open').props.onClick()
- check(false)
+ toggle()
+ expect(shape()[0]).toEqual([expanded, collapsed])
+ expect(shell.style.overflow).toBe('clip')
})