Skip to content

fix: robust global hotkey registration with informative conflict errors - #1292

Open
4Roman wants to merge 1 commit into
pot-app:masterfrom
4Roman:pr/hotkey-registration
Open

fix: robust global hotkey registration with informative conflict errors#1292
4Roman wants to merge 1 commit into
pot-app:masterfrom
4Roman:pr/hotkey-registration

Conversation

@4Roman

@4Roman 4Roman commented Jun 17, 2026

Copy link
Copy Markdown

Problem

When a global hotkey fails to register, the current behaviour has a few rough edges:

  • In the bulk registration pass, the ? operator bailed on the first error, so a single conflicting/invalid binding silently disabled all the remaining hotkeys.
  • After an unclean shutdown, a restart, or a previously failed attempt, a shortcut could stay tracked internally as "already registered" for the lifetime of the process, so re-registering it (even pressing OK again in settings) kept failing.
  • The error shown to the user ("failed to register hotkey") gives no hint about why.

Changes

  • Independent registration: register each hotkey separately in the "all" pass and collect failures, so one conflict no longer disables the others.
  • Clear stale state: call unregister_all() before bulk (re)registration, plus force-unregister + a short retry per shortcut, fixing the "already registered" desync left by unclean shutdowns / restarts / failed attempts.
  • Informative errors (Windows): add a small conflict probe (hotkey_owner.rs) that classifies the failure (free / held by another app / OS error) and names the owner for well-known system shortcuts; the user-facing error and the startup notification now state exactly which hotkey failed and why.
  • OK always re-grabs: removed the isRegistered pre-check in the Hotkey settings so pressing OK reliably re-claims the shortcut for pot.

Honest limitation

Windows exposes no public API to map a global hotkey back to its owning process, so for arbitrary third-party apps the message can only say "held by another application — pick a different combination". Only well-known OS shortcuts are named.

- Register each hotkey independently in the 'all' pass so a single conflict no longer disables the remaining hotkeys.

- Clear stale state with unregister_all() before bulk (re)registration, plus force-unregister + retry per shortcut, fixing the 'already registered' desync left by unclean shutdowns/restarts/failed attempts.

- Add a Windows conflict probe (hotkey_owner.rs) and surface an actionable, honest error; show a startup notification listing any failures.

- Always re-grab the shortcut for pot when pressing OK in the Hotkey settings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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