Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

refactor: fix all 22 React Compiler lint issues across 15 files

Gabriel Steinba810a42fc74
diff --git a/src/components/CommandSearch.tsx b/src/components/CommandSearch.tsx
index c36dd3b5b..8765d494f 100644
--- a/src/components/CommandSearch.tsx
+++ b/src/components/CommandSearch.tsx
@@ -74,6 +74,9 @@ export default function CommandSearch({
const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const searchVersionRef = useRef(0);
const isConversationsMode = mode === "conversations";
+ const [prevOpen, setPrevOpen] = useState(open);
+ const [prevNotes, setPrevNotes] = useState(notes);
+ const [prevQuery, setPrevQuery] = useState(query);
useEffect(() => {
if (isConversationsMode) return;
@@ -83,10 +86,16 @@ export default function CommandSearch({
.catch(() => {});
}, [isConversationsMode]);
- useEffect(() => {
- if (!open) return;
+ if (open && !prevOpen) {
+ setPrevOpen(open);
setQuery("");
setSelectedIndex(0);
+ } else if (open !== prevOpen) {
+ setPrevOpen(open);
+ }
+
+ useEffect(() => {
+ if (!open) return;
if (isConversationsMode) {
window.electronAPI?.getAgentConversationsWithPreview?.(20, 0, false).then((r) => {
if (r)
@@ -167,9 +176,11 @@ export default function CommandSearch({
};
}, [query, isConversationsMode]);
- useEffect(() => {
+ if (notes !== prevNotes || query !== prevQuery) {
+ setPrevNotes(notes);
+ setPrevQuery(query);
setSelectedIndex(0);
- }, [notes, query]);
+ }
const folderMap = useMemo(() => new Map(folders.map((f) => [f.id, f])), [folders]);
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsx
index b157cec3e..3c4f91279 100644
--- a/src/components/ControlPanel.tsx
+++ b/src/components/ControlPanel.tsx
@@ -102,7 +102,7 @@ export default function ControlPanel() {
useEffect(() => {
loadTranscriptions();
- }, []);
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
diff --git a/src/components/DeveloperSection.tsx b/src/components/DeveloperSection.tsx
index e52fb0deb..a52e126d3 100644
--- a/src/components/DeveloperSection.tsx
+++ b/src/components/DeveloperSection.tsx
@@ -1,4 +1,4 @@
-import { useState, useEffect } from "react";
+import { useState, useEffect, useCallback } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "./ui/button";
import { FolderOpen, Copy, Check } from "lucide-react";
@@ -17,11 +17,7 @@ export default function DeveloperSection() {
const [copiedPath, setCopiedPath] = useState(false);
const { toast } = useToast();
- useEffect(() => {
- loadDebugState();
- }, []);
-
- const loadDebugState = async () => {
+ const loadDebugState = useCallback(async () => {
try {
setIsLoading(true);
const state = await window.electronAPI.getDebugState();
@@ -37,7 +33,11 @@ export default function DeveloperSection() {
} finally {
setIsLoading(false);
}
- };
+ }, [t, toast]);
+
+ useEffect(() => {
+ loadDebugState();
+ }, [loadDebugState]);
const handleToggleDebug = async () => {
if (isToggling) return;
diff --git a/src/components/LocalWhisperPicker.tsx b/src/components/LocalWhisperPicker.tsx
index b9a6bf298..bd9b002ff 100644
--- a/src/components/LocalWhisperPicker.tsx
+++ b/src/components/LocalWhisperPicker.tsx
@@ -76,11 +76,22 @@ export default function LocalWhisperPicker({
}, [validateAndSelectModel]);
useEffect(() => {
- if (!hasLoadedRef.current) {
- hasLoadedRef.current = true;
- loadModels();
- }
- }, [loadModels]);
+ if (hasLoadedRef.current) return;
+ hasLoadedRef.current = true;
+
+ window.electronAPI
+ ?.listWhisperModels()
+ .then((result) => {
+ if (result?.success) {
+ setModels(result.models);
+ validateAndSelectModel(result.models);
+ }
+ })
+ .catch((error) => {
+ console.error("[LocalWhisperPicker] Failed to load models:", error);
+ setModels([]);
+ });
+ }, [validateAndSelectModel]);
const {
downloadingModel,
diff --git a/src/components/NoteEditor.tsx b/src/components/NoteEditor.tsx
index 85c10d3f1..a310e1d1a 100644
--- a/src/components/NoteEditor.tsx
+++ b/src/components/NoteEditor.tsx
@@ -31,12 +31,14 @@ export default function NoteEditor({ note, cloudEnabled, onDelete, onUpdate }: N
const saveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const fadeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
+ const [prevNoteId, setPrevNoteId] = useState(note.id);
- useEffect(() => {
+ if (note.id !== prevNoteId) {
+ setPrevNoteId(note.id);
setTitle(note.title);
setContent(note.content);
setSaveState("idle");
- }, [note.id]);
+ }
const autoResize = useCallback(() => {
const ta = textareaRef.current;
diff --git a/src/components/ReferralDashboard.tsx b/src/components/ReferralDashboard.tsx
index e2902a45f..6dcbb8f4e 100644
--- a/src/components/ReferralDashboard.tsx
+++ b/src/components/ReferralDashboard.tsx
@@ -60,23 +60,25 @@ function formatDate(dateStr: string) {
function AnimatedCounter({ value, delay = 0 }: { value: number; delay?: number }) {
const [display, setDisplay] = useState(0);
const rafRef = useRef<number>(0);
+ const [prevValue, setPrevValue] = useState(value);
+
+ if (value !== prevValue) {
+ setPrevValue(value);
+ if (value === 0) setDisplay(0);
+ }
useEffect(() => {
- if (value === 0) {
- setDisplay(0);
- return;
- }
+ if (value === 0) return;
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
- if (prefersReduced) {
- setDisplay(value);
- return;
- }
-
const duration = 800;
let start: number | null = null;
const timeout = setTimeout(() => {
+ if (prefersReduced) {
+ setDisplay(value);
+ return;
+ }
const animate = (timestamp: number) => {
if (!start) start = timestamp;
const progress = Math.min((timestamp - start) / duration, 1);
@@ -85,7 +87,7 @@ function AnimatedCounter({ value, delay = 0 }: { value: number; delay?: number }
if (progress < 1) rafRef.current = requestAnimationFrame(animate);
};
rafRef.current = requestAnimationFrame(animate);
- }, delay);
+ }, prefersReduced ? 0 : delay);
return () => {
clearTimeout(timeout);
diff --git a/src/components/SettingsModal.tsx b/src/components/SettingsModal.tsx
index 4064af648..3df59514d 100644
--- a/src/components/SettingsModal.tsx
+++ b/src/components/SettingsModal.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useMemo } from "react";
+import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import {
Sliders,
@@ -105,14 +105,15 @@ export default function SettingsModal({ open, onOpenChange, initialSection }: Se
);
const [activeSection, setActiveSection] = React.useState<SettingsSectionType>("account");
+ const [prevOpen, setPrevOpen] = useState(open);
- // Navigate to initial section when modal opens, resolving legacy aliases
- useEffect(() => {
- if (open && initialSection) {
- const resolved = (SECTION_ALIASES[initialSection] ?? initialSection) as SettingsSectionType;
- setActiveSection(resolved);
- }
- }, [open, initialSection]);
+ if (open && !prevOpen && initialSection) {
+ setPrevOpen(open);
+ const resolved = (SECTION_ALIASES[initialSection] ?? initialSection) as SettingsSectionType;
+ setActiveSection(resolved);
+ } else if (open !== prevOpen) {
+ setPrevOpen(open);
+ }
return (
<SidebarModal<SettingsSectionType>
diff --git a/src/components/chat/useChatPersistence.ts b/src/components/chat/useChatPersistence.ts
index 2804be888..ef231544d 100644
--- a/src/components/chat/useChatPersistence.ts
+++ b/src/components/chat/useChatPersistence.ts
@@ -1,4 +1,4 @@
-import { useState, useRef, useCallback } from "react";
+import { useState, useRef, useCallback, useEffect } from "react";
import type { Message, ToolCallInfo } from "./types";
interface UseChatPersistenceOptions {
@@ -19,13 +19,20 @@ export interface ChatPersistence {
export function useChatPersistence(options: UseChatPersistenceOptions = {}): ChatPersistence {
const [messages, setMessages] = useState<Message[]>([]);
- const conversationIdRef = useRef<number | null>(options.conversationId ?? null);
+ const [conversationId, setConversationId] = useState<number | null>(
+ options.conversationId ?? null
+ );
+ const conversationIdRef = useRef(conversationId);
+
+ useEffect(() => {
+ conversationIdRef.current = conversationId;
+ }, [conversationId]);
const createConversation = useCallback(
async (title: string, noteId?: number | null): Promise<number> => {
const conv = await window.electronAPI?.createAgentConversation?.(title, noteId ?? undefined);
const id = conv?.id ?? 0;
- conversationIdRef.current = id;
+ setConversationId(id);
options.onConversationCreated?.(id, title);
return id;
},
@@ -35,7 +42,7 @@ export function useChatPersistence(options: UseChatPersistenceOptions = {}): Cha
const loadConversation = useCallback(async (id: number) => {
const conv = await window.electronAPI?.getAgentConversation?.(id);
if (!conv) return;
- conversationIdRef.current = id;
+ setConversationId(id);
const loaded: Message[] = conv.messages.map((m) => {
const parsed = m.metadata ? tryParseMetadata(m.metadata) : undefined;
const toolCalls = parsed?.toolCalls as ToolCallInfo[] | undefined;
@@ -69,13 +76,13 @@ export function useChatPersistence(options: UseChatPersistenceOptions = {}): Cha
const handleNewChat = useCallback(() => {
setMessages([]);
- conversationIdRef.current = null;
+ setConversationId(null);
}, []);
return {
messages,
setMessages,
- conversationId: conversationIdRef.current,
+ conversationId,
createConversation,
loadConversation,
saveUserMessage,
diff --git a/src/components/notes/ActionProcessingOverlay.tsx b/src/components/notes/ActionProcessingOverlay.tsx
index fe628700b..2f8c923f3 100644
--- a/src/components/notes/ActionProcessingOverlay.tsx
+++ b/src/components/notes/ActionProcessingOverlay.tsx
@@ -15,14 +15,19 @@ export default function ActionProcessingOverlay({
}: ActionProcessingOverlayProps) {
const { t } = useTranslation();
const [visible, setVisible] = useState(false);
+ const [prevState, setPrevState] = useState(state);
- useEffect(() => {
+ if (state !== prevState) {
+ setPrevState(state);
if (state === "processing" || state === "success") {
setVisible(true);
- } else if (state === "idle") {
- const id = setTimeout(() => setVisible(false), 300);
- return () => clearTimeout(id);
}
+ }
+
+ useEffect(() => {
+ if (state !== "idle") return;
+ const id = setTimeout(() => setVisible(false), 300);
+ return () => clearTimeout(id);
}, [state]);
if (!visible) return null;
diff --git a/src/components/notes/DictationWidget.tsx b/src/components/notes/DictationWidget.tsx
index f548ecb63..36fa43f66 100644
--- a/src/components/notes/DictationWidget.tsx
+++ b/src/components/notes/DictationWidget.tsx
@@ -22,12 +22,15 @@ export default function DictationWidget({
}: DictationWidgetProps) {
const { t } = useTranslation();
const [elapsed, setElapsed] = useState(0);
+ const [wasRecording, setWasRecording] = useState(isRecording);
+
+ if (isRecording !== wasRecording) {
+ setWasRecording(isRecording);
+ if (!isRecording) setElapsed(0);
+ }
useEffect(() => {
- if (!isRecording) {
- setElapsed(0);
- return;
- }
+ if (!isRecording) return;
const id = setInterval(() => setElapsed((s) => s + 1), 1000);
return () => clearInterval(id);
}, [isRecording]);
diff --git a/src/components/notes/NoteBottomBar.tsx b/src/components/notes/NoteBottomBar.tsx
index afdf1b0e5..62df0d1a0 100644
--- a/src/components/notes/NoteBottomBar.tsx
+++ b/src/components/notes/NoteBottomBar.tsx
@@ -34,12 +34,15 @@ export default function NoteBottomBar({
const inputRef = useRef<HTMLInputElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
const [elapsed, setElapsed] = useState(0);
+ const [wasRecording, setWasRecording] = useState(isRecording);
+
+ if (isRecording !== wasRecording) {
+ setWasRecording(isRecording);
+ if (!isRecording) setElapsed(0);
+ }
useEffect(() => {
- if (!isRecording) {
- setElapsed(0);
- return;
- }
+ if (!isRecording) return;
const id = setInterval(() => setElapsed((s) => s + 1), 1000);
return () => clearInterval(id);
}, [isRecording]);
diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsx
index dbe480c06..c70705042 100644
--- a/src/components/notes/NoteEditor.tsx
+++ b/src/components/notes/NoteEditor.tsx
@@ -134,8 +134,6 @@ export default function NoteEditor({
noteTranscript: note.transcript ?? undefined,
});
const titleRef = useRef<HTMLDivElement>(null);
- const prevNoteIdRef = useRef<number>(note.id);
- const autoShowDoneRef = useRef(false);
const segmentContainerRef = useRef<HTMLDivElement>(null);
const [indicatorStyle, setIndicatorStyle] = useState<React.CSSProperties>({ opacity: 0 });
@@ -194,46 +192,40 @@ export default function NoteEditor({
return () => observer.disconnect();
}, [updateSegmentIndicator]);
- const prevProcessingStateRef = useRef(actionProcessingState);
- useEffect(() => {
- if (prevProcessingStateRef.current === "processing" && actionProcessingState === "success") {
+ const [prevProcessingState, setPrevProcessingState] = useState(actionProcessingState);
+ if (actionProcessingState !== prevProcessingState) {
+ if (prevProcessingState === "processing" && actionProcessingState === "success") {
setViewMode("enhanced");
}
- prevProcessingStateRef.current = actionProcessingState;
- }, [actionProcessingState]);
-
- useEffect(() => {
- if (note.id !== prevNoteIdRef.current) {
- prevNoteIdRef.current = note.id;
- autoShowDoneRef.current = false;
- setChatMode("hidden");
- if (!isMeetingRecording) {
- setViewMode("raw");
- }
- if (titleRef.current && titleRef.current.textContent !== note.title) {
- titleRef.current.textContent = note.title || "";
- }
- editorRef.current?.commands.focus();
+ setPrevProcessingState(actionProcessingState);
+ }
+
+ const [prevNoteId, setPrevNoteId] = useState(note.id);
+ const [autoShowDone, setAutoShowDone] = useState(false);
+ if (note.id !== prevNoteId) {
+ setPrevNoteId(note.id);
+ setAutoShowDone(false);
+ setChatMode("hidden");
+ if (!isMeetingRecording) {
+ setViewMode("raw");
}
- }, [note.id, isMeetingRecording]);
+ }
- // Auto-show chat when hook loads an existing conversation with messages
- useEffect(() => {
- if (
- !autoShowDoneRef.current &&
- embeddedChat.activeConversationId &&
- embeddedChat.messages.length > 0
- ) {
- autoShowDoneRef.current = true;
- setChatMode("floating");
- }
- }, [embeddedChat.activeConversationId, embeddedChat.messages.length]);
+ if (
+ !autoShowDone &&
+ embeddedChat.activeConversationId &&
+ embeddedChat.messages.length > 0
+ ) {
+ setAutoShowDone(true);
+ setChatMode("floating");
+ }
useEffect(() => {
if (titleRef.current && titleRef.current.textContent !== note.title) {
titleRef.current.textContent = note.title || "";
}
- }, [note.title]);
+ editorRef.current?.commands.focus();
+ }, [note.id, note.title]);
const handleTitleInput = useCallback(() => {
if (titleRef.current) {
@@ -255,23 +247,17 @@ export default function NoteEditor({
document.execCommand("insertText", false, text);
}, []);
- // Auto-switch to transcript view after recording stops and transcript is ready
- const prevRecordingRef = useRef(false);
- const pendingTranscriptSwitchRef = useRef(false);
-
- useEffect(() => {
- if (isRecording && !prevRecordingRef.current) {
- pendingTranscriptSwitchRef.current = true;
- }
- prevRecordingRef.current = isRecording;
- }, [isRecording]);
-
- useEffect(() => {
- if (!isRecording && !isProcessing && pendingTranscriptSwitchRef.current && liveTranscript) {
- pendingTranscriptSwitchRef.current = false;
- setViewMode("transcript");
- }
- }, [isRecording, isProcessing, liveTranscript]);
+ const [prevRecording, setPrevRecording] = useState(false);
+ const [pendingTranscriptSwitch, setPendingTranscriptSwitch] = useState(false);
+
+ if (isRecording !== prevRecording) {
+ setPrevRecording(isRecording);
+ if (isRecording) setPendingTranscriptSwitch(true);
+ }
+ if (!isRecording && !isProcessing && pendingTranscriptSwitch && liveTranscript) {
+ setPendingTranscriptSwitch(false);
+ setViewMode("transcript");
+ }
const handleContentChange = useCallback(
(newValue: string) => {
diff --git a/src/components/ui/ProviderTabs.tsx b/src/components/ui/ProviderTabs.tsx
index e1a56bb56..f0143c1a0 100644
--- a/src/components/ui/ProviderTabs.tsx
+++ b/src/components/ui/ProviderTabs.tsx
@@ -1,4 +1,4 @@
-import { ReactNode, useRef, useState, useEffect, useCallback } from "react";
+import { ReactNode, useRef, useEffect, useLayoutEffect, useCallback } from "react";
import { useTranslation } from "react-i18next";
import { ProviderIcon } from "./ProviderIcon";
import type { ColorScheme as BaseColorScheme } from "../../utils/modelPickerStyles";
@@ -31,17 +31,16 @@ export function ProviderTabs({
}: ProviderTabsProps) {
const { t } = useTranslation();
const containerRef = useRef<HTMLDivElement>(null);
- const [indicatorStyle, setIndicatorStyle] = useState<React.CSSProperties>({
- opacity: 0,
- });
+ const indicatorRef = useRef<HTMLDivElement>(null);
const updateIndicator = useCallback(() => {
const container = containerRef.current;
- if (!container) return;
+ const indicator = indicatorRef.current;
+ if (!container || !indicator) return;
const selectedIndex = providers.findIndex((p) => p.id === selectedId);
if (selectedIndex === -1) {
- setIndicatorStyle({ opacity: 0 });
+ indicator.style.opacity = "0";
return;
}
@@ -52,15 +51,13 @@ export function ProviderTabs({
const containerRect = container.getBoundingClientRect();
const buttonRect = selectedButton.getBoundingClientRect();
- setIndicatorStyle({
- width: buttonRect.width,
- height: buttonRect.height,
- transform: `translateX(${buttonRect.left - containerRect.left}px)`,
- opacity: 1,
- });
+ indicator.style.width = `${buttonRect.width}px`;
+ indicator.style.height = `${buttonRect.height}px`;
+ indicator.style.transform = `translateX(${buttonRect.left - containerRect.left}px)`;
+ indicator.style.opacity = "1";
}, [providers, selectedId]);
- useEffect(() => {
+ useLayoutEffect(() => {
updateIndicator();
}, [updateIndicator]);
@@ -77,8 +74,9 @@ export function ProviderTabs({
>
{/* Sliding indicator - frosted glass treatment */}
<div
+ ref={indicatorRef}
className="absolute top-0.5 left-0 rounded-md bg-card border border-border dark:border-border-subtle shadow-sm dark:shadow-(--shadow-card) transition-[width,height,transform,opacity] duration-200 ease-out pointer-events-none"
- style={indicatorStyle}
+ style={{ opacity: 0 }}
/>
{providers.map((provider) => {
diff --git a/src/components/ui/RichTextEditor.tsx b/src/components/ui/RichTextEditor.tsx
index 158772a7c..9c95976a8 100644
--- a/src/components/ui/RichTextEditor.tsx
+++ b/src/components/ui/RichTextEditor.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useCallback, type RefObject } from "react";
+import { useEffect, useRef, useCallback, type MutableRefObject } from "react";
import { useEditor, EditorContent, type Editor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import TaskList from "@tiptap/extension-task-list";
@@ -13,7 +13,7 @@ interface RichTextEditorProps {
placeholder?: string;
className?: string;
disabled?: boolean;
- editorRef?: RefObject<Editor | null>;
+ editorRef?: MutableRefObject<Editor | null>;
}
export function RichTextEditor({
@@ -62,15 +62,10 @@ export function RichTextEditor({
},
});
- // Expose editor to parent via ref
useEffect(() => {
- if (editorRef && "current" in editorRef) {
- (editorRef as React.MutableRefObject<Editor | null>).current = editor;
- }
+ if (editorRef) editorRef.current = editor;
return () => {
- if (editorRef && "current" in editorRef) {
- (editorRef as React.MutableRefObject<Editor | null>).current = null;
- }
+ if (editorRef) editorRef.current = null;
};
}, [editor, editorRef]);
diff --git a/src/hooks/useEmbeddedChat.ts b/src/hooks/useEmbeddedChat.ts
index e0d2e5117..465349547 100644
--- a/src/hooks/useEmbeddedChat.ts
+++ b/src/hooks/useEmbeddedChat.ts
@@ -40,6 +40,7 @@ export function useEmbeddedChat({
const [conversationId, setConversationId] = useState<number | null>(null);
const [noteConversations, setNoteConversations] = useState<NoteConversationItem[]>([]);
const noteIdRef = useRef(noteId);
+ const [prevNoteId, setPrevNoteId] = useState(noteId);
const persistence = useChatPersistence({
conversationId,
@@ -79,15 +80,18 @@ export function useEmbeddedChat({
return conversations ?? [];
}, [noteId]);
- // Load conversations when noteId changes
- useEffect(() => {
- noteIdRef.current = noteId;
+ if (noteId !== prevNoteId) {
+ setPrevNoteId(noteId);
if (!noteId) {
persistence.handleNewChat();
setConversationId(null);
setNoteConversations([]);
- return;
}
+ }
+
+ useEffect(() => {
+ noteIdRef.current = noteId;
+ if (!noteId) return;
let stale = false;
(async () => {