// shared hint printed when the CLI has no bridge or no desktop companion. import { findDesktopCompanion } from '../desktop-companion' import type { BridgeSimInfo } from '../ws-bridge' export function printMissingCompanionHint() { console.error(' no rnx desktop companion found.') console.error('') console.error(' install the desktop app:') console.error(' rnx desktop install') console.error('') console.error(' or install the recommended background service:') console.error(' rnx daemon install') console.error('') } export function printMissingBridgeHint(port: number) { const companion = findDesktopCompanion() console.log(` note: no rnx bridge detected on port ${port}`) if (companion) { console.log(` launch the installed companion with:`) console.log(` rnx desktop`) return } console.log('') console.log(' run `rnx daemon install` to enable the faster background service,') console.log(' or run `rnx serve` in another shell for a foreground bridge.') } export function printMissingSimHint(port: number) { console.error('') console.error(` no sim is connected to the rnx bridge on port ${port}.`) console.error('') console.error(' start your app dev server, then open it in rnx:') console.error(' npx expo start --localhost --port 8081') console.error(' rnx open 8081') console.error('') console.error(' then inspect the live app:') console.error(' rnx describe') } // printed when a command targeted a specific `--sim ` that the bridge // does not know — distinct from printMissingSimHint, which assumes the bridge // has no sims at all. when other sims *are* connected, "no sim is connected" // is a flat-out lie; list the valid ids instead so the user can pick one. export async function printUnknownSimHint( bridge: { listSims: () => Promise }, port: number, requestedId: string, ) { let sims: BridgeSimInfo[] = [] try { sims = await bridge.listSims() } catch { // bridge unreachable while reporting — fall through to the generic hint } console.error('') if (sims.length === 0) { printMissingSimHint(port) return } console.error( ` no sim with id "${requestedId}" is connected to the bridge on port ${port}.`, ) console.error('') console.error(' connected sims:') for (const sim of sims) { const flags = [ sim.isPrimary ? 'primary' : null, sim.readyState, sim.userVisible === false ? 'hidden' : sim.userVisible === true ? 'visible' : null, sim.userFocused ? 'focused' : null, ] .filter(Boolean) .join(', ') console.error(` ${sim.id} (${flags})`) } console.error('') console.error(' pass a valid --sim id, or run `rnx list` to see all sessions.') }