Skip to content

feat: Add Screen Wake Lock API support to Page#23619

Closed
Artur- wants to merge 1 commit into
mainfrom
wake-lock
Closed

feat: Add Screen Wake Lock API support to Page#23619
Artur- wants to merge 1 commit into
mainfrom
wake-lock

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented Feb 22, 2026

Expose the browser Screen Wake Lock API through Page methods, allowing server-side Java code to prevent the screen from dimming or locking for dashboards, kiosks, and presentations.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 22, 2026

Test Results

1 284 files   -   122  1 284 suites   - 122   1h 17m 20s ⏱️ - 5m 9s
8 797 tests  - 1 342  8 746 ✅  - 1 323  51 💤  - 19  0 ❌ ±0 
9 272 runs   - 1 342  9 212 ✅  - 1 323  60 💤  - 19  0 ❌ ±0 

Results for commit fbae707. ± Comparison against base commit 32183d1.

♻️ This comment has been updated with latest results.

@sonarqubecloud
Copy link
Copy Markdown

Comment thread flow-server/src/main/java/com/vaadin/flow/component/page/Page.java Outdated
Comment thread flow-server/src/main/java/com/vaadin/flow/component/page/Page.java Outdated
Comment thread flow-server/src/main/resources/META-INF/frontend/wakeLockConnector.js Outdated
@mshabarov mshabarov moved this from 🔎Iteration reviews to 🟢Ready to Go in Vaadin Flow | Hilla | Kits ongoing work Apr 1, 2026
@mshabarov mshabarov moved this from 🟢Ready to Go to 🪵Product backlog in Vaadin Flow | Hilla | Kits ongoing work Apr 22, 2026
Add a per-UI WakeLock facade reached through Page#getWakeLock(). It
exposes request(), release(), and an active-state Signal<Boolean>,
matching the conventions used for PageVisibility and Geolocation:

- Dedicated facade class under com.vaadin.flow.component.page with a
  package-private constructor.
- Client logic lives in flow-client/src/main/frontend/WakeLock.ts and
  is side-effect-imported from Flow.ts; nothing inlined into Java.
- State travels back as a vaadin-wake-lock-change CustomEvent on
  document.body with an ACTIVE / RELEASED detail; the facade listens
  on the UI element and writes to a private ValueSignal.
- Client transparently re-acquires the lock on visibilitychange so a
  single request() covers the lifetime of a view; release() clears
  the "want lock" flag and drops the current sentinel.
- Failures (insecure context, unsupported browser, denied) log at
  DEBUG and leave the active signal in its false state.
@sonarqubecloud
Copy link
Copy Markdown

@github-actions github-actions Bot added +0.1.0 and removed +0.0.1 labels May 12, 2026
@Artur-
Copy link
Copy Markdown
Member Author

Artur- commented May 12, 2026

Updated to match other PRs

@Artur- Artur- closed this May 12, 2026
@Artur- Artur- deleted the wake-lock branch May 12, 2026 12:44
@github-project-automation github-project-automation Bot moved this from 🪵Product backlog to Done in Vaadin Flow | Hilla | Kits ongoing work May 12, 2026
@Artur-
Copy link
Copy Markdown
Member Author

Artur- commented May 12, 2026

Continues in #24324

Artur- added a commit to vaadin/use-cases that referenced this pull request May 13, 2026
Adds a `wake-lock` module mirroring the `page-visibility` and
`geolocation` modules, with four use cases exercising the new
`Page#getWakeLock()` facade from vaadin/flow#23619:

- UC1 Manual toggle — minimal API exercise, button + status badge
  bound to `wakeLock.activeSignal()`.
- UC2 Recipe — lifetime-of-view pattern; `request()` on attach and
  `release()` on detach.
- UC3 Slideshow — `Signal.effect` couples the lock to a `presenting`
  signal, so reaching the last slide also releases the lock.
- UC4 Workout timer — HIIT timer coupling the lock to a `running`
  signal; uses `TaskScheduler` + `ui.accessLater` for ticks.

Each view has a browserless test; tests reach into the package-private
`WakeLock#setActive` via a reflective `WakeLockTestSupport` helper,
mirroring `PageVisibilityTestSupport`. `wake-lock/API-GAPS.md` records
six friction points observed while building the views (notably the
missing test simulator and missing server-side feature detection).

Pins `flow.version` to `25.2.wake-lock-SNAPSHOT`; revert to a mainline
snapshot once the PR is merged.
Artur- added a commit to vaadin/use-cases that referenced this pull request May 13, 2026
Adds a `wake-lock` module mirroring the `page-visibility` and
`geolocation` modules, with four use cases exercising the new
`Page#getWakeLock()` facade from vaadin/flow#23619:

- UC1 Manual toggle — minimal API exercise, button + status badge
  bound to `wakeLock.activeSignal()`.
- UC2 Recipe — lifetime-of-view pattern; `request()` on attach and
  `release()` on detach.
- UC3 Slideshow — `Signal.effect` couples the lock to a `presenting`
  signal, so reaching the last slide also releases the lock.
- UC4 Workout timer — HIIT timer coupling the lock to a `running`
  signal; uses `TaskScheduler` + `ui.accessLater` for ticks.

Each view has a browserless test; tests reach into the package-private
`WakeLock#setActive` via a reflective `WakeLockTestSupport` helper,
mirroring `PageVisibilityTestSupport`. `wake-lock/API-GAPS.md` records
six friction points observed while building the views (notably the
missing test simulator and missing server-side feature detection).

Pins `flow.version` to `25.2.wake-lock-SNAPSHOT`; revert to a mainline
snapshot once the PR is merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

3 participants