Files
hermes-webui/tests/test_profile_terminal_env.py
T
nesquena-hermes 33a145a669 release: v0.50.240
## Release v0.50.240

Batch release of 13 PRs that passed full triage + code review + test suite (3199 tests, 0 failures).

---

### Added

- **Compact tool activity mode** (`simplified_tool_calling`, default on) — groups tool calls and thinking traces into a single collapsed "Activity" disclosure card per assistant turn. Also adds a new **Calm Console** theme with earth/slate palette and serif prose. @Michaelyklam — #1282
- **PDF first-page preview** — `MEDIA:` `.pdf` files render a canvas thumbnail via PDF.js CDN (4 MB cap). **HTML sandbox iframe** — `.html`/`.htm` files render inline in a sandboxed `<iframe srcdoc>` (256 KB cap). 10 i18n keys × 7 locales. @bergeouss — #1280, closes #480 #482
- **Inline Excalidraw diagram preview** — `.excalidraw` files render as pure SVG (no external deps; rectangles, ellipses, diamonds, text, lines, arrows, freehand; 512 KB cap). @bergeouss — #1279, closes #479
- **Inline CSV table rendering** — fenced `csv` blocks and `MEDIA:` CSV files render as scrollable HTML tables with auto-separator detection. @bergeouss — #1277, closes #485
- **Inline SVG, audio, and video rendering** — SVG as `<img>`, audio as `<audio controls>`, video as `<video controls>`. @bergeouss — #1276, closes #481
- **Batch session select mode** — multi-select sessions for bulk Archive/Delete/Move. 11 i18n keys × 7 locales. @bergeouss — #1275, closes #568
- **Collapsible skill category headers** — click to collapse/expand without re-render; state persists across filter cycles. @bergeouss — #1281
- **`providers.only_configured` setting** — opt-in flag to restrict the model picker to explicitly configured providers. @KingBoyAndGirl — #1268
- **OpenCode Go model catalog** — adds Kimi K2.6, DeepSeek V4 Pro/Flash, MiMo V2.5/Pro, Qwen3.6/3.5 Plus. @nesquena-hermes — #1284, closes #1269

### Fixed

- **Profile `TERMINAL_CWD` TypeError** — `_build_agent_thread_env()` helper merges env before `_set_thread_env()` call. @hi-friday — #1266
- **Service worker subpath cache bypass** — regex now matches `/api/*` under any mount prefix. @Michaelyklam — #1278
- **SSE client disconnect leaks** — `TimeoutError`/`OSError` treated as clean disconnects; server backlog 64, threads daemonized; session list renders before saved-session restore. @KayZz69 — #1267
- **i18n locale corrections** — Korean MCP strings (23), Chinese MCP strings (23), zh-Hant missing keys (41), de missing keys (229). @bergeouss — #1274, closes #1273

---

### Test results

```
3199 passed, 2 skipped, 3 xpassed in 72.79s
```

### PRs on hold (not included)

#1265 (draft), #1271 (superseded by #1266), #1272 (skipped XSS tests), #1232 (partial test run), #1222 (review questions open), #1134 (live-server tests), #1132 (superseded by #1134), #1108 (negative UX review), #1084 (empty description)
2026-04-29 17:42:32 -07:00

94 lines
3.0 KiB
Python

import os
import re
from pathlib import Path
import yaml
def test_profile_runtime_env_includes_terminal_config_and_dotenv(tmp_path):
from api.profiles import get_profile_runtime_env
home = tmp_path / "profiles" / "server-ops"
home.mkdir(parents=True)
(home / "config.yaml").write_text(
yaml.safe_dump(
{
"terminal": {
"backend": "ssh",
"cwd": "/home/dso2ng/repos",
"timeout": 180,
"ssh_host": "pollux",
"ssh_user": "dso2ng",
"persistent_shell": True,
"lifetime_seconds": 300,
}
},
sort_keys=False,
),
encoding="utf-8",
)
(home / ".env").write_text(
"TERMINAL_TIMEOUT=60\n"
"TERMINAL_SSH_HOST=pollux-from-env\n"
"HERMES_MAX_ITERATIONS=90\n",
encoding="utf-8",
)
env = get_profile_runtime_env(home)
assert env["TERMINAL_ENV"] == "ssh"
assert env["TERMINAL_CWD"] == "/home/dso2ng/repos"
assert env["TERMINAL_SSH_USER"] == "dso2ng"
assert env["TERMINAL_PERSISTENT_SHELL"] == "true"
assert env["TERMINAL_LIFETIME_SECONDS"] == "300"
# .env remains the final override source, matching CLI/profile behaviour.
assert env["TERMINAL_TIMEOUT"] == "60"
assert env["TERMINAL_SSH_HOST"] == "pollux-from-env"
assert env["HERMES_MAX_ITERATIONS"] == "90"
def test_streaming_applies_profile_runtime_env_to_agent_run():
src = Path("api/streaming.py").read_text(encoding="utf-8")
assert "get_profile_runtime_env" in src
assert "_profile_runtime_env" in src
assert "old_profile_env" in src
assert "os.environ.update(_profile_runtime_env)" in src
def test_streaming_thread_env_allows_profile_terminal_cwd_override():
src = Path("api/streaming.py").read_text(encoding="utf-8")
assert "def _build_agent_thread_env" in src
assert "_thread_env = _build_agent_thread_env(" in src
assert "_set_thread_env(**_thread_env)" in src
assert "_set_thread_env(\n **_profile_runtime_env,\n TERMINAL_CWD" not in src
match = re.search(
r"(def _build_agent_thread_env\(.*?\n)(?=\ndef |\nclass )",
src,
re.DOTALL,
)
assert match, "_build_agent_thread_env not found in api/streaming.py"
ns: dict = {}
exec(compile(match.group(1), "<streaming_extract>", "exec"), ns)
env = ns["_build_agent_thread_env"](
{
"TERMINAL_CWD": "/profile/config/cwd",
"HERMES_EXEC_ASK": "0",
"HERMES_SESSION_KEY": "old-session",
"HERMES_HOME": "/old/profile/home",
"TERMINAL_ENV": "ssh",
},
"/active/workspace",
"active-session",
"/active/profile/home",
)
assert env["TERMINAL_CWD"] == "/active/workspace"
assert env["HERMES_EXEC_ASK"] == "1"
assert env["HERMES_SESSION_KEY"] == "active-session"
assert env["HERMES_HOME"] == "/active/profile/home"
assert env["TERMINAL_ENV"] == "ssh"