Skip to content

fix(cli): bridge terminal.cwd config to TERMINAL_CWD in TUI gateway#14079

Closed
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/tui-terminal-cwd-not-respected
Closed

fix(cli): bridge terminal.cwd config to TERMINAL_CWD in TUI gateway#14079
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/tui-terminal-cwd-not-respected

Conversation

@konsisumer

Copy link
Copy Markdown
Contributor

When hermes chat launches the TUI, cli.py and its load_cli_config() are never imported, so terminal.cwd in config.yaml was never bridged to the TERMINAL_CWD environment variable. Everything in the TUI gateway then fell back to os.getcwd() (the directory where hermes chat was invoked), ignoring the configured path.

What changed and why

  • tui_gateway/server.py startup: Added a config.yaml → env var bridge for all terminal.* settings, mirroring the equivalent bridge already present in gateway/run.py. Placeholder cwd values (".", "auto", "cwd") are skipped to avoid overwriting a pre-resolved TERMINAL_CWD.
  • complete.path handler: Changed relative path resolution to use TERMINAL_CWD (falling back to os.getcwd()) as the base directory instead of the hardcoded process CWD (".")). Also fixed os.path.relpath() calls to be relative to TERMINAL_CWD, so completion texts are correct.
  • Existing tests (test_complete_path_at_filter.py): Updated four tests to use monkeypatch.setenv("TERMINAL_CWD", ...) instead of monkeypatch.chdir(), matching the new resolution order and making them robust to any pre-set TERMINAL_CWD in the test environment.
  • New tests (tests/tui_gateway/test_cwd_config_bridge.py): 14 tests covering the config bridge semantics (placeholder skipping, override behaviour) and complete.path resolution against TERMINAL_CWD.

How to test

  • Set terminal.cwd: /some/absolute/path in ~/.hermes/config.yaml
  • Run hermes chat (TUI mode)
  • Ask the model to run pwd — it should report /some/absolute/path
  • Type ./ in the chat input — file completions should list contents of /some/absolute/path, not the launch directory
  • Run pytest tests/tui_gateway/test_cwd_config_bridge.py tests/gateway/test_complete_path_at_filter.py -v

What platforms tested on

  • macOS on darwin-arm64 (local)

Fixes #14044

In TUI mode (`hermes chat` with --tui), cli.py and its load_cli_config()
are never imported, so terminal.cwd from config.yaml was never bridged to
the TERMINAL_CWD environment variable. This caused the terminal tool to
use the launch directory (os.getcwd()) rather than the configured path.

- Add config.yaml → env var bridge to tui_gateway/server.py startup,
  mirroring the equivalent bridge already present in gateway/run.py.
  Placeholder cwd values (".", "auto", "cwd") are skipped so they don't
  overwrite a pre-resolved TERMINAL_CWD.

- Fix complete.path handler to resolve relative paths against TERMINAL_CWD
  instead of the process launch directory, so TUI path completions also
  honour the configured working directory.

- Update existing test_complete_path_at_filter tests to use
  monkeypatch.setenv("TERMINAL_CWD", ...) rather than monkeypatch.chdir,
  matching the new resolution order.

Fixes NousResearch#14044
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/cli CLI entry point, hermes_cli/, setup wizard tool/terminal Terminal execution and process management area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists labels Apr 22, 2026
@konsisumer

Copy link
Copy Markdown
Contributor Author

Closing — opened before I saw @alt-glitch's note on #14044 pointing to #12983, #10226, #12689, #10225, #7663 as existing work on the same CWD propagation path. No sense adding a sixth. Happy to revisit once the existing PRs land if additional TUI-gateway-specific glue is still needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: terminal.cwd is not respected by terminal tool

2 participants