Add shared voice dictation support across chat, planning, and task-creation composers. - Add browser speech-recognition and composer insertion hooks. - Provide a reusable mic button with accessible recording states. - Integrate and test dictation across all supported composer surfaces. - Document the feature and add a package changeset. Files changed: .changeset/fn-8573-voice-dictation-mic.md | 7 + docs/dashboard-guide.md | 6 + packages/dashboard/app/components/ChatView.tsx | 44 +++- .../dashboard/app/components/ComposeChatPanel.tsx | 8 +- packages/dashboard/app/components/MicButton.css | 5 + packages/dashboard/app/components/MicButton.tsx | 20 ++ .../dashboard/app/components/PlanningModeModal.tsx | 82 ++++-- .../dashboard/app/components/QuickEntryBox.tsx | 4 + .../app/components/StandardChatSurface.tsx | 108 +++++--- packages/dashboard/app/components/TaskChatTab.tsx | 4 + packages/dashboard/app/components/TaskComments.tsx | 66 ++--- packages/dashboard/app/components/TaskForm.tsx | 18 +- .../app/components/TaskPlannerChatTab.tsx | 7 + .../app/components/__tests__/MicButton.test.tsx | 28 +++ .../components/__tests__/QuickEntryBox.test.tsx | 5 + .../app/components/__tests__/TaskForm.test.tsx | 5 + .../app/components/__tests__/insertAtCaret.test.ts | 25 ++ .../__tests__/voice-dictation-composers.test.tsx | 230 +++++++++++++++++ packages/dashboard/app/components/insertAtCaret.ts | 20 ++ .../hooks/__tests__/useComposerDictation.test.tsx | 58 +++++ .../app/hooks/__tests__/useVoiceDictation.test.tsx | 158 ++++++++++++ .../dashboard/app/hooks/useComposerDictation.ts | 112 +++++++++ .../dashboard/app/hooks/useVoiceDictation.ts | 277 +++++++++++++++++++++ 23 files changed, 1204 insertions(+), 93 deletions(-) Fusion-Task-Id: FN-8573 Fusion-Task-Lineage: 905ae982-3e63-494f-aba8-e3665f00cdda Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
21 lines
1.2 KiB
TypeScript
21 lines
1.2 KiB
TypeScript
/**
|
|
* FNXC:VoiceInput 2026-07-24-03:00:
|
|
* Dictation performs real-time partial-to-final transcription at the caret. The returned anchor
|
|
* keeps successive previews replacing in place so surrounding controlled-composer text survives.
|
|
*/
|
|
export type DictationAnchor = { start: number; end: number };
|
|
export type Insertion = { nextValue: string; nextCaret: number; anchor: DictationAnchor };
|
|
|
|
export function computeInsertion({ value, selectionStart, selectionEnd, insertText }: { value: string; selectionStart: number; selectionEnd: number; insertText: string }): Insertion {
|
|
const start = Math.max(0, Math.min(selectionStart, value.length));
|
|
const end = Math.max(start, Math.min(selectionEnd, value.length));
|
|
const nextValue = `${value.slice(0, start)}${insertText}${value.slice(end)}`;
|
|
const nextCaret = start + insertText.length;
|
|
return { nextValue, nextCaret, anchor: { start, end: nextCaret } };
|
|
}
|
|
|
|
/** Replaces the previous dictated range; callers may shift the anchor when outside edits occur. */
|
|
export function replaceRange({ value, anchor, nextText }: { value: string; anchor: DictationAnchor; nextText: string }): Insertion {
|
|
return computeInsertion({ value, selectionStart: anchor.start, selectionEnd: anchor.end, insertText: nextText });
|
|
}
|