From 2de05d9ca6022c4089be3724e87b2a62ce71f6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Mon, 13 Apr 2026 04:28:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Hermes=20setup=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=90=8E=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E5=BC=95=E6=93=8E?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=B9=B6=E8=B7=B3=E8=BD=AC=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - detectHermesStatus 每次调用前清除 check_hermes 缓存,确保拿到最新数据 - setup 向导检测到已安装+Gateway 运行中时,自动调用 engine.detect() 更新 _ready - refreshHermes 同样清缓存+自动跳转,覆盖安装/配置/启动后的刷新场景 - 修复 sidebar 停留在"初始设置"的问题 --- src/engines/hermes/index.js | 3 ++- src/engines/hermes/pages/setup.js | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/engines/hermes/index.js b/src/engines/hermes/index.js index 83393f5..6bd6048 100644 --- a/src/engines/hermes/index.js +++ b/src/engines/hermes/index.js @@ -2,7 +2,7 @@ * Hermes Agent 引擎 */ import { t } from '../../lib/i18n.js' -import { api } from '../../lib/tauri-api.js' +import { api, invalidate } from '../../lib/tauri-api.js' // Hermes 状态 let _ready = false @@ -12,6 +12,7 @@ let _pollTimer = null async function detectHermesStatus() { try { + invalidate('check_hermes') const info = await api.checkHermes() _ready = !!info?.installed && !!info?.configExists _running = !!info?.gatewayRunning diff --git a/src/engines/hermes/pages/setup.js b/src/engines/hermes/pages/setup.js index 8cfd09d..a5cd2a9 100644 --- a/src/engines/hermes/pages/setup.js +++ b/src/engines/hermes/pages/setup.js @@ -4,7 +4,7 @@ * 状态机: detect → install → configure → gateway → complete */ import { t } from '../../../lib/i18n.js' -import { api } from '../../../lib/tauri-api.js' +import { api, invalidate } from '../../../lib/tauri-api.js' import { PROVIDER_PRESETS } from '../../../lib/model-presets.js' import { getActiveEngine } from '../../../lib/engine-manager.js' @@ -349,6 +349,7 @@ export function render() { phase = 'detect' draw() try { + invalidate('check_hermes', 'check_python') const [py, hm] = await Promise.all([api.checkPython(), api.checkHermes()]) pyInfo = py hermesInfo = hm @@ -359,6 +360,11 @@ export function render() { await new Promise(r => setTimeout(r, 800)) if (hm.installed && hm.gatewayRunning) { phase = 'complete' + // 更新引擎状态并自动跳转仪表盘 + const engine = getActiveEngine() + if (engine?.detect) await engine.detect() + window.location.hash = '#/h/dashboard' + return } else if (hm.installed && hm.configExists) { phase = 'gateway' } else if (hm.installed) { @@ -552,7 +558,16 @@ export function render() { // --- 刷新 hermes 状态 --- async function refreshHermes() { + invalidate('check_hermes') try { hermesInfo = await api.checkHermes() } catch (_) {} + // 已安装且 Gateway 在运行 → 更新引擎状态并跳转仪表盘 + if (hermesInfo?.installed && hermesInfo?.gatewayRunning) { + phase = 'complete' + const engine = getActiveEngine() + if (engine?.detect) await engine.detect() + window.location.hash = '#/h/dashboard' + return + } draw() }