fix(hotkey): make Change replace and Remove unbind#707
Conversation
|
The PR Policy check is blocking this PR because required template information is missing. Please update the PR description with:
Visual files detected:
Screenshots or video are required for UI, UX, settings, onboarding, overlay, menu bar, or visual behavior changes. If this PR has no visual changes, check the no-visual-change box in the template. If this remains incomplete for 48 hours after opening, the PR may be closed. |
Greptile SummaryThis PR makes primary dictation shortcut changes immediately update persistence and the live hotkey manager.
|
|
Full fork CI passed on the same head commit (83568b8): SwiftLint, Xcode build, and tests all green. Run: https://github.com/dschnurbusch/FluidVoice/actions/runs/30101354571 |
Description
Changing or removing a Primary Dictation shortcut currently mutates SwiftUI state and relies on an
onChangeside effect to persist the list and refreshGlobalHotkeyManager. The shortcut-capture callback can bypass that refresh, leaving the manager's in-memory list stale: Change behaves like Add, and removed shortcuts continue firing until restart.This PR routes Change and Remove through one persist-and-live-update method. It also permits removing the final primary shortcut, preserving an explicit unbound state instead of silently restoring the legacy shortcut. Fresh installs still receive the existing default when no primary-shortcut preference has ever been stored.
Type of Change
Related Issue or Discussion
Related to #470 and #498.
#474 contains the direct live-manager refresh for Change, but does not address Remove or an explicitly unbound primary shortcut. #503 covers a narrower active modifier-only press-state edge case; this PR addresses settings-to-live-manager synchronization and removal semantics observed on 1.6.5.
Testing
swiftlint --strict --config .swiftlint.yml Sourcesswiftformat --config .swiftformat Sourcesxcrun swiftc -parsegit diff --checkThe local machine has Command Line Tools rather than full Xcode, so the full Xcode build/test suite was run on the same commit (
83568b8) through the fork's macOS workflow.Screenshots / Video
Before: FluidVoice 1.6.5 shows Remove disabled when only one Primary Dictation shortcut remains. The submitted change enables removal of that final shortcut; once removed, the row disappears and Add shortcut remains available.
Notes
The settings mutation now updates persisted state, normalized SwiftUI state, and the live hotkey manager in one call. The existing
onChangeremains as an idempotent fallback for other state writes.The explicit empty list is distinguishable from a fresh install: missing preference data still falls back to the legacy/default shortcut, while stored
[]remains unbound. The legacy single-shortcut value is left intact for backward-compatible backup/export consumers but is no longer allowed to resurrect an explicitly cleared primary list.