Repository navigation
fix(pairing): pasted links pair as people copy them; QR reads from farther away - #15
Merged
Merged
Conversation
Pasting a pairing link failed with "That isn't a pairing link" (welcome Paste), "That isn't an OpenCode pairing code" (scanner Paste) or "Couldn't connect to server" (link typed as an address) whenever the copy wasn't the bare link. OpenCodePairingLink.decode, like iOS's, only trims the ends, but what our tools print rarely copies that cleanly: - opencode pair --remote (2.2.6) prints an 88-character https://<host>.opentunnel.xyz/auth/connect/<code> link with a two-space indent, 90 columns, so an 80-column terminal wraps it inside the code; - the TUI's /pair dialog lists one link per address in a 29-column box, so each link spans three rows; - people select the whole output, or send the link in a sentence, with brackets or a trailing period. New OpenCodePairingLink.decodeCopied: decode, or else rejoin wrapped lines (not across a blank line or before another link, taken first so a code cut by the wrap isn't read short), then take the links out of the text, minus trailing punctuation; links sharing the first one's code merge their addresses (loopback ones are still never redeemed). validatePairing (paste, scan, opened URLs after exact decode) and Connect's pairing-link check use it; decode itself stays exact. Wrapper URLs that embed a pairing link are still rejected. iOS needs the same change (noted in the parity rows). Verified on FX_4 (API 36) with real opencode 2.2.6 pair --remote codes through OpenTunnel, clipboard set exactly via the emulator's gRPC: before (main 43114fc), the wrapped (80-column and TUI), whole-output, sentence, trailing-period and <bracketed> copies failed on the welcome Paste, the scanner Paste and the address field (24 of 24); after, 10 of 10 fresh codes paired across the three entry points. Unit cases added to :server AppFeatureTests and :app PairingPasteTests; both pass.
… FB-01) Scanning a pairing QR was hit-or-miss: it read only with the phone close to the screen. QRCameraPreview's ImageAnalysis asked for no resolution, so CameraX delivered 640x480 YUV (logcat: configureStreams YCBCR_420_888 640x480), where `opencode pair`'s code (37 modules for one URL, 45 for the LAN + tailnet + tunnel list) must fill over a quarter of the frame's short side to read. iOS sets no preset on its AVCaptureSession (PairingScanner.swift:208-223), so its QR metadata output runs at the default .high, 1080p. The analysis now asks for 1440x1080 (4:3 like the preview, so the same field of view; closest lower size when the camera lacks it). The preview's own size and look are unchanged. Measured with renders of the real 2.2.6 QR (dark terminal, half-block cells, ECC L) at 12-40% of the frame's short side, blur 0-2 px, 0/8 deg: - offline, QRDecoder's ZXing path: 1-URL code 23/42 at 640x480 vs 35/42 at 1440x1080; 3-URL code 21/42 vs 32/42. TRY_HARDER added at most 2/42, so it isn't set. - on FX_4 (API 36, imagefile camera, onboarding playground camera page, same QRCameraPreview): 3-URL code 14/30 read within 6 s of the camera opening before, 22/30 after (analysis 1280x960, the emulator's largest 4:3 size); at <=18% of the short side 2/18 -> 10/18, nothing lost. Cost: 0.9 -> 3.2 ms per frame on the JVM (x86 VM) at 1440x1080; with STRATEGY_KEEP_ONLY_LATEST slower frames are dropped, never queued.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two pairing bugs from users on v0.3.0 (replies to the soft-launch post on X).
OpenCodePairingLink.decodeonly accepted the bare, trimmed link (as iOS,OpenCodePairingLink.swift:91-95). Real copies rarely are:opencode pair --remote(2.2.6) prints an 88-character link with a two-space indent, so an 80-column terminal wraps it inside the code; the TUI's/pairbox spans each link over three rows; people copy the whole output or a sentence with a trailing period. 24 of 24 real-world copies failed on all three paste points. NewdecodeCopiedrejoins wrapped lines, finds the link in surrounding text and drops trailing punctuation; used for paste, scan and a link typed as an address. Opened URLs stay exact (decode). After: 10 of 10 fresh codes pair. iOS needs the same change.PairingScanner.swift:208-223). Now requests 1440x1080 (4:3, like the preview). Real 2.2.6 QR with three URLs on the emulator camera: 14/30 -> 22/30 reads; small codes 2/18 -> 10/18; nothing that read before stopped reading. ~0.9 -> 3.2 ms per frame on a JVM; frames are dropped while busy, not queued.Verified on an emulator with real pairing codes (paste points and virtual-scene camera); cases added to the existing
AppFeatureTestsandPairingPasteTests; fullscripts/check.shpasses.