The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep slow plugin installs from reporting false failure (#121856)
Gille8623cd4a8403
diff --git a/apps/desktop/src/app/settings/plugin-install-modal.test.tsx b/apps/desktop/src/app/settings/plugin-install-modal.test.tsxindex 1545c406f3f..f5a7e614e7d 100644--- a/apps/desktop/src/app/settings/plugin-install-modal.test.tsx+++ b/apps/desktop/src/app/settings/plugin-install-modal.test.tsx@@ -148,7 +148,8 @@ describe('Install from Git entry flow', () => {await waitFor(() =>expect(requestGateway).toHaveBeenCalledWith('plugins.manage',- expect.objectContaining({ action: 'install', catalog_name: 'plugin', profile: 'research' })+ expect.objectContaining({ action: 'install', catalog_name: 'plugin', profile: 'research' }),+ expect.any(Number)))})@@ -171,7 +172,8 @@ describe('Install from Git entry flow', () => {await waitFor(() =>expect(requestGateway).toHaveBeenCalledWith('plugins.manage',- expect.objectContaining({ action: 'install', ref: sha.toLowerCase() })+ expect.objectContaining({ action: 'install', ref: sha.toLowerCase() }),+ expect.any(Number)))})@@ -185,7 +187,9 @@ describe('Unified package desktop half on a local backend', () => {$connection.set({ mode } as NonNullable<ReturnType<typeof $connection.get>>)probePluginRepo.mockResolvedValue({ ok: true, agent: true, agentName: 'pkg', desktop: true, warnings: [] })requestGateway.mockImplementation(async (method, params) =>- method === 'plugins.manage' && params?.action === 'install' ? { ok: false, error: alreadyExists } : { plugins: [] }+ method === 'plugins.manage' && params?.action === 'install'+ ? { ok: false, error: alreadyExists }+ : { plugins: [] })installDesktopPlugin.mockResolvedValue({ ok: true, pluginName: 'pkg' })vi.stubGlobal('hermesDesktop', { installDesktopPlugin, probePluginRepo, reconcileDesktopPlugins })@@ -194,7 +198,11 @@ describe('Unified package desktop half on a local backend', () => {expect(await screen.findByText('This package includes')).toBeTruthy()fireEvent.click(screen.getByRole('button', { name: 'Install' }))await waitFor(() =>- expect(requestGateway).toHaveBeenCalledWith('plugins.manage', expect.objectContaining({ action: 'install' }))+ expect(requestGateway).toHaveBeenCalledWith(+ 'plugins.manage',+ expect.objectContaining({ action: 'install' }),+ expect.any(Number)+ ))expect(await screen.findByText(alreadyExists)).toBeTruthy()}@@ -218,4 +226,24 @@ describe('Unified package desktop half on a local backend', () => {expect(installDesktopPlugin).toHaveBeenCalledWith({ identifier: 'https://github.com/example/pkg', force: false })expect(reconcileDesktopPlugins).not.toHaveBeenCalled()})++ it('does not start the desktop half or offer a retry when the agent install outcome is unknown', async () => {+ $connection.set({ mode: 'remote' } as NonNullable<ReturnType<typeof $connection.get>>)+ requestGateway.mockImplementation(async (method, params) => {+ if (method === 'plugins.manage' && params?.action === 'install') {+ throw new Error('request timed out after 120s: plugins.manage')+ }++ return { plugins: [] }+ })+ renderFlow()+ act(() => openPluginInstallRequest({ repo: 'https://github.com/example/pkg' }))+ expect(await screen.findByText('This package includes')).toBeTruthy()+ fireEvent.click(screen.getByRole('button', { name: 'Install' }))++ const status = await screen.findByRole('status')+ expect(status.textContent).toContain('may still be installing')+ expect(installDesktopPlugin).not.toHaveBeenCalled()+ expect((screen.getByRole('button', { name: 'Install' }) as HTMLButtonElement).disabled).toBe(true)+ })})diff --git a/apps/desktop/src/app/settings/plugin-install-modal.tsx b/apps/desktop/src/app/settings/plugin-install-modal.tsxindex 5637323a4b3..4b6d9116260 100644--- a/apps/desktop/src/app/settings/plugin-install-modal.tsx+++ b/apps/desktop/src/app/settings/plugin-install-modal.tsx@@ -75,6 +75,7 @@ export function PluginInstallModal() {const [pinRef, setPinRef] = useState('')const [installing, setInstalling] = useState(false)const [installError, setInstallError] = useState<string | null>(null)+ const [installUncertain, setInstallUncertain] = useState(false)const probeToken = useRef(0)const resetState = useCallback(() => {@@ -88,6 +89,7 @@ export function PluginInstallModal() {setPinRef('')setInstalling(false)setInstallError(null)+ setInstallUncertain(false)}, [])const applyLegacyHint = useCallback((payload: PluginInstallRequest, detected: ProbeResult) => {@@ -109,6 +111,7 @@ export function PluginInstallModal() {setPhase('probing')setProbe(null)setInstallError(null)+ setInstallUncertain(false)// Reviewed catalog picks streamline the ceremony: enable defaults ON// (installing a reviewed entry to not use it is the rare case).setEnableAgent(payload.enable ?? true)@@ -203,7 +206,7 @@ export function PluginInstallModal() {}const handleInstall = async () => {- if (!request || !probe?.ok || installing) {+ if (!request || !probe?.ok || installing || installUncertain) {return}@@ -215,6 +218,7 @@ export function PluginInstallModal() {setInstalling(true)setInstallError(null)+ setInstallUncertain(false)const errors: string[] = []const successes: string[] = []@@ -260,6 +264,15 @@ export function PluginInstallModal() {for (const warning of result.warnings ?? []) {notify({ kind: 'warning', message: warning })}+ } else if (result.timedOut) {+ // A client timeout does not cancel the backend install. Do not clone+ // the desktop half or offer a retry while the package may still be+ // installing. A read-only list refresh can show an already landed+ // package; the user can rescan later if the backend is still busy.+ setInstallUncertain(true)+ void loadAgentPlugins(requestGateway, targetProfile)++ return} else {errors.push(result.error || m.agentFailed)}@@ -566,6 +579,14 @@ export function PluginInstallModal() {{installError}</p>)}+ {installUncertain && (+ <p+ className="text-[length:var(--conversation-caption-font-size)] text-(--ui-text-secondary)"+ role="status"+ >+ {m.installUncertain}+ </p>+ )}</div>)}@@ -579,7 +600,7 @@ export function PluginInstallModal() {</Button>) : (<Button- disabled={busy || phase !== 'ready' || !probe?.ok || pinRefInvalid}+ disabled={busy || installUncertain || phase !== 'ready' || !probe?.ok || pinRefInvalid}onClick={() => void handleInstall()}>{installing ? m.installing : m.install}diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 69ec70f0ff0..e103815f96c 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -540,6 +540,8 @@ export const ar = defineLocale({empty: 'لا توجد إضافات سطح مكتب مثبتة بعد.',kinds: { bundled: 'مضمّنة', disk: 'على القرص', runtime: 'وقت التشغيل' },installModal: {+ installUncertain:+ 'توقف Hermes عن انتظار نتيجة التثبيت، لكن قد يستمر تثبيت المكوّن الإضافي. أغلق هذه النافذة وأعد فحص قائمة المكوّنات الإضافية قبل محاولة التثبيت مرة أخرى.',toolsConnected: n => `تم توصيل ${n} من الأدوات`,skillsReady: names => (names.length === 1 ? `المهارة ${names[0]} جاهزة` : `${names.length} من المهارات جاهزة`),nextChat: 'أدوات أخرى متاحة في دردشتك التالية',diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 76a4d810ed3..4d31fcc61d3 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -909,6 +909,8 @@ export const deOverrides = {agentSuccess: name => `Agent-Plugin ${name} installiert`,desktopSuccess: name => `Desktop-Plugin ${name} installiert`,agentFailed: 'Installation des Agent-Plugins fehlgeschlagen',+ installUncertain:+ 'Hermes wartet nicht mehr auf das Installationsergebnis, aber das Plugin wird möglicherweise noch installiert. Schließe dieses Fenster und aktualisiere die Pluginliste, bevor du die Installation erneut startest.',desktopFailed: 'Installation des Desktop-Plugins fehlgeschlagen',missingEnv: (name, vars) =>`${name} ist installiert, benötigt aber einen Schlüssel, um zu funktionieren: ${vars}. Fügen Sie ihn jetzt hinzu, sonst schlagen die Tools des Plugins fehl.`diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 03fc35cb6ae..8c5e95e8ac0 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -899,6 +899,8 @@ export const en: Translations = {agentSuccess: name => `Agent plugin ${name} installed`,desktopSuccess: name => `Desktop plugin ${name} installed`,agentFailed: 'Agent plugin install failed',+ installUncertain:+ 'Hermes stopped waiting for the install result, but the plugin may still be installing. Close this dialog and use Rescan in Plugins before trying Install again.',desktopFailed: 'Desktop plugin install failed',missingEnv: (name, vars) =>`${name} is installed but needs a key before it can work: ${vars}. Add it now, or the plugin's tools will fail.`diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex a67ba6933ba..a490cc9ae80 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -909,6 +909,8 @@ export const esOverrides = {agentSuccess: name => `Plugin del agente ${name} instalado`,desktopSuccess: name => `Plugin de escritorio ${name} instalado`,agentFailed: 'Error al instalar el plugin del agente',+ installUncertain:+ 'Hermes dejó de esperar el resultado de la instalación, pero es posible que el plugin siga instalándose. Cierra este cuadro y actualiza la lista de plugins antes de volver a instalarlo.',desktopFailed: 'Error al instalar el plugin de escritorio',missingEnv: (name, vars) =>`${name} está instalado, pero necesita una clave para funcionar: ${vars}. Añádela ahora o las herramientas del plugin fallarán.`diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex 92622644afd..03f5378e30d 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -910,6 +910,8 @@ export const frOverrides = {agentSuccess: name => `Plugin de l'agent ${name} installé`,desktopSuccess: name => `Plugin Desktop ${name} installé`,agentFailed: "Échec de l'installation du plugin de l'agent",+ installUncertain:+ "Hermes n'attend plus le résultat de l'installation, mais le plugin est peut-être encore en cours d'installation. Fermez cette fenêtre et actualisez la liste des plugins avant de relancer l'installation.",desktopFailed: "Échec de l'installation du plugin Desktop",missingEnv: (name, vars) =>`${name} est installé, mais a besoin d'une clé pour fonctionner : ${vars}. Ajoutez-la maintenant, sinon les outils du plugin échoueront.`diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 2e41d12f7b2..99c945be0ae 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -401,6 +401,8 @@ export const ja = defineLocale({plugins: {openFolder: 'デスクトッププラグインフォルダーを開く',installModal: {+ installUncertain:+ 'Hermes はインストール結果の待機を終了しましたが、プラグインのインストールはまだ進行中の可能性があります。この画面を閉じ、再インストールする前にプラグイン一覧を再スキャンしてください。',installFromGit: 'Git からインストール',reviewRepository: 'リポジトリを確認',repoPlaceholder: 'https://github.com/owner/repo',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex 1b3a44cb2f5..d87068ad99c 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -536,6 +536,8 @@ export const ru = defineLocale({agentSuccess: name => `Плагин агента ${name} установлен`,desktopSuccess: name => `Плагин приложения ${name} установлен`,agentFailed: 'Не удалось установить плагин агента',+ installUncertain:+ 'Hermes перестал ждать результат установки, но плагин может всё ещё устанавливаться. Закройте это окно и обновите список плагинов перед повторной установкой.',desktopFailed: 'Не удалось установить плагин приложения',missingEnv: (_name, vars) => `Не хватает переменных окружения: ${vars}. Добавьте их в Настройки → Ключи.`,toolsConnected: n => `Подключено инструментов: ${n}`,diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 7e417033ae3..cd3242eb801 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -761,6 +761,7 @@ export interface Translations {agentSuccess: (name: string) => stringdesktopSuccess: (name: string) => stringagentFailed: string+ installUncertain: stringdesktopFailed: stringmissingEnv: (name: string, vars: string) => string}diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 6e82484286e..475f3bb339c 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -360,6 +360,7 @@ export const zhHant = defineLocale({plugins: {openFolder: '開啟桌面外掛資料夾',installModal: {+ installUncertain: 'Hermes 已停止等待安裝結果,但外掛可能仍在安裝中。請關閉此視窗,重新掃描外掛清單後再嘗試安裝。',installFromGit: '從 Git 安裝',reviewRepository: '檢查儲存庫',repoPlaceholder: 'https://github.com/owner/repo',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 8bf7eb1578d..bb4d81e38b7 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -676,6 +676,7 @@ export const zh = defineLocale({agentSuccess: name => `智能体插件 ${name} 已安装`,desktopSuccess: name => `桌面插件 ${name} 已安装`,agentFailed: '智能体插件安装失败',+ installUncertain: 'Hermes 已停止等待安装结果,但插件可能仍在安装。关闭此窗口并刷新插件列表,然后再尝试安装。',desktopFailed: '桌面插件安装失败',missingEnv: (_name, vars) => `缺少环境变量:${vars}。请在设置 → 密钥中添加。`}diff --git a/apps/desktop/src/store/agent-plugins.test.ts b/apps/desktop/src/store/agent-plugins.test.tsindex 91535133e03..3c9162f35c4 100644--- a/apps/desktop/src/store/agent-plugins.test.ts+++ b/apps/desktop/src/store/agent-plugins.test.ts@@ -1,8 +1,9 @@-import { describe, expect, it, vi } from 'vitest'+import { afterEach, describe, expect, it, vi } from 'vitest'import {$agentPlugins,type AgentPluginRow,+ installAgentPlugin,isDesktopRelevantPlugin,normalizeAgentPluginRow,saveAgentPluginSettings@@ -11,6 +12,51 @@ import {const row = (partial: Partial<AgentPluginRow>): AgentPluginRow =>({ name: partial.key ?? 'x', status: 'enabled', ...partial }) as AgentPluginRow+afterEach(() => vi.useRealTimers())++describe('installAgentPlugin', () => {+ it('waits for a slow successful install instead of reporting the generic 30s timeout', async () => {+ vi.useFakeTimers()++ const request = vi.fn(+ <T>(_method: string, _params?: Record<string, unknown>, timeoutMs = 30_000): Promise<T> =>+ new Promise((resolve, reject) => {+ const deadline = setTimeout(+ () => reject(new Error(`request timed out after ${timeoutMs / 1000}s: plugins.manage`)),+ timeoutMs+ )++ setTimeout(() => {+ clearTimeout(deadline)+ resolve({ ok: true, plugin_name: 'demo' } as T)+ }, 45_000)+ })+ )++ const install = installAgentPlugin(request as never, { identifier: 'demo', profile: 'research' })++ await vi.advanceTimersByTimeAsync(45_000)++ expect(await install).toMatchObject({ ok: true, pluginName: 'demo' })+ expect(request).toHaveBeenCalledWith(+ 'plugins.manage',+ expect.objectContaining({ action: 'install', profile: 'research' }),+ expect.any(Number)+ )+ })++ it('marks a client timeout as an unknown install outcome', async () => {+ const request = vi.fn(async () => {+ throw new Error('request timed out after 120s: plugins.manage')+ })++ expect(await installAgentPlugin(request as never, { identifier: 'demo' })).toMatchObject({+ ok: false,+ timedOut: true+ })+ })+})+describe('normalizeAgentPluginRow', () => {it('treats an absent servers field as an empty full snapshot', () => {const previous = normalizeAgentPluginRow(diff --git a/apps/desktop/src/store/agent-plugins.ts b/apps/desktop/src/store/agent-plugins.tsindex 3a2f3b1e04a..01675a845ad 100644--- a/apps/desktop/src/store/agent-plugins.ts+++ b/apps/desktop/src/store/agent-plugins.ts@@ -91,7 +91,7 @@ export const COMMIT_SHA_RE = /^[0-9a-f]{40}$/iexport type AgentPluginsStatus = 'idle' | 'loading' | 'ready' | 'error'/** The recovering `requestGateway` from `useGatewayRequest`. */-export type GatewayRequest = <T>(method: string, params?: Record<string, unknown>) => Promise<T>+export type GatewayRequest = <T>(method: string, params?: Record<string, unknown>, timeoutMs?: number) => Promise<T>export const $agentPlugins = atom<AgentPluginRow[]>([])export const $agentPluginsStatus = atom<AgentPluginsStatus>('idle')@@ -237,6 +237,8 @@ export async function toggleAgentPlugin(export interface AgentPluginInstallResult {ok: boolean+ /** The client stopped waiting; the backend may still finish the install. */+ timedOut?: booleanpluginName?: stringwarnings?: string[]missingEnv?: string[]@@ -261,6 +263,12 @@ export interface AgentPluginLiveNow {const NO_LIVE: AgentPluginLiveNow = { mcpServers: [], skills: [] }+// Installing a catalog package can clone a repository and resolve Python dependencies.+// The ordinary Desktop RPC deadline is 30s, which can expire after the backend+// has already begun an install that will succeed. Keep this wait bounded while+// giving normal installs time to return their authoritative result.+const PLUGIN_INSTALL_REQUEST_TIMEOUT_MS = 120_000+export async function installAgentPlugin(request: GatewayRequest,opts: {@@ -302,7 +310,8 @@ export async function installAgentPlugin(...(opts.ref ? { ref: opts.ref } : {})},opts.profile- )+ ),+ PLUGIN_INSTALL_REQUEST_TIMEOUT_MS)if (!result?.ok) {@@ -322,9 +331,12 @@ export async function installAgentPlugin(nextChat: Object.keys(result.activation?.deferred ?? {}).length > 0}} catch (e) {+ const message = e instanceof Error ? e.message : String(e)+return {ok: false,- error: e instanceof Error ? e.message : String(e),+ timedOut: /^request timed out after \d+s: plugins\.manage$/.test(message),+ error: message,live: NO_LIVE,nextChat: false}