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.
TypeScript ai-meeting-assistantai-notetakerelectrongranola-alternativelinuxllama-cpplocal-ailocal-firstmacosmcpmeeting-minutesmeeting-notesoffline-firstopen-sourceprivacyspeech-to-texttranscriptionwhisperwhisper-cppwindows
Ask: Rename and Delete dialogs keep focus when opened from the history menu
Eric Brownrout80b50b6a57cb
diff --git a/app/src/renderer/src/components/ConversationActions.tsx b/app/src/renderer/src/components/ConversationActions.tsxindex 157ef003..24863175 100644--- a/app/src/renderer/src/components/ConversationActions.tsx+++ b/app/src/renderer/src/components/ConversationActions.tsx@@ -14,7 +14,7 @@ export function ConversationActions({ id, title, onNew, onDeleted, onEdit, classconst container = useRef<HTMLElement | null>(null)const mountButton = useCallback((node: HTMLButtonElement | null) => { button.current = node; container.current = node?.closest('dialog') ?? null }, [])const [dialog, setDialog] = useState<Edit>()- const edit = (kind: Edit) => { button.current?.focus(); if (onEdit) onEdit(kind); else setDialog(kind) }+ const edit = (kind: Edit) => { button.current?.focus(); setDialog(kind); onEdit?.(kind) }const cancel = () => { setDialog(undefined); button.current?.focus({ preventScroll: true }) }return <><Menu.Root modal={false}>@@ -29,7 +29,7 @@ export function ConversationActions({ id, title, onNew, onDeleted, onEdit, class</Menu.Positioner></Menu.Portal></Menu.Root>- {dialog && <ConversationDialog id={id} title={title} kind={dialog} container={container.current ?? undefined} onClose={cancel} onDeleted={onDeleted} />}+ {dialog && !onEdit && <ConversationDialog id={id} title={title} kind={dialog} container={container.current ?? undefined} onClose={cancel} onDeleted={onDeleted} />}</>}diff --git a/app/test/conversationActions.test.ts b/app/test/conversationActions.test.tsnew file mode 100644index 00000000..3c5315df--- /dev/null+++ b/app/test/conversationActions.test.ts@@ -0,0 +1,38 @@+import { beforeEach, expect, it, vi } from 'vitest'+import { createElement, useState, type ComponentProps, type ReactNode } from 'react'+import { renderToStaticMarkup } from 'react-dom/server'+import { Menu } from '@base-ui/react/menu'+import { ConversationActions } from '../src/renderer/src/components/ConversationActions'++vi.mock('react', async importOriginal => {+ const react = await importOriginal<typeof import('react')>()+ return { ...react, useState: vi.fn(react.useState) }+})+vi.mock('@base-ui/react/menu', () => {+ const children = ({ children }: { children?: ReactNode }) => children+ return { Menu: { Root: children, Trigger: children, Portal: children, Positioner: children, Popup: vi.fn(children), Item: vi.fn(children) } }+})+vi.mock('../src/renderer/src/components/Modal', () => ({+ Modal: () => { throw new Error('Recent owns the dialog; the menu must not render another') },+ ModalClose: () => null,+}))++beforeEach(() => vi.clearAllMocks())++it.each(['rename', 'delete'] as const)('hands focus to a %s dialog owned by Recent', kind => {+ let dialog: string | undefined+ vi.mocked(useState).mockImplementation(() => [dialog, next => { dialog = next as string }])+ const onEdit = vi.fn()+ const render = () => renderToStaticMarkup(createElement(ConversationActions, { id: 'chat', title: 'Weekly', onDeleted() {}, onEdit }))+ const popup = () => vi.mocked(Menu.Popup).mock.calls.at(-1)![0]+ render()+ // Ordinary menu dismissal still returns focus to its trigger.+ expect(popup().finalFocus).toEqual({ current: null })+ const item = vi.mocked(Menu.Item).mock.calls.map(([props]) => props as ComponentProps<typeof Menu.Item> & { 'data-testid': string })+ .find(props => props['data-testid'] === `chat-${kind}`)!+ item.onClick!({} as never)+ expect(onEdit).toHaveBeenCalledWith(kind)+ render()+ // Explicit trigger restoration runs after the menu's exit and would steal dialog focus.+ expect(popup().finalFocus).toBe(false)+})