Repository navigation
feat(daemon): settling re-poll after controller reconnect - #11
Merged
Merged
Conversation
A physical mode switch re-enumerates the controller; the single post-add poll can read it mid-transition and show the previous mode's battery until the next poll tick. Schedule short follow-up polls (1s, 3s) so the settled value reaches both frontends within seconds. Co-Authored-By: Claude Opus 4.8 (1M context) <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
addpoll can read the device mid-transition —openHIDrides the ~1.5s udevuaccessrace, andreader.Read/power_supplyattrs may not be ready yet — soreadHIDreturns aStaleread carrying the previous mode's battery, and nothing corrects it until the next poll tick (30–60s).settleDelays = {1s, 3s}) after each hotplugaddvia a newscheduleSettlehelper feeding a bufferedsettleCh, so the settled value reaches both frontends within seconds. Daemon-only — the GNOME extension and COSMIC applet already mirror the state file.Test Plan
go test ./cmd/cyclone2/ -run TestScheduleSettle -v— new unit tests (arms one timer per delay; simultaneous fires coalesce to one queued send)go test ./...,go build ./...,go vet ./...— clean (andgo test -raceclean)$XDG_RUNTIME_DIR/cyclone2-linux.jsonreflects the new mode/battery within a few seconds, not after a full poll interval🤖 Generated with Claude Code