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.

Motion: the sidebar's contents keep pace when it collapses, ⌘K holds still under a resting mouse, and ⌘J toggles

Eric Brownroutaca7d04f7895
diff --git a/app/e2e/chat.spec.ts b/app/e2e/chat.spec.ts
index 158be9a0..7c5512aa 100644
--- a/app/e2e/chat.spec.ts
+++ b/app/e2e/chat.spec.ts
@@ -54,9 +54,13 @@ test('Ask opens one contained panel, keeps the note usable, and restores focus w
await expect(trigger).toBeFocused()
await trigger.click()
await expect(input).toHaveValue('A question to come back to')
- // Command-J resumes/focuses this conversation; Escape closes it.
+ // Command-J toggles this conversation without losing its draft.
+ await page.keyboard.press('Meta+j')
+ await expect(panel).toHaveCount(0)
+ await expect(trigger).toBeFocused()
await page.keyboard.press('Meta+j')
await expect(input).toBeFocused()
+ await expect(input).toHaveValue('A question to come back to')
await expect(panel).toBeVisible()
await page.keyboard.press('Escape')
await expect(trigger).toBeFocused()
@@ -362,7 +366,7 @@ test('Ask grows from its button identically for either trigger and keeps typing
} finally { await app.close() }
})
-for (const width of [1100, 720]) test(`Command-J focuses Ask from any focus at ${width}px and still opens Chat elsewhere`, async () => {
+for (const width of [1100, 720]) test(`Command-J toggles Ask from any focus at ${width}px and still opens Chat elsewhere`, async () => {
const { app, page } = await launch()
try {
await app.evaluate(({ BrowserWindow }, width) => BrowserWindow.getAllWindows()[0].setSize(width, 760), width)
@@ -374,18 +378,20 @@ for (const width of [1100, 720]) test(`Command-J focuses Ask from any focus at $
await expect(input).toBeFocused()
await input.fill('Keep my draft')
await page.keyboard.press('Meta+j')
- await expect(panel).toBeVisible()
- await expect(input).toBeFocused()
- await page.keyboard.press('Escape')
+ await expect(panel).toHaveCount(0)
await expect(trigger).toBeFocused()
await page.keyboard.press('Meta+j')
await expect(input).toHaveValue('Keep my draft')
await page.getByTestId('chat-menu').focus()
await page.keyboard.press('Meta+j')
+ await expect(panel).toHaveCount(0)
+ await page.keyboard.press('Meta+j')
await expect(input).toBeFocused()
if (width === 1100) {
await page.getByTestId('note-title').click()
await page.keyboard.press('Meta+j')
+ await expect(panel).toHaveCount(0)
+ await page.keyboard.press('Meta+j')
await expect(input).toBeFocused()
}
await page.keyboard.press('Escape')
diff --git a/app/src/renderer/src/components/Chat.tsx b/app/src/renderer/src/components/Chat.tsx
index 19215918..8e4928af 100644
--- a/app/src/renderer/src/components/Chat.tsx
+++ b/app/src/renderer/src/components/Chat.tsx
@@ -127,6 +127,7 @@ export function Ask({ id, recording, anchor, onSource }: { id: string; recording
return <>
<button id="meeting-ask" ref={trigger} data-testid="chat-open" className="chat-trigger" type="button" aria-expanded={open} aria-controls="meeting-chat"
title={onMac() ? t('Ask Yogurt (⌘J)') : `${t('Ask Yogurt')} (${keys('⌘J')})`} onClick={() => {
+ if (open && !closing.current) { close(); return }
// Programmatic and pointer opens share the same anchored motion.
if (closing.current) { closing.current = false; morph(true) }
animateOpen.current = true; setError(false); setOpen(true)
diff --git a/app/src/renderer/src/components/Search.tsx b/app/src/renderer/src/components/Search.tsx
index 368ec4b0..1f7e6260 100644
--- a/app/src/renderer/src/components/Search.tsx
+++ b/app/src/renderer/src/components/Search.tsx
@@ -2,7 +2,6 @@ import { Dialog } from '@animate-ui/react/primitives/base-ui/dialog'
import { MotionPopup } from './MotionPopup'
import { motion } from '../motion'
import { FolderGlyph } from './FolderAppearance'
-import { Swap } from './Swap'
import { Fragment, useEffect, useRef, useState } from 'react'
import { AudioLines, CalendarDays, FileText, FolderIcon, Keyboard, LogIn, MessageCircle, Monitor, Moon, PanelLeft, Search as SearchIcon, Settings, Sun, Trash2, UserRound, X } from 'lucide-react'
import type { SearchResult, SnippetPart, Folder, Person } from '../../../shared/types'
@@ -63,6 +62,13 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
}, [])
const seq = useRef(0)
const list = useRef<HTMLUListElement>(null)
+ const scrollSelection = useRef(false)
+ const hover = (e: React.MouseEvent, index: number) => {
+ // Chromium can send a stationary mousemove when the popup or its rows move under the pointer.
+ if (!e.movementX && !e.movementY) return
+ scrollSelection.current = false
+ setActive(index)
+ }
useEffect(() => {
const mine = ++seq.current
@@ -116,7 +122,7 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
useEffect(() => {
defaultSelection.current = q.trim() && rows[palette.active] ? searchSelectionKey(rows[palette.active]) : undefined
})
- const intent = selected?.kind === 'command' ? `command:${selected.command.id}` : selected?.kind === 'ask' ? 'ask' : selected?.kind === 'person' ? 'person' : 'search'
+ const intent = !q.trim() && active === null ? 'search' : selected?.kind === 'command' ? `command:${selected.command.id}` : selected?.kind === 'ask' ? 'ask' : selected?.kind === 'person' ? 'person' : 'search'
const dateLabel = parsed.date && searchDateLabel(parsed.date)
const clearDate = () => { if (parsed.dateSpan) setQ(removeSearchSpan(q, parsed.dateSpan)); setActive(null); input.current?.focus() }
const clearPerson = (person: Person) => {
@@ -133,6 +139,7 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
setQ(completeSearchPerson(q, match)); setActive(null); input.current?.focus()
}
useEffect(() => {
+ if (!scrollSelection.current) return
list.current?.querySelector<HTMLElement>('[aria-selected="true"]')?.scrollIntoView({ block: 'nearest' })
}, [activeIndex, results])
const runCommand = async (command: typeof allCommands[number]) => {
@@ -156,8 +163,8 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
const onKeyDown = (e: React.KeyboardEvent) => {
if (e.nativeEvent.isComposing) return
if ((e.key === 'Enter' || e.key === ' ') && e.target instanceof HTMLButtonElement) return
- if (e.key === 'ArrowDown') { e.preventDefault(); setActive(Math.min(Math.max(0, count - 1), activeIndex + 1)) }
- else if (e.key === 'ArrowUp') { e.preventDefault(); setActive(Math.max(0, activeIndex - 1)) }
+ if (e.key === 'ArrowDown') { e.preventDefault(); scrollSelection.current = true; setActive(Math.min(Math.max(0, count - 1), activeIndex + 1)) }
+ else if (e.key === 'ArrowUp') { e.preventDefault(); scrollSelection.current = true; setActive(Math.max(0, activeIndex - 1)) }
else if (e.key === 'Backspace' && (parsed.date || selectedPeople.length) && e.target === input.current && input.current?.selectionStart === 0 && input.current.selectionEnd === 0) { e.preventDefault(); if (parsed.date) clearDate(); else clearPerson(selectedPeople[selectedPeople.length - 1]) }
else if (e.key === 'Enter') { e.preventDefault(); if (command(e)) { if (q.trim()) void ask(q.trim()) } else enter() }
else if (e.key === 'Escape') { e.preventDefault(); setOpen(false) }
@@ -201,14 +208,14 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
className="search-panel flex max-h-[74vh] w-full max-w-[640px] flex-col overflow-hidden rounded-2xl border border-line bg-float">
<div className="search-header">
<div className="search-input-row">
- <span data-testid="search-intent-icon" data-icon={intent} className="flex shrink-0" aria-hidden="true">
- <Swap show={intent} className="search-intent text-muted" options={{
+ <span data-testid="search-intent-icon" data-icon={intent} className="flex shrink-0 text-muted" aria-hidden="true">
+ {{
search: <SearchIcon size={24} strokeWidth={1.6} />,
ask: <MessageCircle size={24} strokeWidth={1.6} />,
person: <UserRound size={24} strokeWidth={1.6} />,
...Object.fromEntries(allCommands.map(c => [`command:${c.id}`, 'folder' in c
? <FolderGlyph appearance={c.folder} size={24} /> : <c.Icon size={24} strokeWidth={1.6} />])),
- }} />
+ }[intent]}
</span>
<div className="search-field">
<div ref={highlight} className="search-input-highlight" aria-hidden="true">
@@ -216,7 +223,7 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
? <mark key={i} data-testid={`search-${part.kind}-highlight`}>{part.text}</mark> : <Fragment key={i}>{part.text}</Fragment>)}</span>
</div>
<input
- data-testid="search-input" ref={input} autoFocus value={q} onChange={(e) => { setQ(e.target.value); setActive(null); setError(false) }} onScroll={syncHighlight}
+ data-testid="search-input" ref={input} autoFocus value={q} onChange={(e) => { scrollSelection.current = true; setQ(e.target.value); setActive(null); setError(false) }} onScroll={syncHighlight}
placeholder={t('Search meetings or run a command…')} aria-label={t('Search')} spellCheck={false}
role="combobox" aria-expanded="true" aria-controls="search-results" aria-activedescendant={selected?.kind === 'meeting' ? `search-${selected.meeting.meetingId}` : selected?.kind === 'command' ? `command-${selected.command.id}` : selected?.kind === 'person' ? `search-person-${encodeURIComponent(searchPersonKey(selected.person))}` : selected ? 'search-ask' : undefined}
/>
@@ -237,13 +244,13 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
</span>}
</div>}
</div>
- <ul ref={list} id="search-results" role="listbox" aria-label={t('Results')} aria-busy={running || !settled} className="min-h-0 flex-1 overflow-y-auto px-2.5 pb-3">
+ <ul ref={list} id="search-results" role="listbox" aria-label={t('Results')} aria-busy={running || !settled} className="min-h-0 flex-1 overflow-y-auto [overflow-anchor:none] px-2.5 pb-3">
{rows.map((row, i) => {
const previous = rows[i - 1]
if (row.kind === 'ask') return <Fragment key="ask">
<li role="presentation" className="command-section">{t('Ask')}</li>
<li id="search-ask" data-testid="search-ask" role="option" aria-selected={activeIndex === i} aria-disabled={running}
- onMouseMove={() => setActive(i)} onClick={() => void ask(row.query)} className="search-row command-row">
+ onMouseMove={(e) => hover(e, i)} onClick={() => void ask(row.query)} className="search-row command-row">
<MessageCircle size={16} strokeWidth={1.75} aria-hidden="true" />
<span className="shrink-0 text-accent">{t('Ask Yogurt')}</span><span className="command-label truncate">{row.query}</span>
<kbd className="search-key search-return" aria-hidden="true">↵</kbd>
@@ -252,7 +259,7 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
if (row.kind === 'person') return <Fragment key={searchPersonKey(row.person)}>
{previous?.kind !== 'person' && <li role="presentation" className="command-section">{t('People')}</li>}
<li id={`search-person-${encodeURIComponent(searchPersonKey(row.person))}`} data-testid="search-person" role="option" aria-selected={activeIndex === i}
- onMouseMove={() => setActive(i)} onClick={() => pickPerson(row)} className="search-row command-row">
+ onMouseMove={(e) => hover(e, i)} onClick={() => pickPerson(row)} className="search-row command-row">
<UserRound size={16} strokeWidth={1.75} aria-hidden="true" />
<span className="command-label">{t('Meetings with {name}', { name: row.person.name || row.person.email || '' })}</span>
{row.person.email && <span className="search-metadata truncate">{row.person.email}</span>}
@@ -265,7 +272,7 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
{previous?.kind !== 'meeting' && <li role="presentation" className="command-section">{typed || filtered ? t('Meetings') : t('Recent meetings')}</li>}
<li
id={`search-${r.meetingId}`} data-testid="search-result" role="option" aria-selected={i === activeIndex}
- onMouseMove={() => setActive(i)} onClick={() => onOpen(r.meetingId)}
+ onMouseMove={(e) => hover(e, i)} onClick={() => onOpen(r.meetingId)}
className="search-row search-meeting"
>
<span className="search-result-icon"><FileText size={17} strokeWidth={1.6} aria-hidden="true" /></span>
@@ -283,7 +290,7 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
return <li key={c.id} role="presentation">
{(previous?.kind !== 'command' || previous.command.group !== c.group) && <p className="command-section">{c.group}</p>}
<div id={`command-${c.id}`} data-testid={`command-${c.id}`} role="option" aria-selected={activeIndex === i} aria-current={current || undefined} aria-disabled={running}
- onMouseMove={() => setActive(i)} onClick={() => void runCommand(c)} className="search-row command-row">
+ onMouseMove={(e) => hover(e, i)} onClick={() => void runCommand(c)} className="search-row command-row">
{'folder' in c ? <FolderGlyph appearance={c.folder} /> : <c.Icon size={16} strokeWidth={1.75} aria-hidden="true" />}
<span className="command-label">{c.label}{current && <span aria-hidden="true"> ✓</span>}</span>{'shortcut' in c && <kbd className="search-key search-shortcut">{c.shortcut}</kbd>}
<kbd className="search-key search-return" aria-hidden="true">↵</kbd>
diff --git a/app/src/renderer/src/components/Workspace.tsx b/app/src/renderer/src/components/Workspace.tsx
index 3e9135c7..1817b685 100644
--- a/app/src/renderer/src/components/Workspace.tsx
+++ b/app/src/renderer/src/components/Workspace.tsx
@@ -46,7 +46,7 @@ export function Workspace({ route, meeting, folders, go, back, forward, search,
const key = (e: KeyboardEvent) => {
if (!command(e) || (onMac() && e.ctrlKey) || e.altKey || e.shiftKey || e.code !== 'KeyJ' || e.defaultPrevented) return
e.preventDefault()
- ask()
+ if (!e.repeat && !e.isComposing) ask()
}
const fromMenu = () => { void window.yogurt.nav.takeAsk().then(pending => { if (pending) ask() }) }
const off = window.yogurt.nav.onAsk(fromMenu)
diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.css
index d7211465..09b8c84a 100644
--- a/app/src/renderer/src/styles.css
+++ b/app/src/renderer/src/styles.css
@@ -417,9 +417,6 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:v
.search-panel { position:fixed;top:12vh;left:50%;translate:-50% 0;z-index:101;width:min(640px,calc(100vw - 32px));outline:none;height:min(560px,74vh);box-shadow:var(--shadow);border-radius:12px; }
.search-header { flex:none;border-bottom:1px solid var(--line); }
.search-input-row { display:flex;align-items:center;gap:14px;padding-inline:22px; }
-.swap.search-intent { width:24px;height:24px; }
-.swap.search-intent>* { filter:none;transform:none;transition:opacity var(--dur-micro) var(--ease-out); }
-@media (prefers-reduced-motion:reduce) { .swap.search-intent>* { transition:opacity var(--dur-micro) var(--ease-out); } }
.search-field { position:relative;min-width:0;flex:1;font-size:22px;font-weight:500;line-height:30px;letter-spacing:-.02em; }
.search-field input { position:relative;display:block;width:100%;min-width:0;height:76px;padding:23px 0;border:0;background:transparent;color:var(--ink);caret-color:var(--accent);font:inherit;letter-spacing:inherit;outline:none; }
.search-field input::placeholder { color:var(--muted);font-weight:400; }
diff --git a/app/src/renderer/src/workspace.css b/app/src/renderer/src/workspace.css
index 0506c573..77faa8a7 100644
--- a/app/src/renderer/src/workspace.css
+++ b/app/src/renderer/src/workspace.css
@@ -23,8 +23,10 @@
.sidebar-collapsed :is(.workspace-sidebar,.workspace-sidebar-gap) { width:56px; }
.workspace-sidebar-gap { flex:none; }
.workspace-sidebar-inner { display:flex;flex-direction:column;height:100%;min-height:0; }
+/* The page adopts its final width immediately; collapsed controls must not trail across it. */
+.sidebar-collapsed .workspace-sidebar-inner { width:55px; }
.workspace-sidebar .workspace-search>svg { flex:none; }
-.workspace-sidebar .workspace-nav>span:not(.folder-glyph),.workspace-sidebar .workspace-nav>small,.workspace-search>span,.workspace-search>kbd,.workspace-folder-label { transition:opacity var(--dur-micro) var(--ease-out); }
+.workspace-sidebar .workspace-nav>span:not(.folder-glyph),.workspace-sidebar .workspace-nav>small,.workspace-search>span,.workspace-search>kbd,.workspace-folder-label { transition:opacity var(--dur-surface) var(--ease-out); }
.sidebar-collapsed .workspace-nav>span:not(.folder-glyph),.sidebar-collapsed .workspace-nav>small,.sidebar-collapsed .workspace-search>span,.sidebar-collapsed .workspace-search>kbd,.sidebar-collapsed .workspace-folder-label { opacity:0;pointer-events:none; }
.sidebar-collapsed .workspace-nav { padding-inline:10px;gap:0; }
.sidebar-collapsed .workspace-nav>span:not(.folder-glyph),.sidebar-collapsed .workspace-search>span,.sidebar-collapsed .workspace-search>kbd { width:0;flex:none; }
@@ -36,10 +38,10 @@
.workspace[data-sidebar-motion=true] .workspace-wordmark { transition:width var(--dur-surface) var(--ease-out); }
.workspace[data-sidebar-motion=true] .workspace-brand { transition:padding-inline var(--dur-surface) var(--ease-out); }
.workspace-folder-label { height:16px;white-space:nowrap;overflow:hidden; }
-.workspace[data-sidebar-motion=true] .workspace-folder-label { transition:height var(--dur-surface) var(--ease-out),margin var(--dur-surface) var(--ease-out),opacity var(--dur-micro) var(--ease-out); }
+.workspace[data-sidebar-motion=true] .workspace-folder-label { transition:height var(--dur-surface) var(--ease-out),margin var(--dur-surface) var(--ease-out),opacity var(--dur-surface) var(--ease-out); }
.sidebar-collapsed .workspace-folder-label { height:0;margin-block:18px; }
.workspace-brand { gap:0; }
-.workspace[data-sidebar-motion=false] :is(.workspace-nav>span,.workspace-nav>small,.workspace-search>span,.workspace-search>kbd,.workspace-folder-label,.workspace-wordmark,.workspace-brand) { transition:none; }
+.workspace:is([data-sidebar-motion=false],.sidebar-collapsed) :is(.workspace-nav>span,.workspace-nav>small,.workspace-search>span,.workspace-search>kbd,.workspace-folder-label,.workspace-wordmark,.workspace-brand) { transition:none; }
@media (prefers-reduced-motion:reduce) {
.workspace-sidebar :is(span,small,kbd),.workspace-folder-label,.workspace-toolbar,.workspace-brand { transition:none!important;filter:none!important; }
}
diff --git a/app/test/motion.test.ts b/app/test/motion.test.ts
index d0e167b6..c70d54d2 100644
--- a/app/test/motion.test.ts
+++ b/app/test/motion.test.ts
@@ -116,3 +116,20 @@ it('keeps the anchored panel curve monotonic with a shorter close', () => {
previous = progress
}
})
+
+it('collapses sidebar controls immediately and expands children on the sidebar duration and curve', () => {
+ const css = readFileSync(new URL('../src/renderer/src/workspace.css', import.meta.url), 'utf8')
+ const source = readFileSync(new URL('../src/renderer/src/components/Workspace.tsx', import.meta.url), 'utf8')
+ expect(source).toContain('duration: sidebarMotion ? motion.surface / 1000 : 0, ease: motion.out')
+ // The page snaps to its final layout: the search field must not keep the outgoing sidebar width.
+ expect(css).toContain('.sidebar-collapsed .workspace-sidebar-inner { width:55px; }')
+ expect(css).toContain('.workspace:is([data-sidebar-motion=false],.sidebar-collapsed) :is(.workspace-nav>span,.workspace-nav>small,.workspace-search>span,.workspace-search>kbd,.workspace-folder-label,.workspace-wordmark,.workspace-brand) { transition:none; }')
+ const children = css.slice(css.indexOf('.workspace-sidebar .workspace-nav>span'), css.indexOf('.sidebar-titlebar'))
+ for (const transition of children.matchAll(/transition:([^;]+);/g)) {
+ if (transition[1] === 'none' || transition[1] === 'none!important') continue
+ expect(transition[1]).not.toContain('--dur-micro')
+ for (const property of transition[1].split(',')) expect(property).toMatch(/var\(--dur-surface\) var\(--ease-out\)$/)
+ }
+ expect(children).toContain('@media (prefers-reduced-motion:reduce)')
+ expect(children).toContain('transition:none!important')
+})
diff --git a/app/test/motionInteractions.test.ts b/app/test/motionInteractions.test.ts
new file mode 100644
index 00000000..902dd0a6
--- /dev/null
+++ b/app/test/motionInteractions.test.ts
@@ -0,0 +1,109 @@
+import { afterEach, expect, it, vi } from 'vitest'
+import { useEffect, useRef, useState, type ReactElement, type ReactNode } from 'react'
+import { Search } from '../src/renderer/src/components/Search'
+import { Ask } from '../src/renderer/src/components/Chat'
+import { Workspace } from '../src/renderer/src/components/Workspace'
+
+vi.mock('react', async original => ({
+ ...await original<typeof import('react')>(), useState: vi.fn(), useRef: vi.fn(), useEffect: vi.fn(), useLayoutEffect: vi.fn(),
+}))
+afterEach(() => { vi.unstubAllGlobals(); vi.clearAllMocks() })
+
+// Exercise the component's handlers and state without starting Electron or a browser.
+function renderer(component: () => ReactNode) {
+ const states: unknown[] = [], refs: { current: unknown }[] = []
+ return () => {
+ let state = 0, ref = 0
+ vi.mocked(useState).mockImplementation((initial?: unknown): [unknown, (next: unknown) => void] => {
+ const i = state++
+ if (!(i in states)) states[i] = typeof initial === 'function' ? initial() : initial
+ return [states[i], next => { states[i] = typeof next === 'function' ? next(states[i]) : next }]
+ })
+ vi.mocked(useRef).mockImplementation(initial => refs[ref++] ??= { current: initial })
+ vi.mocked(useEffect).mockClear()
+ return component()
+ }
+}
+function find(node: ReactNode, testId: string): ReactElement<any> {
+ const visit = (value: ReactNode): ReactElement<any> | undefined => {
+ if (Array.isArray(value)) return value.map(visit).find(Boolean)
+ if (!value || typeof value !== 'object' || !('props' in value)) return
+ const element = value as ReactElement<any>
+ if (element.props['data-testid'] === testId || element.props.id === testId) return element
+ return visit(element.props.children)
+ }
+ const result = visit(node)
+ if (!result) throw new Error(`Missing ${testId}`)
+ return result
+}
+
+it('keeps initial search results still, ignores stationary hover, and scrolls only for keyboard selection', async () => {
+ const meetings = [{ meetingId: 'm1', title: 'Recent meeting', startedAt: 1000, parts: [] }]
+ vi.stubGlobal('document', { activeElement: null })
+ vi.stubGlobal('HTMLButtonElement', class {})
+ vi.stubGlobal('window', { yogurt: { search: { query: vi.fn().mockResolvedValue(meetings) } } })
+ const render = renderer(() => Search({ onOpen() {}, onNavigate() {}, onSettingsChange() {}, onShortcuts() {}, onClose() {}, sidebarCollapsed: false, onToggleSidebar() {} }))
+ const scrollIntoView = vi.fn()
+ const scroll = () => { vi.mocked(useEffect).mock.lastCall![0]() }
+ let tree = render()
+ find(tree, 'search-results').props.ref.current = { querySelector: () => ({ scrollIntoView }) }
+ expect(find(tree, 'search-results').props.className).toContain('[overflow-anchor:none]')
+ expect(find(tree, 'search-intent-icon').props['data-icon']).toBe('search')
+ scroll()
+ expect(scrollIntoView).not.toHaveBeenCalled()
+ // Recent meetings arrive after the initial commands, without scrolling the commands back into view.
+ vi.mocked(useEffect).mock.calls.find(([, deps]) => deps?.length === 6)![0]()
+ await Promise.resolve()
+ tree = render(); scroll()
+ expect(find(tree, 'search-result').props['aria-selected']).toBe(true)
+ expect(scrollIntoView).not.toHaveBeenCalled()
+ find(tree, 'command-meetings').props.onMouseMove({ movementX: 0, movementY: 0 })
+ tree = render(); scroll()
+ expect(find(tree, 'search-result').props['aria-selected']).toBe(true)
+ expect(find(tree, 'search-intent-icon').props['data-icon']).toBe('search')
+ find(tree, 'command-meetings').props.onMouseMove({ movementX: 1, movementY: 0 })
+ tree = render(); scroll()
+ expect(find(tree, 'command-meetings').props['aria-selected']).toBe(true)
+ expect(find(tree, 'search-intent-icon').props.children.type.displayName).toBe('FileText')
+ expect(scrollIntoView).not.toHaveBeenCalled()
+ find(tree, 'search').props.onKeyDown({ key: 'ArrowDown', nativeEvent: {}, preventDefault() {} })
+ tree = render(); scroll()
+ expect(find(tree, 'command-chat').props['aria-selected']).toBe(true)
+ expect(scrollIntoView).toHaveBeenCalledWith({ block: 'nearest' })
+ scrollIntoView.mockClear()
+ find(tree, 'command-meetings').props.onMouseMove({ movementX: 0, movementY: 0 })
+ tree = render()
+ expect(find(tree, 'command-chat').props['aria-selected']).toBe(true)
+ find(tree, 'search-result').props.onMouseMove({ movementX: 0, movementY: 1 })
+ tree = render(); scroll()
+ expect(find(tree, 'search-result').props['aria-selected']).toBe(true)
+ expect(scrollIntoView).not.toHaveBeenCalled()
+})
+
+it.each(['darwin', 'win32'])('toggles the meeting panel once per shortcut press on %s', os => {
+ const listeners = new Map<string, (e: any) => void>()
+ vi.stubGlobal('window', { matchMedia: () => ({ matches: false }), addEventListener: (name: string, fn: (e: any) => void) => listeners.set(name, fn), removeEventListener() {},
+ yogurt: { os, nav: { onAsk: () => () => {}, takeAsk: vi.fn().mockResolvedValue(false) } } })
+ const renderAsk = renderer(() => Ask({ id: 'm1', recording: false, anchor: null, onSource() {} }))
+ let tree = renderAsk()
+ const click = vi.fn(() => { find(tree, 'chat-open').props.onClick(); tree = renderAsk() })
+ const querySelector = vi.fn().mockReturnValue(null)
+ vi.stubGlobal('document', { querySelector, getElementById: () => ({ click }) })
+ const renderWorkspace = renderer(() => Workspace({ route: '/note/m1', go() {}, search() {}, collapsed: false, sidebarMotion: false, toggleSidebar() {}, children: null }))
+ renderWorkspace()
+ vi.mocked(useEffect).mock.lastCall![0]()
+ const press = (extra = {}) => listeners.get('keydown')!({ code: 'KeyJ', metaKey: os === 'darwin', ctrlKey: os !== 'darwin', preventDefault() {}, ...extra })
+ expect(find(tree, 'chat-open').props['aria-expanded']).toBe(false)
+ press()
+ expect(find(tree, 'chat-open').props['aria-expanded']).toBe(true)
+ press({ repeat: true }); press({ isComposing: true }); press({ defaultPrevented: true })
+ expect(click).toHaveBeenCalledTimes(1)
+ expect(find(tree, 'chat-open').props['aria-expanded']).toBe(true)
+ press()
+ expect(find(tree, 'chat-open').props['aria-expanded']).toBe(false)
+ press()
+ expect(find(tree, 'chat-open').props['aria-expanded']).toBe(true)
+ querySelector.mockReturnValue({})
+ press()
+ expect(click).toHaveBeenCalledTimes(3)
+})