The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-screen): older backends without display.* settle instead of checking forever
teknium1d175ca5b6d23
diff --git a/apps/desktop/src/plugins/hermes-bots/i18n.ts b/apps/desktop/src/plugins/hermes-bots/i18n.tsindex 2d1786b18d9..22ebec4f692 100644--- a/apps/desktop/src/plugins/hermes-bots/i18n.ts+++ b/apps/desktop/src/plugins/hermes-bots/i18n.ts@@ -253,6 +253,8 @@ type BotsMessages = {portalStopped: stringportalNotInstalled: stringportalUnsupported: string+ portalUnavailable: string+ unavailableTitle: stringrecheck: stringstoppedTitle: stringstoppedBody: string@@ -521,6 +523,8 @@ const en: BotsMessages = {portalStopped: 'Stopped',portalNotInstalled: 'Not installed on host',portalUnsupported: 'Not available on this host',+ portalUnavailable: 'Update the bot\u2019s Hermes to use Screen',+ unavailableTitle: 'Screen needs a newer Hermes',recheck: 'Check again',stoppedTitle: 'Screen is off',stoppedBody: 'Start this bot\u2019s desktop to watch what it does and take over when it needs you.',@@ -784,6 +788,8 @@ const ja: BotsMessages = {portalStopped: '停止中',portalNotInstalled: 'ホストに未インストール',portalUnsupported: 'このホストでは利用できません',+ portalUnavailable: 'Screen を使うにはボットの Hermes を更新してください',+ unavailableTitle: 'Screen には新しい Hermes が必要です',recheck: '再確認',stoppedTitle: '画面はオフです',stoppedBody: 'このボットのデスクトップを起動すると、動作を見守り、必要なときに操作を引き継げます。',@@ -1042,6 +1048,8 @@ const zh: BotsMessages = {portalStopped: '已停止',portalNotInstalled: '主机未安装',portalUnsupported: '此主机不可用',+ portalUnavailable: '更新机器人的 Hermes 以使用屏幕',+ unavailableTitle: '屏幕需要更新版的 Hermes',recheck: '重新检查',stoppedTitle: '屏幕已关闭',stoppedBody: '启动此机器人的桌面,观看它的操作,并在需要时接管。',@@ -1300,6 +1308,8 @@ const zhHant: BotsMessages = {portalStopped: '已停止',portalNotInstalled: '主機未安裝',portalUnsupported: '此主機不可用',+ portalUnavailable: '更新機器人的 Hermes 以使用螢幕',+ unavailableTitle: '螢幕需要較新版的 Hermes',recheck: '重新檢查',stoppedTitle: '螢幕已關閉',stoppedBody: '啟動此機器人的桌面,觀看它的操作,並在需要時接手。',diff --git a/apps/desktop/src/plugins/hermes-bots/screen-connection.ts b/apps/desktop/src/plugins/hermes-bots/screen-connection.tsindex e77ffea9b80..40b580358a9 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-connection.ts+++ b/apps/desktop/src/plugins/hermes-bots/screen-connection.ts@@ -82,6 +82,19 @@ export function leaseHeldBy(lease: DisplayLease | null | undefined, viewer: Screreturn lease.viewer_id != null ? lease.viewer_id === viewer.id : lease.viewer_hash === viewer.hash}+/** JSON-RPC method-not-found: the bot's Hermes predates the `display.*` surface. */+export function isDisplayUnavailable(error: unknown): boolean {+ const record = typeof error === 'object' && error !== null ? (error as { code?: unknown; message?: unknown }) : null++ if (record?.code === -32601) {+ return true+ }++ const message = typeof record?.message === 'string' ? record.message.toLowerCase() : ''++ return message.includes('method not found') || message.includes('method-not-found')+}+/** Bare-profile fallback so a v1 local bot (no registry route) still resolves. */export function botScreenRoute(bot: RosterRow): PluginProfileRoute | string {return botConnectionRoute(bot) ?? bot.namediff --git a/apps/desktop/src/plugins/hermes-bots/screen-hero.tsx b/apps/desktop/src/plugins/hermes-bots/screen-hero.tsxindex 93ad3e1bddc..647b866d4e5 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-hero.tsx+++ b/apps/desktop/src/plugins/hermes-bots/screen-hero.tsx@@ -116,7 +116,7 @@ function ScreenHeroContent({ bot, meta }: { bot: RosterRow; meta?: BotMeta | nulconst running = tone === 'live' || tone === 'human' || tone === 'other'const { dataUrl, boxRef, stale, suppressed } = useLiveThumbnail(bot, running)- if (tone === 'unsupported') {+ if (tone === 'unsupported' || tone === 'unavailable') {return null}@@ -127,6 +127,7 @@ function ScreenHeroContent({ bot, meta }: { bot: RosterRow; meta?: BotMeta | nuloff: t.screen.heroStopped,missing: t.screen.heroNotInstalled,unsupported: t.screen.portalUnsupported,+ unavailable: t.screen.portalUnavailable,unknown: t.screen.heroConnecting}[tone]diff --git a/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsxindex 926a34d8edd..ffb83505190 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx@@ -33,6 +33,7 @@ vi.mock('./i18n', () => ({heroOpenLive: 'Open live',heroStale: 'Last seen',heroSuppressed: 'Hidden while someone has control',+ portalUnavailable: 'Update the bot',heroConnecting: 'Connecting'}})@@ -182,3 +183,19 @@ it('captions a suppressed thumbnail as hidden-while-controlled and never ages itexpect(view.getByRole('button').getAttribute('aria-label')).not.toContain('Last seen')view.unmount()})++it('settles on an older backend without display.*: portal tone is unavailable and the hero renders nothing', async () => {+ vi.mocked(host.requestProfile).mockRejectedValue(Object.assign(new Error('Method not found: display.status'), { code: -32601 }))+ const hook = renderHook(() => useScreenPortalState(botA))+ await act(async () => {})+ expect(hook.result.current.tone).toBe('unavailable')+ hook.rerender()+ await act(async () => {})+ expect(vi.mocked(host.requestProfile)).toHaveBeenCalledTimes(1)+ hook.unmount()++ const view = render(<ScreenHero bot={botA} />)+ await act(async () => {})+ expect(view.container.firstChild).toBeNull()+ view.unmount()+})diff --git a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsxindex d9f3952637e..9376a1a7861 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx+++ b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx@@ -15,9 +15,9 @@ import type { RpcEvent } from '@hermes/plugin-sdk'import { useCallback, useEffect, useRef, useState } from 'react'import { useBots } from './i18n'-import { type DisplayLease, type DisplayObserveResult, displayRequest, type DisplayStatus, isEventForBotScreen, leaseHeldBy, resolveScreenWsUrl, retainBotScreen, viewerHash } from './screen-connection'+import { type DisplayLease, type DisplayObserveResult, displayRequest, type DisplayStatus, isDisplayUnavailable, isEventForBotScreen, leaseHeldBy, resolveScreenWsUrl, retainBotScreen, viewerHash } from './screen-connection'import { ScreenInstallCard } from './screen-install'-import { $screenState, screenStateFor, setScreenLease, setScreenStatus, setScreenViewer } from './screen-state'+import { $screenState, screenStateFor, setScreenLease, setScreenStatus, setScreenUnavailable, setScreenViewer } from './screen-state'import type { RosterRow } from './types'type RfbLike = {@@ -71,6 +71,10 @@ export function BotScreenPane({ bot }: { bot: RosterRow }) {setScreenStatus(bot, next)setError(null)} catch (err) {+ if (isDisplayUnavailable(err)) {+ setScreenUnavailable(bot)+ }+setError(err instanceof Error ? err.message : String(err))}}, [bot])@@ -256,6 +260,10 @@ export function BotScreenPane({ bot }: { bot: RosterRow }) {}}, [bot, viewer?.id])+ if (state?.unavailable) {+ return <EmptyState description={t.screen.portalUnavailable} title={t.screen.unavailableTitle} />+ }+if (status && !status.supported) {return <EmptyState description={t.screen.unsupportedBody} title={t.screen.unsupportedTitle} />}diff --git a/apps/desktop/src/plugins/hermes-bots/screen-portal.tsx b/apps/desktop/src/plugins/hermes-bots/screen-portal.tsxindex 2587f284e53..5a050a2abc0 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-portal.tsx+++ b/apps/desktop/src/plugins/hermes-bots/screen-portal.tsx@@ -17,15 +17,19 @@ import { useEffect } from 'react'import { $lastRoster } from './data'import { useBots } from './i18n'import { resolveBotConnectionRoute } from './routing'-import { type DisplayLease, displayRequest, type DisplayStatus, isEventForBotScreen, leaseHeldBy, type ScreenViewer } from './screen-connection'+import { type DisplayLease, displayRequest, type DisplayStatus, isDisplayUnavailable, isEventForBotScreen, leaseHeldBy, type ScreenViewer } from './screen-connection'import { openBotScreen } from './screen-open'-import { $screenState, screenStateFor, setScreenLease, setScreenStatus } from './screen-state'+import { $screenState, screenStateFor, setScreenLease, setScreenStatus, setScreenUnavailable } from './screen-state'import type { BotMeta, RosterRow } from './types'-export type PortalTone = 'live' | 'human' | 'other' | 'off' | 'missing' | 'unsupported' | 'unknown'+export type PortalTone = 'live' | 'human' | 'other' | 'off' | 'missing' | 'unsupported' | 'unavailable' | 'unknown'/** Pure: map cached status + lease (+ this window's minted viewer, if attached) to what the portal says. */-export function portalTone(status: DisplayStatus | null, lease: DisplayLease | null, viewer: ScreenViewer | null = null): PortalTone {+export function portalTone(status: DisplayStatus | null, lease: DisplayLease | null, viewer: ScreenViewer | null = null, unavailable = false): PortalTone {+ if (unavailable) {+ return 'unavailable'+ }+if (!status) {return 'unknown'}@@ -56,6 +60,7 @@ const TONE_ICON: Record<PortalTone, string> = {off: 'debug-stop',missing: 'cloud-download',unsupported: 'circle-slash',+ unavailable: 'circle-slash',unknown: 'device-desktop'}@@ -66,6 +71,7 @@ const TONE_DOT: Record<PortalTone, string> = {off: 'bg-(--ui-text-quaternary)',missing: 'bg-(--ui-text-quaternary)',unsupported: 'bg-(--ui-text-quaternary)',+ unavailable: 'bg-(--ui-text-quaternary)',unknown: 'bg-(--ui-text-quaternary)'}@@ -76,7 +82,7 @@ export function useScreenPortalState(bot: RosterRow) {const profileKey = status?.profile_keyuseEffect(() => {- if (status) {+ if (status || state?.unavailable) {return}@@ -88,14 +94,18 @@ export function useScreenPortalState(bot: RosterRow) {setScreenStatus(bot, next)}})- .catch(() => {- /* offline bot / older backend: the portal stays in its unknown state */+ .catch((error: unknown) => {+ // An older Hermes without display.* is a settled answer (hide the surface);+ // an offline bot is transient and stays in its unknown state.+ if (!cancelled && isDisplayUnavailable(error)) {+ setScreenUnavailable(bot)+ }})return () => {cancelled = true}- }, [bot, status])+ }, [bot, state?.unavailable, status])useEffect(() =>@@ -109,7 +119,7 @@ export function useScreenPortalState(bot: RosterRow) {[bot, profileKey])- return { status, lease: state?.lease ?? null, tone: portalTone(status, state?.lease ?? null, state?.viewer ?? null) }+ return { status, lease: state?.lease ?? null, tone: portalTone(status, state?.lease ?? null, state?.viewer ?? null, state?.unavailable) }}export function ScreenPortal({ bot, meta, compact = false }: { bot: RosterRow; meta?: BotMeta | null; compact?: boolean }) {@@ -123,10 +133,11 @@ export function ScreenPortal({ bot, meta, compact = false }: { bot: RosterRow; moff: t.screen.portalStopped,missing: t.screen.portalNotInstalled,unsupported: t.screen.portalUnsupported,+ unavailable: t.screen.portalUnavailable,unknown: status?.display ?? ''}[tone]- if (tone === 'unsupported' && compact) {+ if ((tone === 'unsupported' || tone === 'unavailable') && compact) {return null}diff --git a/apps/desktop/src/plugins/hermes-bots/screen-state.ts b/apps/desktop/src/plugins/hermes-bots/screen-state.tsindex 71e9ebfcc8a..8697e8dc72e 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-state.ts+++ b/apps/desktop/src/plugins/hermes-bots/screen-state.ts@@ -15,6 +15,8 @@ export interface BotScreenState {lease: DisplayLease | null/** This window's server-minted identity for the bot's current attach; null until the pane observes. */viewer: ScreenViewer | null+ /** The bot's Hermes has no `display.*` methods (older backend): nothing to check, ever. */+ unavailable?: boolean}export const $screenState = atom<Record<string, BotScreenState>>({})@@ -30,6 +32,19 @@ export function setScreenStatus(bot: RosterRow, status: DisplayStatus): void {$screenState.set({ ...current, [key]: { status, lease: status.lease ?? prev?.lease ?? null, viewer: prev?.viewer ?? null } })}+/** `display.status` answered method-not-found: remember it so no surface keeps "checking". */+export function setScreenUnavailable(bot: RosterRow): void {+ const key = botSelectionKey(bot)+ const current = $screenState.get()+ const prev = current[key]++ if (prev?.unavailable) {+ return+ }++ $screenState.set({ ...current, [key]: { status: null, lease: null, viewer: null, unavailable: true } })+}+export function setScreenLease(bot: RosterRow, lease: DisplayLease): void {const key = botSelectionKey(bot)const current = $screenState.get()