Skip to content

refactor: dedupe silent exception cleanup in hotkey service and main app - #62

Merged
TimInTech merged 1 commit into
mainfrom
refactor/dedupe-exception-cleanup
Sep 18, 2026
Merged

TimInTech merged 1 commit into
mainfrom
refactor/dedupe-exception-cleanup

Conversation

@TimInTech

Copy link
Copy Markdown
Owner

What changed?

Two behavior-preserving deduplications of silent exception handling (2 files, +12/-18):

  1. app/hotkey_service.py: the two hand-written fallback-candidate close loops in _discover_keyboards now call the existing _close_devices() helper (_close_devices(fallback_candidates) and _close_devices(fallback_candidates[1:])). The helper does exactly the same: iterate over a list() copy, dev.close(), ignore errors.
  2. app/blitztext_linux.py: the two identical cosmetic try: window.setWindowIcon(theme.create_app_icon()) / except Exception: pass blocks in _ensure_compose_window and _ensure_main_window are centralized in a module-level _apply_window_icon(window) (keeps # pragma: no cover; comment now in English).

Why?

Follow-up to #61 from the same cleanup audit: removes duplicated blind/silent handlers without changing what they catch or when. Nothing else from the audit is included on purpose (no narrowing of exception types, no logging).

Note: the icon helper contains one handler itself, so item 2 nets -1 (not -2) per rule; item 1 nets -2 per rule.

How did you test it?

Baseline on main (5fbe28d) vs. this branch (be4d8d3).

Tests (QT_QPA_PLATFORM=offscreen WHISPER_GUI_TESTS=1 XDG_RUNTIME_DIR=/run/user/1000):

main this branch
pytest tests/ 684 passed 684 passed

Ruff (0.16.8, --no-cache, default rules for the repo-wide count; --select BLE001,S110 app/ for the rule counts):

main this branch
ruff repo total (ruff check .) 287 281
BLE001 + S110 in app/ 35 29
of which BLE001 25 22
of which S110 10 7

The per-rule statistics differ only in BLE001 and S110; every other rule count is identical. git diff --check is clean.

Real Wayland GUI smoke test (native wayland session, isolated temp HOME, hotkey worker disabled so it does not compete with the running user service; same script run against an export of main and against this branch):

Check main this branch
Main window opens (visible, title "Blitztext", window icon set, 242x213) yes yes, identical
Compose window opens (visible, title "Text bearbeiten", window icon set, 620x400) yes yes, identical
Second show_* call reuses the same window objects yes yes
Log warnings/errors, Qt messages, sys.excepthook hits, stderr none none
_discover_keyboards() against real /dev/input (read-only, no grab): returned devices 5 same 5
evdev close() calls (during discovery / total) 34 / 39 34 / 39
theme.create_app_icon raising RuntimeError: Compose window still constructed yes yes

Rendered screenshots of both windows were inspected and look correct.

Limits: the hotkey worker was disabled in the smoke test, so the new _close_devices calls were exercised through _discover_keyboards() with real devices, not through a live listener. The icon paths have no unit tests (create_app_icon is not mocked in tests/).

Rollback: git revert <squash commit>.

AI assistance

Yes. Implemented and verified with Claude Code (Claude Sonnet 5) from an exception-handler audit; the diff was reviewed by the maintainer before committing.

Checklist

  • I ran pytest tests/ (offscreen) or explained why not.
  • I did not commit API keys, tokens, private recordings, or confidential transcripts.
  • I considered whether this changes privacy, security, or data flow. (No: error handling behavior is unchanged.)
  • I kept the change focused on the Linux scope.

🤖 Generated with Claude Code

- hotkey_service: reuse _close_devices() for the two fallback-candidate
  close loops in _discover_keyboards instead of repeating try/except/pass.
- blitztext_linux: centralize the identical cosmetic window-icon
  try/except in _apply_window_icon() for the compose and main windows.

Behavior is unchanged. BLE001 35 -> 29 and S110 10 -> 7 in app/,
repo-wide ruff 287 -> 281; pytest 684 passed before and after.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@TimInTech
TimInTech merged commit 39d98f3 into main Sep 18, 2026
9 checks passed
@TimInTech
TimInTech deleted the refactor/dedupe-exception-cleanup branch September 18, 2026 23:22
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