Skip to content

fix(pairing): pasted links pair as people copy them; QR reads from farther away - #15

Merged
R44VC0RP merged 2 commits into
mainfrom
pairing-feedback
Nov 9, 2026
Merged

R44VC0RP merged 2 commits into
mainfrom
pairing-feedback

Conversation

@R44VC0RP

@R44VC0RP R44VC0RP commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Two pairing bugs from users on v0.3.0 (replies to the soft-launch post on X).

  • FB-02, "pasting the pairing link consistently gives errors": OpenCodePairingLink.decode only 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 /pair box 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. New decodeCopied rejoins 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.
  • FB-01, "QR is hit-or-miss": the analysis use case set no resolution, so CameraX delivered 640x480 frames and a code had to fill over a quarter of the frame. iOS reads from its default 1080p preset (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 AppFeatureTests and PairingPasteTests; full scripts/check.sh passes.

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.
@R44VC0RP
R44VC0RP merged commit 1ce1f81 into main Nov 9, 2026
3 checks passed
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