Skip to content

fix: prevent phone QR pairing from connecting indefinitely #259

Open

Description

@nextestudios

Problem

After scanning the pairing QR code on an iPhone, Safari opens the local ControlFS page, but it remains on “Connecting to PC...” indefinitely. The phone never reaches the connected control screen and receives no error or retry option.

The attached screenshot shows the page open at a local address (192.168.1.162) with the connection still pending.

Goal

Make QR pairing either connect successfully or fail with a clear, actionable status instead of leaving the phone in an endless connecting state.

Requirements

  • Reproduce the reported flow on iPhone Safari and diagnose why the local pairing handshake does not complete.
  • Verify the QR address, session token, connection endpoint and handshake work together on the same local network.
  • Show a bounded connection timeout and a useful error when the PC is unreachable, the pairing session expires, or the handshake fails.
  • Provide a clear retry action and explain when the user needs to rescan the QR code.
  • Keep the desktop and phone connection states synchronized, including disconnects and expired sessions.
  • Preserve the short-lived pairing credential and authenticated, encrypted local connection required by feat: use a phone for navigation and text input over local P2P #223; do not expose credentials in error messages or logs.
  • Verify the same pairing flow in current iOS Safari and Android mobile browsers.

Acceptance Criteria

  • Scanning a valid QR code on the same local network completes pairing and opens the phone control interface.
  • A connection attempt cannot remain on “Connecting...” forever; it either succeeds or times out with a useful message.
  • An expired or invalid pairing session tells the user to generate and scan a new QR code.
  • An unreachable PC or failed handshake shows an actionable error and allows retry.
  • Reconnection and disconnect update the status on both devices without leaving stale connecting indicators.
  • Pairing works in current iOS Safari and Android browsers without weakening the security requirements in feat: use a phone for navigation and text input over local P2P #223.

Testing

Reproduce with an iPhone on the same Wi-Fi network as the PC, then verify successful pairing, expired QR, unreachable PC, interrupted connection, and retry. Verify Android browser behavior as well.

Dependencies


MoSCoW: Should have · Milestone: 2 · Controller-First Windows UI

Activity

  1. added
    type: enhancement
    moscow: should
    on Sep 29, 2026
  2. nextestudios commented on Sep 29, 2026

    @nextestudios
    OwnerAuthor

    Fixed a reproducible root cause in #266 (merged): the phone page's script is allowed by a CSP hash computed over the embedded HTML; with CRLF line endings (Windows checkout with autocrlf) browsers hash LF, so the script was blocked and the page stayed on its first text ("Connecting to PC…") with no error. Reproduced with the real server on WebKit and Chromium; fixed by hashing LF text and pinning the page files to LF. The page now also ends every attempt in a clear state (bounded timeouts, distinct messages, Try again, rescan guidance) and the PC dialog/local log show the reason a phone was refused.

    Still open: this was not verified on a physical iPhone or Android, and I can't prove the CRLF cause was what the reporter's build hit. Please retest with the next release on a real iPhone (same Wi-Fi) and on Android; if it still hangs, the page now shows why and logs\startup.log has the reason codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    moscow: shouldtype: enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions