Skip to content

Claude/pawgate rust implementation o9 iy j#2

Merged
timothywarner merged 5 commits intomainfrom
claude/pawgate-rust-implementation-O9IyJ
Dec 28, 2025
Merged

Claude/pawgate rust implementation o9 iy j#2
timothywarner merged 5 commits intomainfrom
claude/pawgate-rust-implementation-O9IyJ

Conversation

@timothywarner
Copy link
Copy Markdown

No description provided.

Complete Rust rewrite for Windows with improved performance and smaller footprint:

Core Features:
- Low-level keyboard hook using Win32 SetWindowsHookEx
- Single hotkey toggle (default: Ctrl+B) for lock/unlock
- Full keyboard blocking including numpad, function keys, laptop media keys
- Semi-transparent overlay window spanning all monitors
- System tray icon with context menu
- Native Windows settings dialog for configuration

Technical Highlights:
- Uses official Microsoft `windows` crate for Win32 APIs
- No runtime dependencies - single standalone executable
- Optimized release build (~2-3MB vs ~15MB Python)
- DPI-aware with proper Windows manifest
- Single-instance enforcement via lockfile

Colorblind Accessibility:
- New high-contrast blue/orange icon distinguishable by all color vision types
- Icon generated programmatically with included Python script
- Multiple colorblind-friendly overlay color presets

Configuration:
- JSON config at ~/.pawgate/config.json
- Settings dialog for hotkey, opacity, overlay color, notifications
- Compatible config format with Python version

Files:
- pawgate-rs/src/*.rs - Rust source modules
- pawgate-rs/resources/ - Icons, Windows manifest, resource script
- pawgate-rs/build.bat - Windows build script
- pawgate-rs/README.md - Documentation
Documentation:
- INSTALL.md: Complete Rust installation guide for Windows, macOS, Linux
  - Step-by-step rustup/cargo setup
  - Visual Studio Build Tools instructions
  - Cross-compilation from macOS/Linux
  - Troubleshooting common issues
  - Cargo commands reference

- README.md: Expanded with beginner-friendly content
  - Clear default keybind (Ctrl+B) prominent at top
  - Quick start for download and build
  - Detailed feature descriptions
  - Hotkey format reference with examples
  - Auto-start instructions (3 methods)

- DEVELOPMENT.md: Contributor guide
  - Development environment setup
  - Project architecture explanation
  - Data flow and threading model
  - How to add new features
  - Testing and debugging tips
  - Code style guidelines

- ROADMAP.md: Feature planning
  - Current implementation status
  - Missing features by priority
  - Implementation details for planned features
  - GitHub Actions workflow examples
  - Competitor comparison

CI/CD:
- rust-ci.yml: Runs on push/PR to pawgate-rs/
  - Format check (rustfmt)
  - Clippy lints
  - Windows release build
  - Artifact upload

- rust-release.yml: Triggered by version tags (v*)
  - Builds optimized release
  - Creates ZIP package with docs
  - Generates SHA256 checksum
  - Creates GitHub Release automatically
Python Tests (tests/unit/):
- test_hotkey_listener.py: Hotkey registration, callback, cleanup
- test_path_util.py: Development vs packaged mode path resolution
- test_notifications.py: Toast notification mocking and verification

Rust Tests (pawgate-rs/src/config.rs):
- Config defaults verification
- JSON serialization/deserialization round-trip
- Overlay color parsing (valid, invalid, short hex)
- Hotkey parsing (Windows-only):
  - Simple hotkeys (ctrl+b)
  - Complex multi-modifier (ctrl+shift+alt+f12)
  - Case insensitivity
  - Function keys F1-F24
  - Special keys (space, enter, escape, etc.)
  - Number keys 0-9
  - Modifier aliases (ctrl/control)

Documentation:
- TESTING.md: Comprehensive testing guide for both implementations
  - Quick start commands
  - Test directory structure
  - pytest markers explanation
  - cargo test usage
  - Test writing templates
  - CI/CD integration examples
  - Troubleshooting guide
Python Release (.github/workflows/release.yml):
- Triggers on tags: v1.0.0, v2.1.0-beta, etc.
- Builds single ZIP containing:
  - PawGate.exe (Windows executable)
  - SHA256SUMS.txt (checksum for verification)
- Clean release page with:
  - Quick start instructions
  - Default hotkey table (Ctrl+B)
  - Feature list
  - System requirements
  - Security note about SmartScreen

Rust Release (.github/workflows/rust-release.yml):
- Triggers on tags: rust-v1.0.0, rust-v2.1.0-beta, etc.
- Runs tests before release
- Builds single ZIP containing:
  - PawGate.exe (Rust executable, ~2-3MB)
  - SHA256SUMS.txt (checksum for verification)
- Clean release page with:
  - Quick start instructions
  - Default hotkey table (Ctrl+B)
  - Feature list with performance metrics
  - Python vs Rust comparison table
  - System requirements

Both workflows:
- Support manual trigger via workflow_dispatch
- Auto-detect prerelease from tag (alpha, beta, rc)
- Include SHA256 checksum in package
- Updated to softprops/action-gh-release@v2

Tag patterns:
- Python: v1.0.0, v1.2.3-beta
- Rust: rust-v1.0.0, rust-v1.2.3-beta
Bug fixes:
- keyboard.rs: Fix keyboard hook return value not propagating from closure
  WHY: Returns inside thread_local!().with() only return from closure,
  not from the outer function. Keys were never actually being blocked.

- overlay.rs: Remove WS_VISIBLE flag so overlay starts hidden
  WHY: Overlay was briefly appearing on startup before being hidden.
  Now only shows when keyboard is actually locked.

- settings_dialog.rs: Fix font memory leak by storing handle and deleting in WM_DESTROY
  WHY: GDI font objects must be explicitly deleted or they leak.
  Also removed unused notification variable warning.

- tray.rs: Use None instead of HWND(std::ptr::null_mut()) for cleaner code
  WHY: The windows crate accepts Option<HWND> which is more idiomatic.

- main.rs: Add Default impl for AppState
  WHY: Satisfies clippy::new_without_default lint and allows AppState::default().

Co-Authored-By: Claude <[email protected]>
@timothywarner timothywarner merged commit 1283142 into main Dec 28, 2025
0 of 6 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.

2 participants