fix(skins): restore brightness when skin view closes - #643
Conversation
Reset display brightness to OS-managed mode when SkinView is removed so a sleeping skin cannot leave the native UI unreadably dim.
tadelv
left a comment
There was a problem hiding this comment.
Looks good. The host-side lifecycle boundary is the right place to restore brightness when leaving SkinView, and the regression coverage is appropriate.
Optional follow-up: the docs currently say closing the embedded skin resets brightness to 100 / OS-managed. With lowBatteryBrightnessLimit active below 30%, setBrightness(100) is still capped by native policy, so effective brightness remains 20 rather than resetting the platform override. I think that behavior is desirable; it would just be worth tightening the wording (and optionally adding a small regression case) to say that the skin's fixed-brightness request is discarded and native display policy becomes authoritative, including the low-battery cap.
Summary
What changed, and why?
SkinViewthe productionDisplayControllerand restoreOS-managed brightness through
setBrightness(100)when the view is removed.active REST or WebSocket fixed-brightness request.
Change Type (select all)
Scope (select all touched areas)
Linked Issues
Fixes #621
Root Cause (if bug fix)
SkinView; theview did not own the production controller needed to restore OS-managed
brightness when it closed.
brightness cleanup on
SkinViewremoval.client disconnect must not reset another client's brightness.
Regression Test Plan (if bug fix or refactor)
simulate=1+ curl/websocat)test/unit/skin_feature/skin_view_brightness_test.dart.SkinViewwhile another clientrequests brightness 40 replaces that request with 100 and resets platform
brightness exactly once.
Documentation Obligations (required)
assets/api/rest_v1.ymlorassets/api/websocket_v1.yml(if REST/WebSocket changed)doc/Api.md(if user-facing endpoint changed)doc/Plugins.md(if events/API changed)doc/Skins.md(if skin behavior changed)doc/Profiles.md(if profile handling changed)doc/DeviceManagement.md(if device flows changed)Security Impact (required)
No.No.No.No.No.No.Yes, explain risk and mitigation: N/A.User-Visible Changes
and returns the display to OS-managed brightness.
client's brightness.
Verification
Local gates (run before pushing)
dart format lib test- no remaining candidate changesflutter analyze- cleanflutter test- 3,179 passed, 1 skipped./scripts/fetch_dye2_plugin.sh- not rerun for this local draftManual verification (if applicable)
simulate=1):Yes.No; physical Android tablet only.brightness, and separation from WebSocket client cleanup.
Evidence
Detailed evidence:
because
SkinViewhad no host brightness restore hook.flutter test --no-pub test/unit/skin_feature/skin_view_brightness_test.dart test/controllers/display_controller_test.dart(41 passed).
dart format --output=none --set-exit-if-changed lib/main.dart lib/src/app.dart lib/src/skin_feature/skin_view.dart test/unit/skin_feature/skin_view_brightness_test.dartflutter analyze --no-pub(no issues).flutter test --no-pubwith the package-matched QuickJS DLL onPATH(3,179 passed, 1 skipped).
PUT /api/v1/display/brightnesswith10returned requested and applied brightness 10. Androiddumpsys displayreportedscreenBrightnessOverride=0.1,reason=override, andOverrideBrightnessStrategy.screenBrightnessOverride=NaN,reason=automatic, andInvalidBrightnessStrategy; automatic-brightness mode remained enabled. The panel did not visibly brighten because Android selected approximately 4% for the current lighting.live SkinView and renders the native launcher on Windows.
Compatibility & Migration
Yes.No.No.Risks & Mitigations
the skin UI is gone.
on skin exit; clients can request fixed brightness again afterward.
Contributor Responsibility
AI-assisted development is allowed. The submitter remains responsible for the submitted work.