Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(settings): Pair phone — in-app QR pairing for nodeterm mobile

enesd3253bda265a
diff --git a/package-lock.json b/package-lock.json
index 5fd2b9c9f..b7cfbc119 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,14 +1,14 @@
{
"name": "node-terminal",
- "version": "0.2.0",
+ "version": "0.2.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "node-terminal",
- "version": "0.2.0",
+ "version": "0.2.1",
"hasInstallScript": true,
- "license": "SEE LICENSE IN LICENSE",
+ "license": "BUSL-1.1",
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.3.201",
"dompurify": "^3.4.11",
@@ -16,6 +16,7 @@
"marked": "^12.0.2",
"monaco-editor": "^0.52.2",
"node-pty": "^1.0.0",
+ "qrcode": "^1.5.4",
"tweetnacl": "^1.0.3",
"ws": "^8.21.0",
"zustand": "^4.5.7"
@@ -24,6 +25,7 @@
"@electron/rebuild": "^4.1.0",
"@tailwindcss/vite": "^4.3.1",
"@types/node": "^26.0.0",
+ "@types/qrcode": "^1.5.6",
"@types/react": "^18.3.31",
"@types/react-dom": "^18.3.7",
"@types/ws": "^8.18.1",
@@ -2713,6 +2715,16 @@
"devOptional": true,
"license": "MIT"
},
+ "node_modules/@types/qrcode": {
+ "version": "1.5.6",
+ "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",
+ "integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/react": {
"version": "18.3.31",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.31.tgz",
@@ -3085,7 +3097,6 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -3095,7 +3106,6 @@
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
@@ -3649,6 +3659,15 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/camelcase": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/caniuse-lite": {
"version": "1.0.30001799",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001799.tgz",
@@ -3800,7 +3819,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
@@ -3813,7 +3831,6 @@
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true,
"license": "MIT"
},
"node_modules/color-string": {
@@ -4104,6 +4121,15 @@
}
}
},
+ "node_modules/decamelize": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
+ "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/decompress-response": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
@@ -4229,6 +4255,12 @@
"license": "MIT",
"optional": true
},
+ "node_modules/dijkstrajs": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",
+ "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==",
+ "license": "MIT"
+ },
"node_modules/dir-compare": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-4.2.0.tgz",
@@ -4591,7 +4623,6 @@
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
- "dev": true,
"license": "MIT"
},
"node_modules/encodeurl": {
@@ -5038,6 +5069,19 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/find-up": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
+ "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
+ "license": "MIT",
+ "dependencies": {
+ "locate-path": "^5.0.0",
+ "path-exists": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/form-data": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz",
@@ -5134,7 +5178,6 @@
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
- "dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
@@ -5570,7 +5613,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -6044,6 +6086,18 @@
"url": "https://opencollective.com/parcel"
}
},
+ "node_modules/locate-path": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
+ "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
+ "license": "MIT",
+ "dependencies": {
+ "p-locate": "^4.1.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/lodash": {
"version": "4.18.1",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
@@ -6559,6 +6613,42 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/p-locate": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
+ "license": "MIT",
+ "dependencies": {
+ "p-limit": "^2.2.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/p-locate/node_modules/p-limit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+ "license": "MIT",
+ "dependencies": {
+ "p-try": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/p-try": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
+ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
@@ -6569,6 +6659,15 @@
"node": ">= 0.8"
}
},
+ "node_modules/path-exists": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
@@ -6707,6 +6806,15 @@
"node": ">=10.4.0"
}
},
+ "node_modules/pngjs": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
+ "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.13.0"
+ }
+ },
"node_modules/postcss": {
"version": "8.5.15",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz",
@@ -6864,6 +6972,89 @@
"node": ">=16.0.0"
}
},
+ "node_modules/qrcode": {
+ "version": "1.5.4",
+ "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",
+ "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==",
+ "license": "MIT",
+ "dependencies": {
+ "dijkstrajs": "^1.0.1",
+ "pngjs": "^5.0.0",
+ "yargs": "^15.3.1"
+ },
+ "bin": {
+ "qrcode": "bin/qrcode"
+ },
+ "engines": {
+ "node": ">=10.13.0"
+ }
+ },
+ "node_modules/qrcode/node_modules/cliui": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
+ "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
+ "license": "ISC",
+ "dependencies": {
+ "string-width": "^4.2.0",
+ "strip-ansi": "^6.0.0",
+ "wrap-ansi": "^6.2.0"
+ }
+ },
+ "node_modules/qrcode/node_modules/wrap-ansi": {
+ "version": "6.2.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
+ "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
+ "license": "MIT",
+ "dependencies": {
+ "ansi-styles": "^4.0.0",
+ "string-width": "^4.1.0",
+ "strip-ansi": "^6.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/qrcode/node_modules/y18n": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
+ "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
+ "license": "ISC"
+ },
+ "node_modules/qrcode/node_modules/yargs": {
+ "version": "15.4.1",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
+ "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
+ "license": "MIT",
+ "dependencies": {
+ "cliui": "^6.0.0",
+ "decamelize": "^1.2.0",
+ "find-up": "^4.1.0",
+ "get-caller-file": "^2.0.1",
+ "require-directory": "^2.1.1",
+ "require-main-filename": "^2.0.0",
+ "set-blocking": "^2.0.0",
+ "string-width": "^4.2.0",
+ "which-module": "^2.0.0",
+ "y18n": "^4.0.0",
+ "yargs-parser": "^18.1.2"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/qrcode/node_modules/yargs-parser": {
+ "version": "18.1.3",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
+ "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
+ "license": "ISC",
+ "dependencies": {
+ "camelcase": "^5.0.0",
+ "decamelize": "^1.2.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/qs": {
"version": "6.15.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz",
@@ -6993,7 +7184,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
@@ -7008,6 +7198,12 @@
"node": ">=0.10.0"
}
},
+ "node_modules/require-main-filename": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
+ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
+ "license": "ISC"
+ },
"node_modules/resedit": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/resedit/-/resedit-1.7.2.tgz",
@@ -7307,6 +7503,12 @@
"url": "https://opencollective.com/express"
}
},
+ "node_modules/set-blocking": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
+ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",
+ "license": "ISC"
+ },
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
@@ -7586,7 +7788,6 @@
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
- "dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
@@ -7601,7 +7802,6 @@
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
- "dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
@@ -8253,6 +8453,12 @@
"node": ">= 8"
}
},
+ "node_modules/which-module": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",
+ "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",
+ "license": "ISC"
+ },
"node_modules/why-is-node-running": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",
diff --git a/src/main/index.ts b/src/main/index.ts
index fc86353a2..462d89a06 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -45,6 +45,7 @@ import { initLicense } from './license'
import { initClaudeAccounts, claudeConfigDirFor } from './claude-accounts'
import { isSafeLocalTranscriptPath } from './claude-accounts-core'
import { installClaudeHooksInto } from './agents/hooks/claude'
+import { createPairingService } from './pairing-service'
import { initRemoteHost } from './remote/host-service'
import { initRemoteClient } from './remote/client-service'
import { initSshProject } from './remote-ssh/ssh-project'
@@ -351,6 +352,18 @@ app.whenReady().then(async () => {
// Writable base dir for app-managed files (e.g. default git worktree location).
ipcMain.handle(IPC.appUserDataDir, () => app.getPath('userData'))
+ // Phone pairing (nodeterm iOS "scan a QR" flow): a one-shot LAN listener that installs the
+ // phone's Ed25519 key into ~/.ssh/authorized_keys. The completion result is forwarded to the
+ // window over `pairing:done` so the settings section can show the paired/timeout state.
+ const pairingService = createPairingService()
+ ipcMain.handle(IPC.pairingStart, () =>
+ pairingService.start((result) => {
+ const w = getMainWindow()
+ if (w && !w.isDestroyed()) w.webContents.send(IPC.pairingDone, result)
+ })
+ )
+ ipcMain.handle(IPC.pairingStop, () => pairingService.stop())
+
ipcMain.on(IPC.shellReveal, (_e, p: string) => {
if (p) shell.showItemInFolder(p)
})
diff --git a/src/main/pairing-core.test.ts b/src/main/pairing-core.test.ts
new file mode 100644
index 000000000..689f96458
--- /dev/null
+++ b/src/main/pairing-core.test.ts
@@ -0,0 +1,124 @@
+import { describe, it, expect } from 'vitest'
+import {
+ buildPairingPayload,
+ isValidEd25519PublicKey,
+ normalizeAuthorizedKeysLine,
+ pickLanIPv4
+} from './pairing-core'
+
+// A real Ed25519 public key blob (32 zero bytes) wrapped in the OpenSSH wire format:
+// uint32(len "ssh-ed25519") + "ssh-ed25519" + uint32(32) + 32 bytes.
+function makeEd25519Blob(): string {
+ const name = Buffer.from('ssh-ed25519', 'ascii')
+ const key = Buffer.alloc(32)
+ const buf = Buffer.concat([
+ u32(name.length),
+ name,
+ u32(key.length),
+ key
+ ])
+ return buf.toString('base64')
+}
+function u32(n: number): Buffer {
+ const b = Buffer.alloc(4)
+ b.writeUInt32BE(n, 0)
+ return b
+}
+
+describe('buildPairingPayload', () => {
+ it('emits single-line JSON with the fixed key order and defaults', () => {
+ const json = buildPairingPayload({
+ host: '192.168.1.5',
+ user: 'enes',
+ token: 'tok123',
+ pairPort: 54321,
+ name: 'MacBook'
+ })
+ expect(json).toBe(
+ '{"v":1,"host":"192.168.1.5","port":22,"user":"enes","token":"tok123","pairPort":54321,"nodeterm":true,"name":"MacBook"}'
+ )
+ expect(json).not.toContain('\n')
+ expect(JSON.parse(json)).toMatchObject({ v: 1, port: 22, nodeterm: true })
+ })
+
+ it('honors an explicit port override', () => {
+ const json = buildPairingPayload({
+ host: 'h',
+ port: 2222,
+ user: 'u',
+ token: 't',
+ pairPort: 1,
+ name: 'n'
+ })
+ expect(JSON.parse(json).port).toBe(2222)
+ })
+})
+
+describe('isValidEd25519PublicKey', () => {
+ const blob = makeEd25519Blob()
+
+ it('accepts a well-formed ssh-ed25519 line with a comment', () => {
+ expect(isValidEd25519PublicKey(`ssh-ed25519 ${blob} phone@nodeterm`)).toBe(true)
+ })
+
+ it('accepts a line without a comment', () => {
+ expect(isValidEd25519PublicKey(`ssh-ed25519 ${blob}`)).toBe(true)
+ })
+
+ it('rejects a non-ed25519 key type', () => {
+ expect(isValidEd25519PublicKey(`ssh-rsa ${blob} x`)).toBe(false)
+ })
+
+ it('rejects a spoofed prefix with a garbage blob', () => {
+ expect(isValidEd25519PublicKey('ssh-ed25519 not-base64!!!')).toBe(false)
+ })
+
+ it('rejects an ed25519 prefix whose embedded name disagrees', () => {
+ // Base64 blob whose wire-format name is "ssh-rsa" but prefixed textually as ed25519.
+ const name = Buffer.from('ssh-rsa', 'ascii')
+ const fake = Buffer.concat([u32(name.length), name, u32(0)]).toString('base64')
+ expect(isValidEd25519PublicKey(`ssh-ed25519 ${fake}`)).toBe(false)
+ })
+
+ it('rejects empty / malformed lines', () => {
+ expect(isValidEd25519PublicKey('')).toBe(false)
+ expect(isValidEd25519PublicKey('ssh-ed25519')).toBe(false)
+ })
+})
+
+describe('normalizeAuthorizedKeysLine', () => {
+ it('trims and collapses whitespace to a single line', () => {
+ expect(normalizeAuthorizedKeysLine(' ssh-ed25519 AAAA phone\n')).toBe(
+ 'ssh-ed25519 AAAA phone'
+ )
+ })
+})
+
+describe('pickLanIPv4', () => {
+ it('picks the first non-internal, non-link-local IPv4', () => {
+ const picked = pickLanIPv4({
+ lo0: [{ address: '127.0.0.1', family: 'IPv4', internal: true }],
+ en0: [
+ { address: 'fe80::1', family: 'IPv6', internal: false },
+ { address: '169.254.10.1', family: 'IPv4', internal: false },
+ { address: '192.168.1.42', family: 'IPv4', internal: false }
+ ]
+ })
+ expect(picked).toBe('192.168.1.42')
+ })
+
+ it('accepts the numeric family form (family: 4)', () => {
+ expect(
+ pickLanIPv4({ en0: [{ address: '10.0.0.2', family: 4, internal: false }] })
+ ).toBe('10.0.0.2')
+ })
+
+ it('returns null when nothing suitable exists', () => {
+ expect(
+ pickLanIPv4({
+ lo0: [{ address: '127.0.0.1', family: 'IPv4', internal: true }],
+ en0: [{ address: '169.254.1.1', family: 'IPv4', internal: false }]
+ })
+ ).toBe(null)
+ })
+})
diff --git a/src/main/pairing-core.ts b/src/main/pairing-core.ts
new file mode 100644
index 000000000..36081c3d7
--- /dev/null
+++ b/src/main/pairing-core.ts
@@ -0,0 +1,89 @@
+// Pure helpers for the phone-pairing service (no I/O), so they can be unit-tested with fakes.
+//
+// The QR payload + the authorized_keys line validation are the two bits of the pairing flow
+// with a fixed on-the-wire contract shared with the nodeterm iOS app — keep them here, pure.
+
+/** Inputs for the QR payload the iOS app scans. `port` defaults to 22 (SSH). */
+export interface PairingPayloadInput {
+ host: string
+ port?: number
+ user: string
+ token: string
+ pairPort: number
+ name: string
+}
+
+/**
+ * Build the single-line JSON the QR encodes. The key order + compact separators match the
+ * contract the phone parses:
+ * {"v":1,"host":"…","port":22,"user":"…","token":"…","pairPort":N,"nodeterm":true,"name":"…"}
+ */
+export function buildPairingPayload(input: PairingPayloadInput): string {
+ return JSON.stringify({
+ v: 1,
+ host: input.host,
+ port: input.port ?? 22,
+ user: input.user,
+ token: input.token,
+ pairPort: input.pairPort,
+ nodeterm: true,
+ name: input.name
+ })
+}
+
+/**
+ * Validate that a phone-supplied public key is a well-formed `ssh-ed25519` line
+ * (`ssh-ed25519 AAAA… comment`). Anything else → the listener answers 400.
+ * Beyond the textual prefix we decode the base64 blob and check its embedded algorithm
+ * name, so a spoofed `ssh-ed25519 <garbage>` line can't slip through.
+ */
+export function isValidEd25519PublicKey(line: string): boolean {
+ const parts = line.trim().split(/\s+/)
+ if (parts.length < 2) return false
+ if (parts[0] !== 'ssh-ed25519') return false
+ const b64 = parts[1]
+ if (!/^[A-Za-z0-9+/]+={0,2}$/.test(b64)) return false
+ let buf: Buffer
+ try {
+ buf = Buffer.from(b64, 'base64')
+ } catch {
+ return false
+ }
+ // OpenSSH wire format: uint32 length-prefixed algorithm name comes first.
+ if (buf.length < 4) return false
+ const nameLen = buf.readUInt32BE(0)
+ const NAME = 'ssh-ed25519'
+ if (nameLen !== NAME.length || buf.length < 4 + nameLen) return false
+ return buf.subarray(4, 4 + nameLen).toString('ascii') === NAME
+}
+
+/** Collapse a public-key line to the single trimmed line we append to authorized_keys. */
+export function normalizeAuthorizedKeysLine(line: string): string {
+ return line.trim().replace(/\s+/g, ' ')
+}
+
+/** Minimal shape of `os.networkInterfaces()` we need — kept structural so tests can fake it. */
+export interface NetInterfaceAddr {
+ address: string
+ family: string | number
+ internal: boolean
+}
+
+/**
+ * Pick a usable LAN IPv4 from `os.networkInterfaces()`, skipping internal (loopback) and
+ * link-local (169.254.x.x) addresses. Returns null when none is present.
+ */
+export function pickLanIPv4(
+ interfaces: Record<string, NetInterfaceAddr[] | undefined>
+): string | null {
+ for (const addrs of Object.values(interfaces)) {
+ if (!addrs) continue
+ for (const a of addrs) {
+ const isV4 = a.family === 'IPv4' || a.family === 4
+ if (!isV4 || a.internal) continue
+ if (a.address.startsWith('169.254.')) continue
+ return a.address
+ }
+ }
+ return null
+}
diff --git a/src/main/pairing-service.ts b/src/main/pairing-service.ts
new file mode 100644
index 000000000..32470581a
--- /dev/null
+++ b/src/main/pairing-service.ts
@@ -0,0 +1,229 @@
+// Phone-pairing service (main process) — the host side of the nodeterm iOS "scan a QR" flow.
+//
+// start() mints a one-time token, opens a single-shot LAN HTTP listener on a random port, and
+// returns the JSON payload (for the renderer to render as a QR) plus whether SSH looks reachable.
+// The phone scans the QR, generates an Ed25519 keypair on-device, and POSTs {token, publicKey}
+// to http://<host>:<pairPort>/pair. On a token match we append the key to ~/.ssh/authorized_keys
+// and stop the listener. The private key never leaves the phone; the only secret in the QR is the
+// single-use token.
+//
+// Pure bits (payload build, key validation, LAN-IPv4 pick) live in `pairing-core.ts` so they're
+// unit-tested without spinning up a server.
+
+import { createServer, type IncomingMessage, type Server, type ServerResponse } from 'http'
+import { connect as netConnect } from 'net'
+import { randomBytes } from 'crypto'
+import { promises as fs } from 'fs'
+import { execFile } from 'child_process'
+import { promisify } from 'util'
+import os from 'os'
+import path from 'path'
+import {
+ buildPairingPayload,
+ isValidEd25519PublicKey,
+ normalizeAuthorizedKeysLine,
+ pickLanIPv4
+} from './pairing-core'
+
+const execFileAsync = promisify(execFile)
+
+/** How long the listener waits for the phone before giving up. */
+const PAIR_TIMEOUT_MS = 2 * 60 * 1000
+/** Probe timeout for the "is sshd listening on :22?" check. */
+const SSH_PROBE_MS = 500
+/** Reject oversized POST bodies (a public key line is well under this). */
+const MAX_BODY_BYTES = 64 * 1024
+
+export interface PairingStartResult {
+ /** The single-line JSON to encode into the QR. */
+ payload: string
+ /** True when 127.0.0.1:22 accepted a connection — sshd is (probably) running. */
+ sshOpen: boolean
+}
+
+/** Fired once when pairing finishes: ok=true → a key was installed, ok=false → timeout/cancel. */
+export type PairingDone = { ok: boolean }
+
+export interface PairingService {
+ /** Begin pairing; resolves once the listener is up. `onDone` fires exactly once later. */
+ start(onDone: (result: PairingDone) => void): Promise<PairingStartResult>
+ /** Cancel an in-flight pairing (idempotent). Does NOT fire onDone. */
+ stop(): void
+}
+
+/** Detect the machine's display name (macOS ComputerName, else hostname). */
+async function computerName(): Promise<string> {
+ if (process.platform === 'darwin') {
+ try {
+ const { stdout } = await execFileAsync('scutil', ['--get', 'ComputerName'])
+ const name = stdout.trim()
+ if (name) return name
+ } catch {
+ // fall through to hostname
+ }
+ }
+ return os.hostname()
+}
+
+/** Quick TCP probe of 127.0.0.1:22 to guess whether Remote Login (sshd) is on. */
+function probeSsh(): Promise<boolean> {
+ return new Promise((resolve) => {
+ let done = false
+ const finish = (open: boolean): void => {
+ if (done) return
+ done = true
+ try {
+ sock.destroy()
+ } catch {
+ // ignore
+ }
+ resolve(open)
+ }
+ const sock = netConnect({ host: '127.0.0.1', port: 22 })
+ sock.setTimeout(SSH_PROBE_MS)
+ sock.once('connect', () => finish(true))
+ sock.once('timeout', () => finish(false))
+ sock.once('error', () => finish(false))
+ })
+}
+
+/** Append a validated public-key line to ~/.ssh/authorized_keys with the right permissions. */
+async function appendAuthorizedKey(publicKey: string): Promise<void> {
+ const sshDir = path.join(os.homedir(), '.ssh')
+ await fs.mkdir(sshDir, { recursive: true, mode: 0o700 })
+ await fs.chmod(sshDir, 0o700).catch(() => {})
+ const authPath = path.join(sshDir, 'authorized_keys')
+ // Guard against a file that doesn't end in a newline (would concatenate onto the last key).
+ let prefix = ''
+ try {
+ const existing = await fs.readFile(authPath, 'utf8')
+ if (existing.length > 0 && !existing.endsWith('\n')) prefix = '\n'
+ } catch {
+ // no file yet — appendFile creates it
+ }
+ await fs.appendFile(authPath, prefix + normalizeAuthorizedKeysLine(publicKey) + '\n')
+ await fs.chmod(authPath, 0o600)
+}
+
+/** Read the whole request body (capped), rejecting oversized payloads. */
+function readBody(req: IncomingMessage): Promise<string> {
+ return new Promise((resolve, reject) => {
+ const chunks: Buffer[] = []
+ let size = 0
+ req.on('data', (c: Buffer) => {
+ size += c.length
+ if (size > MAX_BODY_BYTES) {
+ reject(new Error('body too large'))
+ req.destroy()
+ return
+ }
+ chunks.push(c)
+ })
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
+ req.on('error', reject)
+ })
+}
+
+export function createPairingService(): PairingService {
+ let server: Server | null = null
+ let timer: ReturnType<typeof setTimeout> | null = null
+ let onDoneCb: ((result: PairingDone) => void) | null = null
+
+ const cleanup = (): void => {
+ if (timer) {
+ clearTimeout(timer)
+ timer = null
+ }
+ if (server) {
+ server.close()
+ server = null
+ }
+ }
+
+ // Fire the completion callback exactly once, then tear everything down.
+ const finish = (result: PairingDone): void => {
+ const cb = onDoneCb
+ onDoneCb = null
+ cleanup()
+ cb?.(result)
+ }
+
+ const start = async (onDone: (result: PairingDone) => void): Promise<PairingStartResult> => {
+ // A prior in-flight pairing is cancelled silently (no onDone) before starting a new one.
+ onDoneCb = null
+ cleanup()
+ onDoneCb = onDone
+
+ const host = pickLanIPv4(os.networkInterfaces())
+ if (!host) {
+ onDoneCb = null
+ throw new Error("Couldn't detect a LAN IP address — connect to Wi-Fi and try again.")
+ }
+ const token = randomBytes(24).toString('base64url')
+ const user = os.userInfo().username
+
+ const srv = createServer((req: IncomingMessage, res: ServerResponse) => {
+ void handleRequest(req, res)
+ })
+ server = srv
+
+ // Bind a random high port on all interfaces (0.0.0.0) so the phone on the LAN can reach it.
+ await new Promise<void>((resolve, reject) => {
+ srv.once('error', reject)
+ srv.listen(0, '0.0.0.0', () => {
+ srv.removeListener('error', reject)
+ resolve()
+ })
+ })
+
+ const addr = srv.address()
+ const pairPort = typeof addr === 'object' && addr ? addr.port : 0
+ const [name, sshOpen] = await Promise.all([computerName(), probeSsh()])
+ const payload = buildPairingPayload({ host, port: 22, user, token, pairPort, name })
+
+ // Give up after 2 minutes with a timeout result.
+ timer = setTimeout(() => finish({ ok: false }), PAIR_TIMEOUT_MS)
+ timer.unref?.()
+
+ async function handleRequest(req: IncomingMessage, res: ServerResponse): Promise<void> {
+ if (req.method !== 'POST' || req.url !== '/pair') {
+ res.writeHead(404).end()
+ return
+ }
+ try {
+ const raw = await readBody(req)
+ let body: { token?: unknown; publicKey?: unknown }
+ try {
+ body = JSON.parse(raw)
+ } catch {
+ res.writeHead(400).end('bad json')
+ return
+ }
+ if (body.token !== token) {
+ res.writeHead(403).end('bad token')
+ return
+ }
+ const publicKey = typeof body.publicKey === 'string' ? body.publicKey.trim() : ''
+ if (!isValidEd25519PublicKey(publicKey)) {
+ res.writeHead(400).end('unexpected key type')
+ return
+ }
+ await appendAuthorizedKey(publicKey)
+ res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({ ok: true }))
+ finish({ ok: true })
+ } catch (err) {
+ res.writeHead(500).end('pairing failed')
+ console.warn('[pairing] request failed:', err)
+ }
+ }
+
+ return { payload, sshOpen }
+ }
+
+ const stop = (): void => {
+ onDoneCb = null
+ cleanup()
+ }
+
+ return { start, stop }
+}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index ce39710b4..076bdea27 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -348,6 +348,15 @@ const api: NodeTerminalApi = {
build: (sessionId, agentId, sourceNodeId, cwd, accountId) =>
ipcRenderer.invoke(IPC.handoffBuild, sessionId, agentId, sourceNodeId, cwd, accountId)
},
+ pairing: {
+ start: () => ipcRenderer.invoke(IPC.pairingStart),
+ stop: () => ipcRenderer.invoke(IPC.pairingStop),
+ onDone: (cb) => {
+ const handler = (_e: unknown, result: { ok: boolean }) => cb(result)
+ ipcRenderer.on(IPC.pairingDone, handler)
+ return () => ipcRenderer.removeListener(IPC.pairingDone, handler)
+ }
+ },
contextLink: {
setLinks: (map) => ipcRenderer.invoke(IPC.contextLinkSetLinks, map)
},
diff --git a/src/renderer/components/settings/SettingsIcons.tsx b/src/renderer/components/settings/SettingsIcons.tsx
index 195ce8d90..ab1abf8a2 100644
--- a/src/renderer/components/settings/SettingsIcons.tsx
+++ b/src/renderer/components/settings/SettingsIcons.tsx
@@ -23,6 +23,12 @@ const PATHS: Record<SettingsSectionId, React.JSX.Element> = {
<path d="M8 2.5a5.5 5.5 0 0 0 0 11z" fill="currentColor" stroke="none" />
</>
),
+ phone: (
+ <>
+ <rect x="4.5" y="2" width="7" height="12" rx="1.6" />
+ <path d="M7 12h2" />
+ </>
+ ),
agents: (
<path d="M8 2.3 9.4 5.9 13 7.3 9.4 8.7 8 12.3 6.6 8.7 3 7.3 6.6 5.9z" />
),
diff --git a/src/renderer/components/settings/SettingsPage.tsx b/src/renderer/components/settings/SettingsPage.tsx
index 58d060695..d1c554d03 100644
--- a/src/renderer/components/settings/SettingsPage.tsx
+++ b/src/renderer/components/settings/SettingsPage.tsx
@@ -8,6 +8,7 @@ import { TerminalSection } from './sections/TerminalSection'
import { ShellSection } from './sections/ShellSection'
import { BehaviorSection } from './sections/BehaviorSection'
import { AppearanceSection } from './sections/AppearanceSection'
+import { PhoneSection } from './sections/PhoneSection'
import { AgentsSection } from './sections/AgentsSection'
import { AccountsSection } from './sections/AccountsSection'
import { CustomAgentsSection } from './sections/CustomAgentsSection'
@@ -65,6 +66,7 @@ export function SettingsPage({
<ShellSection isActive={active === 'shell'} />
<BehaviorSection isActive={active === 'behavior'} />
<AppearanceSection isActive={active === 'appearance'} />
+ <PhoneSection isActive={active === 'phone'} />
<AgentsSection isActive={active === 'agents'} />
<AccountsSection isActive={active === 'accounts'} />
<CustomAgentsSection isActive={active === 'custom-agents'} />
diff --git a/src/renderer/components/settings/nav.ts b/src/renderer/components/settings/nav.ts
index fda932e7e..707afd554 100644
--- a/src/renderer/components/settings/nav.ts
+++ b/src/renderer/components/settings/nav.ts
@@ -3,6 +3,7 @@ export type SettingsSectionId =
| 'shell'
| 'behavior'
| 'appearance'
+ | 'phone'
| 'agents'
| 'accounts'
| 'custom-agents'
@@ -29,7 +30,8 @@ export const SETTINGS_GROUPS: SettingsGroup[] = [
{ id: 'terminal', title: 'Terminal' },
{ id: 'shell', title: 'Shell' },
{ id: 'behavior', title: 'Behavior' },
- { id: 'appearance', title: 'Appearance' }
+ { id: 'appearance', title: 'Appearance' },
+ { id: 'phone', title: 'Phone' }
]
},
{
diff --git a/src/renderer/components/settings/sections/PhoneSection.tsx b/src/renderer/components/settings/sections/PhoneSection.tsx
new file mode 100644
index 000000000..e8a21c093
--- /dev/null
+++ b/src/renderer/components/settings/sections/PhoneSection.tsx
@@ -0,0 +1,139 @@
+import { useEffect, useRef, useState } from 'react'
+import { toDataURL } from 'qrcode'
+import { SettingsSection } from '../SettingsSection'
+import { SearchableRow } from '../SearchableRow'
+import { Button } from '@renderer/ui/Button'
+
+const ROWS = {
+ pair: {
+ title: 'Pair phone',
+ keywords: ['phone', 'pair', 'qr', 'ios', 'mobile', 'ssh', 'scan', 'nodeterm']
+ }
+}
+const ENTRIES = Object.values(ROWS)
+
+type Phase = 'idle' | 'waiting' | 'paired' | 'timeout'
+
+export function PhoneSection({ isActive }: { isActive: boolean }): React.JSX.Element {
+ const [phase, setPhase] = useState<Phase>('idle')
+ const [qr, setQr] = useState('')
+ const [sshOpen, setSshOpen] = useState(true)
+ const [error, setError] = useState('')
+ const [busy, setBusy] = useState(false)
+ // Track whether a pairing listener is currently running so unmount can stop it.
+ const runningRef = useRef(false)
+
+ const startPairing = async (): Promise<void> => {
+ setError('')
+ setBusy(true)
+ try {
+ const { payload, sshOpen: open } = await window.nodeTerminal.pairing.start()
+ const dataUrl = await toDataURL(payload, { margin: 1, width: 240 })
+ setQr(dataUrl)
+ setSshOpen(open)
+ setPhase('waiting')
+ runningRef.current = true
+ } catch (err) {
+ setError((err as Error).message)
+ } finally {
+ setBusy(false)
+ }
+ }
+
+ const stopPairing = (): void => {
+ if (runningRef.current) {
+ runningRef.current = false
+ void window.nodeTerminal.pairing.stop()
+ }
+ setPhase('idle')
+ setQr('')
+ }
+
+ // Subscribe to the completion event; drives paired/timeout state.
+ useEffect(() => {
+ const off = window.nodeTerminal.pairing.onDone((result) => {
+ runningRef.current = false
+ setQr('')
+ setPhase(result.ok ? 'paired' : 'timeout')
+ })
+ return off
+ }, [])
+
+ // Stop any in-flight pairing when the section unmounts (settings closed / navigated away).
+ useEffect(() => {
+ return () => {
+ if (runningRef.current) {
+ runningRef.current = false
+ void window.nodeTerminal.pairing.stop()
+ }
+ }
+ }, [])
+
+ return (
+ <SettingsSection
+ id="phone"
+ title="Phone"
+ description="Pair the nodeterm iOS app so it can connect to this machine over your local network — no terminal commands needed."
+ isActive={isActive}
+ searchEntries={ENTRIES}
+ >
+ <SearchableRow {...ROWS.pair}>
+ <div className="space-y-4">
+ <h4 className="text-[13px] font-medium text-text">Pair phone</h4>
+ <p className="text-sm text-muted">
+ Pair the nodeterm iOS app: scan this QR with your phone. Your phone generates its own
+ key on-device — nothing secret leaves this machine except a single-use pairing token.
+ </p>
+
+ {phase === 'idle' || phase === 'timeout' ? (
+ <div className="space-y-3">
+ {phase === 'timeout' ? (
+ <p className="text-sm text-muted">
+ Pairing timed out. Start again and scan the new code within two minutes.
+ </p>
+ ) : null}
+ <Button variant="primary" disabled={busy} onClick={() => void startPairing()}>
+ {busy ? 'Starting…' : 'Start pairing'}
+ </Button>
+ </div>
+ ) : null}
+
+ {phase === 'waiting' && qr ? (
+ <div className="space-y-3">
+ <img
+ src={qr}
+ width={240}
+ height={240}
+ alt="Pairing QR code"
+ className="rounded-lg bg-white p-2"
+ />
+ <p className="text-sm text-muted">Waiting for your phone… (2 min)</p>
+ {!sshOpen ? (
+ <p className="text-sm" style={{ color: '#ff9f0a' }}>
+ SSH doesn&apos;t appear to be reachable. Enable Remote Login in System Settings →
+ General → Sharing so your phone can connect after pairing.
+ </p>
+ ) : null}
+ <Button onClick={stopPairing}>Cancel</Button>
+ </div>
+ ) : null}
+
+ {phase === 'paired' ? (
+ <div className="space-y-3">
+ <p className="text-sm font-medium" style={{ color: '#30d158' }}>
+ ✓ Paired. Your phone can now connect with its own key.
+ </p>
+ <Button onClick={() => setPhase('idle')}>Pair another phone</Button>
+ </div>
+ ) : null}
+
+ {error ? (
+ <p className="text-sm" style={{ color: '#ff9f0a' }}>
+ {error}
+ </p>
+ ) : null}
+ </div>
+ </SearchableRow>
+ </SettingsSection>
+ )
+}
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index c99d51522..e859e89a9 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -178,5 +178,10 @@ export const IPC = {
`remote:client:exit:${connectionId}:${streamId}`,
// Fired when a connection's relay socket drops (host/relay gone).
remoteClientClosed: (connectionId: string) => `remote:client:closed:${connectionId}`,
- handoffBuild: 'handoff:build'
+ handoffBuild: 'handoff:build',
+ // Phone pairing (nodeterm iOS "scan a QR" flow): renderer starts/stops the one-shot LAN
+ // listener; main pushes the completion result back over `pairing:done`.
+ pairingStart: 'pairing:start',
+ pairingStop: 'pairing:stop',
+ pairingDone: 'pairing:done'
} as const
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 41f18f9f3..82cb22d4f 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -960,6 +960,16 @@ export interface RemoteClientApi {
fsWrite(connectionId: string, path: string, content: string): Promise<boolean>
}
+/** Phone-pairing (nodeterm iOS "scan a QR" flow) bridge. */
+export interface PairingApi {
+ /** Start the one-shot LAN listener; resolves with the QR payload + an SSH-reachable hint. */
+ start(): Promise<{ payload: string; sshOpen: boolean }>
+ /** Cancel an in-flight pairing (e.g. when the settings section unmounts). */
+ stop(): Promise<void>
+ /** Fires once when pairing finishes (ok=true paired, ok=false timeout). Returns unsubscribe. */
+ onDone(cb: (result: { ok: boolean }) => void): () => void
+}
+
export interface NodeTerminalApi {
pty: PtyApi
workspace: WorkspaceApi
@@ -988,6 +998,7 @@ export interface NodeTerminalApi {
remoteHost: RemoteHostApi
remoteClient: RemoteClientApi
handoff: HandoffApi
+ pairing: PairingApi
/** Fires when the user presses Cmd/Ctrl+M (toggle markdown view). Returns unsubscribe. */
onMarkdownToggle(listener: () => void): () => void
/** Fires when the user presses Cmd/Ctrl+W (close selected node). Returns unsubscribe. */