Skip to content

The agent that grows with you

fix(desktop): Hermes Cloud bots without Screen say it is not included instead of offering an install

IAvecilla757705867a1b
diff --git a/apps/desktop/src/plugins/hermes-bots/i18n-bind.ts b/apps/desktop/src/plugins/hermes-bots/i18n-bind.ts
new file mode 100644
index 00000000000..d4e6c6f902b
--- /dev/null
+++ b/apps/desktop/src/plugins/hermes-bots/i18n-bind.ts
@@ -0,0 +1,27 @@
+import type { PluginTranslate } from '@hermes/plugin-sdk'
+
+// Bind the message SHAPE to a plugin translator: string leaves resolve now,
+// function leaves forward their args through t(path, …).
+export type Bound<T> = {
+ [K in keyof T]: T[K] extends (...args: infer A) => string
+ ? (...args: A) => string
+ : T[K] extends object
+ ? Bound<T[K]>
+ : string
+}
+
+export function bind<T extends object>(t: PluginTranslate, template: T, prefix = ''): Bound<T> {
+ const out = {} as Record<string, unknown>
+
+ for (const [key, value] of Object.entries(template)) {
+ const path = prefix ? `${prefix}.${key}` : key
+ out[key] =
+ typeof value === 'function'
+ ? (...args: unknown[]) => t(path, ...args)
+ : value && typeof value === 'object'
+ ? bind(t, value as object, path)
+ : t(path)
+ }
+
+ return out as Bound<T>
+}
diff --git a/apps/desktop/src/plugins/hermes-bots/i18n.ts b/apps/desktop/src/plugins/hermes-bots/i18n.ts
index 5f568971324..27d7579a3e8 100644
--- a/apps/desktop/src/plugins/hermes-bots/i18n.ts
+++ b/apps/desktop/src/plugins/hermes-bots/i18n.ts
@@ -32,6 +32,7 @@
import { type PluginLocaleBundles, type PluginTranslate, usePluginI18n } from '@hermes/plugin-sdk'
import { useMemo } from 'react'
+import { bind, type Bound } from './i18n-bind'
import { getPluginCtx } from './shared'
type BotsMessages = {
@@ -388,6 +389,8 @@ type BotsMessages = {
portalUnavailable: string
/** Managed runtimes (Hermes Cloud): updates are the platform's job, not the user's. */
portalUnavailableManaged: string
+ managedNotIncludedTitle: string
+ managedNotIncludedBody: string
unavailableTitle: string
autoOpenMenu: string
autoOpenOnToast: (name: string) => string
@@ -827,6 +830,9 @@ const en: BotsMessages = {
portalUnsupported: 'Not available on this host',
portalUnavailable: 'Update the bot\u2019s Hermes to use Screen',
portalUnavailableManaged: 'Screen is not available on this managed Hermes release yet',
+ managedNotIncludedTitle: 'Screen isn’t included on this bot',
+ managedNotIncludedBody:
+ 'Hermes Cloud includes Screen on bots with 8 GB of memory or more. It can’t be installed on a smaller bot.',
unavailableTitle: 'Screen needs a newer Hermes',
autoOpenMenu: 'Open Screen when the bot uses it',
autoOpenOnToast: name => `${name}’s Screen opens when it starts using its desktop`,
@@ -1267,6 +1273,9 @@ const ja: BotsMessages = {
portalUnsupported: 'このホストでは利用できません',
portalUnavailable: 'Screen を使うにはボットの Hermes を更新してください',
portalUnavailableManaged: 'この管理された Hermes リリースではまだ Screen を利用できません',
+ managedNotIncludedTitle: 'このボットには Screen が含まれていません',
+ managedNotIncludedBody:
+ 'Hermes Cloud では、メモリが 8 GB 以上のボットに Screen が含まれます。これより小さいボットにはインストールできません。',
unavailableTitle: 'Screen には新しい Hermes が必要です',
autoOpenMenu: 'ボットが画面を使い始めたら Screen を開く',
autoOpenOnToast: name => `${name} がデスクトップを使い始めると Screen が開きます`,
@@ -1691,6 +1700,8 @@ const zh: BotsMessages = {
portalUnsupported: '此主机不可用',
portalUnavailable: '更新机器人的 Hermes 以使用屏幕',
portalUnavailableManaged: '此托管 Hermes 版本尚不支持屏幕',
+ managedNotIncludedTitle: '此机器人不包含屏幕',
+ managedNotIncludedBody: 'Hermes Cloud 为内存 8 GB 及以上的机器人提供屏幕,较小的机器人无法安装。',
unavailableTitle: '屏幕需要更新版的 Hermes',
autoOpenMenu: '机器人使用屏幕时自动打开',
autoOpenOnToast: name => `${name} 开始使用桌面时会自动打开屏幕`,
@@ -2115,6 +2126,8 @@ const zhHant: BotsMessages = {
portalUnsupported: '此主機不可用',
portalUnavailable: '更新機器人的 Hermes 以使用螢幕',
portalUnavailableManaged: '此託管 Hermes 版本尚不支援螢幕',
+ managedNotIncludedTitle: '此機器人不包含螢幕',
+ managedNotIncludedBody: 'Hermes Cloud 為記憶體 8 GB 以上的機器人提供螢幕,較小的機器人無法安裝。',
unavailableTitle: '螢幕需要較新版的 Hermes',
autoOpenMenu: '機器人使用螢幕時自動開啟',
autoOpenOnToast: name => `${name} 開始使用桌面時會自動開啟螢幕`,
@@ -2210,32 +2223,6 @@ const zhHant: BotsMessages = {
/** Registered via `ctx.i18n.register` at plugin load (disposer tracked). */
export const BOTS_LOCALES: PluginLocaleBundles = { en, ja, zh, 'zh-hant': zhHant }
-// Bind the message SHAPE to a plugin translator: string leaves resolve now,
-// function leaves forward their args through t(path, …).
-type Bound<T> = {
- [K in keyof T]: T[K] extends (...args: infer A) => string
- ? (...args: A) => string
- : T[K] extends object
- ? Bound<T[K]>
- : string
-}
-
-function bind<T extends object>(t: PluginTranslate, template: T, prefix = ''): Bound<T> {
- const out = {} as Record<string, unknown>
-
- for (const [key, value] of Object.entries(template)) {
- const path = prefix ? `${prefix}.${key}` : key
- out[key] =
- typeof value === 'function'
- ? (...args: unknown[]) => t(path, ...args)
- : value && typeof value === 'object'
- ? bind(t, value as object, path)
- : t(path)
- }
-
- return out as Bound<T>
-}
-
export type BotsText = Bound<BotsMessages>
/** The Bot Mode strings for the active locale — one hook every component reads. */
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-install.tsx b/apps/desktop/src/plugins/hermes-bots/screen-install.tsx
index 41ebfefd74f..9a72d6bf6b3 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-install.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-install.tsx
@@ -9,12 +9,18 @@
* a fresh status the caller uses to flip the pane to "Start screen".
*/
-import { Button, Codicon, GlyphSpinner, host } from '@hermes/plugin-sdk'
+import { Button, Codicon, EmptyState, GlyphSpinner, host } from '@hermes/plugin-sdk'
import type { RpcEvent } from '@hermes/plugin-sdk'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useBots } from './i18n'
-import { displayRequest, type DisplayStatus, isEventForBotScreen, retainBotScreen } from './screen-connection'
+import {
+ displayRequest,
+ type DisplayStatus,
+ isEventForBotScreen,
+ isManagedBackend,
+ retainBotScreen
+} from './screen-connection'
import type { RosterRow } from './types'
const LOG_KEEP = 200
@@ -25,6 +31,21 @@ interface ScreenInstallCardProps {
onInstalled: (status: DisplayStatus) => void
}
+/**
+ * The pane for a host without the screen packages. Hermes Cloud ships Screen in the image of
+ * its larger sizes; a smaller bot's image leaves it out, and packages installed by hand would
+ * not survive the next update, so only a self-managed host is offered the install.
+ */
+export function ScreenNotInstalled(props: ScreenInstallCardProps) {
+ const t = useBots()
+
+ if (isManagedBackend(props.bot)) {
+ return <EmptyState description={t.screen.managedNotIncludedBody} title={t.screen.managedNotIncludedTitle} />
+ }
+
+ return <ScreenInstallCard {...props} />
+}
+
export function ScreenInstallCard({ bot, status, onInstalled }: ScreenInstallCardProps) {
const t = useBots()
const [phase, setPhase] = useState<'idle' | 'running' | 'failed'>('idle')
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-managed-copy.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-managed-copy.test.tsx
index fb431c46692..062ac6d9f32 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-managed-copy.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-managed-copy.test.tsx
@@ -3,11 +3,15 @@
* rendered as "Update the bot's Hermes": the user cannot update a managed release, and the
* managed Cloud tab already reports it is on the latest release (#120852). A self-upgradable
* (git/remote) backend keeps the update instruction.
+ *
+ * Likewise, missing screen packages on a managed backend are a property of its size, not
+ * something to install: only a self-managed host gets the install card.
*/
import { act, render } from '@testing-library/react'
import type { ButtonHTMLAttributes, ReactNode } from 'react'
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
+import type { DisplayStatus } from './screen-connection'
import type { RosterRow } from './types'
vi.mock('@hermes/plugin-sdk', async () => {
@@ -41,7 +45,11 @@ vi.mock('./i18n', () => ({
title: 'Screen',
portalUnavailable: 'Update the bot’s Hermes to use Screen',
portalUnavailableManaged: 'Screen is not available on this managed Hermes release yet',
- unavailableTitle: 'Screen needs a newer Hermes'
+ unavailableTitle: 'Screen needs a newer Hermes',
+ managedNotIncludedTitle: 'Screen isn’t included on this bot',
+ managedNotIncludedBody: 'Hermes Cloud includes Screen on bots with 8 GB of memory or more.',
+ notInstalledTitle: 'Screen packages missing',
+ install: 'Install on host'
}
})
}))
@@ -85,3 +93,38 @@ it('a self-upgradable backend keeps the update instruction', async () => {
expect(view.queryByText('Screen is not available on this managed Hermes release yet')).toBeNull()
view.unmount()
})
+
+const packagesMissing: DisplayStatus = {
+ profile: 'default',
+ profile_key: '/home/hermes/.hermes',
+ supported: true,
+ installed: false,
+ missing: ['tigervnc-standalone-server'],
+ running: false,
+ pid: null,
+ display: null,
+ socket: null,
+ geometry: '1440x900',
+ install_command: 'sudo apt-get install -y tigervnc-standalone-server',
+ lease: { holder: 'agent', viewer_id: null, viewer_hash: null, since: 1, reason: '', epoch: 0 }
+}
+
+it('a managed Cloud backend without screen packages says Screen is not included, with no install', async () => {
+ vi.mocked(host.requestProfile).mockResolvedValue(packagesMissing)
+ const view = render(<BotScreenPane bot={cloudBot} />)
+ await act(async () => {})
+
+ expect(view.getByText('Screen isn’t included on this bot')).toBeTruthy()
+ expect(view.queryByText('Install on host')).toBeNull()
+ view.unmount()
+})
+
+it('a self-managed host without screen packages keeps the install card', async () => {
+ vi.mocked(host.requestProfile).mockResolvedValue(packagesMissing)
+ const view = render(<BotScreenPane bot={gitBot} />)
+ await act(async () => {})
+
+ expect(view.getByText('Install on host')).toBeTruthy()
+ expect(view.queryByText('Screen isn’t included on this bot')).toBeNull()
+ view.unmount()
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx
index 917544e7777..e51fa79732a 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx
@@ -30,7 +30,7 @@ import {
retainBotScreen,
viewerHash
} from './screen-connection'
-import { ScreenInstallCard } from './screen-install'
+import { ScreenNotInstalled } from './screen-install'
import {
$screenState,
beginScreenStatusRequest,
@@ -425,7 +425,7 @@ export function BotScreenPane({ bot }: { bot: RosterRow }) {
}
if (status && !status.installed) {
- return <ScreenInstallCard bot={bot} onInstalled={next => setScreenStatus(bot, next)} status={status} />
+ return <ScreenNotInstalled bot={bot} onInstalled={next => setScreenStatus(bot, next)} status={status} />
}
if (status && !status.running && status.image_switch) {