Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat(mobile): Add an Ask pill and shortcut chips to note chat (#2357)
Chad Piha8e0d901eb6bb
diff --git a/openwhispr-mobile/src/components/notes/NoteChatSheet.tsx b/openwhispr-mobile/src/components/notes/NoteChatSheet.tsxindex b4ef40c42..c96216089 100644--- a/openwhispr-mobile/src/components/notes/NoteChatSheet.tsx+++ b/openwhispr-mobile/src/components/notes/NoteChatSheet.tsx@@ -16,6 +16,7 @@ import { MarkdownRenderer } from '@/components/notes/MarkdownRenderer';import { useKeyboardHeight } from '@/hooks/useKeyboardHeight';import { BRAND } from '@/config/colors';import type { ChatOverNoteMessage } from '@/lib/notes/chatOverNote';+import type { NoteChatSuggestion } from '@/lib/notes/noteChatSuggestions';const INPUT_KEYBOARD_GAP = 10;@@ -26,8 +27,10 @@ interface NoteChatSheetProps {isProcessing: boolean;error: string | null;canSend: boolean;+ suggestions: readonly NoteChatSuggestion[];onDraftChange: (text: string) => void;onSend: () => void;+ onSuggestion: (prompt: string) => void;onRetry: () => void;onClear: () => void;onClose: () => void;@@ -40,8 +43,10 @@ export function NoteChatSheet({isProcessing,error,canSend,+ suggestions,onDraftChange,onSend,+ onSuggestion,onRetry,onClear,onClose,@@ -52,6 +57,10 @@ export function NoteChatSheet({const keyboardHeight = useKeyboardHeight(visible);const canSubmit = canSend && draft.trim().length > 0 && !isProcessing;const hasMessages = messages.length > 0;+ // Shortcuts only seed the first question: they'd crowd an existing thread, and a tap sends+ // immediately, so they step aside once the user starts typing rather than discard the draft.+ const showSuggestions = !hasMessages && !draft.trim() && suggestions.length > 0;+ const canUseSuggestion = canSend && !isProcessing;const sheetHeight = Math.min(windowHeight * 0.82, windowHeight - insets.top - 8);const bottomPad =keyboardHeight > 0 ? keyboardHeight + INPUT_KEYBOARD_GAP : Math.max(insets.bottom, 14);@@ -83,7 +92,7 @@ export function NoteChatSheet({<View className="flex-1 pr-3"><Text className="text-[19px] font-bold text-label">Ask about this note</Text><Text className="mt-1 text-[13px] text-secondaryLabel">- Answers use only this note and this chat.+ Answers use only this note. This chat is temporary and won't be saved.</Text></View>{hasMessages ? (@@ -102,23 +111,15 @@ export function NoteChatSheet({</GlassIconButton></View>+ {/* With the keyboard up the sheet is short, so an empty thread must not squeeze the chips. */}<ScrollViewref={scrollRef}- className="min-h-[220px] flex-1"+ className={`flex-1 ${hasMessages ? 'min-h-[220px]' : ''}`}keyboardShouldPersistTaps="handled"showsVerticalScrollIndicator={false}onContentSizeChange={() => scrollRef.current?.scrollToEnd({ animated: true })}>- {!hasMessages ? (- <View className="min-h-[200px] justify-center">- <Text className="text-[15px] font-medium text-label">- Ask for decisions, action items, quotes, or who said what.- </Text>- <Text className="mt-2 text-[14px] leading-5 text-secondaryLabel">- The conversation is temporary and will not be saved.- </Text>- </View>- ) : (+ {hasMessages ? (<View className="gap-3 pb-3">{messages.map((message) => {const isUser = message.role === 'user';@@ -150,7 +151,7 @@ export function NoteChatSheet({</View>) : null}</View>- )}+ ) : null}</ScrollView>{error ? (@@ -168,6 +169,32 @@ export function NoteChatSheet({</View>) : null}+ {/* Bleeds past the sheet's side padding so chips scroll edge to edge. */}+ {showSuggestions ? (+ <ScrollView+ horizontal+ className="-mx-5 mb-3 shrink-0 grow-0"+ contentContainerClassName="gap-2 px-5"+ keyboardShouldPersistTaps="handled"+ showsHorizontalScrollIndicator={false}+ >+ {suggestions.map((suggestion) => (+ <Pressable+ key={suggestion.label}+ onPress={() => onSuggestion(suggestion.prompt)}+ disabled={!canUseSuggestion}+ accessibilityRole="button"+ accessibilityLabel={suggestion.label}+ accessibilityHint="Sends this question"+ className="rounded-full bg-tertiarySystemFill px-4 py-2.5 active:opacity-70 disabled:opacity-50"+ style={{ borderCurve: 'continuous' }}+ >+ <Text className="text-[15px] font-medium text-label">{suggestion.label}</Text>+ </Pressable>+ ))}+ </ScrollView>+ ) : null}+<View className="flex-row items-end gap-2 rounded-[22px] bg-secondarySystemBackground px-3 py-2"><TextInputvalue={draft}diff --git a/openwhispr-mobile/src/components/notes/__tests__/NoteChatSheet.test.tsx b/openwhispr-mobile/src/components/notes/__tests__/NoteChatSheet.test.tsxnew file mode 100644index 000000000..42c2b1d92--- /dev/null+++ b/openwhispr-mobile/src/components/notes/__tests__/NoteChatSheet.test.tsx@@ -0,0 +1,82 @@+import { fireEvent, render } from '@testing-library/react-native';+import { NoteChatSheet } from '../NoteChatSheet';+import { getNoteChatSuggestions } from '@/lib/notes/noteChatSuggestions';+import type { ChatOverNoteMessage } from '@/lib/notes/chatOverNote';++jest.mock('react-native-safe-area-context', () => ({+ useSafeAreaInsets: () => ({ top: 0, right: 0, bottom: 0, left: 0 }),+}));+jest.mock('@/hooks/useKeyboardHeight', () => ({ useKeyboardHeight: () => 0 }));+jest.mock('@/components/ui/Text', () => ({ Text: require('react-native').Text }));+jest.mock('@/components/ui/SystemIcon', () => ({ SystemIcon: () => null }));+jest.mock('@/components/ui/GlassIconButton', () => ({ GlassIconButton: () => null }));+jest.mock('@/components/notes/MarkdownRenderer', () => ({+ MarkdownRenderer: ({ content }: { content: string }) => {+ const { Text } = require('react-native');+ return <Text>{content}</Text>;+ },+}));++const meetingSuggestions = getNoteChatSuggestions(true);++const renderSheet = (overrides: Partial<React.ComponentProps<typeof NoteChatSheet>> = {}) => {+ const props: React.ComponentProps<typeof NoteChatSheet> = {+ visible: true,+ messages: [],+ draft: '',+ isProcessing: false,+ error: null,+ canSend: true,+ suggestions: meetingSuggestions,+ onDraftChange: jest.fn(),+ onSend: jest.fn(),+ onSuggestion: jest.fn(),+ onRetry: jest.fn(),+ onClear: jest.fn(),+ onClose: jest.fn(),+ ...overrides,+ };+ return { ...render(<NoteChatSheet {...props} />), props };+};++describe('NoteChatSheet suggestions', () => {+ it('offers the meeting shortcuts in order before the first message', () => {+ const { getAllByRole } = renderSheet();+ const labels = getAllByRole('button')+ .map((button) => button.props.accessibilityLabel)+ .filter((label) => meetingSuggestions.some((suggestion) => suggestion.label === label));+ expect(labels).toEqual([+ 'List action items',+ 'Write follow-up email',+ 'Key decisions',+ 'List Q&A',+ ]);+ });++ it('sends the full prompt, not the chip label, when a chip is tapped', () => {+ const { getByLabelText, props } = renderSheet();+ fireEvent.press(getByLabelText('List action items'));+ expect(props.onSuggestion).toHaveBeenCalledWith(+ 'What are the next steps from the meeting above that I need to do?',+ );+ });++ it('drops the shortcuts once the conversation has started', () => {+ const messages: ChatOverNoteMessage[] = [+ { id: '1', role: 'user', text: 'Who owns the launch?', createdAt: 0 },+ ];+ const { queryByLabelText } = renderSheet({ messages });+ expect(queryByLabelText('List action items')).toBeNull();+ });++ it('steps aside once the user starts typing so a tap cannot discard the draft', () => {+ const { queryByLabelText } = renderSheet({ draft: 'Who owns the' });+ expect(queryByLabelText('List action items')).toBeNull();+ });++ it('ignores chip taps when there is nothing to ask about', () => {+ const { getByLabelText, props } = renderSheet({ canSend: false });+ fireEvent.press(getByLabelText('List action items'));+ expect(props.onSuggestion).not.toHaveBeenCalled();+ });+});diff --git a/openwhispr-mobile/src/lib/notes/noteChatSuggestions.ts b/openwhispr-mobile/src/lib/notes/noteChatSuggestions.tsnew file mode 100644index 000000000..76e0fc7f8--- /dev/null+++ b/openwhispr-mobile/src/lib/notes/noteChatSuggestions.ts@@ -0,0 +1,43 @@+export interface NoteChatSuggestion {+ label: string;+ prompt: string;+}++const MEETING_SUGGESTIONS: readonly NoteChatSuggestion[] = [+ {+ label: 'List action items',+ prompt: 'What are the next steps from the meeting above that I need to do?',+ },+ {+ label: 'Write follow-up email',+ prompt:+ 'Write a follow-up email summarizing the meeting above, including decisions and next steps.',+ },+ {+ label: 'Key decisions',+ prompt: 'What decisions were made in the meeting above?',+ },+ {+ label: 'List Q&A',+ prompt: 'List the questions asked in the meeting above and the answers given.',+ },+];++const NOTE_SUGGESTIONS: readonly NoteChatSuggestion[] = [+ {+ label: 'Summarize',+ prompt: 'Summarize this note in a few bullet points.',+ },+ {+ label: 'List action items',+ prompt: 'What are the next steps from this note that I need to do?',+ },+ {+ label: 'Draft an email',+ prompt: 'Draft an email based on this note.',+ },+];++export function getNoteChatSuggestions(isMeeting: boolean): readonly NoteChatSuggestion[] {+ return isMeeting ? MEETING_SUGGESTIONS : NOTE_SUGGESTIONS;+}diff --git a/openwhispr-mobile/src/screens/NoteEditorScreen.tsx b/openwhispr-mobile/src/screens/NoteEditorScreen.tsxindex 96556ecc5..22373ead9 100644--- a/openwhispr-mobile/src/screens/NoteEditorScreen.tsx+++ b/openwhispr-mobile/src/screens/NoteEditorScreen.tsx@@ -11,6 +11,7 @@ import {Alert,} from 'react-native';import * as Clipboard from 'expo-clipboard';+import { useSafeAreaInsets } from 'react-native-safe-area-context';import { Text } from '@/components/ui/Text';import { isMicPermissionError, showMicPermissionAlert } from '@/lib/permissions';import { useLocalSearchParams, useRouter } from 'expo-router';@@ -38,6 +39,7 @@ import { VoiceprintSuggestionSheet } from '@/components/notes/VoiceprintSuggestiimport { ReasoningService } from '@/services/reasoning/ReasoningService';import { SystemIcon } from '@/components/ui/SystemIcon';import { GradientGlassSurface } from '@/components/ui/GradientGlassSurface';+import { Glass } from '@/components/ui/Glass';import { GlassBackButton } from '@/components/ui/GlassBackButton';import { TabScreenHeader } from '@/components/ui/TabScreenHeader';import { buildNoteShareContent, exportNote } from '@/lib/noteExport';@@ -75,6 +77,7 @@ import { useKeyboardHeight } from '@/hooks/useKeyboardHeight';import type { Note } from '@/data/types';import type { ReasoningRoutingOptions } from '@/types';import type { ChatOverNoteMessage } from '@/lib/notes/chatOverNote';+import { getNoteChatSuggestions } from '@/lib/notes/noteChatSuggestions';import {formatTranscriptForExport,getSpeakerDisplayName,@@ -169,6 +172,7 @@ export default function NoteEditorScreen() {const [isChatProcessing, setIsChatProcessing] = useState(false);const [isRetryingTranscript, setIsRetryingTranscript] = useState(false);const keyboardHeight = useKeyboardHeight();+ const insets = useSafeAreaInsets();const contentRef = useRef(content);contentRef.current = content;@@ -297,10 +301,11 @@ export default function NoteEditorScreen() {(suggestion) => suggestion.label.trim().toLowerCase() !== currentName,);}, [activeSpeakerName, calendarParticipants]);+ const isTranscriptInProgress = ['recording', 'transcribing', 'diarizing'].includes(+ transcriptStatus,+ );const shouldShowTranscriptStatus =- isAudioTranscript &&- !hasTranscriptSegments &&- ['recording', 'transcribing', 'diarizing'].includes(transcriptStatus);+ isAudioTranscript && !hasTranscriptSegments && isTranscriptInProgress;const shouldShowTranscriptFailed =isAudioTranscript && !hasTranscriptSegments && transcriptStatus === 'failed';const shouldRenderPlainEditor =@@ -748,6 +753,14 @@ export default function NoteEditorScreen() {runChatWithCloudConfirmation(chatDraft, true);}, [chatDraft, runChatWithCloudConfirmation]);+ const handleChatSuggestion = useCallback(+ (prompt: string) => {+ safeHaptics('light');+ runChatWithCloudConfirmation(prompt, true);+ },+ [runChatWithCloudConfirmation],+ );+const handleRetryChat = useCallback(() => {if (!chatLastQuestion.trim()) return;runChatWithCloudConfirmation(chatLastQuestion, false);@@ -857,6 +870,17 @@ export default function NoteEditorScreen() {const contentEmpty = !actionInputText.trim();const isEnhancingHeader = processingState === 'processing';+ // A finished meeting gets a persistent Ask pill instead of a menu entry. Status alone+ // can't mean "finished": synced notes keep the local default 'idle' even with a full+ // transcript. Segment transcripts never show the dictate FAB, so the two can't overlap.+ const showAskPill =+ chatEnabled && usesSegmentTranscript && !isTranscriptInProgress && !contentEmpty;+ // The tab bar is hidden on the note editor, so the pill sits on the home-indicator inset.+ const askPillBottom = insets.bottom + ASK_PILL_GAP;+ // Uploads can be lectures or voice memos, so only meetings get meeting-worded shortcuts.+ const chatSuggestions = getNoteChatSuggestions(+ usesSegmentTranscript && note?.noteType !== 'upload',+ );if (!note && !isNaN(noteId)) {return (@@ -903,7 +927,7 @@ export default function NoteEditorScreen() {processing={isEnhancingHeader}onRunAction={handleRunAction}onManageActions={handleManageActions}- onAskNote={chatEnabled ? handleAskNote : undefined}+ onAskNote={chatEnabled && !showAskPill ? handleAskNote : undefined}askNoteDisabled={isChatProcessing}onCopyGeneratedNote={note?.enhancedContent ? handleCopyGeneratedNote : undefined}onCopyTranscript={usesSegmentTranscript ? handleCopyTranscript : undefined}@@ -925,7 +949,11 @@ export default function NoteEditorScreen() {paddingHorizontal: 20,paddingTop: 16,paddingBottom:- keyboardHeight > 0 ? NOTE_EDITOR_KEYBOARD_BOTTOM_PADDING : NOTE_EDITOR_BOTTOM_PADDING,+ keyboardHeight > 0+ ? NOTE_EDITOR_KEYBOARD_BOTTOM_PADDING+ : showAskPill+ ? askPillBottom + ASK_PILL_HEIGHT + ASK_PILL_GAP * 2+ : NOTE_EDITOR_BOTTOM_PADDING,}}><TextInput@@ -1129,6 +1157,40 @@ export default function NoteEditorScreen() {/></Pressable>) : null}+ {showAskPill ? (+ <Pressable+ onPress={() => {+ safeHaptics('light');+ handleAskNote();+ }}+ testID="note-ask-pill"+ accessibilityRole="button"+ accessibilityLabel="Ask anything"+ accessibilityHint="Opens a chat about this note"+ style={{+ position: 'absolute',+ left: 20,+ right: 20,+ bottom: askPillBottom,+ shadowColor: '#000',+ shadowOffset: { width: 0, height: 4 },+ shadowOpacity: 0.12,+ shadowRadius: 10,+ }}+ >+ <Glass.Interactive style={{ height: ASK_PILL_HEIGHT, borderRadius: ASK_PILL_HEIGHT / 2 }}>+ <View className="flex-1 flex-row items-center justify-center gap-2">+ <SystemIcon+ name="bubble.left.fill"+ mdName="MessageCircle"+ size={17}+ color="secondaryLabel"+ />+ <Text className="text-[17px] font-medium text-label">Ask anything</Text>+ </View>+ </Glass.Interactive>+ </Pressable>+ ) : null}<NoteChatSheetvisible={chatVisible}messages={chatMessages}@@ -1136,8 +1198,10 @@ export default function NoteEditorScreen() {isProcessing={isChatProcessing}error={chatError}canSend={!contentEmpty}+ suggestions={chatSuggestions}onDraftChange={setChatDraft}onSend={handleSendChat}+ onSuggestion={handleChatSuggestion}onRetry={handleRetryChat}onClear={handleClearChat}onClose={handleCloseChat}@@ -1179,4 +1243,6 @@ export default function NoteEditorScreen() {// inset). Used to lift the floating mic FAB clear of the tab bar.const TAB_BAR_OFFSET = Platform.OS === 'ios' ? 110 : 70;const FAB_BOTTOM = TAB_BAR_OFFSET + 32;+const ASK_PILL_HEIGHT = 52;+const ASK_PILL_GAP = 12;const SYSTEM_RED = '#FF3B30';diff --git a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsxindex 5872e531d..e300fc0d0 100644--- a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx@@ -70,6 +70,10 @@ const mockDictionaryState = {addLearnedWords: mockAddLearnedWords,};+jest.mock('react-native-safe-area-context', () => ({+ useSafeAreaInsets: () => ({ top: 0, right: 0, bottom: 0, left: 0 }),+}));+jest.mock('expo-router', () => ({useLocalSearchParams: () => ({ id: '7' }),useRouter: () => ({@@ -285,12 +289,16 @@ jest.mock('@/components/notes/VoiceprintSuggestionSheet', () => ({jest.mock('@/components/notes/NoteChatSheet', () => ({NoteChatSheet: ({draft,+ suggestions,onDraftChange,onSend,+ onSuggestion,}: {draft: string;+ suggestions: readonly { label: string; prompt: string }[];onDraftChange: (text: string) => void;onSend: () => void;+ onSuggestion: (prompt: string) => void;}) =>(() => {const {@@ -302,6 +310,13 @@ jest.mock('@/components/notes/NoteChatSheet', () => ({<MockView><MockTextInput testID="chat-draft" value={draft} onChangeText={onDraftChange} /><MockPressable testID="chat-send" onPress={onSend} />+ {suggestions.map((suggestion) => (+ <MockPressable+ key={suggestion.label}+ testID={`chat-suggestion-${suggestion.label}`}+ onPress={() => onSuggestion(suggestion.prompt)}+ />+ ))}</MockView>);})(),@@ -544,15 +559,83 @@ describe('NoteEditorScreen generated meeting context', () => {});describe('NoteEditorScreen note chat', () => {- it('offers Ask about this note while Chat & Voice Assistant is on', () => {- const { getByText } = render(<NoteEditorScreen />);+ const PILL = 'note-ask-pill';++ it('shows the Ask pill instead of the menu entry once a meeting has finished', () => {+ const { getByTestId, queryByText } = render(<NoteEditorScreen />);+ expect(getByTestId(PILL)).toBeTruthy();+ expect(queryByText('Ask about this note')).toBeNull();+ });++ it('shows the Ask pill for a synced meeting that kept the local idle status', () => {+ mockNote = note({ transcriptionStatus: 'idle' });+ mockNotesState.notes = [mockNote];+ const { getByTestId } = render(<NoteEditorScreen />);+ expect(getByTestId(PILL)).toBeTruthy();+ });++ it('keeps the Ask pill once notes have been generated', () => {+ mockNote = note({+ enhancedContent: 'Generated calendar-aware notes',+ enhancementPrompt: 'Transform this meeting into notes.',+ });+ mockNotesState.notes = [mockNote];+ const { getByTestId } = render(<NoteEditorScreen />);+ expect(getByTestId(PILL)).toBeTruthy();+ });++ it.each(['recording', 'transcribing', 'diarizing'] as const)(+ 'hides the Ask pill while the meeting is %s',+ (transcriptionStatus) => {+ mockNote = note({ transcriptionStatus });+ mockNotesState.notes = [mockNote];+ const { queryByTestId } = render(<NoteEditorScreen />);+ expect(queryByTestId(PILL)).toBeNull();+ },+ );++ it('keeps Ask about this note in the menu and note-worded shortcuts for a plain note', () => {+ mockNote = note({+ noteType: 'personal',+ diarizationEnabled: 0,+ calendarEventId: null,+ participants: null,+ });+ mockNotesState.notes = [mockNote];+ mockSegments = [];+ const { getByText, getByTestId, queryByTestId } = render(<NoteEditorScreen />);expect(getByText('Ask about this note')).toBeTruthy();+ expect(queryByTestId(PILL)).toBeNull();+ expect(getByTestId('chat-suggestion-Summarize')).toBeTruthy();+ expect(queryByTestId('chat-suggestion-Key decisions')).toBeNull();});- it('hides Ask about this note when Chat & Voice Assistant is off', () => {+ it('offers note-worded shortcuts for an uploaded recording', () => {+ mockNote = note({ noteType: 'upload', diarizationEnabled: 0, calendarEventId: null });+ mockNotesState.notes = [mockNote];+ const { getByTestId, queryByTestId } = render(<NoteEditorScreen />);+ expect(getByTestId(PILL)).toBeTruthy();+ expect(getByTestId('chat-suggestion-Summarize')).toBeTruthy();+ expect(queryByTestId('chat-suggestion-Key decisions')).toBeNull();+ });++ it('hides every Ask entry point when Chat & Voice Assistant is off', () => {mockConfigState.config.dictationAgentEnabled = false;- const { queryByText } = render(<NoteEditorScreen />);+ const { queryByText, queryByTestId } = render(<NoteEditorScreen />);expect(queryByText('Ask about this note')).toBeNull();+ expect(queryByTestId(PILL)).toBeNull();+ });++ it('sends a meeting shortcut prompt immediately when its chip is tapped', async () => {+ (ReasoningService.chatOverNote as jest.Mock).mockResolvedValue({ text: 'Answer', model: 'x' });+ const { getByTestId } = render(<NoteEditorScreen />);+ await act(async () => {+ fireEvent.press(getByTestId('chat-suggestion-List action items'));+ });+ await waitFor(() => expect(ReasoningService.chatOverNote).toHaveBeenCalledTimes(1));+ expect((ReasoningService.chatOverNote as jest.Mock).mock.calls[0][0].question).toBe(+ 'What are the next steps from the meeting above that I need to do?',+ );});});diff --git a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.conflictBanner.test.tsx b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.conflictBanner.test.tsxindex 5f5fb9ba0..e38632eee 100644--- a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.conflictBanner.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.conflictBanner.test.tsx@@ -62,6 +62,10 @@ const mockDictionaryState = {addLearnedWords: mockAddLearnedWords,};+jest.mock('react-native-safe-area-context', () => ({+ useSafeAreaInsets: () => ({ top: 0, right: 0, bottom: 0, left: 0 }),+}));+jest.mock('expo-router', () => ({useLocalSearchParams: () => ({ id: '7' }),useRouter: () => ({