[PR #129] [MERGED] fix: waitReconnect detects puck reappearance without auto-connect (Android Chrome) #219

Closed
opened 2026-10-22 05:07:46 +00:00 by roman · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/safijari/openpuck/pull/129
Author: @Copilot
Created: 7/5/2026
Status: ✅ Merged
Merged: 7/5/2026
Merged by: @safijari

Base: main ← Head: copilot/handle-puck-reconnection


📝 Commits (1)

  • 5367249 fix: detect puck reappearance in waitReconnect for Android Chrome

📊 Changes

1 file changed (+20 additions, -2 deletions)

View changed files

📝 docs/index.html (+20 -2)

📄 Description

On Android Chrome, openDevice() requires a user gesture, so autoConnect() silently fails after the firmware update reboot. waitReconnect() was gated on dev && _lastBlobTs > t0 — a condition that can never be true without a successful openDevice() — causing the updater to hit the 40 s timeout and show a failure modal even when the update applied cleanly.

Changes

  • waitReconnect() — after observing the disconnect (seenGone), now also polls navigator.usb.getDevices() each iteration. Returns "appeared" if the puck is back in the authorized-device list but dev is still null (auto-open failed); returns true on full reconnect+blob as before; false on genuine timeout.

  • runUpdate() — handles the new "appeared" outcome as success, showing "Update applied — the puck is back. Tap Connect to reconnect." instead of the bogus error.

async function waitReconnect(t0, ms){
  let seenGone = !dev;
  while(Date.now() < deadline){
    if(dev && window._lastBlobTs > t0) return true;          // desktop: full auto-reconnect
    if(!dev) seenGone = true;
    if(seenGone && !dev){
      const ds = await navigator.usb.getDevices();
      if(ds.some(x => USB_FILTERS.some(f => f.vendorId === x.vendorId)))
        return "appeared";                                    // Android: visible but can't auto-open
    }
    await dfuSleep(400);
  }
  return false;                                               // genuine timeout
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/safijari/openpuck/pull/129 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 7/5/2026 **Status:** ✅ Merged **Merged:** 7/5/2026 **Merged by:** [@safijari](https://github.com/safijari) **Base:** `main` ← **Head:** `copilot/handle-puck-reconnection` --- ### 📝 Commits (1) - [`5367249`](https://github.com/safijari/openpuck/commit/536724982c5f346dd60ce0b845172760bff4d552) fix: detect puck reappearance in waitReconnect for Android Chrome ### 📊 Changes **1 file changed** (+20 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/index.html` (+20 -2) </details> ### 📄 Description On Android Chrome, `openDevice()` requires a user gesture, so `autoConnect()` silently fails after the firmware update reboot. `waitReconnect()` was gated on `dev && _lastBlobTs > t0` — a condition that can never be true without a successful `openDevice()` — causing the updater to hit the 40 s timeout and show a failure modal even when the update applied cleanly. ## Changes - **`waitReconnect()`** — after observing the disconnect (`seenGone`), now also polls `navigator.usb.getDevices()` each iteration. Returns `"appeared"` if the puck is back in the authorized-device list but `dev` is still null (auto-open failed); returns `true` on full reconnect+blob as before; `false` on genuine timeout. - **`runUpdate()`** — handles the new `"appeared"` outcome as success, showing *"Update applied — the puck is back. Tap Connect to reconnect."* instead of the bogus error. ```js async function waitReconnect(t0, ms){ let seenGone = !dev; while(Date.now() < deadline){ if(dev && window._lastBlobTs > t0) return true; // desktop: full auto-reconnect if(!dev) seenGone = true; if(seenGone && !dev){ const ds = await navigator.usb.getDevices(); if(ds.some(x => USB_FILTERS.some(f => f.vendorId === x.vendorId))) return "appeared"; // Android: visible but can't auto-open } await dfuSleep(400); } return false; // genuine timeout } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
roman 2026-10-22 05:07:46 +00:00
Sign in to join this conversation.
No labels
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
safijari/openpuck#219
No description provided.