feat: support deep-link QR pairing in mobile

Generate mobilevoice deep links in serve QR output and let mobile parse both raw payloads and pair query links, while keeping advertised-host ordering and removing QR name overrides.
This commit is contained in:
Ryan Vogel
2026-03-29 19:38:19 -04:00
parent cb535eef9d
commit 2f44d1900e
2 changed files with 139 additions and 60 deletions
+9 -3
View File
@@ -80,6 +80,10 @@ function hosts(hostname: string, port: number, advertised: string[] = []) {
return [...preferred, ...entries.map((item) => item.url)]
}
function pairLink(pair: unknown) {
return `mobilevoice:///?pair=${encodeURIComponent(JSON.stringify(pair))}`
}
export const ServeCommand = cmd({
command: "serve",
builder: (yargs) =>
@@ -153,14 +157,16 @@ export const ServeCommand = cmd({
}
if (pair) {
console.log("experimental push relay enabled")
const payload = JSON.stringify(pair)
const code = await QRCode.toString(payload, {
const link = pairLink(pair)
const code = await QRCode.toString(link, {
type: "terminal",
small: true,
errorCorrectionLevel: "M",
})
console.log("scan qr code in mobile app")
console.log("scan qr code in mobile app or phone camera")
console.log(code)
console.log("qr link")
console.log(link)
console.log("qr payload")
console.log(JSON.stringify(pair, null, 2))
}