Skip to content

Commit e0f94d4

Browse files
committed
fix(whisper): keep custom mode active until recorder saves, not on timer
The previous 150ms timeout-based useEffect fired immediately when custom mode was entered, snapping the dropdown back before the user could record anything. Now custom mode only clears when the HotkeyRecorder's onChange resolves (i.e. after IPC save completes).
1 parent da899b8 commit e0f94d4

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/renderer/src/settings/AITab.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,7 @@ const AITab: React.FC = () => {
276276
const [whisperCustomMode, setWhisperCustomMode] = useState(false);
277277
const whisperSpeakToggleHotkey = (settings?.commandHotkeys || {})[WHISPER_SPEAK_TOGGLE_COMMAND_ID] ?? '';
278278

279-
// Clear custom mode once the stored hotkey is saved (IPC roundtrip completes).
280-
// A short timeout handles the edge case where the recorded value equals the
281-
// current stored value (so the store won't change to trigger the effect).
282-
useEffect(() => {
283-
if (!whisperCustomMode) return;
284-
const timer = setTimeout(() => setWhisperCustomMode(false), 150);
285-
return () => clearTimeout(timer);
286-
}, [whisperCustomMode, whisperSpeakToggleHotkey]);
279+
287280

288281
const settingsRef = useRef<AppSettings | null>(null);
289282
const pullingModelRef = useRef<string | null>(null);
@@ -1504,7 +1497,9 @@ const AITab: React.FC = () => {
15041497
<HotkeyRecorder
15051498
value={whisperSpeakToggleHotkey}
15061499
onChange={(hotkey) => {
1507-
void handleWhisperHotkeyChange(WHISPER_SPEAK_TOGGLE_COMMAND_ID, hotkey);
1500+
void handleWhisperHotkeyChange(WHISPER_SPEAK_TOGGLE_COMMAND_ID, hotkey).then(() => {
1501+
setWhisperCustomMode(false);
1502+
});
15081503
}}
15091504
compact
15101505
variant="whisper"

0 commit comments

Comments
 (0)