Files
noteflow/spikes/spike_01_ui_tray_hotkeys/FINDINGS.md
Travis Vasceannie af1285b181 Add initial project structure and files
- Introduced .python-version for Python version management.
- Added AGENTS.md for documentation on agent usage and best practices.
- Created alembic.ini for database migration configurations.
- Implemented main.py as the entry point for the application.
- Established pyproject.toml for project dependencies and configurations.
- Initialized README.md for project overview.
- Generated uv.lock for dependency locking.
- Documented milestones and specifications in docs/milestones.md and docs/spec.md.
- Created logs/status_line.json for logging status information.
- Added initial spike implementations for UI tray hotkeys, audio capture, ASR latency, and encryption validation.
- Set up NoteFlow core structure in src/noteflow with necessary modules and services.
- Developed test suite in tests directory for application, domain, infrastructure, and integration testing.
- Included initial migration scripts in infrastructure/persistence/migrations for database setup.
- Established security protocols in infrastructure/security for key management and encryption.
- Implemented audio infrastructure for capturing and processing audio data.
- Created converters for ASR and ORM in infrastructure/converters.
- Added export functionality for different formats in infrastructure/export.
- Ensured all new files are included in the repository for future development.
2025-12-17 18:28:59 +00:00

4.5 KiB

Spike 1: UI + Tray + Hotkeys - FINDINGS

Status: Implementation Complete, Requires Display Server

System Requirements

X11 or Wayland display server is required for pystray and pynput:

# pystray on Linux requires X11 or GTK AppIndicator
# pynput requires X11 ($DISPLAY must be set)

# Running from terminal with display:
export DISPLAY=:0  # If not already set
python -m spikes.spike_01_ui_tray_hotkeys.demo

Implementation Summary

Files Created

  • protocols.py - Defines TrayController, HotkeyManager, Notifier protocols
  • tray_impl.py - PystrayController implementation with icon states
  • hotkey_impl.py - PynputHotkeyManager for global hotkeys
  • demo.py - Interactive Flet + pystray demo

Key Design Decisions

  1. Flet for UI: Modern Python UI framework with hot reload
  2. pystray for Tray: Cross-platform system tray (separate thread)
  3. pynput for Hotkeys: Cross-platform global hotkey capture
  4. Queue Communication: Thread-safe event passing between tray and UI

Architecture: Flet + pystray Integration

┌─────────────────────────────────────────┐
│              Main Thread                │
│  ┌─────────────────────────────────┐    │
│  │         Flet Event Loop        │    │
│  │  - UI rendering                │    │
│  │  - Event polling (100ms)       │    │
│  │  - State updates               │    │
│  └─────────────────────────────────┘    │
│                   ▲                     │
│                   │ Queue               │
│                   │                     │
└───────────────────┼─────────────────────┘
                    │
┌───────────────────┼─────────────────────┐
│  ┌────────────────▼────────────────┐    │
│  │        Event Queue              │    │
│  │  - "toggle" -> toggle state     │    │
│  │  - "quit" -> cleanup + exit     │    │
│  └────────────────┬────────────────┘    │
│                   │                     │
│  ┌────────────────┴────────────────┐    │
│  │    pystray Thread (daemon)      │    │
│  │    pynput Thread (daemon)       │    │
│  │  - Tray icon & menu             │    │
│  │  - Global hotkey listener       │    │
│  └─────────────────────────────────┘    │
│             Background Threads          │
└─────────────────────────────────────────┘

Exit Criteria Status

  • Protocol definitions complete
  • Implementation complete
  • Flet window opens and displays controls (requires display)
  • System tray icon appears on Linux (requires X11)
  • Tray menu has working items (requires X11)
  • Global hotkey works when window not focused (requires X11)
  • Notifications display (requires X11)

Cross-Platform Notes

  • Linux: Requires X11 or AppIndicator; Wayland support limited
  • macOS: Requires Accessibility permissions for global hotkeys
    • System Preferences > Privacy & Security > Accessibility
    • Add Terminal or the app to allowed list
  • Windows: Should work out of box

Running the Demo

With a display server running:

python -m spikes.spike_01_ui_tray_hotkeys.demo

Features:

  • Flet window with Start/Stop recording buttons
  • System tray icon (gray = idle, red = recording)
  • Global hotkey: Ctrl+Shift+R to toggle
  • Notifications on state changes

Known Limitations

  1. pystray Threading: Must run in separate thread, communicate via queue
  2. pynput on macOS: Marked "experimental" - may require Accessibility permissions
  3. Wayland: pynput only receives events from X11 apps via Xwayland

Next Steps

  1. Test with X11 display server
  2. Verify cross-platform behavior
  3. Add window hide-to-tray functionality
  4. Implement notification action buttons