Skip to content

Commit 43dca35

Browse files
committed
feat: Enhance HotkeyInput with editing state notification and update onboarding hotkey initialization
- Add onEditingChange callback to HotkeyInput to notify parent when edit mode changes - Remove setTimeout in handleSave for immediate UI feedback - Initialize onboarding hotkey with user's current settings instead of default - Disable Continue button in onboarding when hotkey is being edited - Disable minimize/maximize window controls in Tauri config (close-only)
1 parent 5a3dd8c commit 43dca35

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

src-tauri/tauri.conf.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"center": true,
2121
"visible": true,
2222
"skipTaskbar": true,
23-
"alwaysOnTop": true
23+
"alwaysOnTop": true,
24+
"minimizable": false,
25+
"maximizable": false
2426
}
2527
],
2628
"security": {

src/components/HotkeyInput.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ interface HotkeyInputProps {
1818
placeholder?: string;
1919
validationRules?: KeyValidationRules;
2020
label?: string; // e.g., "Recording Hotkey", "Custom Hotkey"
21+
onEditingChange?: (isEditing: boolean) => void; // Notify parent when edit mode changes
2122
}
2223

2324
export const HotkeyInput = React.memo(function HotkeyInput({
2425
value,
2526
onChange,
2627
placeholder,
27-
validationRules = ValidationPresets.standard()
28+
validationRules = ValidationPresets.standard(),
29+
onEditingChange
2830
}: HotkeyInputProps) {
2931
const [mode, setMode] = useState<"display" | "edit">("display");
3032
const [keys, setKeys] = useState<Set<string>>(new Set());
@@ -209,16 +211,14 @@ export const HotkeyInput = React.memo(function HotkeyInput({
209211

210212
onChange(normalizedShortcut);
211213
setSaveStatus("success");
212-
213-
setTimeout(() => {
214-
setMode("display");
215-
setSaveStatus("idle");
216-
setPendingHotkey("");
217-
setKeys(new Set());
218-
setCurrentKeysDisplay("");
219-
}, 1500);
214+
setMode("display");
215+
setSaveStatus("idle");
216+
setPendingHotkey("");
217+
setKeys(new Set());
218+
setCurrentKeysDisplay("");
219+
onEditingChange?.(false); // Notify parent that editing is done
220220
}
221-
}, [pendingHotkey, validationError, onChange]);
221+
}, [pendingHotkey, validationError, onChange, onEditingChange]);
222222

223223
const handleCancel = useCallback(() => {
224224
setPendingHotkey("");
@@ -227,7 +227,8 @@ export const HotkeyInput = React.memo(function HotkeyInput({
227227
setSaveStatus("idle");
228228
setValidationError("");
229229
setCurrentKeysDisplay("");
230-
}, []);
230+
onEditingChange?.(false); // Notify parent that editing is cancelled
231+
}, [onEditingChange]);
231232

232233
const handleEdit = useCallback(() => {
233234
setPendingHotkey("");
@@ -236,7 +237,8 @@ export const HotkeyInput = React.memo(function HotkeyInput({
236237
setValidationError("");
237238
setCurrentKeysDisplay("");
238239
setKeys(new Set());
239-
}, []);
240+
onEditingChange?.(true); // Notify parent that editing has started
241+
}, [onEditingChange]);
240242

241243
// Reset save status after showing success
242244
useEffect(() => {

src/components/onboarding/OnboardingDesktop.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const OnboardingDesktop = function OnboardingDesktop({
3333
onComplete,
3434
modelManagement
3535
}: OnboardingDesktopProps) {
36-
const { updateSettings } = useSettings();
36+
const { settings, updateSettings } = useSettings();
3737
const {
3838
hasPermission: hasMicPermission,
3939
checkPermission: checkMicPermission,
@@ -46,9 +46,10 @@ export const OnboardingDesktop = function OnboardingDesktop({
4646
} = useAccessibilityPermission();
4747

4848
const [currentStep, setCurrentStep] = useState<Step>("welcome");
49-
const [hotkey, setHotkey] = useState("CommandOrControl+Shift+Space");
49+
const [hotkey, setHotkey] = useState(settings?.hotkey || "CommandOrControl+Shift+Space");
5050
const [isRequesting, setIsRequesting] = useState<string | null>(null);
5151
const [checkingPermissions, setCheckingPermissions] = useState<Set<string>>(new Set());
52+
const [isEditingHotkey, setIsEditingHotkey] = useState(false);
5253

5354
// Convert hook states to onboarding format
5455
const permissions = {
@@ -501,7 +502,11 @@ export const OnboardingDesktop = function OnboardingDesktop({
501502
<Keyboard className="h-4 w-4 text-primary" />
502503
Recording Hotkey
503504
</label>
504-
<HotkeyInput value={hotkey} onChange={setHotkey} />
505+
<HotkeyInput
506+
value={hotkey}
507+
onChange={setHotkey}
508+
onEditingChange={setIsEditingHotkey}
509+
/>
505510
</div>
506511

507512
{/* <Card className="p-4 bg-border-primary/20"> */}
@@ -519,7 +524,11 @@ export const OnboardingDesktop = function OnboardingDesktop({
519524
<ChevronLeft className="mr-1 h-4 w-4" />
520525
Back
521526
</Button>
522-
<Button onClick={handleNext} size="sm">
527+
<Button
528+
onClick={handleNext}
529+
size="sm"
530+
disabled={isEditingHotkey}
531+
>
523532
Continue
524533
<ChevronRight className="ml-1 h-4 w-4" />
525534
</Button>

0 commit comments

Comments
 (0)