feat(kscan): support peripheral diagnostics via QueryPeripheral relay#112
Merged
Merged
Conversation
Implements the web UI side of zmk-feature-kscan-diagnostics PR #2 (peripheral kscan diagnostics over the split event-relay). Protocol: - Add QueryPeripheral and PeripheralEvent messages to the proto and regenerate the TypeScript bindings. Hook (useKscanDiagnostics): - queryPeripheral() helper wraps any inner Request in a QueryPeripheral RPC and awaits matching PeripheralEvent notifications via zmkApp.onNotification, resolving on the target source's response or a configurable timeout. - fetchPeripheralTopology(source) relays the full paginated topology fetch (GetInfo / GetLayout / GetDevice / GetGpioPins / GetPositionMap) for one peripheral source. - loadPeripheralTopologies() broadcasts GetInfo for discovery, then fetches topology for every responding source. - New return values: peripheralTopologies, isLoadingPeripheralTopologies, peripheralTopologyErrors, loadPeripheralTopologies. Demo transport: - KscanDiagnosticsHandler handles queryPeripheral: returns Ok and fires a PeripheralEvent notification (50 ms later) for a simulated 4x6 right-half peripheral (source=1). - demo.ts wires the kscan notify callback into the transport pipeline. UI (KscanDiagnosticsSection): - Calls loadPeripheralTopologies() alongside loadTopology() on expand. - Shows a loading indicator while peripheral data is being fetched. - Renders each peripheral's wiring as a KscanKeyboardView labeled "Peripheral N". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The baseKscan() helper in the section test was missing the new peripheral props introduced in the previous commit, causing CI to throw "Cannot read properties of undefined (reading 'entries')" when the component tried to iterate peripheralTopologyErrors. Also updates the expand test to assert that loadPeripheralTopologies is called alongside loadTopology on first expand. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReturnType<typeof useContext<typeof ZMKAppContext>> evaluates to typeof ZMKAppContext (the Context object itself), not the value it holds. This caused three TS errors in CI: - onNotification does not exist on Context<UseZMKAppReturn | null> - UseZMKAppReturn not assignable to Context<UseZMKAppReturn | null> Fix: use a conditional type to extract the value type from the Context and strip null, giving ZmkApp = UseZMKAppReturn as intended. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🚀 Cloudflare Workers PreviewPreview URL: https://87ecac6c-dya-studio-dev.cormoran707.workers.dev Deployed from commit 2c6089f |
… timeout When QueryPeripheral is supported but no peripheral sends a PeripheralEvent within the discovery window, set peripheralDiscoveryError and display a SectionError in KscanDiagnosticsSection so the user knows the query timed out. Firmware that lacks QueryPeripheral support still silently skips. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Implements the web UI side of zmk-feature-kscan-diagnostics PR #2 — peripheral kscan diagnostics over the split event-relay.
QueryPeripheral(request) andPeripheralEvent(notification) messages; regenerate TS bindingsuseKscanDiagnostics):loadPeripheralTopologies()discovers peripheral sources by broadcastingGetInfoviaQueryPeripheral, then relays the full paginated topology fetch (GetInfo/GetLayout/GetDevice/GetGpioPins/GetPositionMap) for each responding peripheral, collectingPeripheralEventnotifications per pageKscanDiagnosticsHandlerhandlesqueryPeripheral(returnsOk, fires aPeripheralEventnotification 50ms later for a simulated 4×6 right-half peripheral at source=1);demo.tswires the notify pipelineKscanDiagnosticsSection): callsloadPeripheralTopologies()on expand, shows a loading indicator, and renders each peripheral's wiring as aKscanKeyboardViewlabeled "Peripheral N"Test plan
npx tsc --noEmit)demo-kscan-diagnosticstests all pass (16 tests, including 2 newqueryPeripheraltests that verifyOkreturn and notification delivery)🤖 Generated with Claude Code