Skip to content

fix(dashboard): show QR loading state immediately and keep polling until ready#97

Open
MrViSiOn wants to merge 2 commits into
rmyndharis:mainfrom
MrViSiOn:fix/qr-polling-on-session-start
Open

fix(dashboard): show QR loading state immediately and keep polling until ready#97
MrViSiOn wants to merge 2 commits into
rmyndharis:mainfrom
MrViSiOn:fix/qr-polling-on-session-start

Conversation

@MrViSiOn
Copy link
Copy Markdown

@MrViSiOn MrViSiOn commented May 19, 2026

Problem

When a session is in Failed or disconnected state and the user clicks Reconnect, Chromium takes a few seconds to initialize before the QR is available. During that window, GET /api/sessions/:id/qr returns a 404/error. The previous code caught that error, displayed a global banner "QR code not available yet. Try again in a moment." and stopped — leaving the user unable to scan without clicking Reconnect again (and again).

Root cause

handleShowQR only called setQrData on success. On error it fell through to setError, which meant qrData stayed null and the existing 5-second polling interval never started.

Additionally, fetchQR (called by the interval) cleared qrData on any error, killing the interval even for transient "not ready yet" responses.

Fix

Two small changes in dashboard/src/pages/Sessions.tsx:

  1. handleShowQR — sets qrData with an empty qrCode before the fetch, so the modal opens immediately showing a loading spinner and the polling interval starts right away. A transient fetch error no longer clears the modal.

  2. fetchQR — on error, checks the session status before clearing qrData. If the session is still initializing/connecting it keeps polling; it only stops when the session reaches a terminal state (failed / disconnected) or when the QR is successfully scanned (status: ready).

Behaviour after fix

  • User clicks Reconnect → modal opens instantly with loading spinner
  • Every 5 s the interval retries getQR
  • As soon as Chromium generates the QR it appears in the modal automatically
  • If the session fails, the modal closes and the session list refreshes

No new dependencies. Single file changed.

MrViSiOn added 2 commits May 19, 2026 13:16
…til ready

When Chromium is still initializing, getQR returns an error before the
QR is available. The previous code caught that error, set a global error
banner, and stopped — leaving the user with no way to scan without
manually retrying.

This fix opens the QR modal in a loading state as soon as the user
triggers Reconnect/Start, so the existing 5-second polling interval
starts immediately. The interval now keeps running on transient errors
(QR not ready yet) and only stops when the session itself reaches a
terminal state (failed/disconnected) or when the QR is successfully
scanned (status: ready).
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.

1 participant