GeezerVison is showing github.com — cli: pair QR encodes custom JSON payload instead of plain connect URL · Issue #54871 · anomalyco/opencode
cli: pair QR encodes custom JSON payload instead of plain connect URL #54871DescriptionSummary
The QR code printed by opencode pair does not encode a browser-openable URL. It encodes a custom JSON envelope containing the pairing code and base server urls, which only the OpenCode app can parse. Generic phone scanners (Google Lens, iOS camera) render it as plain text with no tappable link, so pairing via a phone browser requires manually typing the full printed URL. Additionally, when the service is bound to loopback only (the default), the urls field contains 127.0.0.1, which is unreachable from any other device.
Environment
- opencode version: v2.0.27 (latest channel)
- OS: Darwin 25.6.0 (darwin arm64), macOS MacBook Pro
- Terminal: Ghostty (TERM_PROGRAM=ghostty, TERM=xterm-ghostty, COLORTERM=truecolor)
- Shell: /bin/zsh
- Install/channel: latest release
- Active plugins: none found in config
Reproduction
- Start the service listening on all interfaces:
opencode service set hostname 0.0.0.0 then opencode service start.
- Run
opencode pair.
- Scan the QR code with a phone camera / Google Lens, or decode it with any standard QR decoder (e.g., Apple Vision).
Expected Behavior
The QR should encode the full one-time connect URL as plain text — e.g., http://<lan-ip>:49374/auth/connect/<code> — so that scanning from any device on the LAN opens the web UI directly in a browser. If a custom app-only payload format is kept, it should be documented, and the printed link should remain the only way to pair via browser.
Actual Behavior
Decoded QR payloads (one-time codes redacted):
Default (opencode pair, service bound to 0.0.0.0):
{"code":"<redacted>","urls":["http://192.168.x.x:49374"]}
With --url (opencode pair --url http://192.168.x.x:49374):
{"code":"<redacted>","urls":["http://192.168.x.x:49374"]}
The payload never contains the /auth/connect/<code> path; the code and base URL are separate JSON fields, so no generic scanner can turn it into a browser navigation. Google Lens displays the raw JSON text.
Additional Context
- The terminal output prints both
http://127.0.0.1:<port>/auth/connect/... and http://<lan-ip>:<port>/auth/connect/...; when bound to 0.0.0.0, the QR's urls array contains only the non-loopback address (verified by decoding).
- The reporter initially observed a
127.0.0.1 URL in the QR; this is consistent with the service being bound to loopback only at that time (the default bind), where urls would contain only the loopback address. After switching to hostname 0.0.0.0, urls contains the LAN IP but remains wrapped in JSON.
- Workaround: open the full printed link manually on the phone, or use the OpenCode app which parses this payload format.
Activityopencode-agent commented on Oct 12, 2026 Thanks for the detailed report. I reproduced this in the TUI /pair dialog on v2.0.27, and it still happens on the latest dev (5683367).
Steps: bind the server to 0.0.0.0, open the TUI and run /pair. The dialog lists both the 127.0.0.1 link and the LAN link, but the QR code decodes to http://127.0.0.1:<port>/auth/connect/<code>. The dialog also still suggests running opencode service set hostname 0.0.0.0, even though the service is already bound to it. The recording and screenshot below show this, and the script below reproduces it.
The CLI behaved differently in my test. With the service on 0.0.0.0, the QR from opencode pair decoded to {"code":"…","urls":["http://<lan-ip>:<port>"]}, with no loopback address in it. That content is meant for OpenCode's in-app scanner, not a plain web link, so a phone's camera app may not open it as one. If you saw the 127.0.0.1 QR from opencode pair itself rather than from the TUI's /pair, please reply with how you decoded it.
Related:
recording.mp4

Reproduction script (drive.ts)
// Reproduces #54871 in the TUI: with the server bound to 0.0.0.0, the /pair dialog's QR code
// encodes the http://127.0.0.1:<port>/auth/connect/<code> link, which a phone cannot reach.
// Run: OPENCODE_DRIVE_MEDIA_DIR=/workspace/media opencode-drive run drive.ts (OC_DEV=<checkout> to run from source)
import { chmodSync, writeFileSync } from "node:fs"
import { Effect } from "effect"
import { OpenCodeDriver } from "opencode-drive"
// Wrapper that adds `--hostname 0.0.0.0` to `opencode serve`, like `opencode service set hostname 0.0.0.0`.
const wrapper = "/tmp/opencode/serve-all-interfaces.sh"
writeFileSync(
wrapper,
`#!/bin/sh
if [ -n "$OC_DEV" ]; then
set -- bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js" "$OC_DEV/packages/cli/src/index.ts" "$@"
else
set -- opencode "$@"
fi
for a; do [ "$a" = serve ] && exec "$@" --hostname 0.0.0.0; done
exec "$@"
`,
)
chmodSync(wrapper, 0o755)
export default OpenCodeDriver.use(
{
opencode: { command: [wrapper] },
tui: { recording: true, viewport: { cols: 140, rows: 50 } },
},
({ ui, opencode }) =>
Effect.gen(function* () {
const info = yield* opencode.server.info()
yield* Effect.log(`server urls: ${JSON.stringify(info.urls)}`) // loopback + LAN address
yield* ui.screenshot("home")
yield* ui.submit("/pair")
yield* ui.waitFor("auth/connect")
yield* Effect.sleep("1500 millis")
yield* ui.screenshot("pair-dialog")
// Save the frame; the QR block on the right decodes to the 127.0.0.1 link.
const frame = yield* ui.capture()
const text = frame.lines.map((l: any) => l.spans.map((s: any) => s.text).join("")).join("\n")
yield* Effect.promise(() => Bun.write("/workspace/repro/pair-dialog.txt", text))
}),
)
Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.
changed the title [-]cli: pair QR code encodes localhost link when server listens on 0.0.0.0[/-] [+]cli: pair QR encodes custom JSON payload instead of plain connect URL[/+] on Oct 14, 2026Adyrhan commented on Oct 14, 2026 Update from the reporter: I decoded the QR payload with a standard decoder (Apple Vision). The QR does not encode a URL at all — it encodes {"code":"...","urls":["http://:49374"]}, a custom envelope only the OpenCode app parses, so generic scanners (Google Lens) show raw JSON text. Also: when bound to 0.0.0.0, urls already contains only the LAN IP — the original report's claim that the QR points at 127.0.0.1 came from a loopback-only bind. Title and body revised accordingly. Finn763 commented on Oct 19, 2026 I'd like to work on this — the QR payload should be a plain connect URL (the same one printed in the terminal), not the JSON envelope, so generic scanners can open it.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|