Skip to content

fix(transport) + feat(dui/iconkey): kill phantom release events and add notification badge#386

Merged
Faerkeren merged 3 commits into
mainfrom
dui/iconkey-alert
May 28, 2026
Merged

fix(transport) + feat(dui/iconkey): kill phantom release events and add notification badge#386
Faerkeren merged 3 commits into
mainfrom
dui/iconkey-alert

Conversation

@Faerkeren
Copy link
Copy Markdown
Contributor

Summary

Three logically distinct changes surfaced while running the examples/streamdeck.py demo against a real Stream Deck +.

1. fix(transport): phantom release events on every key

AsyncTransport initialised _prev_key_states and _prev_encoder_states to empty tuples. On the first KeyStateEvent/EncoderButtonEvent the per-index guard idx < len(self._prev_*_states) was always false, so the transport enqueued a KeyEvent/EncoderButtonEvent for every index in the snapshot — including released keys. Each spurious pressed=False event then fired a release handler on every other DuiKey on the screen, manifesting as random keys briefly flashing into their release state whenever any key was pressed.

Fix: seed both tuples to all-False sized from the device's key_count / dial_count. First snapshot now correctly emits events only for keys/buttons whose state differs from the assumed-released baseline. Two regression tests added.

2. feat(dui/iconkey): notification badge

Adds two bindings to the bundled IconKey.dui package:

  • show_notification (visibility, default false) — toggles a notification badge in the upper-right of the key.
  • notification_count (text, default "1") — number rendered inside the badge.

Badge is a coloured circle (uses the error CSS class) with a centred number, positioned at (82.5, 25) in the 120x120 key space and rendered with the existing drop-shadow filter for visual consistency with the icon and label.

tests/test_example_streamdeck.py fixture updated to mirror the manifest (new bindings, badge SVG nodes, and the existing hold event mapping).

3. chore(examples): demo the notification + tidy screenshot path

  • SceneController now toggles show_notification on the "Screenshot" IconKey so the badge appears when wired and clears on release.
  • Screenshot path moved from /tmp/deck_screenshot to examples/screenshots/ so artefacts stay with the example.
  • MEDIA_CATALOG trimmed 4 → 3 entries.
  • A few log.info traces on press/release to make the example easier to follow.

Testing

1986 passed, 1 skipped in 36.74s
Required test coverage of 95% reached. Total coverage: 95.62%
ruff: All checks passed!
mypy: Success: no issues found in 67 source files

Related

Commits

  1. 7d9800e fix(transport): seed prev key/encoder states from device capabilities
  2. 7df6c4f feat(dui/iconkey): add notification badge with show/count bindings
  3. 84f7418 chore(examples): demo IconKey notification and route screenshots to examples dir

Faerkeren added 3 commits May 28, 2026 09:19
The transport initialised _prev_key_states and _prev_encoder_states
to empty tuples. On the first :class:`KeyStateEvent` (or
:class:`EncoderButtonEvent`) the per-index guard
``idx < len(self._prev_*_states)`` was always false, so the transport
enqueued a :class:`KeyEvent`/:class:`EncoderButtonEvent` for *every*
index in the snapshot -- including released keys. Each spurious
``pressed=False`` event then triggered a `release` handler on every
other DuiKey on the screen.

Initialise both tuples to all-False with the device's `key_count` /
`dial_count`. The first snapshot now correctly emits events only for
keys/buttons whose state differs from the assumed-released baseline.

Add regression tests for both code paths covering the
initial-snapshot scenario.
Adds two new bindings to the bundled IconKey.dui package:

- `show_notification` (visibility, default false): toggles a
  notification badge group in the upper-right of the key.
- `notification_count` (text, default "1"): sets the number rendered
  inside the badge.

The badge is a coloured circle (uses the `error` CSS class for fill)
with a centred number, positioned at (82.5, 25) in the 120x120 key
coordinate space and rendered with the existing drop-shadow filter for
visual consistency with the icon and label.

Updates the `_iconkey_spec` test fixture in
`tests/test_example_streamdeck.py` to include the new bindings, a
matching `<g id="notification">` group in `_KEY_SVG`, and a `hold`
event mapping so the spec stays in sync with the manifest.
…xamples dir

- SceneController now toggles `show_notification` on the "Screenshot"
  IconKey: badge appears when wired and clears on release.
- Screenshot output path moved from `/tmp/deck_screenshot` to
  `examples/screenshots/` so demo artefacts stay with the example.
- MEDIA_CATALOG trimmed from 4 to 3 entries (covers the favourites
  example with one fewer scrolling step).
- Adds a few `log.info` traces on key press/release/click to make the
  example easier to follow when running interactively.
@Faerkeren Faerkeren merged commit ec47bba into main May 28, 2026
16 checks passed
@Faerkeren Faerkeren deleted the dui/iconkey-alert branch May 28, 2026 11:01
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