fix(transport) + feat(dui/iconkey): kill phantom release events and add notification badge#386
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three logically distinct changes surfaced while running the
examples/streamdeck.pydemo against a real Stream Deck +.1.
fix(transport): phantom release events on every keyAsyncTransportinitialised_prev_key_statesand_prev_encoder_statesto empty tuples. On the firstKeyStateEvent/EncoderButtonEventthe per-index guardidx < len(self._prev_*_states)was always false, so the transport enqueued aKeyEvent/EncoderButtonEventfor every index in the snapshot — including released keys. Each spuriouspressed=Falseevent then fired areleasehandler on every otherDuiKeyon 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 badgeAdds two bindings to the bundled
IconKey.duipackage:show_notification(visibility, defaultfalse) — 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
errorCSS 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.pyfixture updated to mirror the manifest (new bindings, badge SVG nodes, and the existingholdevent mapping).3.
chore(examples): demo the notification + tidy screenshot pathSceneControllernow togglesshow_notificationon the "Screenshot"IconKeyso the badge appears when wired and clears on release./tmp/deck_screenshottoexamples/screenshots/so artefacts stay with the example.MEDIA_CATALOGtrimmed 4 → 3 entries.log.infotraces on press/release to make the example easier to follow.Testing
Related
Commits
7d9800efix(transport): seed prev key/encoder states from device capabilities7df6c4ffeat(dui/iconkey): add notification badge with show/count bindings84f7418chore(examples): demo IconKey notification and route screenshots to examples dir