Skip to content

feat(tui): port classic CLI /reload (.env hot-reload) to TUI#17129

Closed
OutThisLife wants to merge 3 commits into
mainfrom
bb/tui-reload-env
Closed

feat(tui): port classic CLI /reload (.env hot-reload) to TUI#17129
OutThisLife wants to merge 3 commits into
mainfrom
bb/tui-reload-env

Conversation

@OutThisLife

@OutThisLife OutThisLife commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Classic CLI exposes /reload (re-reads ~/.hermes/.env into os.environ via hermes_cli.config.reload_env) so newly added API keys take effect without restarting the session. The TUI was missing the parity command, so users had to Ctrl+C out and re-run hermes --tui whenever they added or rotated a credential.

This brings the TUI to parity with the classic CLI surface.

Changes

  • New reload.env JSON-RPC method in tui_gateway/server.py that delegates to hermes_cli.config.reload_env and reports { updated: <count> }.
  • New /reload slash command in ui-tui/src/app/slash/commands/ops.ts, matching the existing /reload-mcp pattern (native RPC, no slash worker).
  • CommandDef("reload", ..., cli_only=True) is kept. cli_only only excludes a command from the messaging-gateway dispatcher (GATEWAY_KNOWN_COMMANDS); it does NOT remove it from COMMANDS (which feeds TUI complete.slash autocomplete) or from the TUI's own SLASH_COMMANDS registry. gateway/run.py has no handler for /reload, so flipping the flag would silently forward the literal /reload text to the LLM in Slack/Discord/Telegram. Native TUI slash + native RPC is the right path for this command.

Caveat (matches classic CLI)

The currently constructed agent's credential pool and provider routing don't auto-rebuild. Users who want a brand-new credential resolution should follow with /new.

Test plan

  • scripts/run_tests.sh tests/test_tui_gateway_server.py92/92 pass (2 new).
  • scripts/run_tests.sh tests/hermes_cli/test_commands.py128/128 pass.
  • npm run type-check clean (in ui-tui/).
  • npm test -- --run390/390 pass, slash-parity matrix extended with ['/reload', 'reload.env', {}].

Refs

Audit High #1 (asheriif): "Incomplete configuration hot-reload". Closes the visible parity gap between classic CLI and TUI for .env reloading.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 28, 2026
@OutThisLife OutThisLife requested review from Copilot and teknium1 and removed request for teknium1 April 28, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds /reload support to the TUI so users can hot-reload ~/.hermes/.env (API keys/credentials) without restarting, matching classic CLI behavior.

Changes:

  • Add reload.env JSON-RPC method in tui_gateway/server.py delegating to hermes_cli.config.reload_env.
  • Add TUI /reload slash command wiring to reload.env, plus TS response typing.
  • Update command registry metadata and extend test coverage for the new RPC + slash routing.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ui-tui/src/gatewayTypes.ts Adds ReloadEnvResponse type for the new RPC response shape.
ui-tui/src/app/slash/commands/ops.ts Implements /reload to call reload.env and report updated var count.
ui-tui/src/tests/createSlashHandler.test.ts Extends native-RPC slash routing matrix to include /reload.
tui_gateway/server.py Adds @method("reload.env") handler that calls hermes_cli.config.reload_env().
tests/test_tui_gateway_server.py Adds tests verifying reload.env calls into hermes_cli.config.reload_env and surfaces errors.
hermes_cli/commands.py Makes /reload no longer cli_only, affecting gateway-visible command surfaces.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hermes_cli/commands.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tui_gateway/server.py Outdated
Comment thread tui_gateway/server.py
Classic CLI exposes ``/reload`` (re-reads ~/.hermes/.env into
``os.environ`` via ``hermes_cli.config.reload_env``) so newly added API
keys take effect without restarting the session.  The TUI was missing
the parity command, so users had to Ctrl+C out and ``hermes --tui``
again whenever they added or rotated a credential.

Three small wires:

* New ``reload.env`` JSON-RPC method in ``tui_gateway/server.py`` that
  delegates to ``hermes_cli.config.reload_env`` and returns the count
  of vars updated.
* New ``/reload`` slash command in ``ui-tui/src/app/slash/commands/ops.ts``
  matching the existing ``/reload-mcp`` pattern (native RPC, no slash
  worker).
* Drop ``cli_only=True`` from the ``reload`` ``CommandDef`` in
  ``hermes_cli/commands.py`` so help/menus surface it in the TUI too.
  ``reload_env`` itself is environment-agnostic.

Same caveat as classic CLI: the *currently constructed* agent's
credential pool / provider routing does not auto-rebuild.  Users who
want a brand-new credential resolution should follow with ``/new``.

Tests:
* New ``test_reload_env_rpc_calls_hermes_cli_reload_env`` confirms
  RPC delegates and reports the count.
* New ``test_reload_env_rpc_surfaces_errors`` confirms exceptions are
  rendered as JSON-RPC errors.
* ``createSlashHandler.test.ts`` slash-parity matrix extended with
  ``['/reload', 'reload.env', {}]`` so we can't regress the routing.

Validation:
  scripts/run_tests.sh tests/test_tui_gateway_server.py — 92/92.
  scripts/run_tests.sh tests/hermes_cli/test_commands.py — 128/128.
  cd ui-tui && npm run type-check — clean; npm test --run — 390/390.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants