Skip to content

The agent that grows with you

fix(bot-screen): hero says why the preview is hidden while a human holds control

teknium1078bd3163ffb
diff --git a/apps/desktop/src/plugins/hermes-bots/i18n.ts b/apps/desktop/src/plugins/hermes-bots/i18n.ts
index 637a9ee4b9f..2d1786b18d9 100644
--- a/apps/desktop/src/plugins/hermes-bots/i18n.ts
+++ b/apps/desktop/src/plugins/hermes-bots/i18n.ts
@@ -243,6 +243,7 @@ type BotsMessages = {
heroNotInstalled: string
heroConnecting: string
heroStale: string
+ heroSuppressed: string
heroOpenLive: string
heroInstall: string
heroStart: string
@@ -510,6 +511,7 @@ const en: BotsMessages = {
heroNotInstalled: 'Not installed on this host',
heroConnecting: 'Checking the screen…',
heroStale: 'Last seen — screen unreachable',
+ heroSuppressed: 'Hidden while someone has control',
heroOpenLive: 'Open live',
heroInstall: 'Install',
heroStart: 'Start',
@@ -772,6 +774,7 @@ const ja: BotsMessages = {
heroNotInstalled: 'このホストには未インストール',
heroConnecting: '画面を確認中…',
heroStale: '最終表示 — 画面に接続できません',
+ heroSuppressed: '他の人が操作中は非表示',
heroOpenLive: 'ライブで開く',
heroInstall: 'インストール',
heroStart: '開始',
@@ -1029,6 +1032,7 @@ const zh: BotsMessages = {
heroNotInstalled: '此主机未安装',
heroConnecting: '正在检查屏幕…',
heroStale: '最后画面 — 屏幕无法访问',
+ heroSuppressed: '有人控制时隐藏',
heroOpenLive: '实时打开',
heroInstall: '安装',
heroStart: '启动',
@@ -1286,6 +1290,7 @@ const zhHant: BotsMessages = {
heroNotInstalled: '此主機未安裝',
heroConnecting: '正在檢查螢幕…',
heroStale: '最後畫面 — 螢幕無法連線',
+ heroSuppressed: '有人控制時隱藏',
heroOpenLive: '即時開啟',
heroInstall: '安裝',
heroStart: '啟動',
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-connection.ts b/apps/desktop/src/plugins/hermes-bots/screen-connection.ts
index e19917bbb46..90dfd846260 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-connection.ts
+++ b/apps/desktop/src/plugins/hermes-bots/screen-connection.ts
@@ -42,6 +42,12 @@ export interface DisplayStatus {
lease: DisplayLease
}
+export interface DisplayThumbnail {
+ data_url: string | null
+ /** Set while a human holds the screen: the frame is withheld, not missing. */
+ suppressed?: 'human_has_control' | null
+}
+
export interface DisplayObserveResult extends DisplayStatus {
ticket: string
path: string
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-hero.tsx b/apps/desktop/src/plugins/hermes-bots/screen-hero.tsx
index 2e108c20c24..93ad3e1bddc 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-hero.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-hero.tsx
@@ -12,7 +12,7 @@ import { useEffect, useRef, useState } from 'react'
import { botSelectionKey } from './data'
import { useBots } from './i18n'
-import { displayRequest } from './screen-connection'
+import { displayRequest, type DisplayThumbnail } from './screen-connection'
import { openBotScreen } from './screen-open'
import { type PortalTone, useScreenPortalState } from './screen-portal'
import type { BotMeta, RosterRow } from './types'
@@ -25,12 +25,16 @@ function useLiveThumbnail(bot: RosterRow, running: boolean) {
// Consecutive failed refreshes; past STALE_AFTER the frame is shown dimmed as "last seen" so a
// dead gateway never keeps looking live. Success resets it.
const [misses, setMisses] = useState(0)
+ // The backend withholds frames while a human holds the screen; that is a
+ // deliberate answer, not a failed refresh, so it never ages into "stale".
+ const [suppressed, setSuppressed] = useState(false)
const boxRef = useRef<HTMLButtonElement | null>(null)
useEffect(() => {
if (!running) {
setDataUrl(null)
setMisses(0)
+ setSuppressed(false)
return
}
@@ -61,10 +65,11 @@ function useLiveThumbnail(bot: RosterRow, running: boolean) {
return
}
- void displayRequest<{ data_url: string | null }>(bot, 'display.thumbnail')
+ void displayRequest<DisplayThumbnail>(bot, 'display.thumbnail')
.then(result => {
if (!cancelled) {
setDataUrl(result.data_url)
+ setSuppressed(result.suppressed === 'human_has_control')
setMisses(0)
}
})
@@ -92,7 +97,7 @@ function useLiveThumbnail(bot: RosterRow, running: boolean) {
}
}, [bot, running])
- return { dataUrl, boxRef, stale: misses >= STALE_AFTER }
+ return { dataUrl, boxRef, stale: misses >= STALE_AFTER, suppressed }
}
const TONE_RING: Partial<Record<PortalTone, string>> = {
@@ -109,13 +114,13 @@ function ScreenHeroContent({ bot, meta }: { bot: RosterRow; meta?: BotMeta | nul
const t = useBots()
const { tone } = useScreenPortalState(bot)
const running = tone === 'live' || tone === 'human' || tone === 'other'
- const { dataUrl, boxRef, stale } = useLiveThumbnail(bot, running)
+ const { dataUrl, boxRef, stale, suppressed } = useLiveThumbnail(bot, running)
if (tone === 'unsupported') {
return null
}
- const caption = stale ? t.screen.heroStale : {
+ const caption = suppressed ? t.screen.heroSuppressed : stale ? t.screen.heroStale : {
live: t.screen.portalWatching,
human: t.screen.portalYouControl,
other: t.screen.portalOtherControls,
diff --git a/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx
index ce342893ad1..926a34d8edd 100644
--- a/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/screen-isolation.test.tsx
@@ -32,6 +32,7 @@ vi.mock('./i18n', () => ({
portalOtherControls: 'Other viewer',
heroOpenLive: 'Open live',
heroStale: 'Last seen',
+ heroSuppressed: 'Hidden while someone has control',
heroConnecting: 'Connecting'
}
})
@@ -165,3 +166,19 @@ it('discards a late thumbnail from the previous owner and retains a same-owner f
expect(view.getByRole('button').getAttribute('aria-label')).toContain('Last seen')
view.unmount()
})
+
+it('captions a suppressed thumbnail as hidden-while-controlled and never ages it into stale', async () => {
+ vi.useFakeTimers()
+ setScreenStatus(botA, status)
+ vi.mocked(host.requestProfile).mockResolvedValue({ data_url: null, suppressed: 'human_has_control' })
+ const view = render(<ScreenHero bot={botA} />)
+ await act(async () => {})
+ expect(view.getByRole('button').getAttribute('aria-label')).toContain('Hidden while someone has control')
+
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(20_000)
+ })
+ expect(view.getByRole('button').getAttribute('aria-label')).toContain('Hidden while someone has control')
+ expect(view.getByRole('button').getAttribute('aria-label')).not.toContain('Last seen')
+ view.unmount()
+})