uttrflow / uttrflow/uttrflow-swift

Test that the shortcut editor refuses a shortcut another action already holds, and names that action

Open Beginner friendly
#752 0 comments 0 reactions 0 assignees View on GitHub
area:general enhancement good first issue P2
Dominant language
Swift
Stars
4
Forks
17
Avg merge
3h 32m
Merged PRs (30d)
277

Description

## What happens

`Sources/UttrflowUX/SettingsEditor.swift`:

- line 36: `apply(.shortcut(action, binding))` throwing the clash, and lines 150-158: `clash(for:binding:in:)` finding another action ("That is already the clipboard shortcut."). The clash path has never run;
- lines 174-177: the "did not register cleanly" rejection for a binding that isn't `isCoherent`.

Because `clash` is the only production caller of `ShortcutRegistry.label(for:)`, all of `Sources/UttrflowUX/ShortcutRegistry.swift` (`claimed`, `descriptor(for:)`, `label(for:)`) is also at 0%. `descriptor(for:)` falls back to `all[0]` ("Dictate") for an action with no entry, so a new action added without an entry would be labelled "Dictate" and nothing would fail.

Measured on origin/main `26d7bc1` with `swift test --enable-code-coverage` (5,384 tests, all passing) and `xcrun llvm-cov export` over the test binary. The regions named below have an execution count of 0: no test runs them, so a change that breaks them passes `make verify`.

## Why it matters

Two actions on one shortcut means one press fires both, for example opening the clipboard panel and starting dictation. The refusal is the only thing preventing it in Settings, and the message has to name the right shortcut so the user knows which one to change. `ShortcutRegistry.claimed` also decides which hot keys `AppDelegate` registers with the system.

## How to reproduce

Run `swift test --enable-code-coverage`, then `xcrun llvm-cov show -instr-profile .build/debug/codecov/default.profdata .build/debug/UttrflowPackageTests.xctest/Contents/MacOS/UttrflowPackageTests Sources/UttrflowUX/SettingsEditor.swift` and look for the `0` counts on the lines named above.

## Acceptance criteria

- Setting the dictation shortcut to the current clipboard shortcut throws a `SettingsRejection` whose reason is "That is already the clipboard shortcut.", and the settings are unchanged.
- An incoherent binding is refused with the "did not register cleanly" reason.
- A test over `ShortcutAction.allCases` asserts that `ShortcutRegistry.descriptor(for:)` returns a descriptor whose `action` is that action (no fallback), and that `claimed` is exactly the actions with `.claimed` delivery.
- Each new test fails when the branch it covers is broken. Check this by hand before opening the PR: temporarily change the branch (flip the condition or return the other value), see the test fail, then restore it.

## Where to start

- `Tests/UttrflowUXTests/SettingsEditorTests.swift`, suites "The shortcut cannot be saved undeliverable" and "Applying a change".
- Add a small `ShortcutRegistryTests.swift` in `Tests/UttrflowUXTests/`.
- `Docs/shortcuts.md` describes the actions.

Read `CONTRIBUTING.md` first. Iterate with `swift test --filter `, then run `make verify` before pushing. Only tests change; no product code needs to.

**Size:** S, under an hour.

Contributor guide

Open the contributing guide

Research direction

Read CONTRIBUTING.md first, then inspect the named suites in Tests/UttrflowUXTests/SettingsEditorTests.swift and add ShortcutRegistryTests.swift under the same directory. Run the relevant swift test --filter suites, verify the rejection messages, unchanged settings, allCases coverage, and mutation failures, then run make verify.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
desktop-dev, testing
Issue type
Bug
Difficulty
2/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.