Repository navigation
fix(mobile): make the phone-connect QR code scannable by phone cameras - #14205
Conversation
|
Intent: Make the phone-connect QR code readable by a phone camera on both surfaces that show it, the connect dialog and the Overview phone access card, by drawing it at its natural size with whole-pixel modules and the spec's 4-module quiet zone. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the code still lays out without a jump in Firefox/Safari — the removed [DESIGN-REVIEWED] 907fb9e |
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No first-time reader has seen the resized QR surfaces — this lane's cap; screenshots otherwise cover both surfaces, both themes, before and after. Watch
[UX-REVIEWED] 907fb9e |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- website/src/components/MobileConnectModal.tsx:242 -- |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The "fixed box at fractional scale" pattern this PR itself harvests survives at 2 counted siblings: the WeChat and WhatsApp pairing panels. Not justified as shipped
What this change shipsInventory (7 items) — 6 justifiedIntent: let a user open Kiro Crew on a phone by scanning the phone-connect QR, which a camera cannot currently read — a FIX (#13510; new tests fail on base).
[FIRST-PRINCIPLES-REVIEWED] 907fb9e |
|
|
Opus 5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNothing blocks; one advisory — removing the fixed FINDING — website/src/components/MobileConnectModal.tsx:242 — [OPUS-REVIEWED] 907fb9e |
ddefe71 to
7e59915
Compare
|
|
7e59915 to
f0d0702
Compare
|
f0d0702 to
c070932
Compare
|
Rebased onto main |
|
c223565 to
2dba1f3
Compare
|
|
|
|
The connect dialog drew the server's QR PNG into a fixed 176px box, and the Overview card drew the same code into a fixed 180px box. An access URL carries a signed token, so its symbol runs to about 80 modules, and those boxes squeezed each module to about 2px, smoothed at a fractional scale. That is too small and soft for a phone camera. The server now encodes the access code at 4px a module, and both surfaces show the image at its natural size with pixelated scaling, so every module is a whole number of screen pixels. The shared encoder's default output is unchanged for its other callers.
2dba1f3 to
907fb9e
Compare
|
Rebased: main moved in files next to or imported by this PR's files since this head went green (4a12bc8 -> 47594b8: #14261's |
|
|
|
|
|
Problem / Motivation
The phone-connect QR code shows on screen, but a phone camera does not pick it up (#13510). The code is drawn far below its real size. The server encodes it at 8px per module, and both places that show it squeeze that 648px image into a fixed box: 176px in the connect dialog, 180px on the Overview page's phone access card. Each module ends up about 2px wide and blurred.
Why it matters
Scanning this code is how a user opens Kiro Crew on a phone over the tailnet. When the camera cannot read it, the feature does not work, and the fallback is moving a link that carries a live session token to the phone by hand.
What changed (motivation → approach → change)
A phone camera can now read the phone-connect QR code. Both surfaces show it at its natural size, and every module (one black or white square) is a whole number of screen pixels.
An access URL carries a signed token, so its code runs to about 80 modules. At 8px per module that is about twice the dialog's width, and any fixed box smaller than the image rescales it by a fractional factor.
tailnet_mobile.pynow asks the shared encoder inqr.pyfor 4px modules, through a new keyword-onlybox_sizewhose default stays 8.MobileConnectModal.tsxandTailnetMobileCard.tsx, the two places that show this code, drop their fixed sizes and show the PNG as it is. Pixelated scaling keeps the upscale on a high-density screen sharp, andmax-w-fullonly shrinks a code wider than its container. The encoder keeps its 2-module quiet zone: the white padding both surfaces draw around the code brings the light margin to at least 4 modules.This fixes the phone-connect code only. Two other panels still draw a QR code into a fixed 180px box: the WeChat login panel (
WeixinPanel.tsx) and the WhatsApp pairing panel (WhatsAppPanel.tsx). Both still read in the same camera model, WeChat down to P = 0.5 and WhatsApp to 0.7, so they are left as they are.Backwards compatibility
Compatible:
render_qr_data_urigains a keyword-onlybox_sizewhose default leaves every other caller's output byte-identical, the WeChat login code included.Tests
test/test_qr.py(new):box_sizesets whole pixels per module; the default output is unchanged for other callers; the mobile module size is 4px, and a realistic access URL at that size fits the dialog's 370px QR box unscaled.test/test_tailnet_mobile.py: the QR handler asks the encoder for the mobile module size.website/src/components/MobileConnectModal.test.tsxandwebsite/src/components/TailnetMobileCard.test.tsx: the QR image has no fixedwidthorheightand carriesmax-w-fulland pixelated scaling.Each one fails with its production change reverted: the encoder and handler tests fail without the
box_sizekeyword, and each component test fails against main's fixed-size image.Manual verification
Rendered the real
MobileConnectModalandTailnetMobileCardin Chromium, with the tailnet endpoints stubbed and the encoder's PNG for a 373-character access URL, at 2x and 1x in both themes. On main, the dialog draws the 648px PNG at 176px and the card at 164px, both withimage-rendering: auto. With this change, both draw the 324px PNG at 324px, pixelated.Then decoded the rendered codes with ZXing (zxing-cpp 2.2.0) through a simple camera model: shrink the 2x screenshot to P camera pixels per CSS pixel with area resampling, add a slight blur, decode, and find the smallest P that still gives back the exact URL.
Both phone-connect surfaces now read at about half the camera resolution, which means from roughly twice as far away.
Two edge cases, measured the same way. At a 390px-wide window the dialog is narrower than the code, so
max-w-fullshrinks it to 281px: it stays free of gray pixels and still decodes down to P = 0.45. At 320px the code shrinks to 218px and its white frame still fits inside the dialog, with no horizontal scrolling. At 2x, drawing the code withimage-rendering: autoinstead leaves 22% of its pixels gray; pixelated leaves none.The images no longer carry a fixed
widthandheight, so their box comes from the PNG itself. Chromium resolves adata:PNG's size before the first frame that paints it: in 80 insertions of a 324px code at 1x and 2x, some made inside an animation-frame callback just before a paint, the first painted box was always the full 324px, so the controls below the code do not jump.Not verified: a scan with a physical phone, and that first-frame check in Firefox and Safari; this environment can run neither.
Screenshots / video
Connect dialog on main: the 648px code squeezed into a 176px box.
Connect dialog with this change: the code at its natural 324px.
Overview card on main, then with this change:
Light theme: connect dialog and Overview card
Related Issues
Fixes #13510
Pattern harvest
Rule candidate: review-prompt
Pattern: a machine-read image (QR code, barcode) drawn into a fixed box at a fractional scale of its natural size
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)