The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(bot-screen): "Hand back (force)" for a lease this window no longer owns
teknium10f513fc5cbc6
diff --git a/apps/desktop/src/plugins/hermes-bots/i18n.ts b/apps/desktop/src/plugins/hermes-bots/i18n.tsindex 22ebec4f692..fd860551e2d 100644--- a/apps/desktop/src/plugins/hermes-bots/i18n.ts+++ b/apps/desktop/src/plugins/hermes-bots/i18n.ts@@ -255,7 +255,6 @@ type BotsMessages = {portalUnsupported: stringportalUnavailable: stringunavailableTitle: string- recheck: stringstoppedTitle: stringstoppedBody: stringstart: string@@ -264,6 +263,9 @@ type BotsMessages = {reconnect: stringtakeOver: stringhandBack: string+ handBackForce: string+ handBackForceHint: string+ openNeedsUpdate: stringyouControl: stringotherControls: stringagentControls: string@@ -525,7 +527,6 @@ const en: BotsMessages = {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.',start: 'Start screen',@@ -534,6 +535,9 @@ const en: BotsMessages = {reconnect: 'Reconnect',takeOver: 'Take over',handBack: 'Hand back',+ handBackForce: 'Hand back (force)',+ handBackForceHint: 'Release a lease held by a viewer that is no longer here, e.g. after a reload.',+ openNeedsUpdate: 'Update Hermes Desktop to open bot screens.',youControl: 'You are in control',otherControls: 'Another viewer is in control',agentControls: 'Bot is in control',@@ -790,7 +794,6 @@ const ja: BotsMessages = {portalUnsupported: 'このホストでは利用できません',portalUnavailable: 'Screen を使うにはボットの Hermes を更新してください',unavailableTitle: 'Screen には新しい Hermes が必要です',- recheck: '再確認',stoppedTitle: '画面はオフです',stoppedBody: 'このボットのデスクトップを起動すると、動作を見守り、必要なときに操作を引き継げます。',start: '画面を起動',@@ -799,6 +802,9 @@ const ja: BotsMessages = {reconnect: '再接続',takeOver: '引き継ぐ',handBack: '戻す',+ handBackForce: '強制的に戻す',+ handBackForceHint: 'もう存在しないビューア(再読み込み後など)が保持しているリースを解放します。',+ openNeedsUpdate: 'ボットの画面を開くには Hermes Desktop を更新してください。',youControl: 'あなたが操作中',otherControls: '別のビューアが操作中',agentControls: 'ボットが操作中',@@ -1050,7 +1056,6 @@ const zh: BotsMessages = {portalUnsupported: '此主机不可用',portalUnavailable: '更新机器人的 Hermes 以使用屏幕',unavailableTitle: '屏幕需要更新版的 Hermes',- recheck: '重新检查',stoppedTitle: '屏幕已关闭',stoppedBody: '启动此机器人的桌面,观看它的操作,并在需要时接管。',start: '启动屏幕',@@ -1059,6 +1064,9 @@ const zh: BotsMessages = {reconnect: '重新连接',takeOver: '接管',handBack: '交还',+ handBackForce: '强制交还',+ handBackForceHint: '释放已不在场的查看者(例如重新加载后)持有的控制权。',+ openNeedsUpdate: '更新 Hermes Desktop 以打开机器人屏幕。',youControl: '你正在控制',otherControls: '另一位查看者正在控制',agentControls: '机器人正在控制',@@ -1310,7 +1318,6 @@ const zhHant: BotsMessages = {portalUnsupported: '此主機不可用',portalUnavailable: '更新機器人的 Hermes 以使用螢幕',unavailableTitle: '螢幕需要較新版的 Hermes',- recheck: '重新檢查',stoppedTitle: '螢幕已關閉',stoppedBody: '啟動此機器人的桌面,觀看它的操作,並在需要時接手。',start: '啟動螢幕',@@ -1319,6 +1326,9 @@ const zhHant: BotsMessages = {reconnect: '重新連線',takeOver: '接手',handBack: '交還',+ handBackForce: '強制交還',+ handBackForceHint: '釋放已不在場的檢視者(例如重新載入後)持有的控制權。',+ openNeedsUpdate: '更新 Hermes Desktop 以開啟機器人螢幕。',youControl: '你正在控制',otherControls: '另一位檢視者正在控制',agentControls: '機器人正在控制',diff --git a/apps/desktop/src/plugins/hermes-bots/screen-open.tsx b/apps/desktop/src/plugins/hermes-bots/screen-open.tsxindex ae0ff946c64..9d05539c4d8 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-open.tsx+++ b/apps/desktop/src/plugins/hermes-bots/screen-open.tsx@@ -6,6 +6,7 @@import { host } from '@hermes/plugin-sdk'import { botSelectionKey } from './data'+import { botsText } from './i18n'import { displayName } from './labels'import { BotScreenPane } from './screen-pane'import { ID } from './shared'@@ -19,7 +20,7 @@ export function screenPaneId(bot: RosterRow): string {export function openBotScreen(bot: RosterRow, meta?: BotMeta | null): void {if (typeof host.openWorkspace !== 'function') {- host.notify({ kind: 'info', message: 'Update Hermes Desktop to open bot screens.' })+ host.notify({ kind: 'info', message: botsText().screen.openNeedsUpdate })return}@@ -33,7 +34,7 @@ export function openBotScreen(bot: RosterRow, meta?: BotMeta | null): void {}const close = host.openWorkspace(`${ID}:screen:${key}`, {- title: `${displayName(bot, meta ?? null)} · Screen`,+ title: `${displayName(bot, meta ?? null)} · ${botsText().screen.title}`,minWidth: '28rem',render: () => <BotScreenPane bot={bot} />,onClose: () => {diff --git a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsxindex 9376a1a7861..c555e2fc3ea 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx+++ b/apps/desktop/src/plugins/hermes-bots/screen-pane.tsx@@ -247,18 +247,25 @@ export function BotScreenPane({ bot }: { bot: RosterRow }) {}}, [attach, bot, conn, viewer?.id])- const handBack = useCallback(async () => {- setBusy(true)-- try {- const result = await displayRequest<{ lease: DisplayLease }>(bot, 'display.lease.release', { viewer_id: viewer?.id })- setScreenLease(bot, result.lease)- } catch (err) {- setError(err instanceof Error ? err.message : String(err))- } finally {- setBusy(false)- }- }, [bot, viewer?.id])+ // `force` is the escape hatch for a lease this window no longer owns (a reload+ // minted a fresh viewer id; the old one still holds): the server refuses a+ // plain release from anyone but the holder.+ const handBack = useCallback(+ async (force = false) => {+ setBusy(true)++ try {+ const params = force ? { force: true } : { viewer_id: viewer?.id }+ const result = await displayRequest<{ lease: DisplayLease }>(bot, 'display.lease.release', params)+ setScreenLease(bot, result.lease)+ } catch (err) {+ setError(err instanceof Error ? err.message : String(err))+ } finally {+ setBusy(false)+ }+ },+ [bot, viewer?.id]+ )if (state?.unavailable) {return <EmptyState description={t.screen.portalUnavailable} title={t.screen.unavailableTitle} />@@ -319,9 +326,16 @@ export function BotScreenPane({ bot }: { bot: RosterRow }) {<Codicon name="debug-continue" /> {t.screen.handBack}</Button>) : (- <Button disabled={busy || conn === 'attaching'} onClick={() => void takeOver()} size="sm">- <Codicon name="record-keys" /> {t.screen.takeOver}- </Button>+ <>+ {humanOther ? (+ <Button disabled={busy} onClick={() => void handBack(true)} size="sm" title={t.screen.handBackForceHint} variant="secondary">+ <Codicon name="debug-continue" /> {t.screen.handBackForce}+ </Button>+ ) : null}+ <Button disabled={busy || conn === 'attaching'} onClick={() => void takeOver()} size="sm">+ <Codicon name="record-keys" /> {t.screen.takeOver}+ </Button>+ </>)}<Button disabled={conn === 'attaching'} onClick={() => void attach()} size="sm" title={t.screen.reconnect} variant="ghost"><Codicon name="refresh" />diff --git a/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsx b/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsxindex 2eeb0c32e21..04a782af7eb 100644--- a/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/screen-viewer-identity.test.tsx@@ -35,6 +35,8 @@ vi.mock('./i18n', () => ({otherControls: 'Other controls',agentControls: 'Bot controls',handBack: 'Hand back',+ handBackForce: 'Hand back (force)',+ handBackForceHint: 'Force',takeOver: 'Take over',reconnect: 'Reconnect',streamLost: 'Stream lost'@@ -133,3 +135,19 @@ it('hands back with the minted id, never a client-generated one', async () => {expect(vi.mocked(displayRequest)).toHaveBeenCalledWith(bot, 'display.lease.release', { viewer_id: MINTED })view.unmount()})++it('offers a forced hand-back for a human lease this window does not hold, sending {force: true} and no viewer id', async () => {+ const view = render(<BotScreenPane bot={bot} />)+ await waitFor(() => expect(vi.mocked(displayRequest)).toHaveBeenCalledWith(bot, 'display.observe'))+ await act(async () => {})++ emitLease(await viewerHash(MINTED))+ expect(view.queryByText('Hand back (force)')).toBeNull()++ emitLease(await viewerHash('viewer-from-before-the-reload'))+ await act(async () => {+ view.getByText('Hand back (force)').click()+ })+ expect(vi.mocked(displayRequest)).toHaveBeenCalledWith(bot, 'display.lease.release', { force: true })+ view.unmount()+})