Skip to content

feat: keep mobile screen awake while using trackpad (#78)#365

Open
mrittickdeb wants to merge 2 commits into
AOSSIE-Org:mainfrom
mrittickdeb:main
Open

feat: keep mobile screen awake while using trackpad (#78)#365
mrittickdeb wants to merge 2 commits into
AOSSIE-Org:mainfrom
mrittickdeb:main

Conversation

@mrittickdeb

@mrittickdeb mrittickdeb commented Jul 13, 2026

Copy link
Copy Markdown

Addressed Issues:

Fixes #78

Description

This PR implements the browser's native Screen Wake Lock API in the trackpad component. When using the mobile device as a remote trackpad, the screen will no longer dim, sleep, or auto-lock.

Key additions:

  • Acquires screen wake lock automatically when the trackpad page mounts.
  • Handles tab visibility changes: Automatically re-acquires the lock if the user tabs away and returns to the trackpad view.
  • Automatic Cleanup: Properly releases the screen lock when the component unmounts (leaving the trackpad route) to preserve the client's battery life.
  • Type Safety: Strictly typed with native DOM WakeLockSentinel types (fully passes the Biome linter and TypeScript compiler checks).

Screenshots/Recordings:

(Not applicable as this is a non-visual background API change)

Functional Verification

  • Please check off the behaviors verified with this change.

Screen Mirror

  • Screen Mirror works.

Authentication

  • Connection doesn't work without a valid token.

Basic Gestures

  • One-finger tap: Verified as Left Click.
  • Two-finger tap: Verified as Right Click.
  • Click and drag: Verified selection behavior.
  • Pinch to zoom: Verified zoom functionality (if applicable).

Modes & Settings

  • Cursor mode: Cursor moves smoothly and accurately.
  • Scroll mode: Page scrolls as expected.
  • Sensitivity: Verified changes in cursor speed/sensitivity settings.
  • Copy and Paste: Verified both Copy and Paste functionality.
  • Invert Scrolling: Verified scroll direction toggles correctly.

Advanced Input

  • Key combinations: Verified "hold" behavior for modifiers (e.g., Ctrl+C) and held keys are shown in buffer.
  • Keyboard input: Verified Space, Backspace, and Enter keys work correctly.
  • Glide typing: Verified path drawing and text output.
  • Voice input: Verified speech-to-text functionality for full sentences.
  • Backspace doesn't send the previous input.

Any other gesture or input behavior introduced:

  • New Gestures: Verified screen wake lock remains active and prevents phone sleep during usage.

Additional Notes:

The Screen Wake Lock API is supported on Chrome, Edge, Opera, and Safari (iOS 13.7+). A warning fallback (console.warn) is included for unsupported browser contexts to avoid app failures.

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord and I will share a link to this PR with the project maintainers there
  • I have read the Contributing guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • Incase of UI change I've added a demo video.

Summary by CodeRabbit

  • New Features
    • The trackpad now helps keep the device screen awake during use.
    • Screen wake protection is automatically restored when returning to the app.

Copilot AI review requested due to automatic review settings July 13, 2026 17:19
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@mrittickdeb, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9c536db5-46dd-4148-98da-6ff7f53e5b07

📥 Commits

Reviewing files that changed from the base of the PR and between 7e4c923 and df1bd62.

📒 Files selected for processing (1)
  • src/routes/trackpad.tsx

Walkthrough

The trackpad page now requests a screen wake lock while visible, re-acquires it after visibility changes, and releases it with event-listener cleanup when unmounted. Unsupported APIs and acquisition failures are handled with guards and logging.

Changes

Trackpad Wake Lock

Layer / File(s) Summary
Wake lock lifecycle
src/routes/trackpad.tsx
A new effect requests the screen wake lock when supported and visible, retries after visibilitychange, and releases the lock while removing the listener during cleanup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: Typescript Lang

Suggested reviewers: copilot, pinjinx, aniket866, rozerxshashank, imxade

Sequence Diagram(s)

sequenceDiagram
  participant TrackpadPage
  participant BrowserVisibility
  participant ScreenWakeLock
  TrackpadPage->>ScreenWakeLock: request("screen") when visible
  BrowserVisibility->>TrackpadPage: visibilitychange
  TrackpadPage->>ScreenWakeLock: re-request lock when visible
  TrackpadPage->>ScreenWakeLock: release lock during cleanup
Loading

Poem

A bunny hops across the pad,
Keeping sleepy screens from feeling sad.
The lock wakes up when tabs return,
Then hops away when routes adjourn.

(\_/)
(•_•)
/ >📱
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes match issue #78 by requesting wake lock on mount, re-acquiring on visibility changes, and releasing on unmount.
Out of Scope Changes check ✅ Passed The changes appear focused on the wake lock feature with no obvious unrelated scope added.
Title check ✅ Passed The title clearly summarizes the main change: keeping the mobile screen awake during trackpad use.
Description check ✅ Passed The description matches the template and covers the issue, summary, verification, notes, and checklist.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Screen Wake Lock support to the /trackpad route so a mobile device used as a remote trackpad doesn’t dim/sleep while the trackpad view is active.

Changes:

  • Acquire a Screen Wake Lock when the trackpad page mounts.
  • Re-acquire the wake lock when the tab becomes visible again.
  • Release the wake lock when the trackpad page unmounts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/routes/trackpad.tsx

// Keep the mobile screen awake while using the trackpad
useEffect(() => {
let wakeLock: WakeLockSentinel | null = null
Comment thread src/routes/trackpad.tsx
Comment on lines +71 to +80
const requestWakeLock = async () => {
if (typeof window !== "undefined" && "wakeLock" in navigator) {
try {
wakeLock = await navigator.wakeLock.request("screen")
console.log("[WakeLock] Screen Wake Lock acquired")
} catch (err) {
console.warn("[WakeLock] Failed to acquire screen wake lock:", err)
}
}
}
Comment thread src/routes/trackpad.tsx Outdated
Comment on lines +92 to +95
return () => {
document.removeEventListener("visibilitychange", handleVisibilityChange)
if (wakeLock) {
wakeLock

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/routes/trackpad.tsx`:
- Line 75: Remove the debug console.log statements in the Wake Lock handling
flow, including the messages at the acquisition and release points. Do not
replace them with additional production logging; preserve the existing wake-lock
behavior.
- Around line 68-106: Update the useEffect wake-lock lifecycle around
requestWakeLock and handleVisibilityChange to track cancellation/unmount state
and prevent stale async requests from assigning unreleased sentinels. Serialize
or otherwise guard in-flight requests, release any existing wakeLock before
replacing it, and ensure a sentinel resolved after cleanup is immediately
released; retain listener removal and normal release behavior during unmount.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f4cbe8fc-9aaa-4ec9-bec1-e5fd804aa62d

📥 Commits

Reviewing files that changed from the base of the PR and between 753c6f5 and 7e4c923.

📒 Files selected for processing (1)
  • src/routes/trackpad.tsx

Comment thread src/routes/trackpad.tsx
Comment thread src/routes/trackpad.tsx Outdated
@mrittickdeb
mrittickdeb requested a review from Copilot July 14, 2026 05:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

[Feature]: Keep mobile screen awake while using the trackpad

2 participants