Skip to content

brightness: retry initial DDC read - #3287

Merged
bbedward merged 1 commit into
duxlabs-dev:masterfrom
li-yuanfei:fix/ddc-brightness-initial-state
Sep 4, 2026
Merged

bbedward merged 1 commit into
duxlabs-dev:masterfrom
li-yuanfei:fix/ddc-brightness-initial-state

Conversation

@li-yuanfei

Copy link
Copy Markdown
Contributor

Closes #3060

Retry the initial DDC brightness read when probing a monitor. Some monitors accept the probe but are not ready to answer the first VCP request, leaving the startup brightness at 0 until the user moves the slider.

Retrying only the initial read makes startup state recoverable without changing the successful path or brightness writes.

Validation: gofmt and git diff --check pass. The brightness package tests could not start because the repository's current lipgloss/cellbuf module graph does not provide github.com/charmbracelet/x/cellbuf.

@bbedward

bbedward commented Sep 4, 2026

Copy link
Copy Markdown
Member

/claude review

@claude

claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found.

Verified the retry loop is correct: success returns immediately (unchanged fast path), the failure log fires exactly once on the last attempt, time was already imported, and neither getVCPFeature, the write path, nor device storage semantics changed. Retries reuse the already-open probe fd, and getVCPFeature drains stale bytes on entry, so repeated attempts on the same fd are safe.

One non-blocking note (not a defect, no change requested): a bus that ACKs the x37 probe but never answers VCP now costs ~950ms instead of ~250ms (2x100ms backoff plus the 50ms sleep + 200ms poll timeout per attempt), and that runs while scanMutex is held inside the 32-bus loop. It is one-time per newly probed bus and initDDC runs in a goroutine, so startup is not blocked; it only lengthens brightness.rescan and udev-triggered rescans. Worth knowing if the retry count is ever raised.

Checked: single-hunk change to core/internal/server/brightness/ddc.go, its callers in manager.go/handlers.go/udev_linux.go, and the lock/latency path through scanI2CDevicesInternal. Model: claude-opus-5.

@bbedward
bbedward merged commit ec22e9e into duxlabs-dev:master Sep 4, 2026
3 checks passed
dank-shell-app Bot pushed a commit that referenced this pull request Sep 4, 2026
port 1.6

(cherry picked from commit ec22e9e)
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.

Brightness slider shows 0% at startup for DDC monitor despite correct value being readable via CLI

2 participants