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.

⌘K: find meetings by date and person, rank commands first, and keep Ask one key away

Eric Brownrout5b6afc11675e
diff --git a/app/e2e/askNaming.spec.ts b/app/e2e/askNaming.spec.ts
index 0f20da68..4330a617 100644
--- a/app/e2e/askNaming.spec.ts
+++ b/app/e2e/askNaming.spec.ts
@@ -31,7 +31,9 @@ for (const locale of ['en', 'ar'] as const) for (const theme of ['light', 'dark'
await page.screenshot({ path: info.outputPath(`ask-${locale}-${theme}-page.png`) })
await page.keyboard.press('Meta+k')
await page.getByTestId('search-input').fill(ask)
- await expect(page.locator('.command-row')).toHaveCount(1)
+ await expect(page.locator('.command-row')).toHaveCount(2)
+ await expect(page.getByTestId('search').getByRole('option').first()).toHaveAttribute('id', 'search-ask')
+ await expect(page.getByTestId('search-ask')).toContainText(ask)
await expect(page.getByTestId('command-chat')).toContainText(ask)
await expect(page.getByTestId('command-chat')).toContainText('⌘2')
await page.screenshot({ path: info.outputPath(`ask-${locale}-${theme}-commands.png`) })
diff --git a/app/e2e/backup.spec.ts b/app/e2e/backup.spec.ts
index 5fbf549c..0ef41d4c 100644
--- a/app/e2e/backup.spec.ts
+++ b/app/e2e/backup.spec.ts
@@ -50,7 +50,8 @@ test('every meeting goes to one file and into a fresh Yogurt, with notes, transc
await b.page.keyboard.press('Meta+a')
await b.page.keyboard.type('invite flow')
await expect(b.page.getByTestId('search-result').first()).toContainText('Customer call with Acme')
- await b.page.keyboard.press('Enter')
+ // Notes-only matches remain searchable; Ask is the default, so choose the restored meeting explicitly.
+ await b.page.getByTestId('search-result').first().click()
await expect(b.page.getByTestId('note-enhanced')).toContainText('a simpler invite flow')
await fake(b.app, 'go', `/note/${id}`)
diff --git a/app/e2e/chatEntrance.spec.ts b/app/e2e/chatEntrance.spec.ts
index a79cb699..5692744c 100644
--- a/app/e2e/chatEntrance.spec.ts
+++ b/app/e2e/chatEntrance.spec.ts
@@ -17,6 +17,9 @@ test('Ask starters hide without moving the landing layout', async ({}, info) =>
await page.getByTestId('nav-chat').click()
const starters = page.getByTestId('chat-starter')
await expect(starters).toHaveCount(3)
+ // The initial landing shell is replaced when its conversation loads; measure the ready composer.
+ await expect(page.getByTestId('chat-page-input')).toBeEditable()
+ await expect(page.getByTestId('chat-page-input')).toBeFocused()
if (!before) {
const title = page.locator('.ask-home-title'), composer = page.getByTestId('chat-page-box')
const titleBox = await title.boundingBox(), composerBox = await composer.boundingBox()
@@ -43,6 +46,8 @@ test('Ask starters hide without moving the landing layout', async ({}, info) =>
await page.emulateMedia({ reducedMotion: 'reduce' })
await page.getByTestId('nav-chat').click()
await expect(page.getByTestId('chat-starter')).toHaveCount(3)
+ await expect(page.getByTestId('chat-page-input')).toBeEditable()
+ await expect(page.getByTestId('chat-page-input')).toBeFocused()
expect(await page.getByTestId('chat-starter').evaluateAll(els => els.every(el => el.getAnimations().length === 0 && getComputedStyle(el).opacity === '1' && getComputedStyle(el).transform === 'none'))).toBe(true)
if (!before) {
const title = page.locator('.ask-home-title'), titleBox = await title.boundingBox()
diff --git a/app/e2e/commands.spec.ts b/app/e2e/commands.spec.ts
index faafc270..9da2c33c 100644
--- a/app/e2e/commands.spec.ts
+++ b/app/e2e/commands.spec.ts
@@ -36,7 +36,7 @@ test('the sidebar shortcut, native View menu, command palette and shortcut refer
await page.keyboard.press('Meta+k')
const command = page.getByTestId('command-sidebar')
await expect(command).toContainText('Hide Sidebar')
- await expect(command.locator('kbd')).toHaveText('⌃⌘S')
+ await expect(command.locator('.search-shortcut')).toHaveText('⌃⌘S')
await command.click()
await expect(page.getByTestId('search')).toHaveCount(0)
await expect(toggle).toHaveAttribute('aria-expanded', 'false')
@@ -74,8 +74,8 @@ test('page shortcuts are taught in the palette, work there, and respect modal ed
]) {
await page.keyboard.press('Meta+k')
const command = page.getByTestId(`command-${id}`)
- await expect(command.locator('kbd')).toHaveText(shortcut)
- expect((await command.locator('kbd').boundingBox())!.x).toBeGreaterThan((await command.locator('.command-label').boundingBox())!.x)
+ await expect(command.locator('.search-shortcut')).toHaveText(shortcut)
+ expect((await command.locator('.search-shortcut').boundingBox())!.x).toBeGreaterThan((await command.locator('.command-label').boundingBox())!.x)
await page.keyboard.press(key)
await expect(page.getByTestId('search')).toHaveCount(0)
await expect(page.getByTestId(screen)).toBeVisible()
@@ -132,7 +132,7 @@ test('the command palette opens pages and folders and changes appearance and set
} finally { await app.close() }
})
-test('appearance commands omit the saved choice and switch between all three modes', async () => {
+test('appearance commands mark the saved choice, allow a no-op and switch between all three modes', async () => {
const { app, page } = await launch()
try {
await page.evaluate(() => window.yogurt.settings.setTheme('system'))
@@ -143,8 +143,16 @@ test('appearance commands omit the saved choice and switch between all three mod
] as const) {
await page.keyboard.press('Meta+k')
await page.getByTestId('search-input').fill('Appearance')
- await expect(page.locator('[data-testid^="command-theme-"]')).toHaveCount(2)
- await expect(page.getByTestId(`command-theme-${current}`)).toHaveCount(0)
+ await expect(page.locator('[data-testid^="command-theme-"]')).toHaveCount(3)
+ const saved = page.getByTestId(`command-theme-${current}`)
+ await expect(saved).toHaveAttribute('aria-current', 'true')
+ await expect(saved).toContainText('✓')
+ await page.getByTestId('search-input').fill(current === 'system' ? 'Match my' : current)
+ await expect(saved).toHaveAttribute('aria-selected', 'true')
+ await page.keyboard.press('Enter')
+ await expect(page.getByTestId('search')).toHaveCount(0)
+ expect((await page.evaluate(() => window.yogurt.settings.get())).theme).toBe(current)
+ await page.keyboard.press('Meta+k')
await page.getByTestId('search-input').fill(query)
await page.keyboard.press('Enter')
await expect(page.getByTestId('search')).toHaveCount(0)
@@ -153,6 +161,204 @@ test('appearance commands omit the saved choice and switch between all three mod
} finally { await app.close() }
})
+test('command ranking controls visible order, selection and Enter alongside matching meetings', async () => {
+ const { app, page } = await launch()
+ try {
+ const id = await app.evaluate(() => (globalThis as unknown as { __fake__: { bigMeeting(n: number): string } }).__fake__.bigMeeting(0))
+ await page.evaluate(id => window.yogurt.meetings.rename(id, 'Dark light settings trash theme mode budget review'), id)
+ const folder = await page.evaluate(() => window.yogurt.folders.create('Dark planning'))
+ await page.reload()
+ await expect(page.getByTestId('home')).toBeVisible()
+ await page.keyboard.press('Meta+k')
+ const input = page.getByTestId('search-input')
+ const results = page.getByRole('listbox', { name: 'Results' })
+ const options = results.getByRole('option')
+ for (const [query, expected] of [
+ ['', `search-${id}`], ['dark', `command-folder-${folder!.id}`], ['light', 'command-theme-light'],
+ ['set', 'command-settings'], ['trash', 'command-trash'], ['budget review', `search-${id}`],
+ ['theme', `search-${id}`], ['mode', `search-${id}`],
+ ]) {
+ await input.fill(query)
+ await expect(results).toHaveAttribute('aria-busy', 'false')
+ await expect(options.first()).toHaveAttribute('id', query ? 'search-ask' : expected)
+ await expect(results.locator('[aria-selected="true"]')).toHaveAttribute('id', expected)
+ await expect(input).toHaveAttribute('aria-activedescendant', expected)
+ await expect(results.locator('[aria-selected="true"] .search-return')).toBeVisible()
+ await expect(page.getByTestId('search-result')).toHaveCount(1)
+ }
+ // Clearing resets settling; equal command scores keep their original order, including folders.
+ await input.fill('')
+ await expect(results).toHaveAttribute('aria-busy', 'false')
+ await input.fill('dark')
+ await expect(options).toHaveCount(4)
+ await expect(input).toHaveAttribute('aria-activedescendant', `command-folder-${folder!.id}`)
+ await expect(options.nth(1)).toHaveAttribute('id', `command-folder-${folder!.id}`)
+ await expect(options.nth(2)).toHaveAttribute('id', 'command-theme-dark')
+ await expect(options.nth(3)).toHaveAttribute('id', `search-${id}`)
+ await page.keyboard.press('ArrowDown')
+ await expect(input).toHaveAttribute('aria-activedescendant', 'command-theme-dark')
+ await page.keyboard.press('ArrowDown')
+ await expect(input).toHaveAttribute('aria-activedescendant', `search-${id}`)
+ await page.keyboard.press('Enter')
+ await expect(page.getByTestId('search')).toHaveCount(0)
+ expect(await page.evaluate(() => window.yogurt.nav.current())).toBe(`/note/${id}`)
+ await page.keyboard.press('Meta+k')
+ await input.fill('set')
+ await expect(page.getByTestId('command-settings')).toHaveAttribute('aria-selected', 'true')
+ await page.keyboard.press('Enter')
+ await expect(page.getByTestId('settings')).toBeVisible()
+ } finally { await app.close() }
+})
+
+test('Enter during a pending search follows command ranking', async () => {
+ const { app, page } = await launch({ YOGURT_FAKE_SEARCH_SLOW: '1' })
+ try {
+ const id = await app.evaluate(() => (globalThis as unknown as { __fake__: { bigMeeting(n: number): string } }).__fake__.bigMeeting(0))
+ await page.evaluate(id => window.yogurt.meetings.rename(id, 'Dark mode planning'), id)
+ await page.evaluate(() => window.yogurt.settings.setTheme('light'))
+ await page.keyboard.press('Meta+k')
+ await expect(page.getByTestId('command-theme-dark')).toBeVisible()
+ await page.getByTestId('search-input').fill('dark')
+ await page.keyboard.press('Enter')
+ await expect(page.getByTestId('search')).toHaveCount(0)
+ expect((await page.evaluate(() => window.yogurt.settings.get())).theme).toBe('dark')
+ await expect(page.getByTestId('home')).toBeVisible()
+ await page.keyboard.press('Meta+k')
+ await page.getByTestId('search-input').fill('mode')
+ await page.keyboard.press('Enter')
+ await expect(page.getByTestId('search')).toHaveCount(0)
+ expect(await page.evaluate(() => window.yogurt.nav.current())).toBe(`/note/${id}`)
+ } finally { await app.close() }
+})
+
+test('Ask is pinned and sends the question into a new conversation, including folder scope', async () => {
+ const { app, page } = await launch()
+ try {
+ const folder = await page.evaluate(() => window.yogurt.folders.create('Project'))
+ for (const scoped of [false, true]) {
+ await page.evaluate(route => window.yogurt.nav.go(route), scoped ? `/folder/${folder!.id}` : '')
+ await expect(page.getByTestId(scoped ? 'folder-title' : 'home')).toBeVisible()
+ await page.keyboard.press('Meta+k')
+ const query = 'What did we decide about the launch?'
+ await page.getByTestId('search-input').fill(query)
+ const ask = page.getByTestId('search-ask')
+ await expect(page.getByRole('listbox').getByRole('option').first()).toHaveAttribute('id', 'search-ask')
+ await expect(ask).toContainText('Ask Yogurt')
+ await expect(ask.locator('.command-label')).toHaveText(query)
+ await expect(ask).toHaveAttribute('aria-selected', 'true')
+ if (scoped) await ask.click()
+ else await page.keyboard.press('Enter')
+ await expect(page.getByTestId('search')).toHaveCount(0)
+ await expect(page.getByTestId('chat-page')).toBeVisible()
+ await expect(page.getByTestId('chat-page-question')).toHaveText(query)
+ const conversation = await page.evaluate(async () => window.yogurt.conversations.get((await window.yogurt.nav.current()).slice(6)))
+ expect(conversation!.turns).toHaveLength(1)
+ expect(conversation!.chips.map(c => ({ kind: c.kind, id: c.id }))).toEqual(scoped ? [{ kind: 'folder', id: folder!.id }] : [])
+ }
+ } finally { await app.close() }
+})
+
+test('a parsed date chip can be removed with its button or Backspace', async () => {
+ const { app, page } = await launch()
+ try {
+ await page.keyboard.press('Meta+k')
+ const input = page.getByTestId('search-input')
+ for (const keyboard of [false, true]) {
+ await input.fill('standup nov 10')
+ await expect(page.getByTestId('search-date')).toBeVisible()
+ await expect(page.getByTestId('search-date-highlight')).toHaveText('nov 10')
+ if (keyboard) {
+ await input.evaluate(el => (el as HTMLInputElement).setSelectionRange(0, 0))
+ await page.keyboard.press('Backspace')
+ } else await page.getByTestId('search-date-clear').click()
+ await expect(page.getByTestId('search-date')).toHaveCount(0)
+ await expect(input).toHaveValue('standup')
+ await expect(input).toBeFocused()
+ }
+ } finally { await app.close() }
+})
+
+test('the icon follows selection, hints stay fixed, and the secondary shortcut sends to Ask', async () => {
+ const { app, page } = await launch()
+ try {
+ await page.keyboard.press('Meta+k')
+ const input = page.getByTestId('search-input')
+ const hints = await page.locator('.search-footer').textContent()
+ for (const query of ['s', 'se', 'set', 'settings', 'why', 'why now?']) {
+ await input.fill(query)
+ await expect(page.locator('.search-footer')).toHaveText(hints!)
+ }
+ await input.fill('settings')
+ await expect(page.getByTestId('command-settings')).toHaveAttribute('aria-selected', 'true')
+ await expect(page.getByTestId('search-intent-icon')).toHaveAttribute('data-icon', 'command:settings')
+ await expect(page.getByTestId('search-primary-hint')).toHaveText('↵Select')
+ await expect(page.getByTestId('search-secondary-hint')).toContainText('Ask')
+ await page.keyboard.press('ArrowUp')
+ await expect(page.getByTestId('search-ask')).toHaveAttribute('aria-selected', 'true')
+ await expect(page.getByTestId('search-intent-icon')).toHaveAttribute('data-icon', 'ask')
+ await expect(page.getByTestId('search-primary-hint')).toHaveText('↵Select')
+ await expect(page.getByTestId('search-secondary-hint')).toContainText('Ask')
+ await page.keyboard.press('ArrowDown')
+ await page.keyboard.press('Meta+Enter')
+ await expect(page.getByTestId('search')).toHaveCount(0)
+ await expect(page.getByTestId('chat-page-question')).toHaveText('settings')
+ await page.keyboard.press('Meta+k')
+ await input.fill('Octob')
+ await expect(page.getByTestId('search-date-highlight')).toHaveCount(0)
+ await input.fill('October 28')
+ await expect(page.getByTestId('search-date-highlight')).toHaveText('October 28')
+ await expect(page.getByTestId('search-date')).toContainText('October 28')
+ await page.keyboard.press('Tab')
+ await expect(page.getByTestId('search-date-clear')).toBeFocused()
+ await page.keyboard.press('Enter')
+ await expect(input).toHaveValue('')
+ await expect(page.getByTestId('search-date')).toHaveCount(0)
+ } finally { await app.close() }
+})
+
+test('people filters recognize exact identities and require a choice for partial names', async () => {
+ const { app, page } = await launch()
+ try {
+ const ids = await app.evaluate(() => {
+ const fake = (globalThis as unknown as { __fake__: { bigMeeting(n: number): string } }).__fake__
+ return [fake.bigMeeting(0), fake.bigMeeting(0), fake.bigMeeting(0)]
+ })
+ await page.evaluate(async ids => {
+ for (const id of ids.slice(0, 2)) await window.yogurt.meetings.setAttendees(id, [{ name: 'Riley Example', email: '[email protected]' }])
+ await window.yogurt.meetings.rename(ids[2], 'Riley Example')
+ }, ids)
+ await page.keyboard.press('Meta+k')
+ const input = page.getByTestId('search-input')
+ for (const query of ['Riley Example', '[email protected]']) {
+ await input.fill(query)
+ await expect(page.getByTestId('search-person-filter')).toHaveCount(1)
+ await expect(page.getByTestId('search-person-highlight')).toHaveText(query)
+ await expect(input).toHaveValue(query)
+ await expect(page.getByTestId('command-settings')).toHaveCount(0)
+ await expect(page.getByTestId('search-result')).toHaveCount(2)
+ await page.getByTestId('search-person-filter').getByRole('button').click()
+ await expect(input).toHaveValue('')
+ }
+ for (const key of ['Enter', 'Tab']) {
+ await input.fill('Ril today')
+ await expect(page.getByTestId('search-person-filter')).toHaveCount(0)
+ await expect(page.getByTestId('search-person')).toHaveCount(1)
+ await expect(page.getByTestId('search-result')).toHaveCount(3)
+ await page.getByTestId('search-person').hover()
+ await page.keyboard.press(key)
+ await expect(page.getByTestId('search-person-filter')).toHaveCount(1)
+ await expect(input).toHaveValue('Riley Example today')
+ await expect(page.getByTestId('search-person-highlight')).toHaveText('Riley Example')
+ await expect(page.getByTestId('search-result')).toHaveCount(2)
+ await page.getByTestId('search-date-clear').click()
+ await input.evaluate((el: HTMLInputElement) => el.setSelectionRange(0, 0))
+ await page.keyboard.press('Backspace')
+ await expect(page.getByTestId('search-person-filter')).toHaveCount(0)
+ await expect(page.getByTestId('search-result')).toHaveCount(3)
+ }
+ } finally { await app.close() }
+})
+
test('closing the palette cancels a pending Enter while search is still answering', async () => {
const { app, page } = await launch({ YOGURT_FAKE_SEARCH_SLOW: '1' })
try {
@@ -226,7 +432,7 @@ test('typing keeps the palette frame steady and replaces meeting and command res
await page.keyboard.press('Meta+k')
const palette = page.getByTestId('search')
const input = page.getByTestId('search-input')
- await expect(palette.getByTestId('search-result')).toHaveCount(8)
+ await expect(palette.getByTestId('search-result')).toHaveCount(3)
await page.evaluate(() => {
const frames: number[][] = []
const measure = () => {
@@ -242,13 +448,14 @@ test('typing keeps the palette frame steady and replaces meeting and command res
await input.fill('sett')
// While the delayed search is pending, retain one coherent result set instead of clearing its rows.
await page.waitForTimeout(250)
- await expect(palette.getByTestId('search-result')).toHaveCount(8)
+ await expect(palette.getByTestId('search-result')).toHaveCount(3)
await expect(palette.getByTestId('command-meetings')).toHaveCount(1)
await expect(palette.getByTestId('search-result')).toHaveCount(0)
await expect(palette.getByTestId('command-settings')).toBeVisible()
await expect(palette.getByTestId('command-meetings')).toHaveCount(0)
await input.fill('zzqx')
- await expect(palette.getByTestId('search-none')).toBeVisible()
+ await expect(palette.getByRole('option')).toHaveCount(1)
+ await expect(palette.getByTestId('search-ask')).toHaveAttribute('aria-selected', 'true')
const frames = await page.evaluate(() => (window as unknown as { paletteFrames: number[][] }).paletteFrames)
for (const i of [0, 1, 2]) expect(Math.max(...frames.map(f => f[i])) - Math.min(...frames.map(f => f[i]))).toBeLessThan(1)
// Enter during a pending query uses the new command, not the retained results.
diff --git a/app/e2e/folders.spec.ts b/app/e2e/folders.spec.ts
index b741eb84..361d8407 100644
--- a/app/e2e/folders.spec.ts
+++ b/app/e2e/folders.spec.ts
@@ -198,7 +198,8 @@ test('a meeting row dragged onto a folder goes into it; ⌘K on a folder page lo
await expect(page.getByTestId('search-scope')).toHaveText('Acme')
await expect(page.getByTestId('search-result')).toHaveCount(2)
await page.keyboard.type('budget')
- await expect(page.getByTestId('search-none')).toBeVisible()
+ await expect(page.getByTestId('search-result')).toHaveCount(0)
+ await expect(page.getByTestId('search-ask')).toHaveAttribute('aria-selected', 'true')
await page.getByTestId('search-scope-clear').click()
await expect(page.getByTestId('search-result').first()).toContainText('Budget review')
await expect(page.getByTestId('search-input')).toBeFocused()
@@ -208,7 +209,11 @@ test('a meeting row dragged onto a folder goes into it; ⌘K on a folder page lo
await page.getByTestId('nav-home').click()
await page.keyboard.press('Meta+k')
await expect(page.getByTestId('search-scope')).toHaveCount(0)
- await expect(page.getByTestId('search-result')).toHaveCount(4)
+ await expect(page.getByTestId('search-result')).toHaveCount(3)
+ // The fourth meeting is outside the recent preview, but still searchable without a folder scope.
+ await page.getByTestId('search-input').fill('design crit')
+ await expect(page.getByTestId('search-result')).toHaveCount(1)
+ await expect(page.getByTestId('search-result')).toContainText('Design crit')
} finally { await app.close() }
})
diff --git a/app/e2e/home.spec.ts b/app/e2e/home.spec.ts
index cc81ae34..df4f02d9 100644
--- a/app/e2e/home.spec.ts
+++ b/app/e2e/home.spec.ts
@@ -111,7 +111,7 @@ test('a prepared calendar note keeps its notes without recording; Start recordin
const hit = search.getByTestId('search-result').filter({ hasText: 'Team standup' })
await expect(hit).toBeVisible()
await expect(hit.locator('mark').first()).toHaveText(/pricing/i)
- await page.keyboard.press('Enter')
+ await hit.click()
await expect(search).toHaveCount(0)
await expect(page.getByTestId('note-title')).toHaveText('Team standup')
expect(await routeOf(page)).toBe(`/note/${id}`)
@@ -285,7 +285,8 @@ test('search: from any screen, as you type, arrows and Enter, Esc closes; a slow
await page.keyboard.press('Meta+k')
await expect(search).toBeVisible()
await page.keyboard.type('zzqx')
- await expect(search.getByTestId('search-none')).toBeVisible()
+ await expect(search.getByTestId('search-result')).toHaveCount(0)
+ await expect(search.getByTestId('search-ask')).toHaveAttribute('aria-selected', 'true')
await page.keyboard.press('Escape')
await expect(search).toHaveCount(0)
} finally { await app.close() }
diff --git a/app/package.json b/app/package.json
index 3faff47d..09f26fa7 100644
--- a/app/package.json
+++ b/app/package.json
@@ -13,6 +13,7 @@
"typecheck": "tsc -p ."
},
"dependencies": {
+ "chrono-node": "2.10.3",
"electron-updater": "6.8.10",
"node-llama-cpp": "3.22.1"
},
diff --git a/app/src/main/index.ts b/app/src/main/index.ts
index c8ead327..0e906b1e 100644
--- a/app/src/main/index.ts
+++ b/app/src/main/index.ts
@@ -1,3 +1,4 @@
+import { matchSearchPeople, searchPersonKey } from '../shared/searchPeople'
import { resolvePeople } from './people'
import { createFolderSuggestions } from './folderSuggestions'
import { speakerColor } from '../shared/speakerColors'
@@ -19,7 +20,7 @@ import { logToFile } from './log'
import { loadSettings, localeOf, recordingReminderOn, spokenSetting, stopsWhenCallEnds, updateSettings } from './settings'
import { CALL_GONE_MS, useCallApps } from './detect'
import { systemLocale } from './locale'
-import { onLanguage, setLanguage, t } from '../shared/i18n'
+import { language as uiLanguage, onLanguage, setLanguage, t } from '../shared/i18n'
import bundledCatalog from '../../../catalog/catalog.json'
import licenses from '../../../catalog/licenses.json'
import { loadCatalog } from './catalog'
@@ -896,19 +897,26 @@ app.whenReady().then(() => {
}
return was
})
- ipcMain.handle('search:query', async (_e, q: unknown, folder: unknown) => {
+ ipcMain.handle('search:people', () => store.searchPeople())
+ ipcMain.handle('search:query', async (_e, q: unknown, folder: unknown, filters: unknown) => {
if (typeof q !== 'string') return []
const query = q.slice(0, 200)
+ const known = store.searchPeople()
+ if (filters !== undefined && (!Array.isArray(filters) || filters.length > 20 || filters.some(p =>
+ !p || typeof p.name !== 'string' || !(p.email === null || typeof p.email === 'string')))) return []
+ const people = (filters ?? []) as Array<{ name: string; email: string | null }>
+ if (people.some(p => !known.some(k => searchPersonKey(k) === searchPersonKey(p)))) return []
+ const personSearch = people.length > 0 || matchSearchPeople(query, known).matches.length > 0
// opened from a folder's page: only its meetings
const sp = isId(folder) ? folder : undefined
// fake mode: short questions answer late, so a test can see an older answer never replace a newer one
if (isFake() && process.env.YOGURT_FAKE_SEARCH_SLOW === '1' && query.trim().length <= 4) await new Promise((r) => setTimeout(r, 1000))
- const hits = query.trim() ? store.search(query, 30, sp) : store.meetingCards({ limit: 8, folder: sp }).map((c) => ({ meetingId: c.id, snippet: '', parts: [] }))
+ const hits = query.trim() || personSearch ? store.search(query, personSearch ? Infinity : 30, sp, { locale: app.getLocale(), language: uiLanguage(), people }) : store.meetingCards({ limit: 3, folder: sp }).map((c) => ({ meetingId: c.id, snippet: '', parts: [] }))
return hits.flatMap((h) => {
const m = store.meeting(h.meetingId)
if (!m) return []
const parts = h.parts.length ? h.parts : [{ text: store.preview(m.id), hit: false }]
- return [{ meetingId: m.id, title: m.title, startedAt: m.startedAt, parts: parts.filter((p) => p.text) }]
+ return [{ meetingId: m.id, title: m.title, startedAt: m.startedAt, confident: 'confident' in h ? h.confident : false, parts: parts.filter((p) => p.text) }]
})
})
// the window's own moves (home, a note from the list): remembered here so a reload stays where it was
diff --git a/app/src/main/store.ts b/app/src/main/store.ts
index 39823eca..f4dc0809 100644
--- a/app/src/main/store.ts
+++ b/app/src/main/store.ts
@@ -1,3 +1,5 @@
+import { matchSearchPeople, searchPersonKey, uniqueSearchPeople } from '../shared/searchPeople'
+import { oneEdit, parseSearchQuery, type SearchOptions } from '../shared/searchQuery'
import { echoConfidence } from './asr/echo'
import { backfillPeople, rememberPeople, resolvePeople } from './people'
import { attendeeMembership, personEmail } from '../shared/people'
@@ -60,13 +62,6 @@ const toSegment = (r: Row): Segment => ({
const CJK = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u
const CJK_RUNS = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]+/gu
-/** Plain words become quoted FTS5 terms, so stray quotes or operators in a search can't break the query. */
-function ftsQuery(q: string): string {
- const words = q.split(/[^\p{L}\p{N}]+/u).filter(Boolean)
- // the last word may still be typing, so it matches as a prefix
- return words.map((w, i) => (i === words.length - 1 ? `"${w}"*` : `"${w}"`)).join(' ')
-}
-
/** A named group of meetings; a meeting can be in several. count: how many meetings are in it */
export type Folder = FolderAppearance & { id: string; name: string; createdAt: number; count: number }
const toFolder = (r: Row): Folder => ({ id: String(r.id), name: String(r.name), createdAt: Number(r.created_at), count: Number(r.count ?? 0), ...folderAppearance(r.icon, r.color) })
@@ -79,7 +74,7 @@ const folderName = (name: string) => name.replace(/\s+/g, ' ').trim().slice(0, 2
export type MeetingCard = Meeting & { /** the first words of the notes, plain text; empty with none yet */ preview: string; folders?: Array<Pick<Folder, 'id' | 'name' | 'icon' | 'color'>> }
export type SnippetPart = { text: string; hit: boolean }
-export type SearchHit = { meetingId: string; snippet: string; parts: SnippetPart[] }
+export type SearchHit = { meetingId: string; snippet: string; parts: SnippetPart[]; confident?: boolean }
// where a matched word starts and ends in a snippet: characters no note or transcript contains
const OPEN = '\u0002', CLOSE = '\u0003'
@@ -101,13 +96,6 @@ function previewOf(enhanced: string | null, mine: string): string {
return text.length > 240 ? text.slice(0, 240).replace(/\s+\S*$/, '') + '…' : text
}
-/** Title words the way the text search sees them: whole words, the last one typed as a beginning; Chinese and Japanese anywhere */
-function titleMatches(title: string, q: string): boolean {
- const split = (x: string) => x.toLocaleLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean)
- const words = split(q), have = split(title)
- return words.length > 0 && words.every((w, i) => CJK.test(w) ? title.includes(w) : i === words.length - 1 ? have.some((h) => h.startsWith(w)) : have.includes(w))
-}
-
/** an FTS snippet with OPEN/CLOSE marks → pieces of plain text */
function partsOf(snippet: string): SnippetPart[] {
const parts: SnippetPart[] = []
@@ -487,47 +475,85 @@ export class Store {
return previewOf(n.enhanced, n.mine)
}
- /**
- * Meetings whose title, transcript or notes contain the words; one hit per meeting. Titles first (newest first),
- * then the best text matches. parts: the snippet in pieces, hit on the words matched, plain text only (the
- * window shows them as text, never as markup). folder: only the meetings in that folder.
- */
- search(q: string, limit: number, folder?: string): SearchHit[] {
- const fts = ftsQuery(q)
- if (!fts) return []
- // narrowed to a folder: every query below keeps only its meetings (the folder id is the last argument of each)
- // and never a meeting in the Trash
- const inFolder = (col: string) => notTrashed(col) + (folder == null ? '' : ` AND ${col} IN (SELECT meeting_id FROM folder_meetings WHERE folder_id = ?)`)
- const sp = folder == null ? [] : [folder]
- const out = new Map<string, SearchHit>()
- const add = (id: string, parts: SnippetPart[]) => {
- if (out.has(id)) { if (!out.get(id)!.parts.length && parts.length) out.set(id, hitOf(id, parts)); return }
- out.set(id, hitOf(id, parts))
+ searchPeople(): Person[] {
+ const rows = this.db.prepare('SELECT attendees FROM meetings WHERE trashed_at IS NULL ORDER BY started_at DESC, id DESC').all()
+ const attendees = uniqueSearchPeople(rows.flatMap(r => JSON.parse(String(r.attendees)) as Person[]))
+ return resolvePeople(this.db, attendees)
+ .filter(p => p.name.trim() || p.email?.trim()).sort((a, b) => a.name.localeCompare(b.name))
+ }
+
+ /** Each word can match a different field; dates and folder scope always filter the meeting itself. */
+ search(q: string, limit: number, folder?: string, options: SearchOptions = {}): SearchHit[] {
+ const parsedPeople = matchSearchPeople(q, this.searchPeople(), options.people, options)
+ const people = uniqueSearchPeople([...(options.people ?? []), ...parsedPeople.matches.map(m => m.person)])
+ const { words, date } = parseSearchQuery(parsedPeople.text, options)
+ if (!words.length && !date && !people.length) return []
+ const inScope = (col: string) => notTrashed(col)
+ + (folder == null ? '' : ` AND ${col} IN (SELECT meeting_id FROM folder_meetings WHERE folder_id = ?)`)
+ + (date ? ` AND ${col} IN (SELECT id FROM meetings WHERE started_at >= ? AND started_at < ?)` : '')
+ const args = [...(folder == null ? [] : [folder]), ...(date ? [date.start, date.end] : [])]
+ const rows = this.db.prepare(`SELECT id, title, attendees, started_at,
+ (SELECT group_concat(f.name, char(10)) FROM folders f JOIN folder_meetings fm ON fm.folder_id = f.id WHERE fm.meeting_id = meetings.id) AS folders
+ FROM meetings WHERE 1${inScope('id')} ORDER BY started_at DESC, id DESC`).all(...args) as Row[]
+ const scopedRows = rows.filter(r => {
+ const attendees = (JSON.parse(String(r.attendees)) as Person[]).map(searchPersonKey)
+ return people.every(p => attendees.includes(searchPersonKey(p)))
+ })
+ const tokens = (text: string) => text.toLocaleLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean)
+ const phrase = words.join(' ')
+ const hasPhrase = (text: string) => words.length > 1 && ` ${tokens(text).join(' ')} `.includes(` ${phrase} `)
+ const matchScore = (text: string, word: string, prefix: boolean, fuzzy: boolean, score: number) => {
+ const have = tokens(text)
+ if (have.some(w => CJK.test(word) ? w.includes(word) : w === word || (prefix && w.startsWith(word)))) return score
+ return fuzzy && have.some(w => oneEdit(word, w)) ? score - 1 : 0
}
- const titled = (this.db.prepare(`SELECT id, title FROM meetings WHERE 1${inFolder('id')} ORDER BY started_at DESC, id DESC`).all(...sp) as Row[])
- .filter((r) => titleMatches(String(r.title), q)).slice(0, limit)
- for (const r of titled) out.set(String(r.id), hitOf(String(r.id), []))
- const rows = this.db.prepare(`
- SELECT meeting_id, snippet, MIN(rank) AS best FROM (
- SELECT s.meeting_id AS meeting_id, snippet(segments_fts, 0, '${OPEN}', '${CLOSE}', '…', 12) AS snippet, segments_fts.rank AS rank
- FROM segments_fts JOIN segments s ON s.id = segments_fts.rowid WHERE segments_fts MATCH ? AND s.hidden = 0${inFolder('s.meeting_id')}
+ const found = new Map(scopedRows.map(r => {
+ const title = String(r.title), attendees = (JSON.parse(String(r.attendees)) as Person[]).map(p => p.name).join(' '), folders = String(r.folders ?? '')
+ const fields = [[title, 40, true], [attendees, 30, true], [folders, 30, false]] as const
+ const scores = words.map((w, i) => Math.max(0, ...fields.map(([text, score, fuzzy]) => matchScore(text, w, i === words.length - 1, fuzzy, score))))
+ return [String(r.id), { scores, bonus: fields.some(([text]) => hasPhrase(text)) ? 5 : 0, parts: [] as SnippetPart[], snippetScore: 0 }]
+ }))
+ words.forEach((word, i) => {
+ const fts = `"${word}"${i === words.length - 1 ? '*' : ''}`
+ // Use the existing text indexes per word, then intersect at meeting level rather than within one field or line.
+ const hits = this.db.prepare(`SELECT meeting_id, snippet, score, MIN(rank) FROM (
+ SELECT n.meeting_id, snippet(notes_fts, -1, '${OPEN}', '${CLOSE}', '…', 24) AS snippet, 20 AS score, notes_fts.rank AS rank
+ FROM notes_fts JOIN notes n ON n.id = notes_fts.rowid WHERE notes_fts MATCH ?${inScope('n.meeting_id')}
UNION ALL
- SELECT n.meeting_id, snippet(notes_fts, -1, '${OPEN}', '${CLOSE}', '…', 12), notes_fts.rank
- FROM notes_fts JOIN notes n ON n.id = notes_fts.rowid WHERE notes_fts MATCH ?${inFolder('n.meeting_id')}
- ) GROUP BY meeting_id ORDER BY best LIMIT ?`).all(fts, ...sp, fts, ...sp, limit) as Row[]
- for (const r of rows) add(String(r.meeting_id), partsOf(String(r.snippet)))
- // Chinese and Japanese: NOFOLDERS_P, so the search sees a whole run as one word; lines with every pair of the characters match
- const runs = q.match(CJK_RUNS) ?? []
- if (runs.length && out.size < limit) {
- const pairs = pairsOf(runs)
- const where = (col: string) => pairs.map(() => `instr(${col}, ?) > 0`).join(' AND ')
- const found = [
- ...(this.db.prepare(`SELECT meeting_id, text FROM segments WHERE hidden = 0 AND ${where('text')}${inFolder('meeting_id')} ORDER BY meeting_id, start_ms LIMIT 500`).all(...pairs, ...sp) as Row[]),
- ...(this.db.prepare(`SELECT meeting_id, coalesce(enhanced, '') || char(10) || mine AS text FROM notes WHERE ${where("coalesce(enhanced, '') || char(10) || mine")}${inFolder('meeting_id')} LIMIT 500`).all(...pairs, ...sp) as Row[]),
- ]
- for (const r of found) if (out.size < limit && !out.get(String(r.meeting_id))?.parts.length) add(String(r.meeting_id), around(String(r.text), pairs))
+ SELECT s.meeting_id, snippet(segments_fts, 0, '${OPEN}', '${CLOSE}', '…', 24), 10, segments_fts.rank
+ FROM segments_fts JOIN segments s ON s.id = segments_fts.rowid WHERE segments_fts MATCH ? AND s.hidden = 0${inScope('s.meeting_id')}
+ ) GROUP BY meeting_id, score`).all(fts, ...args, fts, ...args) as Row[]
+ const add = (id: string, parts: SnippetPart[], score: number) => {
+ const hit = found.get(id)
+ if (!hit) return
+ hit.scores[i] = Math.max(hit.scores[i], score)
+ if (score > hit.snippetScore) { hit.parts = parts; hit.snippetScore = score }
+ }
+ for (const r of hits) add(String(r.meeting_id), partsOf(String(r.snippet)), Number(r.score))
+ // FTS treats CJK runs as one token; retain matching inside those runs.
+ if (CJK.test(word)) {
+ const pairs = pairsOf([word])
+ const where = (col: string) => pairs.map(() => `instr(${col}, ?) > 0`).join(' AND ')
+ for (const r of this.db.prepare(`SELECT meeting_id, coalesce(enhanced, '') || char(10) || mine AS text FROM notes
+ WHERE ${where("coalesce(enhanced, '') || char(10) || mine")}${inScope('meeting_id')}`).all(...pairs, ...args) as Row[]) add(String(r.meeting_id), around(String(r.text), pairs), 20)
+ for (const r of this.db.prepare(`SELECT meeting_id, text FROM segments WHERE hidden = 0 AND ${where('text')}${inScope('meeting_id')}`).all(...pairs, ...args) as Row[]) add(String(r.meeting_id), around(String(r.text), pairs), 10)
+ }
+ })
+ if (words.length > 1) {
+ const exact = `"${phrase}"`
+ const phrases = this.db.prepare(`
+ SELECT n.meeting_id FROM notes_fts JOIN notes n ON n.id = notes_fts.rowid WHERE notes_fts MATCH ?${inScope('n.meeting_id')}
+ UNION
+ SELECT s.meeting_id FROM segments_fts JOIN segments s ON s.id = segments_fts.rowid WHERE segments_fts MATCH ? AND s.hidden = 0${inScope('s.meeting_id')}
+ `).all(exact, ...args, exact, ...args) as Row[]
+ for (const r of phrases) { const hit = found.get(String(r.meeting_id)); if (hit) hit.bonus = 5 }
}
- return [...out.values()].slice(0, limit)
+ return scopedRows.map(r => {
+ const hit = found.get(String(r.id))!
+ return { ...hitOf(String(r.id), hit.parts), score: hit.scores.reduce((a, b) => a + b, 0) + hit.bonus,
+ matches: hit.scores.every(s => s > 0), confident: hit.scores.every(s => s >= 29) }
+ }).filter(h => h.matches).sort((a, b) => b.score - a.score).slice(0, limit)
+ .map(({ meetingId, snippet, parts, confident }) => ({ meetingId, snippet, parts, confident }))
}
/**
diff --git a/app/src/preload/index.ts b/app/src/preload/index.ts
index e06233db..d44415bd 100644
--- a/app/src/preload/index.ts
+++ b/app/src/preload/index.ts
@@ -224,7 +224,7 @@ const api: YogurtApi = {
onLanguage: (cb) => { const f = (_e: unknown, locale: string) => cb(locale); ipcRenderer.on('settings:language', f); return () => { ipcRenderer.off('settings:language', f) } },
setSpoken: (v) => ipcRenderer.invoke('settings:spoken', v),
},
- search: { query: (q, folder) => ipcRenderer.invoke('search:query', q, folder) },
+ search: { query: (q, folder, people) => ipcRenderer.invoke('search:query', q, folder, people), people: () => ipcRenderer.invoke('search:people') },
folders: {
suggestion: (id) => ipcRenderer.invoke('folders:suggestion', id),
dismissSuggestion: (id) => ipcRenderer.invoke('folders:dismiss-suggestion', id),
diff --git a/app/src/renderer/src/components/Search.tsx b/app/src/renderer/src/components/Search.tsx
index 03d4e894..a94b7aef 100644
--- a/app/src/renderer/src/components/Search.tsx
+++ b/app/src/renderer/src/components/Search.tsx
@@ -3,13 +3,18 @@ import { useReducedMotion } from 'motion/react'
import { MotionPopup } from './MotionPopup'
import { surfaceMotion } from '../motion'
import { FolderGlyph } from './FolderAppearance'
-import { useEffect, useRef, useState } from 'react'
-import { AudioLines, FileText, FolderIcon, Keyboard, LogIn, MessageCircle, Monitor, Moon, PanelLeft, Search as SearchIcon, Settings, Sun, Trash2, X } from 'lucide-react'
-import type { SearchResult, SnippetPart, Folder } from '../../../shared/types'
-import { t } from '../../../shared/i18n'
-import { keys, osWords } from '../keys'
+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'
+import { t, language } from '../../../shared/i18n'
+import { command, keys, osWords } from '../keys'
import { markWords } from '../../../shared/highlight'
-import { dayLabel } from '../dates'
+import { dayLabel, timeOf } from '../dates'
+import { parseSearchQuery } from '../../../shared/searchQuery'
+import { completeSearchPerson, matchSearchPeople, removeSearchSpan, searchPersonKey, uniqueSearchPeople, type SearchPersonMatch } from '../../../shared/searchPeople'
+import { searchPalette, searchSelectionKey } from '../searchRanking'
+import { searchDateLabel, searchFilterEmptyMessage, searchFilterHighlights } from '../searchFilters'
/** typing settles this long before the search runs */
const DEBOUNCE_MS = 120
@@ -20,7 +25,7 @@ function Marked({ parts }: { parts: SnippetPart[] }) {
}
/**
- * ⌘K searches meetings and the app's destinations and actions. A folder scopes meeting results only.
+ * ⌘K searches meetings and the app's destinations and actions. A folder scopes meeting results and new questions.
*/
export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange, onShortcuts, onClose, sidebarCollapsed, onToggleSidebar }: {
folder?: Folder; folders?: Folder[]; onOpen: (id: string) => void; onNavigate: (route: string) => void; onSettingsChange: () => void; onShortcuts: () => void; onClose: () => void
@@ -37,74 +42,130 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
}, [open, reduce])
const [q, setQ] = useState('')
const [scope, setScope] = useState(folder)
- const [results, setResults] = useState<{ q: string; scopeId?: string; list: SearchResult[] }>()
- const [active, setActive] = useState(0)
+ const [people, setPeople] = useState<Person[]>([])
+ const [chosenPeople, setChosenPeople] = useState<Person[]>([])
+ const searchOptions = { locale: navigator.language, language: language() }
+ const personQuery = matchSearchPeople(q, people, chosenPeople, searchOptions)
+ const selectedPeople = uniqueSearchPeople(personQuery.matches.map(m => m.person))
+ const peopleKey = selectedPeople.map(searchPersonKey).join('|')
+ const parsed = parseSearchQuery(personQuery.text, searchOptions)
+ const filtered = !!parsed.date || selectedPeople.length > 0
+ const [results, setResults] = useState<{ q: string; scopeId?: string; peopleKey: string; list: SearchResult[] }>()
+ const [active, setActive] = useState<number | null>(null)
const [prefs, setPrefs] = useState<Awaited<ReturnType<typeof window.yogurt.settings.get>>>()
const [error, setError] = useState(false)
const [running, setRunning] = useState(false)
useEffect(() => { void window.yogurt.settings.get().then(setPrefs) }, [])
+ useEffect(() => {
+ let live = true
+ const load = () => void window.yogurt.search.people().then(p => { if (live) setPeople(p) }).catch(() => { if (live) setError(true) })
+ load()
+ const off = window.yogurt.meetings.onChange(load)
+ return () => { live = false; off() }
+ }, [])
const seq = useRef(0)
const list = useRef<HTMLUListElement>(null)
useEffect(() => {
const mine = ++seq.current
- const run = () => void window.yogurt.search.query(q, scope?.id).then((list) => {
+ const run = () => void window.yogurt.search.query(q, scope?.id, selectedPeople).then((list) => {
// an answer to an older question never replaces a newer one
if (mine !== seq.current) return
- setResults({ q, scopeId: scope?.id, list }); setActive(0)
+ setResults({ q, scopeId: scope?.id, peopleKey, list }); setActive(null)
})
if (!q.trim()) { run(); return }
const timer = setTimeout(run, DEBOUNCE_MS)
return () => clearTimeout(timer)
- }, [q, scope])
-
- useEffect(() => {
- list.current?.querySelector<HTMLElement>('[aria-selected="true"]')?.scrollIntoView({ block: 'nearest' })
- }, [active, results])
+ }, [q, scope, peopleKey, people, searchOptions.language, searchOptions.locale])
// focus goes back where it was when search closes: read during the first render, before the input takes it
const [before] = useState(() => document.activeElement as HTMLElement | null)
useEffect(() => () => { seq.current++; if (before?.isConnected) before.focus({ preventScroll: true }) }, [before])
const input = useRef<HTMLInputElement>(null)
+ const highlight = useRef<HTMLDivElement>(null)
+ const syncHighlight = () => { if (highlight.current && input.current) highlight.current.scrollLeft = input.current.scrollLeft }
+ useEffect(syncHighlight, [q])
// Keep one coherent result set on screen until the next search is ready.
const typed = (results?.q ?? '').trim()
- const settled = results?.q === q && results?.scopeId === scope?.id
+ const settled = results?.q === q && results?.scopeId === scope?.id && results?.peopleKey === peopleKey
const items = results?.list ?? []
const navigate = (route: string) => { onNavigate(route) }
const settingsAction = async (run: () => Promise<void>) => { await run(); onSettingsChange() }
const allCommands = [
{ id: 'meetings', label: t('Meetings'), group: t('Go to'), Icon: FileText, run: () => navigate(''), shortcut: keys('⌘1') },
- { id: 'chat', label: t('Ask'), group: t('Go to'), Icon: MessageCircle, run: () => navigate('/chat'), shortcut: keys('⌘2') },
+ { id: 'chat', synonyms: ['chat'], label: t('Ask'), group: t('Go to'), Icon: MessageCircle, run: () => navigate('/chat'), shortcut: keys('⌘2') },
{ id: 'trash', label: t('Trash'), group: t('Go to'), Icon: Trash2, run: () => navigate('/trash'), shortcut: keys('⌘3') },
- { id: 'settings', label: t('Settings'), group: t('Go to'), Icon: Settings, run: () => navigate('/settings'), shortcut: keys('⌘,') },
+ { id: 'settings', synonyms: ['preferences', 'prefs'], label: t('Settings'), group: t('Go to'), Icon: Settings, run: () => navigate('/settings'), shortcut: keys('⌘,') },
{ id: 'shortcuts', label: t('Keyboard shortcuts'), group: t('Go to'), Icon: Keyboard, run: onShortcuts, shortcut: keys('⌘/') },
{ id: 'sidebar', label: sidebarCollapsed ? t('Show Sidebar') : t('Hide Sidebar'), group: t('View'), Icon: PanelLeft, run: onToggleSidebar, shortcut: keys('⌃⌘S') },
...(folders ?? []).map((f) => ({ id: `folder-${f.id}`, label: f.name, group: t('Folders'), Icon: FolderIcon, folder: f, run: () => navigate(`/folder/${f.id}`) })),
- { id: 'theme-light', label: t('Light theme'), group: t('Appearance'), Icon: Sun, run: () => settingsAction(() => window.yogurt.settings.setTheme('light')) },
- { id: 'theme-dark', label: t('Dark theme'), group: t('Appearance'), Icon: Moon, run: () => settingsAction(() => window.yogurt.settings.setTheme('dark')) },
- { id: 'theme-system', label: osWords({ mac: t('Match my Mac'), windows: t('Match Windows'), linux: t('Match my system') }), group: t('Appearance'), Icon: Monitor, run: () => settingsAction(() => window.yogurt.settings.setTheme('system')) },
+ { id: 'theme-light', synonyms: ['theme', 'appearance', 'mode', 'light'], label: t('Light theme'), group: t('Appearance'), Icon: Sun, run: () => settingsAction(() => window.yogurt.settings.setTheme('light')) },
+ { id: 'theme-dark', synonyms: ['theme', 'appearance', 'mode', 'dark'], label: t('Dark theme'), group: t('Appearance'), Icon: Moon, run: () => settingsAction(() => window.yogurt.settings.setTheme('dark')) },
+ { id: 'theme-system', synonyms: ['theme', 'appearance', 'mode', 'system'], label: osWords({ mac: t('Match my Mac'), windows: t('Match Windows'), linux: t('Match my system') }), group: t('Appearance'), Icon: Monitor, run: () => settingsAction(() => window.yogurt.settings.setTheme('system')) },
...(prefs ? [
{ id: 'login', label: prefs.openAtLogin ? t('Turn off open at login') : t('Open Yogurt at login'), group: t('Settings'), Icon: LogIn, run: () => settingsAction(() => window.yogurt.settings.setOpenAtLogin(!prefs.openAtLogin)) },
{ id: 'auto-stop', label: prefs.stopWhenCallEnds ? t('Keep recording when the call ends') : t('Finish recording when the call ends'), group: t('Settings'), Icon: AudioLines, run: () => settingsAction(() => window.yogurt.settings.setStopWhenCallEnds(!prefs.stopWhenCallEnds)) },
] : []),
- ].filter((c) => !c.id.startsWith('theme-') || (!!prefs && c.id !== `theme-${prefs.theme}`))
- const matchingCommands = (query: string) => allCommands.filter((c) => query.trim().toLocaleLowerCase().split(/\s+/).every((word) => `${c.label} ${c.group}`.toLocaleLowerCase().includes(word)))
- const commands = matchingCommands(typed)
- const count = items.length + commands.length
- const runCommand = async (command: typeof commands[number]) => {
+ ].filter((c) => !c.id.startsWith('theme-') || !!prefs)
+ const suggestions = matchSearchPeople(typed, people, chosenPeople, searchOptions).suggestions.slice(0, 5)
+ const defaultSelection = useRef<string | undefined>(undefined)
+ const palette = searchPalette(allCommands, items, typed, q, suggestions, defaultSelection.current, filtered)
+ const rows = palette.rows
+ const count = rows.length
+ const activeIndex = active ?? palette.active
+ const selected = rows[activeIndex]
+ 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 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) => {
+ const key = searchPersonKey(person)
+ setChosenPeople(current => current.filter(p => searchPersonKey(p) !== key))
+ const match = personQuery.matches.find(m => searchPersonKey(m.person) === key)
+ if (match) setQ(removeSearchSpan(q, match))
+ setActive(null); input.current?.focus()
+ }
+ const pickPerson = (choice: SearchPersonMatch) => {
+ const match = personQuery.suggestions.find(m => searchPersonKey(m.person) === searchPersonKey(choice.person))
+ if (!match) return
+ setChosenPeople(current => uniqueSearchPeople([...current.filter(p => p.name !== match.person.name), match.person]))
+ setQ(completeSearchPerson(q, match)); setActive(null); input.current?.focus()
+ }
+ useEffect(() => {
+ list.current?.querySelector<HTMLElement>('[aria-selected="true"]')?.scrollIntoView({ block: 'nearest' })
+ }, [activeIndex, results])
+ const runCommand = async (command: typeof allCommands[number]) => {
if (running) return
setRunning(true); setError(false)
- try { await command.run(); setOpen(false) } catch { setError(true); setRunning(false) }
+ try {
+ if (command.id !== `theme-${prefs?.theme}`) await command.run()
+ setOpen(false)
+ } catch { setError(true); setRunning(false) }
+ }
+ const ask = async (query: string) => {
+ if (running || !query.trim()) return
+ setRunning(true); setError(false)
+ try {
+ const id = await window.yogurt.conversations.current(scope ? [{ kind: 'folder', id: scope.id }] : [], true)
+ const sent = await window.yogurt.conversations.ask(id, query)
+ if (!sent) throw new Error('Question was not saved')
+ onNavigate(`/chat/${sent}`); setOpen(false)
+ } catch { setError(true); setRunning(false) }
}
const onKeyDown = (e: React.KeyboardEvent) => {
if (e.nativeEvent.isComposing) return
- if (e.key === 'ArrowDown') { e.preventDefault(); setActive((a) => Math.min(Math.max(0, count - 1), a + 1)) }
- else if (e.key === 'ArrowUp') { e.preventDefault(); setActive((a) => Math.max(0, a - 1)) }
- else if (e.key === 'Enter') { e.preventDefault(); enter() }
+ 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)) }
+ 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) }
else if (e.key === 'Tab') {
e.preventDefault()
+ if (!e.shiftKey && e.target === input.current && selected?.kind === 'person') { pickPerson(selected); return }
const controls = Array.from(e.currentTarget.querySelectorAll<HTMLElement>('input, button'))
const at = controls.indexOf(document.activeElement as HTMLElement)
controls[(at + (e.shiftKey ? -1 : 1) + controls.length) % controls.length]?.focus()
@@ -112,19 +173,23 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
}
/** what is shown answers what is typed: open the one picked; typed faster than the search: ask now and open its first */
const enter = () => {
+ if (selected?.kind === 'person') { pickPerson(selected); return }
+ if (selected?.kind === 'ask' && active !== null) { void ask(selected.query); return }
if (settled) {
- const r = items[active], command = commands[active - items.length]
- if (r) onOpen(r.meetingId)
- else if (command) void runCommand(command)
+ if (selected?.kind === 'ask') void ask(selected.query)
+ else if (selected?.kind === 'meeting') onOpen(selected.meeting.meetingId)
+ else if (selected?.kind === 'command') void runCommand(selected.command)
return
}
const mine = ++seq.current
- void window.yogurt.search.query(q, scope?.id).then((list) => {
+ void window.yogurt.search.query(q, scope?.id, selectedPeople).then((list) => {
if (mine !== seq.current) return
- const command = matchingCommands(q)[0]
- if (list[0]) onOpen(list[0].meetingId)
- else if (command) void runCommand(command)
- else { setResults({ q, scopeId: scope?.id, list }); setActive(0) }
+ const next = searchPalette(allCommands, list, q, q, personQuery.suggestions, defaultSelection.current, filtered)
+ const first = next.rows[next.active]
+ if (first?.kind === 'ask') void ask(first.query)
+ else if (first?.kind === 'meeting') onOpen(first.meeting.meetingId)
+ else if (first?.kind === 'command') void runCommand(first.command)
+ else { setResults({ q, scopeId: scope?.id, peopleKey, list }); setActive(null) }
})
}
@@ -135,59 +200,114 @@ export function Search({ folder, folders, onOpen, onNavigate, onSettingsChange,
<MotionPopup open={open} reduced={!!reduce} initialFocus={input} finalFocus={() => before} data-testid="search" role="dialog" aria-modal="true" aria-label={t('Search and commands')} onKeyDown={onKeyDown}
// a click anywhere in the panel keeps typing, arrows and Esc in the search box
onMouseDown={(e) => { if (e.target !== input.current) { e.preventDefault(); input.current?.focus() } }}
- className="search-panel flex max-h-[74vh] w-full max-w-[580px] flex-col overflow-hidden rounded-2xl border border-line bg-float">
- <div className="search-input-row flex shrink-0 items-center gap-3 px-5">
- <SearchIcon size={21} strokeWidth={1.7} aria-hidden="true" className="shrink-0 text-muted" />
- {scope && <span data-testid="search-scope" className="note-chip flex h-7 max-w-44 shrink-0 items-center gap-1.5 rounded-md border border-line ps-2.5 pe-1 text-[13px] text-muted">
- <FolderGlyph appearance={scope} size={14} /><span className="truncate">{scope.name}</span>
- <button data-testid="search-scope-clear" onClick={() => { setScope(undefined); input.current?.focus() }} aria-label={t('Search all meetings')} title={t('Search all meetings')}
- className="grid size-5 shrink-0 place-items-center rounded hover:text-ink"><X size={13} aria-hidden="true" /></button>
- </span>}
- <input
- data-testid="search-input" ref={input} autoFocus value={q} onChange={(e) => { setQ(e.target.value); setActive(0); setError(false) }}
- 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={items[active] ? `search-${items[active].meetingId}` : commands[active - items.length] ? `command-${commands[active - items.length].id}` : undefined}
- className="h-[58px] min-w-0 flex-1 bg-transparent text-[15px] outline-none placeholder:text-muted"
- />
- <kbd className="search-key shrink-0">esc</kbd>
+ 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={{
+ 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} />])),
+ }} />
+ </span>
+ <div className="search-field">
+ <div ref={highlight} className="search-input-highlight" aria-hidden="true">
+ <span>{searchFilterHighlights(q, personQuery.matches, parsed.dateSpan).map((part, i) => part.kind
+ ? <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}
+ 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}
+ />
+ </div>
+ </div>
+ {(scope || dateLabel || selectedPeople.length > 0) && <div className="search-filters">
+ {scope && <span data-testid="search-scope" className="search-filter">
+ <FolderGlyph appearance={scope} size={14} /><span className="truncate">{scope.name}</span>
+ <button data-testid="search-scope-clear" onClick={() => { setScope(undefined); input.current?.focus() }} aria-label={t('Search all meetings')} title={t('Search all meetings')}><X size={13} aria-hidden="true" /></button>
+ </span>}
+ {selectedPeople.map(person => <span key={searchPersonKey(person)} data-testid="search-person-filter" className="search-filter">
+ <UserRound size={14} aria-hidden="true" /><span className="truncate" title={person.email || person.name}>{person.name || person.email}</span>
+ <button onClick={() => clearPerson(person)} aria-label={t('Remove {name}', { name: person.name || person.email || '' })}><X size={13} aria-hidden="true" /></button>
+ </span>)}
+ {dateLabel && <span data-testid="search-date" className="search-filter">
+ <CalendarDays size={14} aria-hidden="true" /><span className="truncate" title={dateLabel}>{dateLabel}</span>
+ <button data-testid="search-date-clear" onClick={clearDate} aria-label={t('Remove {name}', { name: dateLabel })}><X size={13} aria-hidden="true" /></button>
+ </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">
- {items.length > 0 && <li role="presentation" className="command-section">{typed ? t('Meetings') : t('Recent meetings')}</li>}
- {items.map((r, i) => (
+ {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">
+ <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>
+ </li>
+ </Fragment>
+ 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">
+ <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>}
+ <kbd className="search-key search-return" aria-hidden="true">↵</kbd>
+ </li>
+ </Fragment>
+ if (row.kind === 'meeting') {
+ const r = row.meeting
+ return <Fragment key={r.meetingId}>
+ {previous?.kind !== 'meeting' && <li role="presentation" className="command-section">{typed || filtered ? t('Meetings') : t('Recent meetings')}</li>}
<li
- key={r.meetingId} id={`search-${r.meetingId}`} data-testid="search-result" role="option" aria-selected={i === active}
+ id={`search-${r.meetingId}`} data-testid="search-result" role="option" aria-selected={i === activeIndex}
onMouseMove={() => setActive(i)} onClick={() => onOpen(r.meetingId)}
- className="search-row flex cursor-default items-start gap-3.5 rounded-md px-3 py-2.5"
+ className="search-row search-meeting"
>
<span className="search-result-icon"><FileText size={17} strokeWidth={1.6} aria-hidden="true" /></span>
<span className="min-w-0 flex-1">
- <span className="flex items-baseline justify-between gap-4">
- <span data-testid="search-result-title" className="truncate text-[13px] font-medium leading-5"><Marked parts={markWords(r.title, typed)} /></span>
- <span className="shrink-0 text-[11px] text-muted">{dayLabel(r.startedAt)}</span>
- </span>
+ <span data-testid="search-result-title" className="block truncate text-sm font-medium leading-5"><Marked parts={markWords(r.title, typed)} /></span>
{typed && r.parts.length > 0 && <span className="mt-0.5 line-clamp-1 text-[13px] leading-relaxed text-muted"><Marked parts={r.parts} /></span>}
</span>
+ <time className="search-metadata" dateTime={new Date(r.startedAt).toISOString()}>{dayLabel(r.startedAt)}<span>{timeOf(r.startedAt)}</span></time>
+ <kbd className="search-key search-return" aria-hidden="true">↵</kbd>
</li>
- ))}
- {commands.map((c, i) => <li key={c.id} role="presentation">
- {(i === 0 || commands[i - 1].group !== c.group) && <p className="command-section">{c.group}</p>}
- <div id={`command-${c.id}`} data-testid={`command-${c.id}`} role="option" aria-selected={active === items.length + i} aria-disabled={running}
- onMouseMove={() => setActive(items.length + 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}</span>{'shortcut' in c && <kbd className="search-key">{c.shortcut}</kbd>}
- </div>
- </li>)}
- {results && !count && (
+ </Fragment>
+ }
+ const c = row.command
+ const current = c.id === `theme-${prefs?.theme}`
+ 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">
+ {'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>
+ </div>
+ </li>
+ })}
+ {settled && filtered && !items.length && <li role="presentation" data-testid="search-filter-empty" className="px-5 py-8 text-center text-sm text-muted">
+ {searchFilterEmptyMessage(selectedPeople, dateLabel)}
+ </li>}
+ {results && !count && !filtered && (
<li role="presentation" data-testid="search-none" className="flex h-full items-center justify-center px-5 py-8 text-center text-sm text-muted">
- {typed ? t('Nothing found for “{query}”.', { query: typed }) : scope ? t('No meetings in this folder yet.') : t('No notes yet.')}
+ {scope ? t('No meetings in this folder yet.') : t('No notes yet.')}
</li>
)}
</ul>
{error && <p role="alert" className="px-5 pb-3 text-xs text-danger">{t("Yogurt couldn't make that change. Try again.")}</p>}
<div className="search-footer">
- <span><kbd className="search-key">↑</kbd><kbd className="search-key">↓</kbd>{t('Navigate')}</span>
- <span><kbd className="search-key">↵</kbd>{t('Select')}</span>
- <button data-testid="search-shortcuts" onClick={onShortcuts}><Keyboard size={14} aria-hidden="true" />{t('Keyboard shortcuts')}<kbd className="search-key">{keys('⌘/')}</kbd></button>
+ <span><kbd className="search-key">↑↓</kbd>{t('Navigate')}</span>
+ <span data-testid="search-primary-hint"><kbd className="search-key">↵</kbd>{t('Select')}</span>
+ <span data-testid="search-secondary-hint"><kbd className="search-key">{keys('⌘↵')}</kbd>{t('Ask')}</span>
+ <span><kbd className="search-key">esc</kbd>{t('Close')}</span>
+ <button data-testid="search-shortcuts" onClick={onShortcuts} aria-label={t('Keyboard shortcuts')} title={`${t('Keyboard shortcuts')} ${keys('⌘/')}`}><Keyboard size={15} aria-hidden="true" /></button>
</div>
</MotionPopup>
</Dialog.Portal>
diff --git a/app/src/renderer/src/searchFilters.ts b/app/src/renderer/src/searchFilters.ts
new file mode 100644
index 00000000..ef876820
--- /dev/null
+++ b/app/src/renderer/src/searchFilters.ts
@@ -0,0 +1,35 @@
+import { t, language } from '../../shared/i18n'
+import type { Person } from '../../shared/types'
+import type { SearchPersonMatch } from '../../shared/searchPeople'
+import type { SearchDate } from '../../shared/searchQuery'
+
+export function searchDateLabel(date: SearchDate, locale = language()) {
+ const start = new Date(date.start)
+ const singleDay = new Date(start.getFullYear(), start.getMonth(), start.getDate() + 1).getTime() === date.end
+ return new Intl.DateTimeFormat(locale, singleDay
+ ? { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' }
+ : { month: 'short', day: 'numeric', year: 'numeric' }).formatRange(date.start, date.end - 1)
+}
+
+/** Spans refer to the original input; only the search terms are stripped for matching. */
+export function searchFilterHighlights(query: string, people: SearchPersonMatch[], date?: { start: number; end: number }) {
+ const spans = [...people.map(p => ({ start: p.start, end: p.end, kind: 'person' as const })),
+ ...(date ? [{ ...date, kind: 'date' as const }] : [])].sort((a, b) => a.start - b.start)
+ const parts: { text: string; kind?: 'person' | 'date' }[] = []
+ let end = 0
+ for (const span of spans) {
+ if (span.start > end) parts.push({ text: query.slice(end, span.start) })
+ parts.push({ text: query.slice(span.start, span.end), kind: span.kind })
+ end = span.end
+ }
+ if (end < query.length) parts.push({ text: query.slice(end) })
+ return parts
+}
+
+export function searchFilterEmptyMessage(people: Person[], date?: string) {
+ const name = new Intl.ListFormat(language(), { type: 'conjunction' }).format(people.map(p => p.name || p.email || ''))
+ if (name && date) return t('No matching meetings with {name} on {date}.', { name, date })
+ if (name) return t('No matching meetings with {name}.', { name })
+ if (date) return t('No matching meetings on {date}.', { date })
+ return undefined
+}
diff --git a/app/src/renderer/src/searchRanking.ts b/app/src/renderer/src/searchRanking.ts
new file mode 100644
index 00000000..59ab2bce
--- /dev/null
+++ b/app/src/renderer/src/searchRanking.ts
@@ -0,0 +1,63 @@
+import { searchPersonKey, type SearchPersonMatch } from '../../shared/searchPeople'
+type Command = { id?: string; label: string; group: string; synonyms?: string[] }
+type Meeting = { meetingId?: string; confident?: boolean }
+type SelectionRow = { kind: 'ask' } | { kind: 'command'; command: Command } | { kind: 'meeting'; meeting: Meeting } | ({ kind: 'person' } & SearchPersonMatch)
+
+export function searchSelectionKey(row: SelectionRow): string {
+ if (row.kind === 'command') return `command:${row.command.id ?? row.command.label}`
+ if (row.kind === 'meeting') return `meeting:${row.meeting.meetingId}`
+ if (row.kind === 'person') return `person:${searchPersonKey(row.person)}`
+ return 'ask'
+}
+
+const normalize = (text: string) => text.trim().toLocaleLowerCase().replace(/\s+/g, ' ')
+const words = (text: string) => text.split(/[^\p{L}\p{N}]+/u)
+
+/** Exact label > label prefix > word start > group/synonym > substring. */
+export function scoreCommand(command: Command, query: string): number {
+ const q = normalize(query), label = normalize(command.label)
+ if (!q) return 0
+ if (label === q) return 5
+ if (label.startsWith(q)) return 4
+ const aliases = [command.group, ...(command.synonyms ?? [])].map(normalize)
+ return Math.min(...q.split(' ').map((word) => {
+ if (words(label).some((part) => part.startsWith(word))) return 3
+ if (aliases.some((alias) => alias.startsWith(word) || words(alias).some((part) => part.startsWith(word)))) return 2
+ return [label, ...aliases].some((text) => text.includes(word)) ? 1 : 0
+ }))
+}
+
+export function orderSearchResults<C extends Command, M>(commands: C[], meetings: M[], query: string) {
+ const ranked = commands.map((command) => ({ command, score: scoreCommand(command, query) }))
+ .filter(({ score }) => !query.trim() || score > 0)
+ .sort((a, b) => b.score - a.score)
+ const commandRows = ranked.map(({ command }) => ({ kind: 'command' as const, command }))
+ const meetingRows = meetings.map((meeting) => ({ kind: 'meeting' as const, meeting }))
+ const leading = ranked[0]?.score >= 3 ? 4 : 0
+ return [...commandRows.slice(0, leading), ...meetingRows, ...commandRows.slice(leading)]
+}
+
+export function searchPalette<C extends Command, M extends Meeting>(commands: C[], meetings: M[], query: string, askQuery = query, people: SearchPersonMatch[] = [], previous?: string, filtered = false) {
+ const matches = orderSearchResults(filtered ? [] : commands, meetings, query)
+ const choices = [...people.map(person => ({ kind: 'person' as const, ...person })), ...matches]
+ const rows = askQuery.trim() ? [{ kind: 'ask' as const, query: askQuery.trim() }, ...choices] : choices
+ // Ask stays pinned, but Enter chooses a strong command or a meeting whose terms all match metadata.
+ // Keep the completed query’s strong selection while new results settle; questions still select Ask.
+ const question = /\?\s*$/.test(askQuery) || /^(who|what|when|where|why|how|did|does|is|are|can|should)\b/i.test(askQuery.trim())
+ const best = askQuery.trim() && query.trim() && !question ? rows.findIndex(row => row.kind === 'command'
+ ? scoreCommand(row.command, query) >= 3 : row.kind === 'meeting' && row.meeting.confident) : -1
+ let active = best < 0 ? 0 : best
+ if (askQuery.trim() && query.trim() && !question && previous) {
+ const prior = rows.findIndex(row => searchSelectionKey(row) === previous)
+ const strength = (row: SelectionRow) => {
+ if (row.kind === 'ask') return 2
+ if (row.kind === 'meeting') return row.meeting.confident ? 4 : 0
+ if (row.kind !== 'command') return 0
+ const score = scoreCommand(row.command, query)
+ return score >= 2 ? score + 1 : 0
+ }
+ // Keep a still-relevant choice across near-ties; a two-point gain, question, or vanished match replaces it.
+ if (prior >= 0 && strength(rows[prior]) > 0 && strength(rows[active]) < strength(rows[prior]) + 2) active = prior
+ }
+ return { rows, active }
+}
diff --git a/app/src/renderer/src/styles.css b/app/src/renderer/src/styles.css
index 4d108aa1..26385438 100644
--- a/app/src/renderer/src/styles.css
+++ b/app/src/renderer/src/styles.css
@@ -431,16 +431,43 @@ html.widget { --pill:#232326;--pill-ink:#F7F7FA;--accent:#B780FF;--pill-accent:v
/* a long list: days off screen skip layout and paint until they scroll near */
.past-day { content-visibility: auto; contain-intrinsic-size: auto 320px; }
.search-backdrop { background:var(--scrim); }
-.search-panel { position:fixed;top:12vh;left:50%;translate:-50% 0;z-index:101;width:min(580px,calc(100vw - 32px));outline:none;height:min(560px,74vh);box-shadow:var(--shadow);border-radius:12px; }
-.search-input-row { border-bottom:1px solid var(--line); }
-.command-section { padding:12px 12px 6px;font-size:11px;line-height:16px;font-weight:500;color:var(--muted); }
-.command-row { display:flex;align-items:center;gap:12px;min-height:36px;padding:7px 12px;border-radius:6px;font-size:13px;line-height:20px;font-weight:500;cursor:default; }
-.command-row>svg { flex:none;color:var(--muted); }
+.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 120ms ease; }
+@media (prefers-reduced-motion:reduce) { .swap.search-intent>* { transition:none; } }
+.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; }
+.search-input-highlight { position:absolute;inset:0;overflow:hidden;padding-block:23px;white-space:pre;pointer-events:none;color:transparent; }
+.search-input-highlight>span { display:inline-block;min-width:100%; }
+.search-input-highlight mark { padding:0;border-radius:3px;background:var(--accent-soft);color:transparent; }
+.search-filters { display:flex;flex-wrap:wrap;gap:8px;padding:0 22px 16px;padding-inline-start:60px; }
+.search-filter { display:flex;align-items:center;gap:7px;min-width:0;max-width:100%;min-height:28px;padding:3px 4px 3px 8px;border-radius:6px;background:var(--control);color:var(--muted);font-size:12px; }
+.search-filter>svg,.search-filter>button { flex:none; }
+.search-filter>button { display:grid;place-items:center;width:22px;height:22px;border-radius:4px; }
+.search-filter>button:hover { color:var(--ink);background:var(--control-hover); }
+.search-filter>button:focus-visible { outline:2px solid var(--focus);outline-offset:2px; }
+.command-section { padding:16px 12px 7px;font-size:11px;line-height:16px;font-weight:500;color:var(--muted); }
+.command-row { display:flex;align-items:center;gap:12px;min-height:48px;padding:12px;border-radius:7px;font-size:14px;line-height:20px;font-weight:500;cursor:default; }
+.command-row>svg { flex:none;width:28px;color:var(--muted); }
.command-label { min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
+.search-meeting { display:flex;align-items:center;gap:12px;min-height:56px;padding:12px;border-radius:7px;cursor:default; }
+.search-metadata { flex:none;max-width:35%;color:var(--muted);font-size:11px;line-height:18px;text-align:end;font-variant-numeric:tabular-nums; }
+.search-metadata>span { display:block; }
+.search-return { flex:none;visibility:hidden; }
+.search-row[aria-selected=true] .search-return { visibility:visible; }
.search-result-icon { display:grid;place-items:center;flex:none;width:28px;height:28px;border:1px solid transparent;border-radius:6px;color:var(--muted);background:var(--control); }
.search-key { display:inline-grid;place-items:center;min-width:18px;height:19px;padding:0 3px;border:1px solid transparent;border-radius:4px;font:10px var(--font-sans);color:var(--muted);background:var(--control); }
-.search-footer { display:flex;align-items:center;gap:16px;flex:none;border-top:1px solid var(--line);padding:10px 19px;color:var(--muted);font-size:10px;background:var(--card); }
-.search-footer>span { display:flex;align-items:center;gap:5px; }
+.search-footer { display:flex;align-items:center;gap:14px;flex:none;min-height:44px;border-top:1px solid var(--line);padding:10px 22px;color:var(--muted);font-size:11px;background:var(--card); }
+.search-footer>span { display:flex;align-items:center;gap:5px;white-space:nowrap; }
+@media (max-width:480px) {
+ .search-input-row { padding-inline:16px;gap:10px; }
+ .search-field { font-size:19px; }
+ .search-filters { padding-inline:16px; }
+ .search-footer { flex-wrap:wrap;gap:8px 12px;padding-inline:16px; }
+}
.search-panel [data-testid="search-input"]:focus-visible { outline: none; }
/* Shared confirmation shell: the native dialog top layer escapes workspace containment. */
diff --git a/app/src/shared/locales/ar.json b/app/src/shared/locales/ar.json
index 3b6993c0..27df49fe 100644
--- a/app/src/shared/locales/ar.json
+++ b/app/src/shared/locales/ar.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "لا توجد اجتماعات مطابقة مع {name}.",
+ "No matching meetings on {date}.": "لا توجد اجتماعات مطابقة في {date}.",
+ "No matching meetings with {name} on {date}.": "لا توجد اجتماعات مطابقة مع {name} في {date}.",
+ "Meetings with {name}": "اجتماعات مع {name}",
"Hide checklist": "إخفاء قائمة التحقق",
"Notes": "ملاحظات",
"Open": "فتح",
diff --git a/app/src/shared/locales/bn.json b/app/src/shared/locales/bn.json
index 6cc39c09..7c1a4a2a 100644
--- a/app/src/shared/locales/bn.json
+++ b/app/src/shared/locales/bn.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "{name}-এর সঙ্গে মিলে যাওয়া কোনো মিটিং নেই।",
+ "No matching meetings on {date}.": "{date} তারিখে মিলে যাওয়া কোনো মিটিং নেই।",
+ "No matching meetings with {name} on {date}.": "{date} তারিখে {name}-এর সঙ্গে মিলে যাওয়া কোনো মিটিং নেই।",
+ "Meetings with {name}": "{name}-এর সঙ্গে মিটিং",
"Hide checklist": "চেকলিস্ট লুকান",
"Notes": "নোট",
"Open": "খুলুন",
diff --git a/app/src/shared/locales/cs.json b/app/src/shared/locales/cs.json
index c1900ba6..43f0a58a 100644
--- a/app/src/shared/locales/cs.json
+++ b/app/src/shared/locales/cs.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Žádné odpovídající schůzky s {name}.",
+ "No matching meetings on {date}.": "Žádné odpovídající schůzky dne {date}.",
+ "No matching meetings with {name} on {date}.": "Žádné odpovídající schůzky s {name} dne {date}.",
+ "Meetings with {name}": "Schůzky s {name}",
"Hide checklist": "Skrýt kontrolní seznam",
"Notes": "Poznámky",
"Open": "Otevřít",
diff --git a/app/src/shared/locales/da.json b/app/src/shared/locales/da.json
index 64afa9a4..e731a5a5 100644
--- a/app/src/shared/locales/da.json
+++ b/app/src/shared/locales/da.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Ingen matchende møder med {name}.",
+ "No matching meetings on {date}.": "Ingen matchende møder den {date}.",
+ "No matching meetings with {name} on {date}.": "Ingen matchende møder med {name} den {date}.",
+ "Meetings with {name}": "Møder med {name}",
"Hide checklist": "Skjul tjekliste",
"Notes": "Noter",
"Open": "Åbn",
diff --git a/app/src/shared/locales/de.json b/app/src/shared/locales/de.json
index 42eb72a4..51046790 100644
--- a/app/src/shared/locales/de.json
+++ b/app/src/shared/locales/de.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Keine passenden Besprechungen mit {name}.",
+ "No matching meetings on {date}.": "Keine passenden Besprechungen am {date}.",
+ "No matching meetings with {name} on {date}.": "Keine passenden Besprechungen mit {name} am {date}.",
+ "Meetings with {name}": "Besprechungen mit {name}",
"Hide checklist": "Checkliste ausblenden",
"Notes": "Notizen",
"Open": "Öffnen",
diff --git a/app/src/shared/locales/el.json b/app/src/shared/locales/el.json
index 9a258421..750ccfe8 100644
--- a/app/src/shared/locales/el.json
+++ b/app/src/shared/locales/el.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Δεν βρέθηκαν συναντήσεις που να ταιριάζουν με {name}.",
+ "No matching meetings on {date}.": "Δεν βρέθηκαν συναντήσεις που να ταιριάζουν στις {date}.",
+ "No matching meetings with {name} on {date}.": "Δεν βρέθηκαν συναντήσεις που να ταιριάζουν με {name} στις {date}.",
+ "Meetings with {name}": "Συναντήσεις με {name}",
"Hide checklist": "Απόκρυψη λίστας ελέγχου",
"Notes": "Σημειώσεις",
"Open": "Άνοιγμα",
diff --git a/app/src/shared/locales/en.json b/app/src/shared/locales/en.json
index 9722d65f..4a8be91d 100644
--- a/app/src/shared/locales/en.json
+++ b/app/src/shared/locales/en.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "No matching meetings with {name}.",
+ "No matching meetings on {date}.": "No matching meetings on {date}.",
+ "No matching meetings with {name} on {date}.": "No matching meetings with {name} on {date}.",
+ "Meetings with {name}": "Meetings with {name}",
"{count} min": {
"one": "{count} min",
"other": "{count} min"
diff --git a/app/src/shared/locales/es.json b/app/src/shared/locales/es.json
index f6ed45ad..ac351d9f 100644
--- a/app/src/shared/locales/es.json
+++ b/app/src/shared/locales/es.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "No hay reuniones coincidentes con {name}.",
+ "No matching meetings on {date}.": "No hay reuniones coincidentes el {date}.",
+ "No matching meetings with {name} on {date}.": "No hay reuniones coincidentes con {name} el {date}.",
+ "Meetings with {name}": "Reuniones con {name}",
"Hide checklist": "Ocultar lista de verificación",
"Notes": "Notas",
"Open": "Abrir",
diff --git a/app/src/shared/locales/fi.json b/app/src/shared/locales/fi.json
index 973df5d6..b2166b67 100644
--- a/app/src/shared/locales/fi.json
+++ b/app/src/shared/locales/fi.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Ei vastaavia kokouksia henkilön {name} kanssa.",
+ "No matching meetings on {date}.": "Ei vastaavia kokouksia päivänä {date}.",
+ "No matching meetings with {name} on {date}.": "Ei vastaavia kokouksia henkilön {name} kanssa päivänä {date}.",
+ "Meetings with {name}": "Kokoukset henkilön {name} kanssa",
"Hide checklist": "Piilota tarkistuslista",
"Notes": "Muistiinpanot",
"Open": "Avaa",
diff --git a/app/src/shared/locales/fil.json b/app/src/shared/locales/fil.json
index cf145d7a..79a07a62 100644
--- a/app/src/shared/locales/fil.json
+++ b/app/src/shared/locales/fil.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Walang tumutugmang pulong kasama si {name}.",
+ "No matching meetings on {date}.": "Walang tumutugmang pulong sa {date}.",
+ "No matching meetings with {name} on {date}.": "Walang tumutugmang pulong kasama si {name} sa {date}.",
+ "Meetings with {name}": "Mga pulong kasama si {name}",
"Hide checklist": "Itago ang checklist",
"Notes": "Mga tala",
"Open": "Buksan",
diff --git a/app/src/shared/locales/fr.json b/app/src/shared/locales/fr.json
index 5ce8fa6b..7841a9f0 100644
--- a/app/src/shared/locales/fr.json
+++ b/app/src/shared/locales/fr.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Aucune réunion correspondante avec {name}.",
+ "No matching meetings on {date}.": "Aucune réunion correspondante le {date}.",
+ "No matching meetings with {name} on {date}.": "Aucune réunion correspondante avec {name} le {date}.",
+ "Meetings with {name}": "Réunions avec {name}",
"Hide checklist": "Masquer la liste de contrôle",
"Notes": "Notes",
"Open": "Ouvrir",
diff --git a/app/src/shared/locales/he.json b/app/src/shared/locales/he.json
index f4ba8b5c..2333c787 100644
--- a/app/src/shared/locales/he.json
+++ b/app/src/shared/locales/he.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "אין פגישות תואמות עם {name}.",
+ "No matching meetings on {date}.": "אין פגישות תואמות בתאריך {date}.",
+ "No matching meetings with {name} on {date}.": "אין פגישות תואמות עם {name} בתאריך {date}.",
+ "Meetings with {name}": "פגישות עם {name}",
"Hide checklist": "הסתרת רשימת הבדיקה",
"Notes": "הערות",
"Open": "פתיחה",
diff --git a/app/src/shared/locales/hi.json b/app/src/shared/locales/hi.json
index 71da6ea3..f6d04b30 100644
--- a/app/src/shared/locales/hi.json
+++ b/app/src/shared/locales/hi.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "{name} के साथ कोई मेल खाती मीटिंग नहीं मिली।",
+ "No matching meetings on {date}.": "{date} को कोई मेल खाती मीटिंग नहीं मिली।",
+ "No matching meetings with {name} on {date}.": "{date} को {name} के साथ कोई मेल खाती मीटिंग नहीं मिली।",
+ "Meetings with {name}": "{name} के साथ मीटिंग",
"Hide checklist": "चेकलिस्ट छिपाएँ",
"Notes": "नोट्स",
"Open": "खोलें",
diff --git a/app/src/shared/locales/hu.json b/app/src/shared/locales/hu.json
index 270bea68..67ff4966 100644
--- a/app/src/shared/locales/hu.json
+++ b/app/src/shared/locales/hu.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Nincs megfelelő megbeszélés vele: {name}.",
+ "No matching meetings on {date}.": "Nincs megfelelő megbeszélés ekkor: {date}.",
+ "No matching meetings with {name} on {date}.": "Nincs megfelelő megbeszélés vele: {name}, ekkor: {date}.",
+ "Meetings with {name}": "Megbeszélések vele: {name}",
"Hide checklist": "Ellenőrzőlista elrejtése",
"Notes": "Jegyzetek",
"Open": "Megnyitás",
diff --git a/app/src/shared/locales/id.json b/app/src/shared/locales/id.json
index 02682052..9f4f2d6d 100644
--- a/app/src/shared/locales/id.json
+++ b/app/src/shared/locales/id.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Tidak ada rapat yang cocok dengan {name}.",
+ "No matching meetings on {date}.": "Tidak ada rapat yang cocok pada {date}.",
+ "No matching meetings with {name} on {date}.": "Tidak ada rapat yang cocok dengan {name} pada {date}.",
+ "Meetings with {name}": "Rapat dengan {name}",
"Hide checklist": "Sembunyikan daftar periksa",
"Notes": "Catatan",
"Open": "Buka",
diff --git a/app/src/shared/locales/it.json b/app/src/shared/locales/it.json
index fa7e72e1..83bdc319 100644
--- a/app/src/shared/locales/it.json
+++ b/app/src/shared/locales/it.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Nessuna riunione corrispondente con {name}.",
+ "No matching meetings on {date}.": "Nessuna riunione corrispondente in data {date}.",
+ "No matching meetings with {name} on {date}.": "Nessuna riunione corrispondente con {name} in data {date}.",
+ "Meetings with {name}": "Riunioni con {name}",
"Hide checklist": "Nascondi checklist",
"Notes": "Note",
"Open": "Apri",
diff --git a/app/src/shared/locales/ja.json b/app/src/shared/locales/ja.json
index 90e3c149..72240259 100644
--- a/app/src/shared/locales/ja.json
+++ b/app/src/shared/locales/ja.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "{name}との一致する会議はありません。",
+ "No matching meetings on {date}.": "{date}に一致する会議はありません。",
+ "No matching meetings with {name} on {date}.": "{date}の{name}との一致する会議はありません。",
+ "Meetings with {name}": "{name} との会議",
"Hide checklist": "チェックリストを非表示",
"Notes": "ノート",
"Open": "開く",
diff --git a/app/src/shared/locales/ko.json b/app/src/shared/locales/ko.json
index a076a8ed..a72bd550 100644
--- a/app/src/shared/locales/ko.json
+++ b/app/src/shared/locales/ko.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "{name}님과의 일치하는 회의가 없습니다.",
+ "No matching meetings on {date}.": "{date}에 일치하는 회의가 없습니다.",
+ "No matching meetings with {name} on {date}.": "{date}에 {name}님과의 일치하는 회의가 없습니다.",
+ "Meetings with {name}": "{name} 님과의 회의",
"Hide checklist": "체크리스트 숨기기",
"Notes": "노트",
"Open": "열기",
diff --git a/app/src/shared/locales/ms.json b/app/src/shared/locales/ms.json
index 7f221d80..08e06ade 100644
--- a/app/src/shared/locales/ms.json
+++ b/app/src/shared/locales/ms.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Tiada mesyuarat yang sepadan dengan {name}.",
+ "No matching meetings on {date}.": "Tiada mesyuarat yang sepadan pada {date}.",
+ "No matching meetings with {name} on {date}.": "Tiada mesyuarat yang sepadan dengan {name} pada {date}.",
+ "Meetings with {name}": "Mesyuarat dengan {name}",
"Hide checklist": "Sembunyikan senarai semak",
"Notes": "Nota",
"Open": "Buka",
diff --git a/app/src/shared/locales/nb.json b/app/src/shared/locales/nb.json
index 7ba232d9..0123bacf 100644
--- a/app/src/shared/locales/nb.json
+++ b/app/src/shared/locales/nb.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Ingen samsvarende møter med {name}.",
+ "No matching meetings on {date}.": "Ingen samsvarende møter den {date}.",
+ "No matching meetings with {name} on {date}.": "Ingen samsvarende møter med {name} den {date}.",
+ "Meetings with {name}": "Møter med {name}",
"Hide checklist": "Skjul sjekkliste",
"Notes": "Notater",
"Open": "Åpne",
diff --git a/app/src/shared/locales/nl.json b/app/src/shared/locales/nl.json
index eebfad3f..0397d402 100644
--- a/app/src/shared/locales/nl.json
+++ b/app/src/shared/locales/nl.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Geen overeenkomende vergaderingen met {name}.",
+ "No matching meetings on {date}.": "Geen overeenkomende vergaderingen op {date}.",
+ "No matching meetings with {name} on {date}.": "Geen overeenkomende vergaderingen met {name} op {date}.",
+ "Meetings with {name}": "Vergaderingen met {name}",
"Hide checklist": "Checklist verbergen",
"Notes": "Notities",
"Open": "Openen",
diff --git a/app/src/shared/locales/pl.json b/app/src/shared/locales/pl.json
index e518b36f..1367761e 100644
--- a/app/src/shared/locales/pl.json
+++ b/app/src/shared/locales/pl.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Brak pasujących spotkań z {name}.",
+ "No matching meetings on {date}.": "Brak pasujących spotkań w dniu {date}.",
+ "No matching meetings with {name} on {date}.": "Brak pasujących spotkań z {name} w dniu {date}.",
+ "Meetings with {name}": "Spotkania z {name}",
"Hide checklist": "Ukryj listę kontrolną",
"Notes": "Notatki",
"Open": "Otwórz",
diff --git a/app/src/shared/locales/pt-BR.json b/app/src/shared/locales/pt-BR.json
index b9a5751f..6c453d01 100644
--- a/app/src/shared/locales/pt-BR.json
+++ b/app/src/shared/locales/pt-BR.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Nenhuma reunião correspondente com {name}.",
+ "No matching meetings on {date}.": "Nenhuma reunião correspondente em {date}.",
+ "No matching meetings with {name} on {date}.": "Nenhuma reunião correspondente com {name} em {date}.",
+ "Meetings with {name}": "Reuniões com {name}",
"Hide checklist": "Ocultar lista de verificação",
"Notes": "Notas",
"Open": "Abrir",
diff --git a/app/src/shared/locales/ro.json b/app/src/shared/locales/ro.json
index 5991785a..689585db 100644
--- a/app/src/shared/locales/ro.json
+++ b/app/src/shared/locales/ro.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Nicio întâlnire corespunzătoare cu {name}.",
+ "No matching meetings on {date}.": "Nicio întâlnire corespunzătoare pe {date}.",
+ "No matching meetings with {name} on {date}.": "Nicio întâlnire corespunzătoare cu {name} pe {date}.",
+ "Meetings with {name}": "Întâlniri cu {name}",
"Hide checklist": "Ascunde lista de verificare",
"Notes": "Notițe",
"Open": "Deschide",
diff --git a/app/src/shared/locales/ru.json b/app/src/shared/locales/ru.json
index 9543b80c..8d191383 100644
--- a/app/src/shared/locales/ru.json
+++ b/app/src/shared/locales/ru.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Нет подходящих встреч с {name}.",
+ "No matching meetings on {date}.": "Нет подходящих встреч на {date}.",
+ "No matching meetings with {name} on {date}.": "Нет подходящих встреч с {name} на {date}.",
+ "Meetings with {name}": "Встречи с {name}",
"Hide checklist": "Скрыть контрольный список",
"Notes": "Заметки",
"Open": "Открыть",
diff --git a/app/src/shared/locales/sv.json b/app/src/shared/locales/sv.json
index bc0efd82..10c7b7e1 100644
--- a/app/src/shared/locales/sv.json
+++ b/app/src/shared/locales/sv.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Inga matchande möten med {name}.",
+ "No matching meetings on {date}.": "Inga matchande möten den {date}.",
+ "No matching meetings with {name} on {date}.": "Inga matchande möten med {name} den {date}.",
+ "Meetings with {name}": "Möten med {name}",
"Hide checklist": "Dölj checklista",
"Notes": "Anteckningar",
"Open": "Öppna",
diff --git a/app/src/shared/locales/th.json b/app/src/shared/locales/th.json
index 8742cfd0..4ab4337a 100644
--- a/app/src/shared/locales/th.json
+++ b/app/src/shared/locales/th.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "ไม่มีการประชุมที่ตรงกันกับ {name}",
+ "No matching meetings on {date}.": "ไม่มีการประชุมที่ตรงกันในวันที่ {date}",
+ "No matching meetings with {name} on {date}.": "ไม่มีการประชุมที่ตรงกันกับ {name} ในวันที่ {date}",
+ "Meetings with {name}": "การประชุมกับ {name}",
"Hide checklist": "ซ่อนรายการตรวจสอบ",
"Notes": "บันทึก",
"Open": "เปิด",
diff --git a/app/src/shared/locales/tr.json b/app/src/shared/locales/tr.json
index 0c5553ed..46a3341b 100644
--- a/app/src/shared/locales/tr.json
+++ b/app/src/shared/locales/tr.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "{name} ile eşleşen toplantı yok.",
+ "No matching meetings on {date}.": "{date} tarihinde eşleşen toplantı yok.",
+ "No matching meetings with {name} on {date}.": "{date} tarihinde {name} ile eşleşen toplantı yok.",
+ "Meetings with {name}": "{name} ile toplantılar",
"Hide checklist": "Kontrol listesini gizle",
"Notes": "Notlar",
"Open": "Aç",
diff --git a/app/src/shared/locales/uk.json b/app/src/shared/locales/uk.json
index aa8f35c0..9b5c08a5 100644
--- a/app/src/shared/locales/uk.json
+++ b/app/src/shared/locales/uk.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Немає відповідних зустрічей з {name}.",
+ "No matching meetings on {date}.": "Немає відповідних зустрічей на {date}.",
+ "No matching meetings with {name} on {date}.": "Немає відповідних зустрічей з {name} на {date}.",
+ "Meetings with {name}": "Зустрічі з {name}",
"Hide checklist": "Приховати контрольний список",
"Notes": "Нотатки",
"Open": "Відкрити",
diff --git a/app/src/shared/locales/vi.json b/app/src/shared/locales/vi.json
index cab56c2c..818eeedc 100644
--- a/app/src/shared/locales/vi.json
+++ b/app/src/shared/locales/vi.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "Không có cuộc họp phù hợp với {name}.",
+ "No matching meetings on {date}.": "Không có cuộc họp phù hợp vào {date}.",
+ "No matching meetings with {name} on {date}.": "Không có cuộc họp phù hợp với {name} vào {date}.",
+ "Meetings with {name}": "Cuộc họp với {name}",
"Hide checklist": "Ẩn danh sách kiểm tra",
"Notes": "Ghi chú",
"Open": "Mở",
diff --git a/app/src/shared/locales/zh-CN.json b/app/src/shared/locales/zh-CN.json
index 33014a6c..b9e9e0e3 100644
--- a/app/src/shared/locales/zh-CN.json
+++ b/app/src/shared/locales/zh-CN.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "没有与{name}的匹配会议。",
+ "No matching meetings on {date}.": "{date}没有匹配的会议。",
+ "No matching meetings with {name} on {date}.": "{date}没有与{name}的匹配会议。",
+ "Meetings with {name}": "与 {name} 的会议",
"Hide checklist": "隐藏检查清单",
"Notes": "笔记",
"Open": "打开",
diff --git a/app/src/shared/locales/zh-TW.json b/app/src/shared/locales/zh-TW.json
index 5a357504..d1780ea3 100644
--- a/app/src/shared/locales/zh-TW.json
+++ b/app/src/shared/locales/zh-TW.json
@@ -1,4 +1,8 @@
{
+ "No matching meetings with {name}.": "沒有與{name}的相符會議。",
+ "No matching meetings on {date}.": "{date}沒有相符的會議。",
+ "No matching meetings with {name} on {date}.": "{date}沒有與{name}的相符會議。",
+ "Meetings with {name}": "與 {name} 的會議",
"Hide checklist": "隱藏檢查清單",
"Notes": "筆記",
"Open": "開啟",
diff --git a/app/src/shared/searchPeople.ts b/app/src/shared/searchPeople.ts
new file mode 100644
index 00000000..eab26a3b
--- /dev/null
+++ b/app/src/shared/searchPeople.ts
@@ -0,0 +1,62 @@
+import type { Person } from './types'
+import { personEmail } from './people'
+import { parseSearchQuery, searchWords, type SearchOptions } from './searchQuery'
+
+const nameKey = (name: string) => name.trim().toLocaleLowerCase().replace(/\s+/g, ' ')
+export const searchPersonKey = (person: Person) => person.email?.trim() ? `email:${personEmail(person.email)}` : `name:${nameKey(person.name)}`
+export const uniqueSearchPeople = (people: Person[]) => [...new Map(people.map(p => [searchPersonKey(p), p])).values()]
+export type SearchPersonMatch = { person: Person; start: number; end: number }
+export const removeSearchSpan = (query: string, span: { start: number; end: number }) => (query.slice(0, span.start) + ' ' + query.slice(span.end)).replace(/\s+/g, ' ').trim()
+export const completeSearchPerson = (query: string, match: SearchPersonMatch) => query.slice(0, match.start) + (match.person.name.trim() || match.person.email || '') + query.slice(match.end)
+const escape = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+
+export function matchSearchPeople(query: string, people: Person[], chosen: Person[] = [], options: SearchOptions = {}) {
+ const candidates = uniqueSearchPeople(people)
+ const chosenKeys = new Set(chosen.map(searchPersonKey))
+ const exact: SearchPersonMatch[] = []
+ for (const person of candidates) {
+ const selected = chosenKeys.has(searchPersonKey(person))
+ const labels = [person.email?.trim(), ...(selected || person.name.trim().split(/\s+/).length > 1 ? [person.name.trim()] : [])].filter((s): s is string => !!s)
+ for (const label of labels) {
+ const match = new RegExp(`(?<![\\p{L}\\p{N}@._+-])${escape(label).replace(/\s+/g, '\\s+')}(?![\\p{L}\\p{N}@._+-])`, 'iu').exec(query)
+ if (match) { exact.push({ person, start: match.index, end: match.index + match[0].length }); break }
+ }
+ }
+ const preferred = exact.filter(m => !exact.some(other => other !== m && other.start === m.start && other.end === m.end
+ && chosenKeys.has(searchPersonKey(other.person)) && !chosenKeys.has(searchPersonKey(m.person))))
+ const longest = preferred.filter(m => !preferred.some(other => other.start <= m.start && other.end >= m.end && other.end - other.start > m.end - m.start))
+ // A shared full name is not enough to choose between different email identities.
+ const matches = longest.filter(m => !longest.some(other => other !== m && other.start < m.end && other.end > m.start))
+ let text = query
+ for (const match of matches) text = text.slice(0, match.start) + ' '.repeat(match.end - match.start) + text.slice(match.end)
+ const date = parseSearchQuery(text, options).dateSpan
+ const tokens = [...text.matchAll(/[\p{L}\p{N}][\p{L}\p{N}@._+'’-]*/gu)]
+ const suggestions: SearchPersonMatch[] = []
+ for (const person of candidates) {
+ if (matches.some(m => searchPersonKey(m.person) === searchPersonKey(person))) continue
+ const ambiguous = longest.find(m => searchPersonKey(m.person) === searchPersonKey(person))
+ if (ambiguous) { suggestions.push(ambiguous); continue }
+ const names = nameKey(person.name).split(/\s+/)
+ let best: SearchPersonMatch | undefined
+ tokens.forEach((token, i) => {
+ if (date && token.index! >= date.start && token.index! < date.end) return
+ const word = token[0].toLocaleLowerCase()
+ if (!searchWords(word).length || word.length < 3 && word !== names[0]) return
+ const offer = (end: number) => {
+ if (!best || end - token.index! > best.end - best.start) best = { person, start: token.index!, end }
+ }
+ if (person.email && personEmail(person.email).startsWith(word)) offer(token.index! + token[0].length)
+ names.forEach((_, j) => {
+ for (let k = 0; i + k < tokens.length && j + k < names.length; k++) {
+ const part = tokens[i + k]
+ if (date && part.index! >= date.start && part.index! < date.end) break
+ if (k && !/^\s+$/.test(query.slice(tokens[i + k - 1].index! + tokens[i + k - 1][0].length, part.index))) break
+ if (!names[j + k].startsWith(part[0].toLocaleLowerCase())) break
+ offer(part.index! + part[0].length)
+ }
+ })
+ })
+ if (best) suggestions.push(best)
+ }
+ return { text, matches, suggestions }
+}
diff --git a/app/src/shared/searchQuery.ts b/app/src/shared/searchQuery.ts
new file mode 100644
index 00000000..28e60f08
--- /dev/null
+++ b/app/src/shared/searchQuery.ts
@@ -0,0 +1,114 @@
+import { casual as en, GB, type Chrono } from 'chrono-node/en'
+import { casual as de } from 'chrono-node/de'
+import { casual as fr } from 'chrono-node/fr'
+import { casual as ja } from 'chrono-node/ja'
+import { casual as pt } from 'chrono-node/pt'
+import { casual as nl } from 'chrono-node/nl'
+import { casual as ru } from 'chrono-node/ru'
+import { casual as es } from 'chrono-node/es'
+import { casual as uk } from 'chrono-node/uk'
+import { casual as it } from 'chrono-node/it'
+import { casual as sv } from 'chrono-node/sv'
+import { casual as fi } from 'chrono-node/fi'
+import { casual as vi } from 'chrono-node/vi'
+import { casual as id } from 'chrono-node/id'
+import { casual as ar } from 'chrono-node/ar'
+import { casual as hans } from 'chrono-node/zh/hans'
+import { casual as hant } from 'chrono-node/zh/hant'
+import type { ParsedComponents } from 'chrono-node'
+import type { Person } from './types'
+export type SearchDate = { start: number; end: number }
+export type SearchOptions = { now?: Date; locale?: string; language?: string; people?: Person[] }
+const stopWords = new Set(['with', 'about', 'from', 'on', 'the', 'a', 'and', 'meeting'])
+export const searchWords = (text: string) => text.toLocaleLowerCase().split(/[^\p{L}\p{N}]+/u).filter(w => w && !stopWords.has(w))
+const parsers: Record<string, Chrono> = { en, de, fr, ja, pt, nl, ru, es, uk, it, sv, fi, vi, id, ar, 'zh-cn': hans, 'zh-tw': hant }
+
+/** Calendar boundaries use local dates, including days that are not 24 hours long. */
+export function parseSearchQuery(query: string, { now = new Date(), locale = new Intl.DateTimeFormat().resolvedOptions().locale, language = locale }: SearchOptions = {}) {
+ let date: SearchDate | undefined
+ let dateSpan: { start: number; end: number } | undefined
+ let text = query
+ const day = (offset = 0) => new Date(now.getFullYear(), now.getMonth(), now.getDate() + offset)
+ const consume = (span: { start: number; end: number }, start: Date, end: Date) => {
+ if (!Number.isFinite(start.getTime()) || !Number.isFinite(end.getTime()) || end <= start) return
+ date = { start: start.getTime(), end: end.getTime() }
+ dateSpan = span
+ text = (query.slice(0, span.start) + ' ' + query.slice(span.end)).replace(/\s+/g, ' ').trim()
+ }
+ const period = /\b(?:(this|last) (week|month)|(past|last) (\d+) (days?|weeks?))\b/i.exec(query)
+ if (period) {
+ let start: Date, end: Date
+ if (period[4]) {
+ // Rolling ranges include today: the past seven days are seven local calendar days.
+ const count = Number(period[4]) * (period[5].toLowerCase().startsWith('week') ? 7 : 1)
+ start = day(1 - count); end = day(1)
+ } else if (period[2].toLowerCase() === 'month') {
+ const offset = period[1].toLowerCase() === 'last' ? -1 : 0
+ start = new Date(now.getFullYear(), now.getMonth() + offset, 1)
+ end = new Date(now.getFullYear(), now.getMonth() + offset + 1, 1)
+ } else {
+ const info = new Intl.Locale(locale) as Intl.Locale & { getWeekInfo?: () => { firstDay: number }; weekInfo?: { firstDay: number } }
+ const first = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay ?? 1
+ const offset = -((now.getDay() - first + 7) % 7) - (period[1].toLowerCase() === 'last' ? 7 : 0)
+ start = day(offset); end = day(offset + 7)
+ }
+ consume({ start: period.index, end: period.index + period[0].length }, start, end)
+ } else {
+ const fields = new Intl.DateTimeFormat(locale).formatToParts(new Date(2001, 10, 22)).map(p => p.type)
+ const dayFirst = fields.indexOf('day') < fields.indexOf('month')
+ const lang = language.toLowerCase()
+ let parser = parsers[lang] ?? parsers[lang.split('-')[0]] ?? en
+ if (parser === en && dayFirst) parser = GB
+ const midnight = (c: ParsedComponents) => new Date(c.get('year')!, c.get('month')! - 1, c.get('day')!)
+ for (const result of parser.parse(query, now)) {
+ const start = midnight(result.start), last = midnight(result.end ?? result.start)
+ const span = { start: result.index, end: result.index + result.text.trimEnd().length }
+ const before = query.slice(0, span.start)
+ const monthOnly = result.start.isCertain('month') && !result.start.isCertain('day')
+ const weekdayOnly = result.start.isCertain('weekday') && !result.start.isCertain('day')
+ const inMonth = /\bin\s+$/i.exec(before)
+ if (monthOnly) {
+ if (!inMonth || result.end) continue
+ span.start = inMonth.index
+ } else if (weekdayOnly) {
+ // A bare weekday within other words may be a title; standalone weekdays and explicit modifiers are dates.
+ if (/^\p{L}+\.?$/u.test(result.text.trim()) && query.trim() !== result.text.trim()) continue
+ if (start > day() && !/\b(next|this)\b/i.test(result.text)) {
+ start.setDate(start.getDate() - 7); last.setDate(last.getDate() - 7)
+ }
+ } else if (!result.start.isCertain('day')) continue
+ if (parser === en || parser === GB) {
+ // Chrono accepts swapped numeric fields; keep the user's regional month/day order unambiguous.
+ const numeric = [...result.text.matchAll(/\b(\d{1,2})\/(\d{1,2})(?:\/\d{4})?\b/g)]
+ if (numeric.some(m => Number(m[dayFirst ? 2 : 1]) > 12)) continue
+ }
+ if (result.start.isCertain('month') && !result.start.isCertain('year') && !result.end?.isCertain('year') && start > day()) {
+ const month = start.getMonth(), lastMonth = last.getMonth()
+ start.setFullYear(start.getFullYear() - 1); last.setFullYear(last.getFullYear() - 1)
+ if (start.getMonth() !== month || last.getMonth() !== lastMonth) continue
+ }
+ if (result.end) {
+ const from = /\bfrom\s+$/i.exec(before)
+ if (from) span.start = from.index
+ }
+ const end = monthOnly ? new Date(start.getFullYear(), start.getMonth() + 1, 1)
+ : new Date(last.getFullYear(), last.getMonth(), last.getDate() + 1)
+ consume(span, start, end)
+ if (date) break
+ }
+ }
+ return { text, words: searchWords(text), date, ...(dateSpan ? { dateSpan } : {}) }
+}
+
+/** A single insertion, deletion or substitution; short words stay exact. */
+export function oneEdit(a: string, b: string): boolean {
+ if (a.length < 5 || Math.abs(a.length - b.length) > 1) return false
+ let i = 0, j = 0, edits = 0
+ while (i < a.length && j < b.length) {
+ if (a[i] === b[j]) { i++; j++; continue }
+ if (++edits > 1) return false
+ if (a.length >= b.length) i++
+ if (b.length >= a.length) j++
+ }
+ return edits + Number(i < a.length || j < b.length) <= 1
+}
diff --git a/app/src/shared/types.ts b/app/src/shared/types.ts
index abf1cbcd..e0b19a3d 100644
--- a/app/src/shared/types.ts
+++ b/app/src/shared/types.ts
@@ -255,8 +255,8 @@ export type YogurtApi = {
/** English only or Multi-language: the meeting being recorded and the next ones */
setSpoken(v: import('./spoken').Spoken): Promise<void>
}
- /** finds meetings by title, transcript and notes; nothing typed: the latest. folder: only the meetings in it */
- search: { query(q: string, folder?: string): Promise<SearchResult[]> }
+ /** finds meetings by date, title, attendees, folders, transcript and notes; nothing typed: the latest. folder: only the meetings in it */
+ search: { query(q: string, folder?: string, people?: Person[]): Promise<SearchResult[]>; people(): Promise<Person[]> }
/** named folders of meetings; a meeting can be in several, and deleting a folder keeps its meetings */
folders: {
suggestion(meetingId: string): Promise<Folder | null>
@@ -315,7 +315,7 @@ export type AgendaEvent = CalEvent & { note?: { id: string; state: Meeting['stat
/** Start notes: the meeting's id, or why it didn't start (gone: the event left the calendar) */
export type StartResult = { id: string; alreadyRecording?: true } | { error: 'gone' | 'failed' }
/** one meeting found: parts is a piece of its notes or transcript, hit on the words matched */
-export type SearchResult = { meetingId: string; title: string; startedAt: number; parts: SnippetPart[] }
+export type SearchResult = { meetingId: string; title: string; startedAt: number; parts: SnippetPart[]; confident?: boolean }
/**
* Where a meeting's enhanced notes are: idle (none yet, the meeting may still be on), waiting (for the transcript or
diff --git a/app/test/meetingSearch.test.ts b/app/test/meetingSearch.test.ts
new file mode 100644
index 00000000..9db27850
--- /dev/null
+++ b/app/test/meetingSearch.test.ts
@@ -0,0 +1,189 @@
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { openStore, type Store } from '../src/main/store'
+
+let store: Store
+beforeEach(() => { store = openStore(':memory:') })
+afterEach(() => store.close())
+const now = new Date(2026, 10, 12, 14)
+const at = (day: number, hour = 10) => new Date(2026, 10, day, hour).getTime()
+const make = (title: string, day = 10, attendees: string[] = []) => store.createMeeting({
+ title, startedAt: at(day), endedAt: at(day, 11), eventId: null, app: null,
+ attendees: attendees.map(name => ({ name, email: null })), state: 'done',
+})
+const transcript = (id: string, text: string, hidden = false) => store.addSegments([
+ { meetingId: id, text, hidden, track: 'them', startMs: 0, endMs: 1000, speaker: null },
+])
+const search = (query: string, folder?: string) => store.search(query, 30, folder, { now, locale: 'en-US' })
+const ids = (query: string, folder?: string) => search(query, folder).map(h => h.meetingId)
+
+describe('meeting search', () => {
+ it('finds standup nov 10 by local start time, including both day boundaries', () => {
+ const first = make('Team standup'), last = make('Team standup'), outside = make('Team standup', 11)
+ store.updateMeeting(first.id, { startedAt: at(10, 0) })
+ store.updateMeeting(last.id, { startedAt: at(11, 0) - 1 })
+ store.updateMeeting(outside.id, { startedAt: at(11, 0) })
+ make('Other discussion')
+ expect(ids('standup nov 10')).toEqual([last.id, first.id])
+ expect(search('standup nov 10').every(h => h.confident)).toBe(true)
+ })
+
+ it('finds a first name and combines words across fields and transcript lines', () => {
+ const m = make('Planning', 10, ['Robin Sample'])
+ const folder = store.createFolder('Launch')
+ store.addToFolder(folder.id, m.id)
+ store.setNotes(m.id, { mine: 'Budget approved' })
+ transcript(m.id, 'Schedule milestones')
+ transcript(m.id, 'Assign owners')
+ expect(ids('Robin')).toEqual([m.id])
+ expect(ids('launch')).toEqual([m.id])
+ expect(ids('meeting with robin about planning from the launch on budget and schedule owners')).toEqual([m.id])
+ expect(ids('planning missing')).toEqual([])
+ expect(search('robin launch')[0].confident).toBe(true)
+ expect(search('budget')[0].confident).toBe(false)
+ })
+
+ it('matches only the last word as a prefix', () => {
+ const m = make('Daily standup', 10, ['Robin Sample'])
+ expect(ids('stand')).toEqual([m.id])
+ expect(ids('robin stand')).toEqual([m.id])
+ expect(ids('rob standup')).toEqual([])
+ expect(ids('tand')).toEqual([])
+ })
+
+ it('allows a single typo only in title and attendee words of at least five letters', () => {
+ const m = make('Standup', 10, ['Robin Sample'])
+ const other = make('Other')
+ store.setNotes(other.id, { mine: 'Standup' })
+ transcript(other.id, 'Standup')
+ const folder = store.createFolder('Standup')
+ store.addToFolder(folder.id, other.id)
+ expect(ids('standap')).toEqual([m.id])
+ expect(ids('robim')).toEqual([m.id])
+ expect(ids('stendap')).toEqual([])
+ const newerTypo = make('Standap', 12)
+ expect(ids('standup')).toEqual([m.id, newerTypo.id, other.id])
+ })
+
+ it('filters yesterday even without other words and returns nothing for a miss', () => {
+ const yesterday = make('Planning', 11)
+ make('Planning', 12)
+ expect(ids('yesterday')).toEqual([yesterday.id])
+ expect(ids('planning yesterday')).toEqual([yesterday.id])
+ expect(ids('unfindable')).toEqual([])
+ expect(ids('meeting with the')).toEqual([])
+ })
+
+ it('ranks title, attendee/folder, notes, then transcript; recency breaks ties', () => {
+ const title = make('Launch', 1)
+ const attendee = make('One', 2, ['Launch'])
+ const folderMeeting = make('Two', 3)
+ const folder = store.createFolder('Launch')
+ store.addToFolder(folder.id, folderMeeting.id)
+ const notes = make('Three', 4)
+ store.setNotes(notes.id, { mine: 'Launch' })
+ const spoken = make('Four', 5)
+ transcript(spoken.id, 'Launch')
+ expect(ids('launch')).toEqual([title.id, folderMeeting.id, attendee.id, notes.id, spoken.id])
+ })
+
+ it('gives an exact phrase a bonus within a field tier', () => {
+ const phrase = make('Launch planning', 1)
+ const separated = make('Planning for launch', 2)
+ expect(ids('launch planning')).toEqual([phrase.id, separated.id])
+ const notePhrase = make('One', 3), noteSeparated = make('Two', 4)
+ store.setNotes(notePhrase.id, { mine: 'Launch planning' })
+ store.setNotes(noteSeparated.id, { mine: 'Planning for launch' })
+ expect(ids('launch planning')).toEqual([phrase.id, separated.id, notePhrase.id, noteSeparated.id])
+ })
+
+ it('respects folder scope, Trash and hidden transcript lines for every term', () => {
+ const inside = make('Standup'), outside = make('Standup'), trashed = make('Standup')
+ const folder = store.createFolder('Project')
+ store.addToFolder(folder.id, inside.id)
+ store.addToFolder(folder.id, trashed.id)
+ store.trashMeeting(trashed.id)
+ transcript(inside.id, 'Hiddenword', true)
+ expect(ids('standup nov 10', folder.id)).toEqual([inside.id])
+ expect(ids('project', folder.id)).toEqual([inside.id])
+ expect(ids('hiddenword')).toEqual([])
+ expect(ids('nov 10')).toContain(outside.id)
+ expect(ids('nov 10')).not.toContain(trashed.id)
+ })
+})
+
+describe('attendee filters', () => {
+ const person = { name: 'Riley Example', email: '[email protected]' }
+ const attending = (day: number, people = [person]) => {
+ const m = make('Planning', day)
+ store.updateMeeting(m.id, { attendees: people })
+ return m
+ }
+
+ it('combines people with an inclusive date range', () => {
+ const first = attending(8), last = attending(10)
+ attending(7); attending(11); make('Planning', 9)
+ expect(ids('Riley Example nov 8 - 10')).toEqual([last.id, first.id])
+ })
+
+ it.each(['may I ask', 'march on', 'sunday standup'])('finds a meeting titled %s without inventing a date filter', title => {
+ const meeting = make(title, 10)
+ expect(ids(title)).toEqual([meeting.id])
+ })
+
+ it('finds all attended meetings by exact name or email, not mentions in notes or titles', () => {
+ const first = attending(10), second = attending(11, [{ name: 'Riley', email: '[email protected]' }])
+ const mention = make('Riley Example', 12)
+ store.setNotes(mention.id, { mine: '[email protected]' })
+ expect(ids('Riley Example')).toEqual([second.id, first.id])
+ expect(ids('[email protected]')).toEqual([second.id, first.id])
+ expect(store.searchPeople()).toEqual([person])
+ })
+
+ it('keeps partial names as ordinary text matches until a person is chosen', () => {
+ const attended = attending(10), title = make('Riley discussion', 11)
+ expect(ids('Ril')).toEqual([title.id, attended.id])
+ expect(store.search('', Infinity, undefined, { people: [person] }).map(h => h.meetingId)).toEqual([attended.id])
+ })
+
+ it('combines automatic and chosen person filters with dates and folder scope', () => {
+ const onDay = attending(10), anotherDay = attending(11)
+ make('Planning', 10)
+ expect(ids('Riley Example nov 10')).toEqual([onDay.id])
+ expect(ids('[email protected] nov 10')).toEqual([onDay.id])
+ const chosen = store.search('nov 10', Infinity, undefined, { now, people: [person] })
+ expect(chosen.map(h => h.meetingId)).toEqual([onDay.id])
+ const folder = store.createFolder('Project')
+ store.addToFolder(folder.id, anotherDay.id)
+ expect(ids('Riley Example', folder.id)).toEqual([anotherDay.id])
+ expect(ids('Riley Example nov 10', folder.id)).toEqual([])
+ })
+
+ it('falls back to names without emails and never includes trashed meetings', () => {
+ const noEmail = { name: 'Casey Sample', email: null }
+ const first = make('Planning', 10, [noEmail.name])
+ const removed = make('Planning', 11, [noEmail.name])
+ store.trashMeeting(removed.id)
+ expect(ids(noEmail.name)).toEqual([first.id])
+ expect(store.searchPeople()).toEqual([noEmail])
+ store.trashMeeting(first.id)
+ expect(store.searchPeople()).toEqual([])
+ })
+
+ it('requires a choice for shared names and filters that choice by email', () => {
+ const other = { ...person, email: '[email protected]' }
+ const first = attending(10), second = attending(11, [other])
+ expect(store.searchPeople()).toHaveLength(2)
+ expect(ids(person.name)).toEqual([second.id, first.id])
+ expect(store.search('', Infinity, undefined, { people: [person] }).map(h => h.meetingId)).toEqual([first.id])
+ expect(store.search(person.name, Infinity, undefined, { people: [person] }).map(h => h.meetingId)).toEqual([first.id])
+ expect(ids(other.email)).toEqual([second.id])
+ })
+
+ it('strips a completed single-word name before searching, including with a date', () => {
+ const single = { name: 'Casey', email: '[email protected]' }
+ const first = attending(10, [single]), second = attending(11, [single])
+ const scoped = (query: string) => store.search(query, Infinity, undefined, { now, people: [single] }).map(h => h.meetingId)
+ expect(scoped('Casey')).toEqual([second.id, first.id])
+ expect(scoped('Casey yesterday')).toEqual([second.id])
+ })
+})
diff --git a/app/test/searchFilters.test.ts b/app/test/searchFilters.test.ts
new file mode 100644
index 00000000..80e1b032
--- /dev/null
+++ b/app/test/searchFilters.test.ts
@@ -0,0 +1,61 @@
+import { describe, expect, it } from 'vitest'
+import { searchDateLabel, searchFilterEmptyMessage, searchFilterHighlights } from '../src/renderer/src/searchFilters'
+import { matchSearchPeople, removeSearchSpan } from '../src/shared/searchPeople'
+import { parseSearchQuery } from '../src/shared/searchQuery'
+import { searchPalette } from '../src/renderer/src/searchRanking'
+
+const person = { name: 'Riley Example', email: '[email protected]' }
+const commands = [{ label: 'Settings', group: 'Go to' }]
+
+describe('search filters', () => {
+ it('shows a compact range pill and highlights and removes the complete range', () => {
+ const query = 'planning from Jun 8 to Jun 10'
+ const parsed = parseSearchQuery(query, { now: new Date(2026, 6, 1), locale: 'en-US' })
+ expect(searchDateLabel(parsed.date!, 'en-US')).toBe(new Intl.DateTimeFormat('en-US', {
+ month: 'short', day: 'numeric', year: 'numeric',
+ }).formatRange(new Date(2026, 5, 8), new Date(2026, 5, 10)))
+ expect(searchFilterHighlights(query, [], parsed.dateSpan)).toEqual([
+ { text: 'planning ' }, { text: 'from Jun 8 to Jun 10', kind: 'date' },
+ ])
+ expect(removeSearchSpan(query, parsed.dateSpan!)).toBe('planning')
+ })
+
+ it('highlights people and dates in place without changing the original input', () => {
+ const query = 'notes with Riley Example today'
+ const people = matchSearchPeople(query, [person])
+ const date = parseSearchQuery(people.text)
+ const parts = searchFilterHighlights(query, people.matches, date.dateSpan)
+ expect(parts).toEqual([
+ { text: 'notes with ' }, { text: person.name, kind: 'person' },
+ { text: ' ' }, { text: 'today', kind: 'date' },
+ ])
+ expect(parts.map(p => p.text).join('')).toBe(query)
+ expect(removeSearchSpan(query, people.matches[0])).toBe('notes with today')
+ expect(removeSearchSpan(query, date.dateSpan!)).toBe('notes with Riley Example')
+ })
+
+ it.each([person.name, person.email, 'today', `${person.name} today`, `${person.name} settings`])('hides commands for the filter %s, even without remaining words', query => {
+ const people = matchSearchPeople(query, [person])
+ const date = parseSearchQuery(people.text)
+ const filtered = !!date.date || people.matches.length > 0
+ const palette = searchPalette(commands, [{ confident: true }], query, query, [], undefined, filtered)
+ expect(palette.rows.map(r => r.kind)).toEqual(['ask', 'meeting'])
+ expect(palette.rows[palette.active].kind).toBe('meeting')
+ })
+
+ it('names the filters with no matches while keeping Ask available and selected', () => {
+ expect(searchFilterEmptyMessage([person])).toBe('No matching meetings with Riley Example.')
+ expect(searchFilterEmptyMessage([], 'Monday')).toBe('No matching meetings on Monday.')
+ expect(searchFilterEmptyMessage([person], 'Monday')).toBe('No matching meetings with Riley Example on Monday.')
+ expect(searchFilterEmptyMessage([])).toBeUndefined()
+ const palette = searchPalette(commands, [], person.name, person.name, [], undefined, true)
+ expect(palette.rows).toEqual([{ kind: 'ask', query: person.name }])
+ expect(palette.active).toBe(0)
+ })
+
+ it('restores ordinary commands after filter text is deleted', () => {
+ const query = removeSearchSpan(person.name, matchSearchPeople(person.name, [person]).matches[0])
+ expect(searchFilterHighlights(query, [])).toEqual([])
+ expect(searchPalette(commands, [], query).rows.map(r => r.kind)).toEqual(['command'])
+ })
+})
diff --git a/app/test/searchPeople.test.ts b/app/test/searchPeople.test.ts
new file mode 100644
index 00000000..208de2dc
--- /dev/null
+++ b/app/test/searchPeople.test.ts
@@ -0,0 +1,111 @@
+import { describe, expect, it } from 'vitest'
+import { completeSearchPerson, matchSearchPeople, removeSearchSpan, searchPersonKey, uniqueSearchPeople } from '../src/shared/searchPeople'
+import { parseSearchQuery } from '../src/shared/searchQuery'
+
+const person = { name: 'Riley Example', email: '[email protected]' }
+const other = { name: 'Riley Sample', email: null }
+const people = [person, other]
+
+describe('people in search', () => {
+ it('completes a suggestion in place and removes only its text when cleared', () => {
+ const query = 'notes with Ril today'
+ const choice = matchSearchPeople(query, people).suggestions[0]
+ const completed = completeSearchPerson(query, choice)
+ expect(completed).toBe('notes with Riley Example today')
+ const recognized = matchSearchPeople(completed, people)
+ expect(recognized.matches[0].person).toEqual(person)
+ expect(removeSearchSpan(completed, recognized.matches[0])).toBe('notes with today')
+ })
+
+ it('keeps chosen single-word names in the text, and stops filtering when edited away', () => {
+ const single = { name: 'Casey', email: null }
+ const choice = matchSearchPeople('Cas today', [single]).suggestions[0]
+ const completed = completeSearchPerson('Cas today', choice)
+ expect(completed).toBe('Casey today')
+ expect(matchSearchPeople(completed, [single], [single]).matches.map(m => m.person)).toEqual([single])
+ expect(matchSearchPeople('Cas today', [single], [single]).matches).toEqual([])
+ expect(matchSearchPeople('today', [single], [single]).matches).toEqual([])
+ })
+
+ it('remembers an explicit identity for a shared full name without removing the name', () => {
+ const sameName = { ...person, email: '[email protected]' }
+ const choices = [person, sameName]
+ const suggestion = matchSearchPeople('Ril', choices).suggestions[1]
+ const completed = completeSearchPerson('Ril', suggestion)
+ expect(completed).toBe(person.name)
+ expect(matchSearchPeople(completed, choices, [sameName]).matches.map(m => m.person)).toEqual([sameName])
+ })
+
+ it.each(['Riley Example', '[email protected]'])('recognizes the exact identity %s', query => {
+ const result = matchSearchPeople(query, people)
+ expect(result.matches.map(m => m.person)).toEqual([person])
+ expect(result.text.trim()).toBe('')
+ expect(result.suggestions).toEqual([])
+ })
+
+ it.each(['Riley', 'Ril'])('suggests %s without turning a partial name into a filter', query => {
+ const result = matchSearchPeople(query, people)
+ expect(result.matches).toEqual([])
+ expect(result.text).toBe(query)
+ expect(result.suggestions.map(m => m.person)).toEqual(people)
+ expect(removeSearchSpan(query, result.suggestions[0])).toBe('')
+ })
+
+ it('does not suggest short prefixes or auto-filter a single-word name', () => {
+ expect(matchSearchPeople('Ri', people).suggestions).toEqual([])
+ expect(matchSearchPeople('Riley', [{ name: 'Riley', email: null }]).matches).toEqual([])
+ expect(matchSearchPeople('Riley', [{ name: 'Riley', email: null }]).suggestions).toHaveLength(1)
+ })
+
+ it('keeps the rest of the query and the date span when extracting a person', () => {
+ const query = 'Riley Example nov 10'
+ const result = matchSearchPeople(query, people)
+ const date = parseSearchQuery(result.text, { now: new Date(2026, 10, 12) })
+ expect(date.words).toEqual([])
+ expect(date.date?.start).toBe(new Date(2026, 10, 10).getTime())
+ expect(query.slice(date.dateSpan!.start, date.dateSpan!.end)).toBe('nov 10')
+ expect(removeSearchSpan(query, result.matches[0])).toBe('nov 10')
+ expect(removeSearchSpan(query, date.dateSpan!)).toBe('Riley Example')
+ const fullPrefix = matchSearchPeople('Riley Exa nov 10', people)
+ expect(removeSearchSpan('Riley Exa nov 10', fullPrefix.suggestions[0])).toBe('nov 10')
+ const partial = matchSearchPeople('standup Ril nov 10', people)
+ expect(removeSearchSpan('standup Ril nov 10', partial.suggestions[0])).toBe('standup nov 10')
+ })
+
+ it('keeps a date intact when part of a suggested name is also a month', () => {
+ const result = matchSearchPeople('Ril nov 10', [{ name: 'Riley November', email: null }])
+ expect(removeSearchSpan('Ril nov 10', result.suggestions[0])).toBe('nov 10')
+ })
+
+ it('recognizes the longer full name when another name is its prefix', () => {
+ const longer = { name: 'Riley Example Sample', email: '[email protected]' }
+ const result = matchSearchPeople(longer.name, [person, longer])
+ expect(result.matches.map(m => m.person)).toEqual([longer])
+ expect(result.suggestions).toEqual([])
+ })
+
+ it('requires whole names and emails, without interpreting punctuation as patterns', () => {
+ for (const query of ['Riley Examples', '[email protected]', '[email protected]']) {
+ expect(matchSearchPeople(query, people).matches).toEqual([])
+ }
+ const literal = { name: 'Riley (Example)', email: '[email protected]' }
+ expect(matchSearchPeople(literal.email, [literal]).matches[0].person).toEqual(literal)
+ expect(matchSearchPeople(literal.name, [literal]).matches[0].person).toEqual(literal)
+ })
+
+ it('deduplicates by normalized email, falling back to normalized name', () => {
+ const duplicate = { name: 'Different display', email: ' [email protected] ' }
+ expect(searchPersonKey(person)).toBe(searchPersonKey(duplicate))
+ expect(uniqueSearchPeople([person, duplicate, other, { name: ' riley sample ', email: null }])).toHaveLength(2)
+ expect(uniqueSearchPeople([person, { ...person, email: '[email protected]' }])).toHaveLength(2)
+ })
+
+ it('asks for a choice when a full name identifies more than one email', () => {
+ const sameName = { ...person, email: '[email protected]' }
+ const result = matchSearchPeople(person.name, [person, sameName])
+ expect(result.matches).toEqual([])
+ expect(result.suggestions.map(m => m.person)).toEqual([person, sameName])
+ expect(removeSearchSpan(person.name, result.suggestions[0])).toBe('')
+ expect(matchSearchPeople(person.email, [person, sameName]).matches.map(m => m.person)).toEqual([person])
+ })
+})
diff --git a/app/test/searchQuery.test.ts b/app/test/searchQuery.test.ts
new file mode 100644
index 00000000..9dbc4d1f
--- /dev/null
+++ b/app/test/searchQuery.test.ts
@@ -0,0 +1,141 @@
+import { describe, expect, it } from 'vitest'
+import { oneEdit, parseSearchQuery } from '../src/shared/searchQuery'
+
+const now = new Date(2026, 10, 12, 14)
+const parse = (query: string, locale = 'en-US') => parseSearchQuery(query, { now, locale })
+const at = (month: number, day: number, year = 2026) => new Date(year, month - 1, day).getTime()
+
+describe('search dates', () => {
+ it.each(['nov 10', 'november 10', '11/10', 'Nov. 10th', 'nov 10 2026'])('extracts %s from the words', date => {
+ expect(parse(`standup ${date}`)).toMatchObject({ text: 'standup', words: ['standup'], date: { start: at(11, 10), end: at(11, 11) } })
+ })
+
+ it.each([
+ ['jun 8 to jun 9', 10], ['from Jun 8 to Jun 10', 11], ['jun 8 - 10', 11],
+ ['June eighth to June tenth', 11],
+ ])('includes both endpoints of %s and removes the whole range', (range, end) => {
+ const query = `planning ${range} notes`
+ const parsed = parse(query)
+ expect(parsed.date).toEqual({ start: at(6, 8), end: at(6, end) })
+ expect(query.slice(parsed.dateSpan!.start, parsed.dateSpan!.end)).toBe(range)
+ expect(parsed.text).toBe('planning notes')
+ })
+
+ it('marks only a complete recognized date without changing the typed text', () => {
+ for (const query of ['Octob', 'October', 'October roadmap']) expect(parse(query).dateSpan).toBeUndefined()
+ const query = 'standup October 28 notes'
+ const parsed = parse(query)
+ expect(query.slice(parsed.dateSpan!.start, parsed.dateSpan!.end)).toBe('October 28')
+ expect(parsed.text).toBe('standup notes')
+ expect(parsed.date).toEqual({ start: at(10, 28), end: at(10, 29) })
+ const relative = 'review last week'
+ const span = parse(relative).dateSpan!
+ expect(relative.slice(span.start, span.end)).toBe('last week')
+ })
+
+ it('uses the locale for numeric dates', () => {
+ expect(parse('standup 10/11', 'en-GB').date).toEqual(parse('standup 11/10').date)
+ expect(parse('11/10', 'en-GB').date).toEqual({ start: at(10, 11), end: at(10, 12) })
+ })
+
+ it.each([
+ ['today', 11, 12, 13], ['yesterday', 11, 11, 12],
+ ['tuesday', 11, 10, 11], ['last tuesday', 11, 10, 11],
+ ['thursday', 11, 12, 13], ['last thursday', 11, 5, 6],
+ ['this week', 11, 8, 15], ['last week', 11, 1, 8],
+ ['last friday', 11, 6, 7], ['3 days ago', 11, 9, 10],
+ ['this month', 11, 1, 31], ['last month', 10, 1, 32],
+ ['past 3 days', 11, 10, 13], ['last 3 days', 11, 10, 13],
+ ['past 2 weeks', 10, 30, 44], ['last 2 weeks', 10, 30, 44],
+ ['in october', 10, 1, 32],
+ ])('parses %s as a local calendar range', (query, month, start, end) => {
+ expect(parse(query).date).toEqual({ start: at(month, start), end: at(month, end) })
+ expect(parse(query).words).toEqual([])
+ })
+
+ it('uses the locale week start and handles year boundaries', () => {
+ expect(parse('last week', 'en-GB').date).toEqual({ start: at(11, 2), end: at(11, 9) })
+ expect(parse('december 31').date).toEqual({ start: at(12, 31, 2025), end: at(1, 1) })
+ expect(parse('in december').date).toEqual({ start: at(12, 1, 2025), end: at(1, 1) })
+ expect(parse('nov 10 2025').date?.start).toBe(at(11, 10, 2025))
+ expect(parse('dec 30 to jan 2').date).toEqual({ start: at(12, 30, 2025), end: at(1, 3) })
+ expect(parse('jun 8 to jun 9 2025').date).toEqual({ start: at(6, 8, 2025), end: at(6, 10, 2025) })
+ expect(parseSearchQuery('last month', { now: new Date(2026, 0, 5) }).date).toEqual({ start: at(12, 1, 2025), end: at(1, 1) })
+ })
+
+ it('uses Monday when locale week information is unavailable', () => {
+ const original = Object.getOwnPropertyDescriptors(Intl.Locale.prototype)
+ try {
+ Object.defineProperty(Intl.Locale.prototype, 'getWeekInfo', { value: undefined, configurable: true })
+ Object.defineProperty(Intl.Locale.prototype, 'weekInfo', { value: undefined, configurable: true })
+ expect(parse('this week', 'en-US').date).toEqual({ start: at(11, 9), end: at(11, 16) })
+ } finally {
+ for (const key of ['getWeekInfo', 'weekInfo']) {
+ if (original[key]) Object.defineProperty(Intl.Locale.prototype, key, original[key])
+ else Reflect.deleteProperty(Intl.Locale.prototype, key)
+ }
+ }
+ })
+
+ it.each(['may I ask', 'march on', 'sunday standup', 'first week of November'])('keeps %s as ordinary search text', query => {
+ expect(parse(query).date).toBeUndefined()
+ expect(parse(query).text).toBe(query)
+ })
+
+ it('keeps explicit weekday searches while resolving an ambiguous weekday into the past', () => {
+ expect(parse('sunday').date).toEqual({ start: at(11, 8), end: at(11, 9) })
+ expect(parse('planning on sunday').date).toEqual({ start: at(11, 8), end: at(11, 9) })
+ })
+
+ it.each([['fr', 'hier'], ['de', 'gestern'], ['es', 'ayer'], ['ja', '昨日'], ['ru', 'вчера'], ['zh-CN', '昨天'], ['it', 'ieri']])('uses the app language %s independently of the regional locale', (language, query) => {
+ expect(parseSearchQuery(query, { now, locale: 'en-US', language }).date).toEqual({ start: at(11, 11), end: at(11, 12) })
+ })
+
+ it('falls back to English for unsupported languages and preserves regional numeric dates', () => {
+ expect(parseSearchQuery('yesterday', { now, language: 'ko' }).date).toEqual({ start: at(11, 11), end: at(11, 12) })
+ expect(parseSearchQuery('10/11', { now, locale: 'en-GB', language: 'en' }).date).toEqual({ start: at(11, 10), end: at(11, 11) })
+ })
+
+ it('does not turn invalid dates or ordinary words into filters', () => {
+ for (const query of ['nov 31', '2/30', '13/10', 'may we meet', 'october roadmap', 'tuesdays', 'nothing']) {
+ expect(parse(query).date).toBeUndefined()
+ expect(parse(query).text).toBe(query)
+ }
+ expect(parse('feb 29 2024').date).toEqual({ start: at(2, 29, 2024), end: at(3, 1, 2024) })
+ expect(parse('feb 29 2025').date).toBeUndefined()
+ })
+
+ it('uses consecutive local midnights across daylight-saving transitions', () => {
+ const saved = process.env.TZ
+ try {
+ process.env.TZ = 'America/Los_Angeles'
+ const spring = parseSearchQuery('today', { now: new Date(2026, 2, 8, 12) }).date!
+ const fall = parseSearchQuery('today', { now: new Date(2026, 10, 1, 12) }).date!
+ expect(spring.end - spring.start).toBe(23 * 60 * 60 * 1000)
+ expect(fall.end - fall.start).toBe(25 * 60 * 60 * 1000)
+ const range = parseSearchQuery('mar 7 to mar 9', { now: new Date(2026, 2, 10) }).date!
+ expect(range.end - range.start).toBe(71 * 60 * 60 * 1000)
+ } finally {
+ if (saved === undefined) delete process.env.TZ
+ else process.env.TZ = saved
+ }
+ })
+
+ it('ignores connecting words and leaves the date removable without losing the rest', () => {
+ const parsed = parse('meeting with Robin about the launch on nov 10')
+ expect(parsed.words).toEqual(['robin', 'launch'])
+ expect(parsed.text).toBe('meeting with Robin about the launch on')
+ expect(parse(parsed.text).date).toBeUndefined()
+ })
+})
+
+describe('light typo tolerance', () => {
+ it.each(['standap', 'stanup', 'standupp'])('accepts one edit in %s', word => {
+ expect(oneEdit(word, 'standup')).toBe(true)
+ })
+ it('rejects short words and multiple edits', () => {
+ expect(oneEdit('plan', 'play')).toBe(false)
+ expect(oneEdit('stendap', 'standup')).toBe(false)
+ expect(oneEdit('stnadup', 'standup')).toBe(false)
+ })
+})
diff --git a/app/test/searchRanking.test.ts b/app/test/searchRanking.test.ts
new file mode 100644
index 00000000..1a4091fe
--- /dev/null
+++ b/app/test/searchRanking.test.ts
@@ -0,0 +1,191 @@
+import { describe, expect, it } from 'vitest'
+import { orderSearchResults, scoreCommand, searchPalette, searchSelectionKey } from '../src/renderer/src/searchRanking'
+
+const commands = [
+ { label: 'Settings', group: 'Go to', synonyms: ['preferences', 'prefs'] },
+ { label: 'Trash', group: 'Go to' },
+ { label: 'Keyboard shortcuts', group: 'Go to' },
+ { label: 'Dark theme', group: 'Appearance', synonyms: ['theme', 'appearance', 'mode', 'dark'] },
+ { label: 'Light theme', group: 'Appearance', synonyms: ['theme', 'appearance', 'mode', 'light'] },
+ { label: 'Match my system', group: 'Appearance', synonyms: ['theme', 'appearance', 'mode', 'system'] },
+ { label: 'Open at login', group: 'Settings' },
+ { label: 'Dark planning', group: 'Folders' },
+]
+const labels = (query: string, source = commands) => orderSearchResults(source, ['meeting'], query)
+ .map((row) => row.kind === 'command' ? row.command.label : row.meeting)
+
+describe('command scoring', () => {
+ it('ranks exact labels, prefixes, word starts, aliases, then substrings', () => {
+ const scores = ['dark theme', 'dark', 'theme', 'mode', 'ark'].map((q) => scoreCommand(commands[3], q))
+ expect(scores).toEqual([5, 4, 3, 2, 1])
+ expect(scoreCommand(commands[3], 'appearance')).toBe(2)
+ expect(scoreCommand(commands[0], 'prefs')).toBe(2)
+ expect(scoreCommand(commands[0], 'preferences')).toBe(2)
+ expect(scoreCommand(commands[0], 'budget review')).toBe(0)
+ })
+
+ it('normalizes case and whitespace and requires every query word to match', () => {
+ expect(scoreCommand(commands[3], ' DARK THEME ')).toBe(5)
+ expect(scoreCommand(commands[3], 'theme dark')).toBe(3)
+ expect(scoreCommand(commands[3], 'dark mode')).toBe(2)
+ expect(scoreCommand(commands[3], 'dark budget')).toBe(0)
+ expect(scoreCommand(commands[3], '(.*)')).toBe(0)
+ })
+
+ it('matches localized labels and groups, with English synonyms as a bonus', () => {
+ const command = { label: 'Thème sombre', group: 'Apparence', synonyms: ['dark', 'mode'] }
+ expect(scoreCommand(command, 'thème')).toBe(4)
+ expect(scoreCommand(command, 'sombre')).toBe(3)
+ expect(scoreCommand(command, 'apparence')).toBe(2)
+ expect(scoreCommand(command, 'dark')).toBe(2)
+ expect(scoreCommand({ label: '深色主题', group: '外观' }, '深色')).toBe(4)
+ })
+})
+
+describe('search ordering', () => {
+ it.each([
+ ['dark', ['Dark theme', 'Dark planning', 'meeting']],
+ ['light', ['Light theme', 'meeting']],
+ ['set', ['Settings', 'Open at login', 'meeting']],
+ ['trash', ['Trash', 'meeting']],
+ ['short', ['Keyboard shortcuts', 'meeting']],
+ ['budget review', ['meeting']],
+ ['theme', ['Dark theme', 'Light theme', 'Match my system', 'meeting']],
+ ['mode', ['meeting', 'Dark theme', 'Light theme', 'Match my system']],
+ ['appearance', ['meeting', 'Dark theme', 'Light theme', 'Match my system']],
+ ['prefs', ['meeting', 'Settings']],
+ ['ark', ['meeting', 'Dark theme', 'Dark planning']],
+ ])('orders commands and meetings for %s', (query, expected) => {
+ expect(labels(query)).toEqual(expected)
+ })
+
+ it('keeps the empty-query order, including whitespace-only queries', () => {
+ for (const query of ['', ' ']) expect(labels(query)).toEqual(['meeting', ...commands.map((c) => c.label)])
+ })
+
+ it('caps promoted commands at four, keeps ties stable and leaves overflow accessible', () => {
+ const folders = Array.from({ length: 6 }, (_, i) => ({ label: `Plan ${i}`, group: 'Folders' }))
+ expect(labels('plan', folders)).toEqual(['Plan 0', 'Plan 1', 'Plan 2', 'Plan 3', 'meeting', 'Plan 4', 'Plan 5'])
+ expect(folders.map((f) => f.label)).toEqual(['Plan 0', 'Plan 1', 'Plan 2', 'Plan 3', 'Plan 4', 'Plan 5'])
+ })
+
+ it('preserves meeting order and shows commands when there are no meetings', () => {
+ expect(orderSearchResults(commands, ['recent', 'older'], 'ark').slice(0, 2))
+ .toEqual([{ kind: 'meeting', meeting: 'recent' }, { kind: 'meeting', meeting: 'older' }])
+ expect(orderSearchResults(commands, [], 'prefs')).toEqual([{ kind: 'command', command: commands[0] }])
+ expect(orderSearchResults(commands, [], 'unknown')).toEqual([])
+ })
+})
+
+
+describe('Ask in the command palette', () => {
+ const meeting = { title: 'Budget review', confident: true }
+ it('pins Ask above results but selects a strong command or confident meeting', () => {
+ const command = searchPalette(commands, [meeting], 'dark')
+ expect(command.rows[0]).toEqual({ kind: 'ask', query: 'dark' })
+ expect(command.rows[command.active]).toEqual({ kind: 'command', command: commands[3] })
+ expect(searchPalette(commands, [meeting], 'dark', ' dark ').active).toBe(command.active)
+ const found = searchPalette(commands, [meeting], 'budget')
+ expect(found.rows[0].kind).toBe('ask')
+ expect(found.rows[found.active]).toEqual({ kind: 'meeting', meeting })
+ })
+ it.each(['Budget review?', 'who', 'what', 'when', 'where', 'why', 'how', 'did', 'does', 'is', 'are', 'can', 'should'])('selects Ask for a question starting with %s', query => {
+ const palette = searchPalette(commands, [meeting], query)
+ expect(palette.active).toBe(0)
+ expect(palette.rows[0]).toEqual({ kind: 'ask', query })
+ })
+ it('uses word boundaries for question words', () => {
+ const palette = searchPalette(commands, [meeting], 'island')
+ expect(palette.rows[palette.active].kind).toBe('meeting')
+ })
+ it('selects the only Ask row for no matches, and prefers Ask over weak matches', () => {
+ expect(searchPalette(commands, [], 'unfindable')).toEqual({ rows: [{ kind: 'ask', query: 'unfindable' }], active: 0 })
+ expect(searchPalette(commands, [{ confident: false }], 'budget').active).toBe(0)
+ expect(searchPalette(commands, [], 'prefs').active).toBe(0)
+ })
+ it('keeps empty-query behavior and shows the latest question while results settle', () => {
+ expect(searchPalette(commands, [meeting], ' ').rows[0]).toEqual({ kind: 'meeting', meeting })
+ const pending = searchPalette(commands, [meeting], '', 'new question')
+ expect(pending.rows[0]).toEqual({ kind: 'ask', query: 'new question' })
+ expect(pending.active).toBe(0)
+ })
+})
+
+
+it('keeps a strong selection through pending keystrokes, while questions stay on Ask', () => {
+ const meeting = { confident: true }
+ for (const [settled, typed] of [['t', 'th'], ['th', 'the'], ['the', 'them'], ['them', 'theme'], ['theme', 'them']]) {
+ const before = searchPalette(commands, [meeting], settled)
+ const pending = searchPalette(commands, [meeting], settled, typed)
+ expect(pending.rows[pending.active]).toEqual(before.rows[before.active])
+ }
+ expect(searchPalette(commands, [meeting], 'theme', 'what is theme').active).toBe(0)
+ expect(searchPalette(commands, [meeting], 'what is', 'what is next').active).toBe(0)
+})
+
+it('puts explicit people choices below Ask without treating them as automatic filters', () => {
+ const choice = { person: { name: 'Riley Example', email: '[email protected]' }, start: 0, end: 3 }
+ const result = searchPalette(commands, [], 'Ril', 'Ril', [choice])
+ expect(result.rows.map(r => r.kind)).toEqual(['ask', 'person'])
+ expect(result.rows[1]).toEqual({ kind: 'person', ...choice })
+ expect(result.active).toBe(0)
+})
+
+describe('default selection settling', () => {
+ const meeting = { meetingId: 'planning', confident: true }
+ const choose = (query: string, previous?: string, meetings = [meeting]) => {
+ const palette = searchPalette(commands, meetings, query, query, [], previous)
+ return searchSelectionKey(palette.rows[palette.active])
+ }
+
+ it('keeps folder ties in command order and settles successive queries like the palette', () => {
+ const source = [commands[0], commands[1], commands[7], commands[4], commands[3]]
+ let previous: string | undefined, completed = ''
+ for (const [query, expected] of [
+ ['', 'meeting:planning'], ['dark', 'command:Dark planning'], ['light', 'command:Light theme'],
+ ['set', 'command:Settings'], ['trash', 'command:Trash'], ['budget review', 'meeting:planning'],
+ ['theme', 'meeting:planning'], ['mode', 'meeting:planning'], ['', 'meeting:planning'],
+ ['dark', 'command:Dark planning'],
+ ]) {
+ const pending = searchPalette(source, [meeting], completed, query, [], previous)
+ previous = query ? searchSelectionKey(pending.rows[pending.active]) : undefined
+ const settled = searchPalette(source, [meeting], query, query, [], previous)
+ expect(searchSelectionKey(settled.rows[settled.active])).toBe(expected)
+ previous = query ? searchSelectionKey(settled.rows[settled.active]) : undefined
+ completed = query
+ }
+ })
+
+ it('keeps the current choice on a near-tie, even when row positions change', () => {
+ expect(choose('dark', 'meeting:planning')).toBe('meeting:planning')
+ expect(choose('mode', 'command:Dark theme')).toBe('command:Dark theme')
+ })
+
+ it('lets a clearly better match take over', () => {
+ expect(choose('dark theme', 'meeting:planning')).toBe('command:Dark theme')
+ expect(choose('theme', 'ask')).toBe('command:Dark theme')
+ expect(choose('budget', 'ask')).toBe('meeting:planning')
+ })
+
+ it('resets a cleared query to the first row', () => {
+ expect(choose('', 'command:Dark theme')).toBe('meeting:planning')
+ expect(choose(' ', 'ask')).toBe('meeting:planning')
+ })
+
+ it('keeps the theme choice through successive keystrokes and pending searches', () => {
+ let previous: string | undefined
+ for (const query of ['t', 'th', 'the', 'them', 'theme']) {
+ const palette = searchPalette([commands[3]], [meeting], query, query, [], previous)
+ previous = searchSelectionKey(palette.rows[palette.active])
+ expect(previous).toBe('command:Dark theme')
+ const pending = searchPalette([commands[3]], [meeting], query, `${query}e`, [], previous)
+ expect(searchSelectionKey(pending.rows[pending.active])).toBe(previous)
+ }
+ })
+
+ it('selects Ask for questions, vanished matches, or a meeting that is no longer confident', () => {
+ expect(choose('what is dark theme?', 'command:Dark theme')).toBe('ask')
+ expect(choose('unfindable', 'command:Dark theme', [])).toBe('ask')
+ expect(choose('budget', 'meeting:planning', [{ ...meeting, confident: false }])).toBe('ask')
+ })
+})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e94af2c8..8d99aa7c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -15,6 +15,9 @@ importers:
app:
dependencies:
+ chrono-node:
+ specifier: 2.10.3
+ version: 2.10.3
electron-updater:
specifier: 6.8.10
version: 6.8.10
@@ -1308,6 +1311,10 @@ packages:
resolution: {integrity: sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw==}
+ resolution: {integrity: sha512-MOfrzXgSMZTH4SZ5gyRKQCVwiCrCKY+uYkSJiWoRLXS88DA6WGJm8UjgS+VVEuUQeew/UUXaxrO+SeDn/WCisg==}
+ engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
+
resolution: {integrity: sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==}
engines: {node: '>=8'}
@@ -3883,6 +3890,8 @@ snapshots:
+