Allow double-tap-only mode for modifier hotkeys#227
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughEnables double-tap-only for modifier-only and key+modifier hotkeys by revising HotKeyProcessor timing/state tracking, updates HotKeySectionView visibility for related controls, adds unit tests for both patterns, and adds a changeset release note. ChangesDouble-tap-only hotkey support
Sequence Diagram(s)sequenceDiagram
participant User
participant HotKeyProcessor
participant State
User->>HotKeyProcessor: First press (matching chord)
HotKeyProcessor->>State: Store doubleTapOnlyPressStartedAt
HotKeyProcessor-->>User: No recording yet (await second tap)
User->>HotKeyProcessor: Release first press (non-matching)
HotKeyProcessor->>State: Compute elapsed since doubleTapOnlyPressStartedAt
HotKeyProcessor-->>State: Set or clear lastTapAt based on threshold
User->>HotKeyProcessor: Second press (matching within threshold)
HotKeyProcessor->>State: Enter doubleTapLock and start recording
HotKeyProcessor-->>User: Recording active
User->>HotKeyProcessor: Release or third press
HotKeyProcessor->>State: Stop recording and reset tracking
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
48a015e to
196a67d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
HexCore/Tests/HexCoreTests/HotKeyProcessorTests.swift (1)
372-384: ⚡ Quick winAssert lock state where the test claims “starts recording in lock mode.”
doubleTapOnly_modifierOnly_requiresSecondPressdocuments lock behavior but does not assertexpectedState, which leaves a small regression gap.Suggested test assertion update
- ScenarioStep(time: 0.2, key: nil, modifiers: [.command], expectedOutput: .startRecording, expectedIsMatched: true), + ScenarioStep(time: 0.2, key: nil, modifiers: [.command], expectedOutput: .startRecording, expectedIsMatched: true, expectedState: .doubleTapLock),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@HexCore/Tests/HexCoreTests/HotKeyProcessorTests.swift` around lines 372 - 384, The test doubleTapOnly_modifierOnly_requiresSecondPress documents that the second press "starts recording in lock mode" but doesn't assert it; update the third ScenarioStep passed to runScenario (the one at time 0.2) to include the expectedState asserting the lock state (e.g. expectedState: .locked or whatever enum/case your tests use for the recording-locked state) so the test verifies the processor entered lock mode when startRecording is emitted; keep earlier steps' expectedState as the idle/non-locked state as appropriate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@HexCore/Tests/HexCoreTests/HotKeyProcessorTests.swift`:
- Line 336: Several ScenarioStep initializers in HotKeyProcessorTests.swift have
trailing commas in their collection literals (e.g., ScenarioStep(time: 0.2, key:
nil, modifiers: [], expectedOutput: nil, expectedIsMatched: false),) which
triggers SwiftLint trailing_comma warnings; edit each offending literal
(instances of ScenarioStep in the test arrays) to remove the final comma after
the last argument so the initializer calls end without a trailing comma, and
repeat this fix for all occurrences mentioned (the other ScenarioStep lines in
the file).
---
Nitpick comments:
In `@HexCore/Tests/HexCoreTests/HotKeyProcessorTests.swift`:
- Around line 372-384: The test doubleTapOnly_modifierOnly_requiresSecondPress
documents that the second press "starts recording in lock mode" but doesn't
assert it; update the third ScenarioStep passed to runScenario (the one at time
0.2) to include the expectedState asserting the lock state (e.g. expectedState:
.locked or whatever enum/case your tests use for the recording-locked state) so
the test verifies the processor entered lock mode when startRecording is
emitted; keep earlier steps' expectedState as the idle/non-locked state as
appropriate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 595aa80e-add6-471b-9d6f-b43d4091e9bd
📒 Files selected for processing (4)
.changeset/72ce3372.mdHex/Features/Settings/HotKeySectionView.swiftHexCore/Sources/HexCore/Logic/HotKeyProcessor.swiftHexCore/Tests/HexCoreTests/HotKeyProcessorTests.swift
✅ Files skipped from review due to trivial changes (1)
- .changeset/72ce3372.md
🚧 Files skipped from review as they are similar to previous changes (2)
- Hex/Features/Settings/HotKeySectionView.swift
- HexCore/Sources/HexCore/Logic/HotKeyProcessor.swift
| steps: [ | ||
| ScenarioStep(time: 0.0, key: .a, modifiers: [.command], expectedOutput: nil, expectedIsMatched: false), | ||
| ScenarioStep(time: 0.1, key: nil, modifiers: [.command], expectedOutput: nil, expectedIsMatched: false), | ||
| ScenarioStep(time: 0.2, key: nil, modifiers: [], expectedOutput: nil, expectedIsMatched: false), |
There was a problem hiding this comment.
Remove trailing commas in collection literals to clear SwiftLint warnings.
These lines currently trigger trailing_comma warnings and should be cleaned up to keep test lint output clean.
Also applies to: 349-349, 365-365, 383-383, 400-400, 418-418, 432-432, 445-445, 460-460
🧰 Tools
🪛 SwiftLint (0.63.2)
[Warning] 336-336: Collection literals should not have trailing commas
(trailing_comma)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@HexCore/Tests/HexCoreTests/HotKeyProcessorTests.swift` at line 336, Several
ScenarioStep initializers in HotKeyProcessorTests.swift have trailing commas in
their collection literals (e.g., ScenarioStep(time: 0.2, key: nil, modifiers:
[], expectedOutput: nil, expectedIsMatched: false),) which triggers SwiftLint
trailing_comma warnings; edit each offending literal (instances of ScenarioStep
in the test arrays) to remove the final comma after the last argument so the
initializer calls end without a trailing comma, and repeat this fix for all
occurrences mentioned (the other ScenarioStep lines in the file).
Modifier-only hotkeys can now use the existing double-tap-only mode. The settings UI also hides hotkey controls that do not apply to the current mode. Refs kitlangton#78, kitlangton#120.
196a67d to
47b5982
Compare
This removes the key+modifier-only restriction from double-tap-only mode, so modifier-only hotkeys like Cmd or Option can use it too.
It also tightens the Settings UI:
Refs #78. Related: #120.
Verified:
swift test --build-path /private/tmp/hexcore-swift-test-buildxcodebuild -scheme Hex -configuration Debug -derivedDataPath /private/tmp/HexDerivedData -skipMacroValidation CODE_SIGNING_ALLOWED=NO buildSummary by CodeRabbit
New Features
Bug Fixes
Tests
Chore