+ ),
+}))
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (_key: string, text: string, values?: any) => text.replace(/{{(\w+)}}/g, (_, k) => values?.[k] ?? ''),
+ }),
+}))
+
+import { DeviceAppSetting } from './DeviceAppSetting'
+import type { DeviceAppSetting as Setting } from '../services/graphQLDeviceApps'
+;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
+
+// The console's "Allow AI commands" (forcible: its administrator may hold it on as well as off).
+const aiCommands = (control: string, more: Partial = {}): Setting => ({
+ name: 'ai_commands',
+ type: 'bool',
+ label: 'Allow AI commands',
+ help: 'Commands an AI runs on this device through MCP, as the people you allow',
+ default: true,
+ value: true,
+ at: null,
+ by: null,
+ onDevice: false,
+ control: control as any,
+ locked: null,
+ choices: null,
+ deprecated: null,
+ ...more,
+})
+
+async function render(setting: Setting, onChange = vi.fn()) {
+ const container = document.createElement('div')
+ await act(async () =>
+ createRoot(container).render(
+
+ )
+ )
+ return container
+}
+const row = (page: HTMLElement) => page.querySelector('[data-row]') as HTMLButtonElement
+
+describe('an app setting its device’s administrator holds', () => {
+ it('ai_commands held off: off, greyed, "Set by this device’s administrator" — no change offered', async () => {
+ const onChange = vi.fn()
+ const page = await render(aiCommands('off', { value: false }), onChange)
+ expect(row(page).dataset.on).toBe('false')
+ expect(row(page).disabled).toBe(true)
+ expect(row(page).textContent).toBe('Allow AI commands — Set by this device’s administrator')
+ await act(async () => row(page).click())
+ expect(onChange).not.toHaveBeenCalled()
+ })
+
+ it('ai_commands held on: on, greyed, said the same', async () => {
+ const page = await render(aiCommands('on', { value: true }))
+ expect(row(page).dataset.on).toBe('true')
+ expect(row(page).disabled).toBe(true)
+ expect(row(page).textContent).toBe('Allow AI commands — Set by this device’s administrator')
+ })
+
+ it('held by its administrator and its product: both said', async () => {
+ const page = await render(
+ aiCommands('off', { value: false, locked: { product: 'Kiosks', level: 'enforced' } as any })
+ )
+ expect(row(page).textContent).toBe(
+ 'Allow AI commands — Set by this device’s administrator · Managed by product Kiosks (enforced)'
+ )
+ })
+
+ it('not held: switched here, its help said; local is set on the device only; its product’s lock alone as before', async () => {
+ for (const control of ['cloud+local', 'cloud']) {
+ const onChange = vi.fn()
+ const page = await render(aiCommands(control), onChange)
+ expect(row(page).disabled).toBe(false)
+ expect(row(page).textContent).toBe(
+ 'Allow AI commands — Commands an AI runs on this device through MCP, as the people you allow'
+ )
+ await act(async () => row(page).click())
+ expect(onChange).toHaveBeenCalledWith(false)
+ }
+ const local = await render(aiCommands('local'))
+ expect(row(local).disabled).toBe(true)
+ expect(row(local).textContent).toBe('Allow AI commands — Set only on the device')
+ const product = await render(aiCommands('cloud+local', { locked: { product: 'Kiosks', level: 'synced' } as any }))
+ expect(row(product).disabled).toBe(true)
+ expect(row(product).textContent).toBe('Allow AI commands — Set by its product Kiosks')
+ })
+
+ it('a choice it fixes: that choice, greyed, said the same', async () => {
+ const mode: Setting = {
+ ...aiCommands('nightly'),
+ name: 'mode',
+ type: 'choice',
+ label: 'Back up',
+ help: null,
+ value: 'nightly',
+ default: 'hourly',
+ choices: [
+ { value: 'hourly', label: 'Every hour' },
+ { value: 'nightly', label: 'Every night' },
+ ],
+ }
+ const page = await render(mode)
+ const select = page.querySelector('[data-select]') as HTMLElement
+ expect(select.dataset.value).toBe('nightly')
+ expect(select.dataset.disabled).toBe('true')
+ expect(select.textContent).toBe('Set by this device’s administrator')
+ const free = await render({ ...mode, control: 'cloud+local' as any })
+ expect((free.querySelector('[data-select]') as HTMLElement).dataset.disabled).toBe('false')
+ })
+})
diff --git a/frontend/src/components/DeviceAppSetting.tsx b/frontend/src/components/DeviceAppSetting.tsx
index 5db43c379..811ef1a7c 100644
--- a/frontend/src/components/DeviceAppSetting.tsx
+++ b/frontend/src/components/DeviceAppSetting.tsx
@@ -4,6 +4,7 @@ import { Button, ListItem, TextField } from '@mui/material'
import type { TFunction } from 'i18next'
import { AppStringRules, DeviceAppSetting as Setting } from '../services/graphQLDeviceApps'
import { settingLocked } from '../services/graphQLDeviceSettings'
+import { productLockNote } from '../helpers/productPolicyHelper'
import { DeviceSettingChoice, DeviceSettingRow, deprecatedLine, settingNote } from './DeviceSettingRow'
import { spacing } from '../styling'
@@ -43,9 +44,25 @@ export const DeviceAppSetting: React.FC = props => {
)
}
+// Whether the device's administrator holds the setting (graphql's DeviceAppSetting.control, the device's
+// `._control`): off, on (where its release says forcible, as the console's ai_commands) or a choice it fixes.
+// The device applies the held value, and graphql refuses a change to it.
+export const adminHolds = (setting: Setting) =>
+ !!setting.control && !['cloud+local', 'cloud', 'local'].includes(setting.control)
+
+/* Why an app's setting is as it is, where that is not the portal's doing: held by the device's administrator — and by
+ its product too, where its product locks it — else what a device setting's row says (set only on the device, its
+ product's lock, a change made on the device). None for one set here. */
+export function appSettingNote(t: TFunction, setting: Setting): string | undefined {
+ if (!adminHolds(setting)) return settingNote(t, setting)
+ const held = t('deviceApps.settingAdminHeld', 'Set by this device’s administrator')
+ return setting.locked ? `${held} · ${productLockNote(t, setting.locked)}` : held
+}
+
const AppSettingControl: React.FC = ({ setting, label, help, disabled, onChange }) => {
const { t } = useTranslation()
const deprecated = deprecatedLine(t, setting.deprecated)
+ const note = appSettingNote(t, setting)
switch (setting.type) {
case 'bool':
@@ -55,7 +72,8 @@ const AppSettingControl: React.FC = ({ setting, label, help, disabled, on
hideIcon
disableGutters
label={label}
- subLabel={help}
+ subLabel={note || help}
+ quiet
deprecated={setting.deprecated}
disabled={disabled}
onChange={onChange}
@@ -71,6 +89,7 @@ const AppSettingControl: React.FC = ({ setting, label, help, disabled, on
label={label}
value={fixed ? setting.control : String(setting.value ?? '')}
choices={choices}
+ why={note}
note={deprecated || help || undefined}
disabled={disabled}
onChange={onChange}
@@ -148,7 +167,7 @@ const AppSettingField: React.FC = ({ setting, label, help, disabled, onCh
onChange(list ? listItems(text) : text)
}
- const note = [deprecatedLine(t, setting.deprecated), settingNote(t, setting) || help].filter(Boolean).join(' · ')
+ const note = [deprecatedLine(t, setting.deprecated), appSettingNote(t, setting) || help].filter(Boolean).join(' · ')
const max = setting.type === 'string' ? setting.declaration?.string?.max : undefined
return (
diff --git a/frontend/src/components/DeviceApps.tsx b/frontend/src/components/DeviceApps.tsx
index f64d98e30..51426d31b 100644
--- a/frontend/src/components/DeviceApps.tsx
+++ b/frontend/src/components/DeviceApps.tsx
@@ -215,8 +215,8 @@ export const DeviceApps: React.FC<{ device: IDevice }> = ({ device }) => {
/* Open, for any app reached as a service (serviceId) while it runs: its service's connection, started and launched as
its application type launches (graphql makes the type from the manifest's protocol: http and https open in the
- browser, vnc and rdp in a viewer), as any service's Connect page does; said by its protocol (Open page, Open
- screen). One whose service
+ browser, vnc and rdp in a viewer, udp nothing: a port for the person's own UDP client), as any service's Connect
+ page does; said by its protocol (Open page, Open screen, Connect). One whose service
opens as a terminal (helpers/sshHelper opensTerminal) has Open terminal instead (components/AppTerminal). */
export const AppOpen: React.FC<{ device: IDevice; app: DeviceApp }> = ({ device, app }) => {
const { t } = useTranslation()
@@ -230,7 +230,8 @@ export const AppOpen: React.FC<{ device: IDevice; app: DeviceApp }> = ({ device,
onClick={() =>
history.push({
pathname: `/devices/${device.id}/${app.serviceId}/connect`,
- state: { autoConnect: true, autoLaunch: true },
+ // A udp service's connection is all it has: its port is for the person's own UDP client.
+ state: app.protocol === 'udp' ? { autoConnect: true } : { autoConnect: true, autoLaunch: true },
})
}
>
diff --git a/frontend/src/components/DeviceSettingRow.tsx b/frontend/src/components/DeviceSettingRow.tsx
index 04ebb47da..43b27bb5f 100644
--- a/frontend/src/components/DeviceSettingRow.tsx
+++ b/frontend/src/components/DeviceSettingRow.tsx
@@ -88,14 +88,17 @@ export const DeviceSettingChoice: React.FC<{
value: string // the value standing, as the setting's control fixes it
choices: ISelect[]
note?: React.ReactNode // the setting's state, below who set it
+ why?: string // who set it, or why it is fixed, in the caller's words (an app's setting); else a device setting's
disabled?: boolean
onChange: (value: string) => void
-}> = ({ setting, icon, hideIcon, label, value, choices, note, disabled, onChange }) => {
+}> = ({ setting, icon, hideIcon, label, value, choices, note, why: said, disabled, onChange }) => {
const { t } = useTranslation()
const fixed = choices.find(choice => choice.key === setting.control)
- const why = fixed
- ? t('deviceSetting.controlFixedTo', "Set to {{value}} by the device's administrator", { value: fixed.name })
- : settingNote(t, setting)
+ const why =
+ said ??
+ (fixed
+ ? t('deviceSetting.controlFixedTo', "Set to {{value}} by the device's administrator", { value: fixed.name })
+ : settingNote(t, setting))
return (
? 'desktop'
: 'cube'
-// Open, in the words of how its service opens (its protocol): a page, a screen, else its service's connection.
+// Open, in the words of how its service opens (its protocol): a page, a screen, a UDP service's connection (nothing to
+// launch: the person's own UDP client uses its port), else its service's connection.
export function openWord(t: TFunction, protocol?: string | null): string {
switch (protocol) {
+ case 'udp':
+ return t('deviceApps.connect', 'Connect')
case 'http':
case 'https':
return t('deviceApps.openPage', 'Open page')
diff --git a/frontend/src/helpers/sshHelper.test.ts b/frontend/src/helpers/sshHelper.test.ts
index 94b68c7e4..b9eada2e8 100644
--- a/frontend/src/helpers/sshHelper.test.ts
+++ b/frontend/src/helpers/sshHelper.test.ts
@@ -15,6 +15,7 @@ describe('sshHelper', () => {
).toBe(true)
expect(opensTerminal({ protocol: 'ssh', capabilities: ['ssh-exec'] })).toBe(false)
expect(opensTerminal({ protocol: 'https', capabilities: ['person-certificates'] })).toBe(false)
+ expect(opensTerminal({ protocol: 'udp', capabilities: ['person-certificates'] })).toBe(false)
expect(opensTerminal({ protocol: null, capabilities: [] })).toBe(false)
expect(opensTerminal(undefined)).toBe(false)
})
diff --git a/frontend/src/i18n/locales/de/app.json b/frontend/src/i18n/locales/de/app.json
index c9a736d97..1651c0f7a 100644
--- a/frontend/src/i18n/locales/de/app.json
+++ b/frontend/src/i18n/locales/de/app.json
@@ -335,6 +335,7 @@
"searchDevices": "",
"service": "",
"serviceLine": "",
+ "serviceLineUdp": "",
"servicePort": "",
"serviceStopped": "",
"sessionAs": "als {{login}}",
@@ -1174,6 +1175,7 @@
"beta": "",
"between": "Von {{min}} bis {{max}}",
"clearDeprecated": "Leeren: zurück zum Standard",
+ "connect": "",
"consented": "Als root zugestimmt von {{by}}, {{when}}",
"consentedCarried": "Läuft als root, wie schon bevor Zustimmungen gespeichert wurden",
"consentedConverted": "",
@@ -1207,6 +1209,7 @@
"screenviewOld": "ScreenView wurde auf die alte Weise installiert.",
"screenviewOldHelp": "Wechseln Sie zur ScreenView-App: von remote.it aktuell gehalten, mit ihren Einstellungen hier. Sie läuft als root, daher wird zuerst gefragt.",
"screenviewSwitch": "Zur App wechseln",
+ "settingAdminHeld": "",
"stable": "",
"starting": "",
"startingDetail": "",
diff --git a/frontend/src/i18n/locales/en/app.json b/frontend/src/i18n/locales/en/app.json
index 73676d20f..e9ec0ea19 100644
--- a/frontend/src/i18n/locales/en/app.json
+++ b/frontend/src/i18n/locales/en/app.json
@@ -335,6 +335,7 @@
"searchDevices": "Search devices…",
"service": "Service",
"serviceLine": "{{name}} · port {{port}}",
+ "serviceLineUdp": "{{name}} · UDP port {{port}}",
"servicePort": "Port people connect to",
"serviceStopped": "Stopped while the app is disabled: enable it to open it",
"sessionAs": "as {{login}}",
@@ -1174,6 +1175,7 @@
"beta": "Beta",
"between": "From {{min}} to {{max}}",
"clearDeprecated": "Clear: back to its default",
+ "connect": "Connect",
"consented": "Consented to run as root by {{by}}, {{when}}",
"consentedCarried": "Runs as root, as it did before consents were kept",
"consentedConverted": "Runs as root, as its old install did: switched to the app by remote.it, {{when}}",
@@ -1207,6 +1209,7 @@
"screenviewOld": "ScreenView was installed the old way.",
"screenviewOldHelp": "Switch to the ScreenView app: kept up to date by remote.it, with its settings here. It runs as root, so it asks first.",
"screenviewSwitch": "Switch to the app",
+ "settingAdminHeld": "Set by this device’s administrator",
"stable": "Stable",
"starting": "Starting — waiting for the device to say so",
"startingDetail": "Starting — {{detail}}",
diff --git a/frontend/src/i18n/locales/es/app.json b/frontend/src/i18n/locales/es/app.json
index b58d51084..05e6998cb 100644
--- a/frontend/src/i18n/locales/es/app.json
+++ b/frontend/src/i18n/locales/es/app.json
@@ -342,6 +342,7 @@
"searchDevices": "",
"service": "",
"serviceLine": "",
+ "serviceLineUdp": "",
"servicePort": "",
"serviceStopped": "",
"sessionAs": "como {{login}}",
@@ -1188,6 +1189,7 @@
"beta": "",
"between": "De {{min}} a {{max}}",
"clearDeprecated": "Borrar: volver al valor predeterminado",
+ "connect": "",
"consented": "Consentimiento para ejecutarse como root de {{by}}, {{when}}",
"consentedCarried": "Se ejecuta como root, como antes de que se guardaran los consentimientos",
"consentedConverted": "",
@@ -1221,6 +1223,7 @@
"screenviewOld": "ScreenView se instaló de la forma antigua.",
"screenviewOldHelp": "Cambie a la app ScreenView: remote.it la mantiene actualizada, con sus ajustes aquí. Se ejecuta como root, así que primero se le pregunta.",
"screenviewSwitch": "Cambiar a la app",
+ "settingAdminHeld": "",
"stable": "",
"starting": "",
"startingDetail": "",
diff --git a/frontend/src/i18n/locales/ja/app.json b/frontend/src/i18n/locales/ja/app.json
index 48a387d7a..bae183e93 100644
--- a/frontend/src/i18n/locales/ja/app.json
+++ b/frontend/src/i18n/locales/ja/app.json
@@ -328,6 +328,7 @@
"searchDevices": "",
"service": "",
"serviceLine": "",
+ "serviceLineUdp": "",
"servicePort": "",
"serviceStopped": "",
"sessionAs": "{{login}} として",
@@ -1160,6 +1161,7 @@
"beta": "",
"between": "{{min}} から {{max}} まで",
"clearDeprecated": "クリア: 既定値に戻す",
+ "connect": "",
"consented": "{{by}} が root での実行に同意 ({{when}})",
"consentedCarried": "同意が記録される前から root で実行",
"consentedConverted": "",
@@ -1193,6 +1195,7 @@
"screenviewOld": "ScreenView は旧方式でインストールされています。",
"screenviewOldHelp": "ScreenView アプリに切り替えます: remote.it が最新に保ち、設定はここで行えます。root で実行されるため、最初に確認します。",
"screenviewSwitch": "アプリに切り替え",
+ "settingAdminHeld": "",
"stable": "",
"starting": "",
"startingDetail": "",
diff --git a/frontend/src/pages/DeviceAppPage.test.tsx b/frontend/src/pages/DeviceAppPage.test.tsx
index 89e676d67..712b6ff1c 100644
--- a/frontend/src/pages/DeviceAppPage.test.tsx
+++ b/frontend/src/pages/DeviceAppPage.test.tsx
@@ -400,6 +400,19 @@ describe('its service, settings, root, delivery and problems', () => {
expect(await words('vnc')).toBe('Open screen')
expect(await words('rdp')).toBe('Open screen')
expect(await words('tcp')).toBe('Open')
+ expect(await words('udp')).toBe('Connect')
+ })
+
+ it('udp: a connection alone — its port, said UDP, for the person’s own UDP client; never a terminal or a page', async () => {
+ params.appID = 'acme.dns'
+ // Even one that declares person-certificates: only ssh opens a terminal.
+ apps.value.apps = [backup({ id: 'acme.dns', name: 'DNS', protocol: 'udp', capabilities: ['person-certificates'] })]
+ const page = await render()
+ expect(text(page, 'service')).toContain('Backup · UDP port 30001')
+ expect(page.querySelector('[data-app-terminal]')).toBeNull()
+ expect(page.querySelector('[data-app-open]')?.textContent).toBe('Connect')
+ await click(page.querySelector('[data-app-open]'))
+ expect(push).toHaveBeenCalledWith({ pathname: '/devices/D1/S7/connect', state: { autoConnect: true } })
})
it('a port its owner chooses is its service’s, edited under Service, not again under Settings', async () => {
diff --git a/frontend/src/pages/DeviceAppPage.tsx b/frontend/src/pages/DeviceAppPage.tsx
index d10c48a20..6abbcbda0 100644
--- a/frontend/src/pages/DeviceAppPage.tsx
+++ b/frontend/src/pages/DeviceAppPage.tsx
@@ -45,7 +45,8 @@ import { LIST_ITEM_ICON_WIDTH, spacing } from '../styling'
would release it (Update now… for a release waiting for root consent, Unpin for a pin, none for the rest)
Channel its channel (the account's, stable, beta) and its pin (none, or a release of it)
Service its service, opened by its protocol — Open terminal for one that is ssh and signs people in by
- certificate (components/AppTerminal), a page for http and https, a viewer for vnc and rdp —, the key it
+ certificate (components/AppTerminal), a page for http and https, a viewer for vnc and rdp, a connection
+ alone for udp (its port, said UDP, is for the person's own UDP client) —, the key it
presents where it reports one, and the port people connect to where its owner chooses it (portSetting:
that setting is edited here, not under Settings). A disabled app has no service to open (graphql gives
none: kept, stopped): said stopped, where its app serves one (its release names a protocol)
@@ -311,9 +312,11 @@ export const DeviceAppPage: React.FC = () => {
- {service
- ? t('apps.serviceLine', '{{name}} · port {{port}}', { name: service.name, port: service.port })
- : app.name}
+ {!service
+ ? app.name
+ : app.protocol === 'udp'
+ ? t('apps.serviceLineUdp', '{{name}} · UDP port {{port}}', { name: service.name, port: service.port })
+ : t('apps.serviceLine', '{{name}} · port {{port}}', { name: service.name, port: service.port })}
{app.hostKey && (