From f8be8bdb295dc42927492ee798b3c42e6b9339e2 Mon Sep 17 00:00:00 2001 From: Evan Bowers Date: Sun, 15 Nov 2026 07:11:55 -0800 Subject: [PATCH 01/12] =?UTF-8?q?Device=20apps=20(portal):=20every=20app?= =?UTF-8?q?=20drawn=20from=20what=20the=20API=20says=20=E2=80=94=20no=20co?= =?UTF-8?q?nsole=20UI,=20no=20console=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The portal had a part of its own for one app: FIRST_PARTY_APPS = {console} (ConsoleApp: its icon, state words, ai_commands label, host key, Open terminal) and a console service found by type 28 at host remoteit-console (sshHelper isConsoleService, in the services' rows, the connect panel and the device's name on this machine). An app anyone ships could have none of it (presence-contract docs/self-contained-apps.md, the portal's row and "Capabilities, as the platform keeps them"). Now every app is drawn from DeviceApp, CatalogApp and CatalogAppRelease alone: - protocol, capabilities, hostKey, sessions and sessionsOpen are read with an app; protocol and capabilities with a catalogue entry and each release (and a product's app, where the schema has them). - An app whose service is ssh and that declares person-certificates (sshHelper opensTerminal) opens in web SSH, with the person's own account, a certificate and its host key checked: Open terminal in the Apps section and on its page, the terminal button in its device's services and the option in its connect panel (AppTerminal, which replaces ConsoleTerminal), the plain ssh command and its hint by name. Its service is the one its app names (DeviceApp.serviceId), or — disabled, naming none — the one at its app host (remoteit-app--); a device's apps are read only for a service at an app host. - The app's page says its state in the shared words, its settings in its release's labels and help (ai_commands included), the key its service presents where the device reports one, and the sessions it serves: how many, and who, as whom, by an AI and since when for those who manage it. Its icon comes from its protocol. - What an app asks of remote.it beyond running is said in words beside Runs as root wherever it is offered — the catalogue, the device's catalogue (from its catalogue entry), the app and its releases, a product's apps — and is part of every root consent (the device's, the product's, Add's): "Keeps accounts for the people you share with", "Signs in people by remote.it certificate", "AI commands go through this app". - This device's Advanced titles an app's on/off and its settings by the API's name and labels (the device by its UID), puts any app's settings under its row, and says "Not served" for an app that serves a service; only the device's own settings keep words here. Until the console declares these (step 3) and its services move to its app host (step 4), services/consoleUntilDeclared takes the console with no capabilities as declaring ssh, person-accounts, person-certificates and ssh-exec, and its host remoteit-console as its app host, so it works as before. It is the only place the portal names the console, and the removal step deletes it with its two calls. SCREENVIEW stays for ScreenView's old install alone. Needs graphql's DeviceApp.protocol/capabilities/hostKey/sessions/sessionsOpen and CatalogApp(Release) .capabilities/protocol: an older graphql refuses these queries. Co-Authored-By: Claude Opus 5.5 --- frontend/src/buttons/ServiceConnectButton.tsx | 24 +- frontend/src/components/AppCatalogRow.tsx | 16 +- frontend/src/components/AppRootConsent.tsx | 36 ++- frontend/src/components/AppTerminal.test.tsx | 248 ++++++++++++++++++ frontend/src/components/AppTerminal.tsx | 132 ++++++++++ .../src/components/BrowserGatewayConnect.tsx | 11 +- frontend/src/components/ConsoleApp.tsx | 79 ------ .../src/components/ConsoleTerminal.test.tsx | 186 ------------- frontend/src/components/ConsoleTerminal.tsx | 120 --------- frontend/src/components/DeviceApps.test.tsx | 92 ++++++- frontend/src/components/DeviceApps.tsx | 29 +- .../src/components/LocalSubnetConnect.tsx | 13 +- .../src/components/ProductPolicyApps.test.tsx | 23 +- frontend/src/components/ProductPolicyApps.tsx | 18 +- frontend/src/components/firstPartyApps.ts | 20 -- .../thisDevice/ThisDeviceAdvanced.tsx | 20 +- frontend/src/components/thisDevice/shared.tsx | 38 ++- frontend/src/helpers/appsHelper.test.ts | 80 +++++- frontend/src/helpers/appsHelper.ts | 47 ++++ frontend/src/helpers/sshHelper.test.ts | 16 +- frontend/src/helpers/sshHelper.ts | 13 +- frontend/src/hooks/useDeviceApps.test.tsx | 83 ++++-- frontend/src/hooks/useDeviceApps.ts | 25 +- frontend/src/i18n/locales/de/app.json | 30 ++- frontend/src/i18n/locales/en/app.json | 30 ++- frontend/src/i18n/locales/es/app.json | 30 ++- frontend/src/i18n/locales/ja/app.json | 30 ++- frontend/src/pages/AppAddDialog.test.tsx | 30 +++ frontend/src/pages/AppAddDialog.tsx | 14 +- frontend/src/pages/AppPage.test.tsx | 15 +- frontend/src/pages/AppPage.tsx | 28 +- frontend/src/pages/AppsPage.test.tsx | 6 +- frontend/src/pages/AppsPage.tsx | 2 + .../src/pages/DeviceAppCatalogPage.test.tsx | 39 ++- frontend/src/pages/DeviceAppCatalogPage.tsx | 41 ++- frontend/src/pages/DeviceAppPage.test.tsx | 87 +++++- frontend/src/pages/DeviceAppPage.tsx | 96 +++++-- frontend/src/pages/DevicePage.tsx | 5 +- frontend/src/pages/TerminalPage.tsx | 3 +- frontend/src/pages/ThisDevicePage.test.tsx | 35 ++- .../services/__fixtures__/appCatalogMock.ts | 22 ++ frontend/src/services/consoleUntilDeclared.ts | 28 ++ .../src/services/graphQLAppCatalog.test.ts | 9 +- frontend/src/services/graphQLAppCatalog.ts | 14 +- .../src/services/graphQLDeviceApps.test.ts | 59 ++++- frontend/src/services/graphQLDeviceApps.ts | 112 +++++--- frontend/src/services/productPolicy.test.ts | 35 ++- frontend/src/services/productPolicy.ts | 6 + 48 files changed, 1500 insertions(+), 675 deletions(-) create mode 100644 frontend/src/components/AppTerminal.test.tsx create mode 100644 frontend/src/components/AppTerminal.tsx delete mode 100644 frontend/src/components/ConsoleApp.tsx delete mode 100644 frontend/src/components/ConsoleTerminal.test.tsx delete mode 100644 frontend/src/components/ConsoleTerminal.tsx delete mode 100644 frontend/src/components/firstPartyApps.ts create mode 100644 frontend/src/services/consoleUntilDeclared.ts diff --git a/frontend/src/buttons/ServiceConnectButton.tsx b/frontend/src/buttons/ServiceConnectButton.tsx index e7571112b..8f96f9be3 100644 --- a/frontend/src/buttons/ServiceConnectButton.tsx +++ b/frontend/src/buttons/ServiceConnectButton.tsx @@ -11,11 +11,12 @@ import { ErrorButton } from '../buttons/ErrorButton' import { DesktopUI } from '../components/DesktopUI' import { Gutters } from '../components/Gutters' import { LocalSubnetConnect } from '../components/LocalSubnetConnect' -import { isConsoleService } from '../helpers/sshHelper' +import { opensTerminal } from '../helpers/sshHelper' import { useLocalSignIn, useSubnetReach } from '../hooks/useLocalSubnetName' import { LocalSignInNotice } from '../components/LocalSignInNotice' import { BrowserGatewayConnect } from '../components/BrowserGatewayConnect' -import { ConsoleTerminalOption } from '../components/ConsoleTerminal' +import { AppTerminalOption } from '../components/AppTerminal' +import { useServiceApp } from '../hooks/useDeviceApps' import { useApplication } from '../hooks/useApplication' import { Link } from '../components/Link' import { LocalPortConnect } from '../components/LocalPortConnect' @@ -35,6 +36,10 @@ export const ServiceConnectButton: React.FC = () => { // (services/browserGateway), the proxy one step away as for a local name. const web = useApplication(service, connection).urlForm const ssh = service?.typeID === 28 + // The app the service belongs to, where it does: one whose service is ssh and that signs people in by certificate + // opens in our web SSH as well, with the person's own account (components/AppTerminal). + const serving = useServiceApp(device, service) + const byCertificate = opensTerminal(serving.app) const gateway = !local && reach.checked && !!reach.name && (!!web || ssh) && !proxy // A local port of this machine (services/localPorts), where it runs our daemon: asked for here, or open already — // then it is what the panel shows, until it is disconnected. @@ -125,7 +130,12 @@ export const ServiceConnectButton: React.FC = () => { ) : named ? ( {local ? ( - + ) : ( { port: service.port || 22, title: service.name, service: service.id, - console: isConsoleService(service), + byCertificate, } : undefined } @@ -167,10 +177,10 @@ export const ServiceConnectButton: React.FC = () => { {portLink} )} - {/* The console: our web SSH, an option beside the ways above. */} - {isConsoleService(service) && ( + {/* An app's ssh service that signs people in by certificate: our web SSH, an option beside the ways above. */} + {byCertificate && ( - + )} {/* The service's other ports here that this machine's daemon lists: the machine's, opened by someone else. */} diff --git a/frontend/src/components/AppCatalogRow.tsx b/frontend/src/components/AppCatalogRow.tsx index 17b10f298..533fdaae3 100644 --- a/frontend/src/components/AppCatalogRow.tsx +++ b/frontend/src/components/AppCatalogRow.tsx @@ -1,11 +1,12 @@ import React from 'react' import { useTranslation } from 'react-i18next' import { Box, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography } from '@mui/material' -import { firstPartyApp } from './firstPartyApps' +import { appIcon, capabilitiesLine } from '../helpers/appsHelper' import { Icon } from './Icon' /* One app in the catalogue (presence-server docs/device-apps-design.md, "The Apps pages"): its name, its publisher with - Verified: and Yours for the account's own, Runs as root or Restricted, its description, its platforms and + Verified: and Yours for the account's own, Runs as root or Restricted and what else it asks of remote.it + (its capabilities, in words), its icon from how its service opens, its description, its platforms and what is said beside them (how many devices have it, or why this device cannot take it). The row opens the app; its action (Add…) sits at its end. */ export type AppCatalogRowProps = { @@ -15,6 +16,8 @@ export type AppCatalogRowProps = { verifiedDomain?: string | null own?: boolean // the account's own publisher root: boolean + capabilities?: string[] + protocol?: string | null // how its service opens: its icon description?: string | null platforms?: string | null // as families aside?: React.ReactNode // beside the platforms: how many devices have it @@ -30,6 +33,8 @@ export const AppCatalogRow: React.FC = ({ verifiedDomain, own, root, + capabilities, + protocol, description, platforms, aside, @@ -41,7 +46,7 @@ export const AppCatalogRow: React.FC = ({ const body = ( <> - + = ({ ? t('apps.runsAsRootFull', 'Runs as root: full control of the device') : t('apps.restricted', 'Restricted')} + {!!capabilities?.length && ( + + {capabilitiesLine(t, capabilities)} + + )} } secondaryTypographyProps={{ component: 'div' }} diff --git a/frontend/src/components/AppRootConsent.tsx b/frontend/src/components/AppRootConsent.tsx index 5933671b9..b7008e151 100644 --- a/frontend/src/components/AppRootConsent.tsx +++ b/frontend/src/components/AppRootConsent.tsx @@ -1,16 +1,19 @@ import React, { useState } from 'react' import { useTranslation } from 'react-i18next' -import { Typography } from '@mui/material' +import { Box, Typography } from '@mui/material' import type { DeviceApp } from '../services/graphQLDeviceApps' import { AppChange, refused } from '../services/deviceAppsShared' import type { DeviceApps } from '../hooks/useDeviceApps' +import { capabilityWords } from '../helpers/appsHelper' import { Confirm } from './Confirm' /* Asking for the person's yes to a root app's full control, in words naming the app, its publisher and that it gets - full control of the device (presence-server docs/device-apps-design.md, "Root, shown and consented to"). For a - product it says the yes covers every device in the product, now and later, as graphql keeps it on the product. */ + full control of the device (presence-server docs/device-apps-design.md, "Root, shown and consented to"), and what + else it asks of remote.it — its capabilities, part of the consent (presence-contract docs/self-contained-apps.md, + "Manifest"). For a product it says the yes covers every device in the product, now and later, as graphql keeps it + on the product. */ export const RootConsent: React.FC<{ - app?: { name: string; publisher: string } // open while there is one + app?: { name: string; publisher: string; capabilities?: string[] } // open while there is one product?: boolean // a product's consent, for every device in it action?: string // the confirm button's words, where they are not turning it on // A release of an app already on that newly runs as root: the consent moves it there (a re-consent). @@ -61,6 +64,7 @@ export const RootConsent: React.FC<{ words )} + {product ? t( @@ -74,8 +78,30 @@ export const RootConsent: React.FC<{ ) } +// What an app asks of remote.it beyond running, a line each: in its consent, and where it is offered. +export const AppCapabilities: React.FC<{ capabilities?: string[]; title?: string }> = ({ capabilities, title }) => { + const { t } = useTranslation() + if (!capabilities?.length) return null + return ( + + {title ?? t('apps.capabilitiesAlso', 'It also asks of remote.it:')} + {capabilities.map(capability => ( + + · {capabilityWords(t, capability)} + + ))} + + ) +} + /* Enabling or disabling an app, from wherever it is offered (the device's Apps section, the app's page on the device, - the console's connect panel). A root app is enabled only once the person says yes (RootConsent); that yes is + an app's service's connect panel). A root app is enabled only once the person says yes (RootConsent); that yes is consentRoot, which graphql refuses a root app without. Disabling, or a restricted app, at once. A release that newly runs as root while the app is enabled (awaitingRoot) is asked for the same way (reconsent): the yes is setDeviceAppRelease's consentRoot alone — Update now —, which moves the device to that release. graphql's refusal, diff --git a/frontend/src/components/AppTerminal.test.tsx b/frontend/src/components/AppTerminal.test.tsx new file mode 100644 index 000000000..ef0ff5d57 --- /dev/null +++ b/frontend/src/components/AppTerminal.test.tsx @@ -0,0 +1,248 @@ +import React, { act } from 'react' +import { createRoot, Root } from 'react-dom/client' +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' + +const { apps, name, openTerminal, env } = vi.hoisted(() => ({ + apps: { value: {} as any }, + name: { value: 'pi-evan.on.remote.it' as string | undefined }, + openTerminal: vi.fn(), + env: { isNative: false }, +})) +// The device's apps as the API says them; which one a service belongs to is the portal's own rule (appsHelper). +vi.mock('../hooks/useDeviceApps', async () => { + const { isAppService, serviceApp } = await import('../helpers/appsHelper') + return { + useServiceApp: (device?: IDevice, service?: IService) => { + const read = device && isAppService(service) ? apps.value : {} + return { ...read, app: serviceApp(read.apps, service) } + }, + } +}) +vi.mock('../hooks/useLocalSubnetName', () => ({ + useSubnetName: (deviceId?: string) => (deviceId ? name.value : undefined), +})) +vi.mock('../helpers/terminalHelper', () => ({ openTerminal })) +vi.mock('../services/browser', () => ({ default: env, windowOpen: vi.fn() })) +vi.mock('./Confirm', () => ({ + Confirm: ({ open, title, children, onConfirm, onDeny }: any) => + open ? ( + + {title} {children} + + ) +} + +/** A service's row in its device's services: a terminal button while its app runs. */ +export const AppTerminalButton: React.FC<{ device: IDevice; service: IService }> = ({ device, service }) => { + const { t } = useTranslation() + const { app } = useServiceApp(device, service) + const terminal = opensTerminal(app) + const name = useSubnetName(terminal ? device.id : undefined) + const port = service.port + if (!app || !terminal || app.state !== 'running' || !app.serviceId || !name || !port) return null + return ( + { + // The row opens the service's page: the button is not the row. + event.stopPropagation() + open(app, name, port) + }} + /> + ) +} + +/** A service's connect panel, where its app opens a terminal (serving: useServiceApp, read by the panel): Open in web + * SSH while the app runs, whichever way the panel connects it — its name on this machine, the browser's client (where + * the panel's own terminal button is this too) or the proxy; otherwise what the app is doing — and, for those who may + * run code on the device (Manage and Scripting), turning it on, with their yes to its running as root + * (components/AppRootConsent). */ +export const AppTerminalOption: React.FC<{ device?: IDevice; service?: IService; serving: ServiceApp }> = ({ + device, + service, + serving: { app, switching, turn, setRelease }, +}) => { + const { t } = useTranslation() + const terminal = opensTerminal(app) + const name = useSubnetName(terminal ? device?.id : undefined) + const { flip, consent } = useAppSwitch({ turn, setRelease }) + if (!app || !terminal || !name) return null + // Not where its product holds it off: graphql refuses that, naming the product. + const canTurnOn = + !app.locked && !!device?.permissions?.includes('MANAGE') && !!device?.permissions?.includes('SCRIPTING') + + const port = service?.port + if (app.state === 'running' && !switching) { + if (!app.serviceId || !port) return null + return ( + + open(app, name, port)}> + + {label(t)} + + + ) + } + + const status = switching + ? t('deviceApps.switching', 'Waiting for the device…') + : app.state === 'starting' + ? t('appTerminal.starting', '{{app}} is starting: web SSH opens it once it runs', { app: app.name }) + : app.state === 'unavailable' + ? t('deviceApps.unavailable', 'Not available here: {{detail}}', { detail: app.detail }) + : t('appTerminal.disabled', '{{app}} is disabled: enable it to open it in web SSH', { app: app.name }) + + return ( + + {status} + {app.state === 'disabled' && !switching && canTurnOn && ( + <> + {' '} + flip(app, true)}>{t('appTerminal.enable', 'Enable it')} + + )} + {consent} + + ) +} diff --git a/frontend/src/components/BrowserGatewayConnect.tsx b/frontend/src/components/BrowserGatewayConnect.tsx index a30525f8f..0a1e706ea 100644 --- a/frontend/src/components/BrowserGatewayConnect.tsx +++ b/frontend/src/components/BrowserGatewayConnect.tsx @@ -12,9 +12,10 @@ import { Icon } from './Icon' browser's remote.it client — nothing to install, and no connection to start. An SSH service opens a terminal in this app instead (pages/TerminalPage), its session through the same client — from the desktop app, in the web portal (helpers/terminalHelper). The counterpart of LocalSubnetConnect, - which is shown instead when an agent here does reach it. The console's plain ssh command is offered to copy as well: - it works from a machine signed in on its remote.it device app. */ -type Props = { name: string; terminal?: { port: number; title?: string; service?: string; console?: boolean } } + which is shown instead when an agent here does reach it. The plain ssh command of an app's service that signs people + in by certificate (byCertificate) is offered to copy as well: it works from a machine signed in on its remote.it + device app. */ +type Props = { name: string; terminal?: { port: number; title?: string; service?: string; byCertificate?: boolean } } export const BrowserGatewayConnect: React.FC = ({ name, terminal }) => { const { t } = useTranslation() @@ -57,14 +58,14 @@ export const BrowserGatewayConnect: React.FC = ({ name, terminal }) => { {t('browserGatewayConnect.failed', 'Could not open it: try again')} )} - {terminal?.console && ( + {terminal?.byCertificate && ( {sshCommand(name, terminal.port)} —{' '} {t('localSubnetConnect.sshHint', 'Works from a machine signed in on its remote.it device app')} )} - {terminal?.console && } + {terminal?.byCertificate && } - device?.services?.find(service => service.id === app.serviceId)?.port - -const ConsoleHostKey: React.FC = ({ app }) => { - const { t } = useTranslation() - const [hostKey, setHostKey] = useState(null) - const running = app.state === 'running' && app.serviceId - - useEffect(() => { - setHostKey(null) - if (!running || !app.serviceId) return - let current = true - graphQLSshHostKey(app.serviceId).then(key => current && setHostKey(key)) - return () => { - current = false - } - }, [running, app.serviceId]) - - if (!running || !hostKey) return null - return ( - - {t('deviceApps.hostKey', 'Host key {{key}}', { key: hostKey })} - - ) -} - -const ConsoleOpenTerminal: React.FC = ({ device, app }) => { - const { t } = useTranslation() - const name = useSubnetName(device.id) - const port = consolePort(device, app) - if (app.state !== 'running' || !name || !port || !app.serviceId) return null - return ( - - ) -} - -export const CONSOLE_APP: FirstPartyApp = { - icon: 'terminal', - state: (t, app) => - app.state === 'running' - ? t('deviceApps.consoleRunning', 'Running — logins by certificate, nothing listening on the device') - : app.state === 'disabled' - ? t('deviceApps.consoleDisabled', 'Disabled — a terminal on this device, from this app, by certificate') - : undefined, - settings: t => ({ - ai_commands: { - label: t('deviceApps.consoleAiCommands', 'Allow AI commands'), - help: t( - 'deviceApps.consoleAiCommandsHelp', - "AI assistants you authorize may run commands on this device's console through remote.it's MCP server. The device's administrator can turn this off on the machine." - ), - }, - }), - Lines: ConsoleHostKey, - Actions: ConsoleOpenTerminal, -} diff --git a/frontend/src/components/ConsoleTerminal.test.tsx b/frontend/src/components/ConsoleTerminal.test.tsx deleted file mode 100644 index 6708a01b6..000000000 --- a/frontend/src/components/ConsoleTerminal.test.tsx +++ /dev/null @@ -1,186 +0,0 @@ -import React, { act } from 'react' -import { createRoot, Root } from 'react-dom/client' -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' - -const { apps, name, openTerminal, env } = vi.hoisted(() => ({ - apps: { value: {} as any }, - name: { value: 'pi-evan.on.remote.it' as string | undefined }, - openTerminal: vi.fn(), - env: { isNative: false }, -})) -vi.mock('../hooks/useDeviceApps', () => ({ useDeviceApps: (deviceId?: string) => (deviceId ? apps.value : {}) })) -vi.mock('../hooks/useLocalSubnetName', () => ({ - useSubnetName: (deviceId?: string) => (deviceId ? name.value : undefined), -})) -vi.mock('../helpers/terminalHelper', () => ({ openTerminal })) -vi.mock('../services/browser', () => ({ default: env, windowOpen: vi.fn() })) -vi.mock('./Confirm', () => ({ - Confirm: ({ open, title, children, onConfirm, onDeny }: any) => - open ? ( - - {title} {children} -