fix: Hermes setup 完成后自动更新引擎状态并跳转仪表盘

- detectHermesStatus 每次调用前清除 check_hermes 缓存,确保拿到最新数据
- setup 向导检测到已安装+Gateway 运行中时,自动调用 engine.detect() 更新 _ready
- refreshHermes 同样清缓存+自动跳转,覆盖安装/配置/启动后的刷新场景
- 修复 sidebar 停留在"初始设置"的问题
This commit is contained in:
晴天
2026-04-13 04:28:18 +08:00
parent a69d0404ac
commit 2de05d9ca6
2 changed files with 18 additions and 2 deletions

View File

@@ -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

View File

@@ -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()
}