The pane, in-app browser, and reaction tools were gated on HERMES_DESKTOP=1 — an env var set only on backends Electron spawns itself (local and SSH). A desktop client connected to a plain URL gateway or Hermes Cloud lost all six: they were stripped from the schema before the model saw them, on the same backend whose platform hint was telling it "you are chatting inside the Hermes desktop app". open_preview, read_preview, read_terminal, close_terminal, focus_pane, and react_to_message were all silently absent. The client is not the host. Capability now resolves from the session's own source, which session.create already carries: - The six tools move into a `desktop_ui` toolset, off _HERMES_CORE_TOOLS so no other platform pays their schema. - _gui_surface_toolsets(platform) folds `desktop_ui` (and the existing `project` tools) into the GUI gateway's resolution when the session's platform is the desktop app — the same answer on every topology. - check_fn drops the env probe. It kept the one thing that is genuinely a per-process/user fact: react_to_message's display.message_reactions opt-in, which the desktop mirrors onto whichever gateway it is connected to. react_to_message was doubly broken: it read that toggle behind the env gate, so even a local-backend user's Settings toggle could not reach a remote session. The embedded terminal pane keeps working correctly the other way round: it runs `hermes --tui` against a desktop-spawned backend, and a tui-sourced session gets no GUI tools even though HERMES_DESKTOP=1 is set on that process.
36 lines
1002 B
Python
36 lines
1002 B
Python
"""Tests for the GUI-surface ``open_preview`` tool."""
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from tools import desktop_ui, open_preview_tool as op
|
|
from tools.registry import registry
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _reset_emitter():
|
|
"""Each test controls the emitter; never leak one across tests."""
|
|
desktop_ui.set_emitter(None)
|
|
yield
|
|
desktop_ui.set_emitter(None)
|
|
|
|
|
|
def test_lives_in_the_gui_surface_toolset(monkeypatch):
|
|
"""Reaches a desktop client on ANY backend, including one with no
|
|
HERMES_DESKTOP in its environment (URL / cloud gateways)."""
|
|
monkeypatch.delenv("HERMES_DESKTOP", raising=False)
|
|
entry = registry.get_entry("open_preview")
|
|
|
|
assert entry is not None
|
|
assert entry.toolset == "desktop_ui"
|
|
assert entry.check_fn is None
|
|
|
|
|
|
def test_emitter_failure_is_reported():
|
|
def _boom(*_a):
|
|
raise RuntimeError("no window")
|
|
|
|
desktop_ui.set_emitter(_boom)
|
|
assert "no window" in json.loads(op.open_preview_tool("https://x.example"))["error"]
|