feat(cli): make connect-url --relay a full anywhere pairing link

- --relay links now carry both routes: direct LAN plus relay fallback,
  matching the UI's Anywhere pairing; devices prefer the direct route
- pairing sessions created by the CLI are marked with usesRelay, and the
  server reconciles relay demand on a timer, so a headless instance
  brings the relay up on its own after connect-url --relay
- warn with LAN_UNREACHABLE when the link's direct route points at
  loopback and other devices cannot use it
- document the --relay flow and the --lan binding caveat in Connect a
  Device and Remote Instances across all locales
This commit is contained in:
Bohdan Triapitsyn
2026-07-10 18:29:15 +03:00
parent de92b8fef4
commit 6ec1797583
21 changed files with 182 additions and 87 deletions
+10
View File
@@ -1508,6 +1508,15 @@ async function main(options = {}) {
// device/session exists, stop it (and clear a stale enabled flag) otherwise.
void relayService.reconcile();
// Relay demand can change outside our routes: `openchamber connect-url
// --relay` writes a pending relay session straight to the on-disk store, and
// pending sessions expire without any request hitting us. Poll reconcile so a
// headless instance picks the relay up (or drops it) within a minute.
const relayReconcileTimer = setInterval(() => {
void relayService.reconcile();
}, 60_000);
relayReconcileTimer.unref?.();
return {
expressApp: app,
httpServer: server,
@@ -1538,6 +1547,7 @@ async function main(options = {}) {
},
stop: (shutdownOptions = {}) => {
realtimeProxyRuntime.stop();
clearInterval(relayReconcileTimer);
try {
relayService.stop();
} catch {