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.

fix(pairing): gate the QR on Remote Login, working Open Settings, 10-min window

enesa5be6c6522c9
diff --git a/src/main/index.ts b/src/main/index.ts
index 2e27c01f5..84575a124 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -647,6 +647,17 @@ app.whenReady().then(async () => {
)
ipcMain.handle(IPC.pairingStop, () => pairingService.stop())
ipcMain.handle(IPC.pairingProbeSsh, () => pairingService.probeSsh())
+ // Same pattern as appOpenNotificationSettings: a main-side constant deep link, NOT routed
+ // through shellOpenExternal's http(s)-only allowlist (which silently drops x-apple.* URLs —
+ // the "Open System Settings" button did nothing when it sent the URL from the renderer).
+ // The `Services_RemoteLogin` query selected the service in the pre-Ventura prefpane and is
+ // harmless on newer macOS, which opens the Sharing pane either way.
+ ipcMain.handle(IPC.pairingOpenRemoteLoginSettings, () => {
+ if (process.platform !== 'darwin') return
+ void shell.openExternal(
+ 'x-apple.systempreferences:com.apple.preferences.sharing?Services_RemoteLogin'
+ )
+ })
ipcMain.handle(IPC.pairingListDevices, () => pairingService.listDevices())
ipcMain.handle(IPC.pairingRevokeDevice, (_e, id: string) => pairingService.revokeDevice(id))
diff --git a/src/main/pairing-service.ts b/src/main/pairing-service.ts
index f8063c8cf..5ca7ba3a3 100644
--- a/src/main/pairing-service.ts
+++ b/src/main/pairing-service.ts
@@ -127,8 +127,10 @@ async function buildRelayContext(
}
}
-/** How long the listener waits for the phone before giving up. */
-const PAIR_TIMEOUT_MS = 2 * 60 * 1000
+/** How long the listener waits for the phone before giving up. 10 minutes, not 2: the QR can
+ * now be gated behind enabling Remote Login first, and a field report showed a user scanning a
+ * long-expired QR — a wider window plus the UI's explicit timeout state beats a tight one. */
+const PAIR_TIMEOUT_MS = 10 * 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). */
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 8f95cd9cf..68e8250b9 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -454,6 +454,7 @@ const api: NodeTerminalApi = {
return () => ipcRenderer.removeListener(IPC.pairingDone, handler)
},
probeSsh: () => ipcRenderer.invoke(IPC.pairingProbeSsh),
+ openRemoteLoginSettings: () => ipcRenderer.invoke(IPC.pairingOpenRemoteLoginSettings),
listDevices: () => ipcRenderer.invoke(IPC.pairingListDevices),
revokeDevice: (id) => ipcRenderer.invoke(IPC.pairingRevokeDevice, id)
},
diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.ts
index 149767850..98fe130dd 100644
--- a/src/renderer/bridge/stubs.ts
+++ b/src/renderer/bridge/stubs.ts
@@ -300,6 +300,7 @@ export function buildStubApi(): Omit<
stop: U('pairing.stop'),
onDone: noopUnsub,
probeSsh: U('pairing.probeSsh'),
+ openRemoteLoginSettings: U('pairing.openRemoteLoginSettings'),
listDevices: U('pairing.listDevices'),
revokeDevice: U('pairing.revokeDevice')
},
diff --git a/src/renderer/components/PhonePairPopover.tsx b/src/renderer/components/PhonePairPopover.tsx
index d07d4a9ac..4b49b42bc 100644
--- a/src/renderer/components/PhonePairPopover.tsx
+++ b/src/renderer/components/PhonePairPopover.tsx
@@ -6,9 +6,6 @@ import { useEntitlement } from '@renderer/state/entitlement'
import { useUpgradeGate } from '@renderer/state/upgradeGate'
import { usePhonePairing } from './settings/usePhonePairing'
-/** Same deep link the Phone settings section uses for the Remote Login toggle. */
-const REMOTE_LOGIN_SETTINGS_URL =
- 'x-apple.systempreferences:com.apple.preferences.sharing?Services_RemoteLogin'
const isMac = /Mac/i.test(navigator.platform || navigator.userAgent)
/**
@@ -65,32 +62,34 @@ export function PhonePairPopover({
<div className="phone-pair__title">Pair your phone</div>
{phase === 'waiting' && qr ? (
- <>
- <img src={qr} width={208} height={208} alt="Pairing QR code" className="phone-pair__qr" />
- <div className="phone-pair__hint">Scan with the nodeterm iOS app · waiting (2 min)</div>
- {!sshOpen ? (
- <div className="phone-pair__warn">
- SSH isn&apos;t reachable — turn on <strong>Remote Login</strong>
- {isMac ? (
- <>
- {' '}
- (
- <button
- className="phone-pair__link"
- onClick={() => window.nodeTerminal.shell.openExternal(REMOTE_LOGIN_SETTINGS_URL)}
- >
- System Settings
- </button>
- &nbsp;— watching, this clears itself).
- </>
- ) : (
- '.'
- )}
- </div>
- ) : sshHealed ? (
- <div className="phone-pair__ok">✓ Remote Login is on.</div>
- ) : null}
- </>
+ !sshOpen ? (
+ // No QR while Remote Login is off — pairing against an unreachable sshd installs a
+ // key the phone can never use. The live probe flips sshOpen and the QR appears.
+ <div className="phone-pair__warn">
+ <strong>Remote Login</strong> is off — the pairing QR appears the moment it is on
+ {isMac ? (
+ <>
+ {' '}
+ (
+ <button
+ className="phone-pair__link"
+ onClick={() => void window.nodeTerminal.pairing.openRemoteLoginSettings()}
+ >
+ System Settings
+ </button>
+ &nbsp;— watching).
+ </>
+ ) : (
+ '.'
+ )}
+ </div>
+ ) : (
+ <>
+ <img src={qr} width={208} height={208} alt="Pairing QR code" className="phone-pair__qr" />
+ <div className="phone-pair__hint">Scan with the nodeterm iOS app · waiting (10 min)</div>
+ {sshHealed ? <div className="phone-pair__ok">✓ Remote Login is on.</div> : null}
+ </>
+ )
) : phase === 'paired' ? (
<div className="phone-pair__ok">✓ Paired — your phone can now connect.</div>
) : phase === 'timeout' ? (
diff --git a/src/renderer/components/settings/sections/PhoneSection.tsx b/src/renderer/components/settings/sections/PhoneSection.tsx
index ac32572bf..bd48e692a 100644
--- a/src/renderer/components/settings/sections/PhoneSection.tsx
+++ b/src/renderer/components/settings/sections/PhoneSection.tsx
@@ -35,12 +35,6 @@ function formatPairedAt(ms: number): string {
})
}
-/** Deep link straight to System Settings → General → Sharing (the Remote Login toggle lives
- * there). The `Services_RemoteLogin` query selected the service in the pre-Ventura prefpane and
- * is harmless on newer macOS, which opens the Sharing pane either way. macOS-only. */
-const REMOTE_LOGIN_SETTINGS_URL =
- 'x-apple.systempreferences:com.apple.preferences.sharing?Services_RemoteLogin'
-
/** The pairing host is this machine, so the renderer's own UA answers "is this a Mac?". */
const isMac = /Mac/i.test(navigator.platform || navigator.userAgent)
@@ -134,7 +128,8 @@ export function PhoneSection({ isActive }: { isActive: boolean }): React.JSX.Ele
<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.
+ Pairing timed out — that code no longer works. Start again and scan the fresh
+ one within ten minutes.
</p>
) : null}
<Button variant="primary" disabled={busy} onClick={() => void start()}>
@@ -145,32 +140,41 @@ export function PhoneSection({ isActive }: { isActive: boolean }): React.JSX.Ele
{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 ? (
+ // No QR until Remote Login is on: a pairing completed against an unreachable
+ // sshd installs a key the phone can never use — the scan must wait, not the fix.
+ // The live probe (usePhonePairing) flips sshOpen and the QR appears by itself.
<div className="space-y-2">
<p className="text-sm" style={{ color: '#ff9f0a' }}>
- SSH doesn&apos;t appear to be reachable — your phone won&apos;t be able to
- connect after pairing. Turn on <strong>Remote Login</strong>
- {isMac ? ' (watching — this notice clears by itself once it is on).' : '.'}
+ <strong>Remote Login</strong> is off, so your phone wouldn&apos;t be able to
+ connect after pairing. Turn it on — the QR appears here the moment it is
+ {isMac ? ' (watching, no need to restart pairing).' : '.'}
</p>
{isMac ? (
- <Button onClick={() => window.nodeTerminal.shell.openExternal(REMOTE_LOGIN_SETTINGS_URL)}>
+ <Button
+ onClick={() => void window.nodeTerminal.pairing.openRemoteLoginSettings()}
+ >
Open System Settings
</Button>
) : null}
</div>
- ) : sshHealed ? (
- <p className="text-sm" style={{ color: '#30d158' }}>
- ✓ Remote Login is on — your phone can connect after pairing.
- </p>
- ) : null}
+ ) : (
+ <>
+ <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… (10 min)</p>
+ {sshHealed ? (
+ <p className="text-sm" style={{ color: '#30d158' }}>
+ ✓ Remote Login is on — scan away.
+ </p>
+ ) : null}
+ </>
+ )}
<Button onClick={stop}>Cancel</Button>
</div>
) : null}
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index a79b9640b..600612a7e 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -315,6 +315,7 @@ export const IPC = {
pairingStop: 'pairing:stop',
pairingDone: 'pairing:done',
pairingProbeSsh: 'pairing:probe-ssh',
+ pairingOpenRemoteLoginSettings: 'pairing:open-remote-login-settings',
pairingListDevices: 'pairing:listDevices',
pairingRevokeDevice: 'pairing:revokeDevice',
// Dictation (desktop/server). speechProgress is a main/server → renderer broadcast of
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 7e47a9c2c..07c7b4b72 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1683,6 +1683,10 @@ export interface PairingApi {
/** Live re-probe of 127.0.0.1:22, so the Remote Login warning can clear the moment the user
* flips the toggle in System Settings (polled by the UI only while the warning is showing). */
probeSsh(): Promise<boolean>
+ /** Open System Settings → General → Sharing (Remote Login). The deep link is a main-side
+ * constant — x-apple.* schemes never pass shellOpenExternal's http(s) allowlist. macOS-only;
+ * a no-op elsewhere. */
+ openRemoteLoginSettings(): Promise<void>
/** List paired devices from ~/.nodeterm/agent.json (never includes the token). */
listDevices(): Promise<PairedDevice[]>
/** Revoke a device: remove its registry entry and delete its authorized_keys line. */