feat: add opt-in user presence overlay for multi-user sessions#211
Open
nullstacked wants to merge 1 commit intopikvm:masterfrom
Open
feat: add opt-in user presence overlay for multi-user sessions#211nullstacked wants to merge 1 commit intopikvm:masterfrom
nullstacked wants to merge 1 commit intopikvm:masterfrom
Conversation
When multiple users connect to the same PiKVM, there is currently no visibility into who else is watching or who is actively controlling the machine. This adds a lightweight presence system behind a new config flag (kvmd.presence.enabled, default false). When enabled, the KVM web UI shows a small overlay listing connected users and their state: "is controlling" (recent HID input), "is watching", or "is watching (idle)". The overlay is toggleable per-browser via Web UI settings. The HID hot path (record_input) is rate-limited to one time.monotonic() syscall per 0.25s per user. WS broadcasts are diff-only. All state is bounded and auto-pruned.
46d3cec to
915e432
Compare
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
kvmd.presence.enabled: falseby default — zero behavior change unless enabledMotivation
When multiple operators share access to a PiKVM device, there is no way to know who else is connected or who is actively sending input. This leads to input conflicts (last-write-wins at the HID gadget) and coordination overhead via external chat. This change gives every connected user real-time visibility into session state.
Performance impact
None measurable.
record_input()adds ~200ns per HID event (one dict lookup + one comparison on the rate-limited common path). At 1kHz mouse input, that is 0.2ms/sec of CPU — invisible against the video encode/decode pipeline (5-15ms/frame)if self.__presence_enabled.record_input()returns after one dict lookup on an empty dictDesign
kvmd/apps/kvmd/presence.py— module-level registry tracking connected users and last HID input timestamp per userrecord_input()is on the HID hot path (~1kHz during mouse drag). Rate-limited to onetime.monotonic()+ dict write per 250ms per user. Common-case cost: one dict lookup + one comparison_last_inputentries auto-pruned after 1 hour (bounds dict size)self.__presence_enabled— zero overhead when disabled--cs-presence-*) for easy themingScreenshots
Files changed
kvmd/apps/kvmd/presence.pykvmd/apps/kvmd/server.pykvmd/apps/kvmd/api/hid.pywsparam, callrecord_inputkvmd/apps/_scheme.pykvmd/apps/kvmd/__init__.pyweb/share/css/kvm/presence.cssweb/share/js/kvm/session.jsweb/kvm/index.htmlUser-facing behavior
When
kvmd.presence.enabled: truein override.yaml:Test plan
kvmd.presence.enabled: truein override.yaml, restart kvmdpresence.enabled, restart — verify zero presence events sent