Skip to content

refactor(app): rebuild settings in GPUI with cleaner layers and reliable key capture - #15

Merged
squidllee merged 2 commits into
mainfrom
t3/rust-gpui-refactor-settings
Nov 9, 2026
Merged

squidllee merged 2 commits into
mainfrom
t3/rust-gpui-refactor-settings

Conversation

@squidllee

@squidllee squidllee commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

The settings app was on iced, and the app crate had grown into one big view file that mixed UI, Win32 glue and app logic. This moves the settings window to GPUI, splits the app into clean layers, polishes the settings UI and makes a few things more reliable.

What changes for users

  • The settings window is rebuilt in GPUI. It has a dark and a light theme that follow Windows, a clear On/Off/Needs-attention badge, and a full keyboard path: Tab and Shift+Tab move through the controls, and Space or Enter activates the focused one. The diagnostics buttons no longer move when status messages appear.
  • Rebinding the trigger key is more reliable. A short-lived low-level hook records exactly the key the engine will see, including Caps Lock, which the UI toolkit cannot report. Binding Space or Enter no longer restarts capture. Pressing a modifier gives a hint, and Esc cancels.
  • Tray, engine and session events now arrive on one event channel instead of a 500 ms poll. Idle CPU is about 0.3% while hidden.

Structure

  • crates/hyperkey-app/src/:
    • controller.rs: app state and logic, with no UI toolkit code; it carries the tests that were already there.
    • copy.rs: all user-facing text.
    • ui/: theme, components and the settings window.
    • platform/: Win32 glue.
    • app.rs: wiring.
  • Key classification lives in hyperkey-core::keys::classify_capture, which is pure and tested. The capture hook is in hyperkey-input::capture.
  • HYPERKEY_SETTINGS_DIR points a dev build at scratch settings and skips the startup registry entry.

Proof

  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • cargo test --workspace: all pass (app 38, core 72, input 24).
  • Exercised the dev build with an isolated profile:
    • dark and light theme;
    • capturing F9, Space and Enter, plus the modifier hint and Esc;
    • Tab, Shift+Tab and Space;
    • enable, restart hook, emergency disable (it does not persist) and copy details;
    • closing the window hides it, a second instance brings it back, and --tray starts hidden.
  • Not exercised at runtime: Quit from the tray menu. It was checked in code only.

Known gaps (follow-ups)

  • GPUI 0.2.2 has no window-icon option, so the window uses the default icon. The tray icon is unchanged.
  • Alt+Tab is swallowed while a capture is waiting for a key; Esc ends the capture.

After

pr-after-08bd4c5d.png

There is no before screenshot: building the old iced app again would have meant a heavy rebuild on a busy machine.

Reviewed with smol-loop: 2 rounds with Sonnet. Minion verdict: approved

Created with Claude Opus 5.5 in Claude Code, with Sonnet subagents.

🤖 Generated with Claude Code

squidllee and others added 2 commits November 9, 2026 13:19
Replace iced with upstream gpui 0.2.2. The app crate is now split into a
toolkit-free controller, user-facing copy, a GPUI ui module (theme,
components, settings window), and platform glue. Trigger rebinding uses a
one-shot low-level capture hook so the captured key matches what the engine
sees, classified by pure core logic. Background threads feed one event
channel drained on the main thread instead of a 500 ms poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Binding Space or Enter re-armed capture: the hook was gone before the
key-up, and GPUI clicks the focused keycap on that key-up. Dropping a
KeyCapture now stops reporting at once but keeps the hook until the keys it
swallowed are released. Also cancel capture on reveal, treat an empty
HYPERKEY_SETTINGS_DIR as unset, and drop the unused scan_code field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@squidllee
squidllee merged commit f598e33 into main Nov 9, 2026
3 checks passed
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