Protect settings during device refresh#95
Conversation
27e2dee to
02ff978
Compare
kissetfall
left a comment
There was a problem hiding this comment.
Thanks for working on protecting pending settings during device refresh. The current implementation still has several lifecycle blockers that need to be resolved before merge:
- Automatic device polling stops whenever a layout or HID handle is present. As a result, a normal USB disconnect is no longer detected and Entropy can remain in a false “connected” state.
- Manual refresh does not recover the same device after unplug/replug: when the device key is unchanged, the stale HID handle is retained and reconnect is not started.
- The “Refresh data” flow can delete the device cache before
device_refresh_blocked()rejects reconnect because of pending Tap Hold, Macro, or Combo state. Please run one shared preflight before any destructive cache action or reconnect transition. - The empty manual-scan status uses the hardcoded English text
No device detected; it needs to use the existing i18n path.
Please keep lightweight disconnect detection active while protecting pending writes, reopen the HID handle when the same device is replugged, make the cache/reconnect transition atomic, and add production-lifecycle regression coverage for unplug/replug of the same device and “Refresh data” with pending editor state. The current helper-only tests do not exercise these paths.
02ff978 to
ad11ada
Compare
|
Addressed:
Added production lifecycle regressions for connected scan scheduling, unplug with pending Combo state, stale scan discard, same-device reconnect, and empty-serial re-enumeration. |
kissetfall
left a comment
There was a problem hiding this comment.
Re-reviewed head ad11ada. Manual same-device reopen, unique re-enumeration matching, refresh-data preflight, and localization are improved. All four hosted builds are green and local tests pass 262/262. Two lifecycle blockers remain.
-
An empty automatic scan is applied even when device_refresh_blocked is true. The new pending-Combo test demonstrates this path but only asserts that HID is cleared; clear_connected_keyboard_state also clears combo_dirty and the pending edit. A physical unplug or transient empty enumeration therefore loses the exact settings this PR is meant to protect. Route disconnect through the shared deferred-state handoff, then reconnect/reconcile without dropping Macro/Combo/Tap Dance/Tap Hold/picker work.
-
On macOS this removes the hid_session_active guard and enumerates every second while HidDevice remains open. The repository's own hid.rs comment says concurrent enumeration while another thread holds an open device can crash on macOS 26. The mutex only serializes individual HID operations; it does not cover the lifetime of the open handle. Keep a macOS-safe lightweight liveness path or close/reopen through one owner instead of concurrent HidApi enumeration.
Also treat a scan worker/channel failure separately from a confirmed physical disconnect; it currently becomes an empty list and clears the live session.
ad11ada to
be973c7
Compare
|
Addressed:
|
EN
Problem
Background device scans could clear or switch an active keyboard when HID enumeration briefly changed, even while firmware settings still had pending writes. A reconnect also returned module and list editors to their first row, making a refresh look like the user's selected controller or setting had disappeared. Connected users had no explicit refresh command to control when device enumeration was applied.
Fix
Verification
cargo test: 196 passed.cargo clippy --all-targets: passed with existing repository warnings.python3 scripts/check_i18n.py: passed.rustfmt --checkandgit diff --check: passed. Repository-widecargo fmt --checkremains blocked by pre-existing formatting differences insrc/keycode.rs.TARGET=aarch64-apple-darwin scripts/build_macos_app.sh: arm64 app, DMG, and ZIP built; architecture and code-signature validation passed.RU
Проблема
Фоновое сканирование устройств могло сбросить или переключить активную клавиатуру при кратковременном изменении результатов HID-поиска, даже если запись настроек прошивки еще не завершилась. После переподключения редакторы модулей и списков также возвращались к первой строке, поэтому выбранный контроллер или параметр выглядел потерянным. Для подключенного устройства не было явной команды обновления, позволяющей пользователю выбрать момент применения результатов поиска.
Исправление
Проверка
cargo test: прошли 196 тестов.cargo clippy --all-targets: прошел с существующими предупреждениями репозитория.python3 scripts/check_i18n.py: прошел.rustfmt --checkиgit diff --check: прошли. Общийcargo fmt --checkпо-прежнему блокируется существующими отличиями форматирования вsrc/keycode.rs.TARGET=aarch64-apple-darwin scripts/build_macos_app.sh: собраны arm64-приложение, DMG и ZIP; архитектура и подпись прошли проверку.