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: Command-J on the Ask page keeps your place

Eric Brownrout97db65497c3f
diff --git a/app/e2e/askContext.spec.ts b/app/e2e/askContext.spec.ts
index 9051a466..34bae293 100644
--- a/app/e2e/askContext.spec.ts
+++ b/app/e2e/askContext.spec.ts
@@ -48,8 +48,11 @@ test('Ask shares meeting history and drafts, and Command-J starts the right cont
await expect(page.locator('.chat-answer-scope')).toHaveText('Searched Design review')
await page.reload()
await expect(page.getByTestId('chat-page-input')).toHaveValue('Keep this question for later')
+ await page.getByTestId('chat-recent').focus()
await page.keyboard.press('Meta+j')
- await expect(page.getByTestId('chat-page-turn')).toHaveCount(0)
+ await expect(page.getByTestId('chat-page-input')).toBeFocused()
+ await expect(page.getByTestId('chat-page-input')).toHaveValue('Keep this question for later')
+ await expect(page.getByTestId('chat-page-turn')).toHaveCount(1)
await expect(page.getByTestId('ask-scope')).toHaveText('All meetings')
const title = await page.evaluate(id => window.yogurt.meetings.get(id).then(v => v!.title), meeting)
await page.getByTestId('chat-page-input').fill(`@${title}`)
@@ -211,6 +214,12 @@ test('Ask has soft thread edges, compact bubbles, and expands the same reading p
await expect(page.getByTestId('chat-page-input')).toHaveValue('Keep my draft')
await expect(page.getByTestId('chat-page-turn')).toHaveCount(30)
await expect.poll(() => page.locator('.ask-thread').evaluate(el => el.scrollTop)).toBeCloseTo(200, 0)
+ await page.getByTestId('chat-recent').focus()
+ await page.keyboard.press('Meta+j')
+ await expect(page.getByTestId('chat-page-input')).toBeFocused()
+ await expect(page.getByTestId('chat-page-input')).toHaveValue('Keep my draft')
+ await expect(page.getByTestId('ask-scope')).toContainText(view!.chips[0].title)
+ expect(await page.locator('.ask-thread').evaluate(el => el.scrollTop)).toBeCloseTo(200, 0)
expect(await page.evaluate(() => window.yogurt.nav.current())).toBe(`/chat/${view!.id}`)
await page.getByTestId('chat-latest').click()
await expect(page.getByTestId('chat-latest')).toHaveCount(0)
diff --git a/app/e2e/chat.spec.ts b/app/e2e/chat.spec.ts
index dbac3c2c..d383bc64 100644
--- a/app/e2e/chat.spec.ts
+++ b/app/e2e/chat.spec.ts
@@ -450,8 +450,22 @@ for (const width of [1100, 720]) test(`Command-J toggles Ask from any focus at $
await fake(app, 'go', '')
await expect(page.getByTestId('home')).toBeVisible()
await page.keyboard.press('Meta+j')
- await expect(page.locator('#library-question')).toBeVisible()
- await page.keyboard.press('Meta+j')
- await expect(page.locator('#library-question')).toBeFocused()
+ await expect(page.getByTestId('chat-page-input')).toBeEditable()
+ await expect.poll(() => page.evaluate(() => window.yogurt.nav.current())).toMatch(/^\/chat\/.+/)
+
+ await page.getByTestId('nav-chat').click()
+ await expect(page.getByTestId('chat-empty')).toBeVisible()
+ const field = page.locator('textarea#library-question')
+ await field.fill('Keep this draft')
+ await field.evaluate((el: HTMLTextAreaElement) => el.setSelectionRange(5, 9))
+ for (const invoke of [() => page.keyboard.press('Meta+j'), () => fake(app, 'trayClick', 'ask')]) {
+ await page.getByTestId('chat-recent').focus()
+ await invoke()
+ await expect(field).toBeFocused()
+ await page.keyboard.press('Meta+j')
+ await expect(field).toHaveValue('Keep this draft')
+ expect(await field.evaluate((el: HTMLTextAreaElement) => [el.selectionStart, el.selectionEnd])).toEqual([5, 9])
+ expect(await page.evaluate(() => window.yogurt.nav.current())).toBe('/chat')
+ }
} finally { await app.close() }
})
diff --git a/app/src/renderer/src/components/Workspace.tsx b/app/src/renderer/src/components/Workspace.tsx
index 0a0a61f8..1bca717a 100644
--- a/app/src/renderer/src/components/Workspace.tsx
+++ b/app/src/renderer/src/components/Workspace.tsx
@@ -39,8 +39,9 @@ export function Workspace({ route, meeting, folders, go, back, forward, search,
const ask = () => {
if (document.querySelector('[aria-modal="true"]:not([data-testid="chat-panel"]), [role="alertdialog"]')) return
const target = askDestination(route)
- if (target.panel) document.getElementById('meeting-ask')?.click()
- else void window.yogurt.conversations.current(target.chips, target.fresh).then(id => go(`/chat/${id}`)).catch(error => {
+ if (target.kind === 'focus') document.getElementById('library-question')?.focus({ preventScroll: true })
+ else if (target.kind === 'panel') document.getElementById('meeting-ask')?.click()
+ else void window.yogurt.conversations.current(target.chips).then(id => go(`/chat/${id}`)).catch(error => {
console.error('Opening Ask failed', error)
toasts.add({ title: t("Yogurt couldn't make that change. Try again.") })
})
diff --git a/app/src/shared/askContext.ts b/app/src/shared/askContext.ts
index 1ff55955..d8b07dd8 100644
--- a/app/src/shared/askContext.ts
+++ b/app/src/shared/askContext.ts
@@ -14,10 +14,12 @@ export function chipScope(chips: ContextChip[], meeting: (id: string) => boolean
if (!chips.length) return undefined
return [...new Set(chips.flatMap(c => c.kind === 'meeting' ? meeting(c.id) ? [c.id] : [] : folder(c.id).filter(meeting)))]
}
-export function askDestination(route: string): { panel: boolean; fresh: boolean; chips: ContextChip[] } {
- if (route.startsWith('/note/')) return { panel: true, fresh: false, chips: [{ kind: 'meeting', id: route.slice(6) }] }
- if (route.startsWith('/folder/')) return { panel: false, fresh: false, chips: [{ kind: 'folder', id: route.slice(8) }] }
- return { panel: false, fresh: route === '/chat' || route.startsWith('/chat/'), chips: [] }
+type AskDestination = { kind: 'focus' } | { kind: 'panel' } | { kind: 'conversation'; chips: ContextChip[] }
+export function askDestination(route: string): AskDestination {
+ if (route === '/chat' || route.startsWith('/chat/')) return { kind: 'focus' }
+ if (route.startsWith('/note/')) return { kind: 'panel' }
+ if (route.startsWith('/folder/')) return { kind: 'conversation', chips: [{ kind: 'folder', id: route.slice(8) }] }
+ return { kind: 'conversation', chips: [] }
}
export function mentionAt(value: string, caret: number): { start: number; end: number; query: string } | undefined {
diff --git a/app/test/askContext.test.ts b/app/test/askContext.test.ts
index 74582908..a55e4d1f 100644
--- a/app/test/askContext.test.ts
+++ b/app/test/askContext.test.ts
@@ -176,11 +176,11 @@ it('unions live folder membership without duplicates or widening an empty/delete
expect(chipScope([], () => true, () => [])).toBeUndefined()
})
-it('routes Command-J to the current note/folder/global conversation, and a fresh global one from Ask', () => {
- expect(askDestination('/note/n')).toEqual({ panel: true, fresh: false, chips: [{ kind: 'meeting', id: 'n' }] })
- expect(askDestination('/folder/f')).toEqual({ panel: false, fresh: false, chips: [{ kind: 'folder', id: 'f' }] })
- for (const route of ['', '/trash', '/settings']) expect(askDestination(route)).toEqual({ panel: false, fresh: false, chips: [] })
- for (const route of ['/chat', '/chat/c']) expect(askDestination(route)).toEqual({ panel: false, fresh: true, chips: [] })
+it('focuses the composer on both Ask routes and opens Ask in context elsewhere', () => {
+ for (const route of ['/chat', '/chat/c']) expect(askDestination(route)).toEqual({ kind: 'focus' })
+ expect(askDestination('/note/n')).toEqual({ kind: 'panel' })
+ expect(askDestination('/folder/f')).toEqual({ kind: 'conversation', chips: [{ kind: 'folder', id: 'f' }] })
+ for (const route of ['', '/trash', '/settings']) expect(askDestination(route)).toEqual({ kind: 'conversation', chips: [] })
})
it('finds a mention at the caret without treating emails as chips or consuming text after the caret', () => {
diff --git a/app/test/motionInteractions.test.ts b/app/test/motionInteractions.test.ts
index 606334ad..cea40cfe 100644
--- a/app/test/motionInteractions.test.ts
+++ b/app/test/motionInteractions.test.ts
@@ -468,6 +468,21 @@ it('keeps row glyphs stable across typing, filters, and keyboard selection witho
expect([...icons.keys()]).toEqual(expect.arrayContaining(['search-m1', 'search-ask', 'command-agenda-date', 'command-folder-f1', 'command-theme-light', 'search-person-email%3Aparticipant%40example.test']))
})
+it.each(['/chat', '/chat/saved'])('focuses Ask without a conversation lookup or navigation on %s', async route => {
+ const current = vi.fn().mockResolvedValue('other'), go = vi.fn(), focus = vi.fn()
+ const keydown = vi.fn(), onAsk = vi.fn(), takeAsk = vi.fn().mockResolvedValueOnce(false).mockResolvedValueOnce(true)
+ vi.stubGlobal('window', { addEventListener: keydown, yogurt: { os: 'win32', conversations: { current }, nav: { onAsk, takeAsk } } })
+ vi.stubGlobal('document', { querySelector: () => null, getElementById: (id: string) => id === 'library-question' ? { focus } : null })
+ renderer(() => Workspace({ route, go, search() {}, collapsed: false, sidebarMotion: false, toggleSidebar() {}, children: null }))()
+ vi.mocked(useEffect).mock.lastCall![0]()
+ keydown.mock.calls[0][1]({ code: 'KeyJ', ctrlKey: true, preventDefault() {} })
+ onAsk.mock.calls[0][0]()
+ await Promise.resolve()
+ expect(focus.mock.calls).toEqual([[{ preventScroll: true }], [{ preventScroll: true }]])
+ expect(current).not.toHaveBeenCalled()
+ expect(go).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() {},