Skip to content

desktop: pairing QR code is inverted in dark theme and cannot be scanned by the Android app #63150

Closed

Description

@Aj002Th

Description

On OpenCode Desktop 2.2.6 with the dark color scheme, the pairing QR code (Settings → Pairing, or the "Pair device" command) is rendered light-on-dark, i.e. as an inverted QR code. The OpenCode Android app 0.3.0 does not recognize it, so pairing from the desktop GUI cannot be completed.

The QR is generated in packages/gui-plugins/src/pairing/page.tsx:

renderSVG(value, { border: 4, blackColor: "currentColor", whiteColor: "transparent" })

renderSVG paints the dark modules with blackColor and the background/quiet zone with whiteColor (packages/util/src/qr.ts). The surrounding element uses bg-v2-background-bg-base p-6 text-v2-text-text-base, so in the dark theme:

  • --v2-text-text-base = #fafafa → light modules
  • --v2-background-bg-base = #161616 → dark background and quiet zone

QR codes are specified as dark modules on a light background. OpenCode's web scanner explicitly works around theme-dependent QRs by calling scanner.setInversionMode("both") in packages/app/src/servers/connect/scanner.tsx, but the Android client does not appear to attempt inverted decoding.

Plugins

superpowers, opencode-github-panel (not related to pairing).

OpenCode version

  • Desktop: 2.2.6 (macOS, installed app ai.opencode.desktop)
  • Android: 0.3.0

Steps to reproduce

  1. Open OpenCode Desktop and set the color scheme to Dark.
  2. Open Settings → Pairing (or run the "Pair device" command) and wait for the QR code to appear.
  3. In the OpenCode Android app 0.3.0, start the pairing QR scanner and point it at the desktop QR code.
  4. The Android scanner does not detect the code and pairing never starts.
  5. Refresh the code or reopen the dialog; the result is the same.

I have not yet repeated step 3 in the light color scheme, but with blackColor: "currentColor" the light theme renders dark modules on a light background, which is the standard orientation.

Expected Behavior

The pairing QR code should be rendered as dark modules on a light background regardless of the desktop color scheme, so any standards-compliant scanner (including the Android app) can read it.

Actual Behavior

In the dark color scheme the QR is inverted (light modules on a dark background), and the Android app does not scan it. Pairing from the desktop GUI fails.

Additional Context

Activity

  1. opencodejr commented on Nov 10, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I can confirm that the pairing QR code is inverted in the dark theme.

    I couldn't run the desktop or Android apps here, so I tested the rendering directly. The script below makes the same renderSVG(..., { blackColor: "currentColor", whiteColor: "transparent" }) call as the pairing dialog, fills in the dialog's theme colors and decodes the image with a standard QR decoder (jsQR):

    • Light theme (#161616 modules on white): decodes normally.
    • Dark theme (#fafafa modules on #161616, quiet zone included): fails unless the decoder also tries inverted codes. That matches what you saw with the Android scanner.

    This still happens on the latest dev (f454acc): the call in page.tsx and the dark theme colors are unchanged. As you noted, setting only blackColor wouldn't be enough, because the transparent background leaves the quiet zone dark.

    I haven't checked the Android 0.3.0 scanner itself; that part is based on your report. Until this is fixed, the workarounds you mentioned (light theme, or pasting the pairing link) are the way to pair.

    Related pairing issues, though not the same problem: #62901, #59962, #58810.

    Reproduction script (repro.ts)
    // Reproduces #63150: the desktop pairing QR (packages/gui-plugins/src/pairing/page.tsx) rendered with the
    // dark-theme tokens is inverted, so a scanner that doesn't try inverted codes can't read it.
    // Usage: QR_SRC=<path to packages/util/src/qr.ts> bun repro.ts   (defaults to ./qr.ts, copied from v2.2.6)
    import jsQR from "jsqr"
    const { renderSVG } = await import(process.env.QR_SRC ?? "./qr.ts")
    
    const payload = JSON.stringify({ code: "ABCD-EFGH-1234", urls: ["http://192.168.1.20:4096", "https://example.opentunnel.dev"] })
    // Exactly the call in page.tsx
    const svg: string = renderSVG(payload, { border: 4, blackColor: "currentColor", whiteColor: "transparent" })
    
    // Resolve CSS as the dialog frame does: bg-v2-background-bg-base + text-v2-text-text-base (theme.css / colors.css)
    const themes = { light: { bg: [0xff, 0xff, 0xff], fg: [0x16, 0x16, 0x16] }, dark: { bg: [0x16, 0x16, 0x16], fg: [0xfa, 0xfa, 0xfa] } }
    
    function raster(svg: string, bg: number[], fg: number[], scale = 4) {
      const width = Number(svg.match(/viewBox="0 0 (\d+)/)![1]) / 10
      const dark = new Set<string>()
      for (const m of svg.matchAll(/M(\d+),(\d+)h10/g)) dark.add(`${+m[1] / 10},${+m[2] / 10}`)
      const rectFill = svg.match(/<rect fill="([^"]+)"/)![1]
      const pathFill = svg.match(/<path fill="([^"]+)"/)![1]
      if (rectFill !== "transparent" || pathFill !== "currentColor") throw new Error("unexpected fills " + rectFill + " " + pathFill)
      const px = width * scale
      const data = new Uint8ClampedArray(px * px * 4)
      for (let y = 0; y < px; y++)
        for (let x = 0; x < px; x++) {
          const c = dark.has(`${Math.floor(x / scale)},${Math.floor(y / scale)}`) ? fg : bg // transparent rect shows the bg
          data.set([...c, 255], (y * px + x) * 4)
        }
      return { data, px }
    }
    
    for (const [name, t] of Object.entries(themes)) {
      const { data, px } = raster(svg, t.bg, t.fg)
      const normal = jsQR(data, px, px, { inversionAttempts: "dontInvert" })
      const inverted = jsQR(data, px, px, { inversionAttempts: "attemptBoth" })
      console.log(`${name.padEnd(5)} modules=#${t.fg.map((v) => v.toString(16)).join("")} background=#${t.bg.map((v) => v.toString(16)).join("")}` +
        `  standard decode: ${normal ? "OK" : "FAIL"}  with inversion: ${inverted?.data === payload ? "OK" : "FAIL"}`)
    }

    Run it: bun repro.ts

  2. ashwinlimaye commented on Nov 10, 2026

    @ashwinlimaye

    I am unable to get it to scan even as dark-on-light. the android in-app scanner simply does not trigger.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions