feat(hermes): launch dashboard from toolbar when Web UI is offline

When the Hermes Web UI probe fails, the toolbar entry now opens an info
confirm dialog offering to run `hermes dashboard` in the user's preferred
terminal. Accepting spawns it via a temp bash/batch script; `hermes
dashboard` itself opens the browser once ready, so we do not poll.
The Memory panel and Health banner keep the existing toast behavior.

Also corrects the stale `hermes web` hint in the offline toast (the real
command is `hermes dashboard`) and reorders Linux terminal detection to
try `which` before stat'ing /usr/bin, /bin, /usr/local/bin.
This commit is contained in:
Jason
2026-04-21 21:11:15 +08:00
parent 38709c94db
commit 8e9452b7ec
9 changed files with 259 additions and 12 deletions
+10 -5
View File
@@ -155,10 +155,11 @@ export function useToggleHermesMemoryEnabled() {
/**
* Returns a handler that probes the local Hermes Web UI, opens it in the
* system browser, and surfaces a localized toast on failure. Callers only
* need to wire the returned function to a click handler.
* system browser, and surfaces a localized toast on failure. When
* `onOffline` is provided, it replaces the default offline toast —
* callers can use this to open a launch-dashboard confirm dialog instead.
*/
export function useOpenHermesWebUI() {
export function useOpenHermesWebUI(onOffline?: () => void) {
const { t } = useTranslation();
return useCallback(
async (path?: string) => {
@@ -167,7 +168,11 @@ export function useOpenHermesWebUI() {
} catch (error) {
const detail = extractErrorMessage(error);
if (detail === HERMES_WEB_OFFLINE_ERROR) {
toast.error(t("hermes.webui.offline"));
if (onOffline) {
onOffline();
} else {
toast.error(t("hermes.webui.offline"));
}
} else {
toast.error(t("hermes.webui.openFailed"), {
description: detail || undefined,
@@ -175,6 +180,6 @@ export function useOpenHermesWebUI() {
}
}
},
[t],
[t, onOffline],
);
}