Skip to content

Add app-specific shortcuts with optional when filters#311

Draft
rahulxsomething wants to merge 1 commit intomikker:mainfrom
rahulxsomething:app-specific-shortcuts
Draft

Add app-specific shortcuts with optional when filters#311
rahulxsomething wants to merge 1 commit intomikker:mainfrom
rahulxsomething:app-specific-shortcuts

Conversation

@rahulxsomething
Copy link

Summary

  • Adds optional when field to actions and groups with includeApps/excludeApps bundle ID arrays
  • The same key can map differently depending on the frontmost app (e.g., t → Terminal globally, t → Google in Chrome)
  • Entire groups can be scoped to specific apps
  • "Everywhere except X" patterns supported via excludeApps
  • Configs without when fields behave identically to before (fully backward compatible)

Config example

{
  "key": "a",
  "type": "command",
  "value": "chrome-action",
  "when": {
    "includeApps": ["com.google.Chrome"],
    "excludeApps": ["com.google.Chrome.canary"]
  }
}

Precedence tiers

Tier Condition Priority
A includeApps matches frontmost app Highest
B excludeApps non-empty, includeApps empty Middle
C No when / both arrays empty Lowest (global)

Changes

File Change
Leader Key/UserConfig.swift When struct; when on Action, Group, ActionOrGroup, Item
Leader Key/AppFilter.swift New — matching, tier computation, resolution
Leader Key/Controller.swift Capture frontmost app in show(), resolve in handleKey()
Leader Key/UserState.swift frontmostBundleID property
Leader Key/Cheatsheet.swift Filter cheatsheet display by app
Leader Key/ConfigValidator.swift Tier-aware duplicate validation, when self-consistency checks
Tests 28 new tests across 3 test files

Test plan

  • All 69 tests pass (0 failures)
  • Tier A override: Chrome-specific key fires in Chrome, global fires elsewhere
  • Tier B exclude: item hidden for excluded app, visible for others
  • App-scoped group: group hidden for non-matching apps
  • Cheatsheet reflects app-specific filtering
  • Backward compatibility: configs without when work identically

🤖 Generated with Claude Code

Allow actions and groups to target specific apps via a `when` field
containing `includeApps` and/or `excludeApps` bundle ID arrays.
The same key can now map differently depending on the frontmost app,
while configs without `when` fields behave identically to before.

Resolution uses a three-tier precedence system:
- Tier A: includeApps matches frontmost app (most specific)
- Tier B: excludeApps non-empty, includeApps empty (everywhere-except)
- Tier C: no when / both empty (global fallback)

Includes tier-aware config validation and 28 new unit tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rahulxsomething rahulxsomething marked this pull request as draft February 16, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments