Repository navigation
Add toggle to command mode and write mode - #38
Conversation
WalkthroughAdds per-shortcut enable toggles for command and rewrite modes, persists them in SettingsStore, exposes bindings to SettingsView and ContentView, and updates GlobalHotkeyManager to gate shortcut handling and clear/cleanup active mode state when a shortcut is disabled. Changes
Sequence DiagramsequenceDiagram
participant User
participant SettingsView
participant ContentView
participant SettingsStore
participant GlobalHotkeyManager
User->>SettingsView: Toggle shortcut enable/disable
SettingsView->>ContentView: Bound state updates
ContentView->>SettingsStore: set commandModeShortcutEnabled / rewriteModeShortcutEnabled
SettingsStore->>SettingsStore: persist to UserDefaults
ContentView->>GlobalHotkeyManager: updateCommandModeShortcutEnabled(enabled) / updateRewriteModeShortcutEnabled(enabled)
GlobalHotkeyManager->>GlobalHotkeyManager: update flag & clear per-mode pressed state if disabled
alt If disabled while active
ContentView->>ContentView: cancel recording, stop ASR, clear mode state, reset overlay
end
SettingsView->>SettingsView: reflect UI (toggle position, opacity, disable buttons)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
Sources/Fluid/UI/SettingsView.swift (1)
28-29: Shortcut enable toggles and disabled-row behavior look consistent end‑to‑end
- The new
@Bindingflags forcommandModeShortcutEnabled/rewriteShortcutEnabled, their use in the two VStacks, and theisEnabledhandling inshortcutRoware wired coherently: disabling hides the live shortcut text, shows a “Shortcut disabled” pill, disables the Change button, and slightly dims the row while leaving the feature itself intact.- State cancellation on disable (handled in
ContentViewvia the bindings) ensures you won’t get stuck in a “recording new shortcut” UI while the row is disabled.No functional issues from this file for the new toggles; behavior is clear and matches the PR intent.
You might later consider a brief footnote/help text near each toggle explaining that it only disables the shortcut (not Command/Write Mode entirely), to avoid user confusion in settings-heavy UIs.
Also applies to: 302-347, 810-880
Sources/Fluid/Persistence/SettingsStore.swift (1)
51-52: Persistence for per‑mode shortcut enable flags is correct; consider regrouping constants
- The
commandModeShortcutEnabled/rewriteModeShortcutEnabledproperties correctly default totruewhen unset and sendobjectWillChangeon writes, which matches how you use them inContentView+ SwiftUI.- Minor organizational nit:
Keys.rewriteModeShortcutEnabledcurrently sits under the “Model Reasoning Config Keys” section (Line 61). For readability, it would be clearer to keep it adjacent to the other “Rewrite Mode Keys” so all rewrite settings live together.Also applies to: 61-62, 413-423, 592-602
Sources/Fluid/Services/GlobalHotkeyManager.swift (1)
13-14: Shortcut enable flags and gating in the hotkey handler are sound
- The new
commandModeShortcutEnabled/rewriteModeShortcutEnabledfields, constructor parameters, and update methods correctly gate command/rewrite handling in all three event paths (keyDown, keyUp, flagsChanged).- Clearing
isCommandModeKeyPressed/isRewriteKeyPressedwhen disabling avoids press‑and‑hold scenarios leaving the internal state stuck whileContentViewseparately stops ASR.Implementation is functionally solid.
If you want to reduce duplication later, you could wrap the command/rewrite checks in small helpers (e.g.
handleCommandShortcutIfEnabled(...)) so thehandleKeyEventbranches read a bit more linearly.Also applies to: 35-42, 52-53, 108-124, 269-314, 333-345, 367-399
Sources/Fluid/ContentView.swift (1)
56-57: End‑to‑end wiring of shortcut enable flags is correct and handles disable‑while‑active safely
- The new
@Stateflags seeded fromSettingsStoreand passed intoSettingsViewandGlobalHotkeyManagerform a coherent data flow: settings are persisted, UI reflects current state, and the event tap respects the enable flags.- The
.onChangehandlers forisCommandModeShortcutEnabledandisRewriteModeShortcutEnabledcorrectly:
- persist to
SettingsStore,- notify
hotkeyManager(if present),- and, on disable, cancel any in‑progress shortcut recording, stop ASR for the corresponding mode, clear rewrite state, and reset the overlay to dictation.
This covers the main correctness and UX edge case (turning a mode off mid‑recording) cleanly.
If similar “disable while active” flows crop up elsewhere, consider extracting tiny helpers (e.g.
cancelActiveCommandShortcutIfNeeded()) to keep the mainbodymodifier chain thinner.Also applies to: 507-539, 923-924, 3633-3639
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Sources/Fluid/ContentView.swift(4 hunks)Sources/Fluid/Persistence/SettingsStore.swift(4 hunks)Sources/Fluid/Services/GlobalHotkeyManager.swift(10 hunks)Sources/Fluid/UI/SettingsView.swift(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
Sources/Fluid/UI/SettingsView.swift (1)
Sources/Fluid/Services/DebugLogger.swift (1)
debug(145-147)
Sources/Fluid/Services/GlobalHotkeyManager.swift (1)
Sources/Fluid/Services/DebugLogger.swift (1)
info(133-135)
Sources/Fluid/ContentView.swift (4)
Sources/Fluid/Services/GlobalHotkeyManager.swift (2)
updateCommandModeShortcutEnabled(108-115)updateRewriteModeShortcutEnabled(117-124)Sources/Fluid/Services/ASRService.swift (1)
stopWithoutTranscription(411-426)Sources/Fluid/Services/MenuBarManager.swift (1)
setOverlayMode(197-200)Sources/Fluid/Services/RewriteModeService.swift (1)
clearState(103-108)
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
Sources/Fluid/UI/SettingsView.swift (1)
824-829: Optional: Add accessibility label to toggle.The toggle uses
.labelsHidden()but lacks an explicit accessibility label for screen readers.Consider adding an accessibility label:
if let isEnabled { Toggle("", isOn: isEnabled) .toggleStyle(.switch) .tint(theme.palette.accent) .labelsHidden() + .accessibilityLabel("Enable \(title) shortcut") }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Sources/Fluid/Networking/ModelDownloader.swift(0 hunks)Sources/Fluid/UI/SettingsView.swift(4 hunks)
💤 Files with no reviewable changes (1)
- Sources/Fluid/Networking/ModelDownloader.swift
🔇 Additional comments (3)
Sources/Fluid/UI/SettingsView.swift (3)
28-29: LGTM! New bindings properly added.The new binding properties for controlling shortcut enablement are correctly declared and follow the existing pattern.
287-330: LGTM! Enable/disable applied correctly to command and write modes.The implementation correctly provides enable/disable toggles only for command mode and write mode shortcuts, while keeping transcribe mode always enabled. This aligns with the PR objectives.
802-870: The recording state is already properly cleared when shortcuts are disabled. ContentView includes onChange handlers for bothisCommandModeShortcutEnabledandisRewriteModeShortcutEnabledthat explicitly set the recording flags to false and stop the ASR service when a shortcut is disabled.

Description
Issue #35
Testing
Check recording - https://drive.google.com/file/d/1kXM2nqO8QpyISBx3Bv0wB9tZHYyMCPW6/view?usp=sharing
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.