fix(tui): register shell hooks and discover plugins at TUI gateway startup#56729
Open
dante32683 wants to merge 1 commit into
Open
fix(tui): register shell hooks and discover plugins at TUI gateway startup#56729dante32683 wants to merge 1 commit into
dante32683 wants to merge 1 commit into
Conversation
…artup ui-tui's gatewayClient spawns tui_gateway/entry.py directly as a subprocess (python -m tui_gateway.entry), bypassing hermes_cli/main.py's _prepare_agent_startup entirely — the only place discover_plugins() and register_from_config() normally run for CLI-driven agent turns. gateway/run.py has its own equivalent startup calls for the same reason, but entry.py had neither, so shell hooks configured under `hooks:` in cli-config.yaml silently never registered for anyone using the TUI (desktop app or `hermes --tui`). Mirrors gateway/run.py's calls: accept_hooks stays False and is resolved from env/config inside register_from_config, whose TTY consent prompt already safely no-ops when stdin isn't a TTY (always true here, since stdin is the JSON-RPC pipe to the TUI).
Collaborator
Duplicate of #24237 — both add the identical |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
tui_gateway/entry.py::main()now callsdiscover_plugins()andagent.shell_hooks.register_from_config()at startup, mirroring the equivalent calls already present ingateway/run.py.Why
ui-tui'sgatewayClient.tsspawns this module directly as a subprocess (spawn(python, ['-m', 'tui_gateway.entry'], ...)), bypassinghermes_cli/main.py's_prepare_agent_startupentirely. That function is the only placediscover_plugins()andregister_from_config()normally run for CLI-driven agent turns (hermes chat,hermes --tuilaunched via the CLI arg parser). The gateway process (gateway/run.py) has its own equivalent startup calls for the same reason (it also doesn't go through_prepare_agent_startup), buttui_gateway/entry.pyhad neither — confirmed via grep, zero hits for either call in the file before this change.Net effect: shell hooks configured under
hooks:incli-config.yamlsilently never registered for anyone using the TUI surface (desktop app orhermes --tui), even though the exact same config works fine for plain CLI chat and the gateway.Approach
Mirrors
gateway/run.py's pattern exactly:discover_plugins()runs first (plugin-defined hooks need discovery to have happened before registration).register_from_config(load_config(), accept_hooks=False)—accept_hooksstaysFalsehere just like the gateway path; the three opt-in channels (--accept-hooksdoesn't apply to this surface, butHERMES_ACCEPT_HOOKSenv var andhooks_auto_accept: truein config) are still resolved insideregister_from_configitself._prompt_and_record'ssys.stdin.isatty()check already handles this safely (returnsFalse, no prompt, just a logged warning), so no interactive-prompt-corrupting-the-protocol risk.gateway/run.py's handling of the same two calls.Test plan
tests/tui_gateway/test_entry_shell_hook_registration.py:main()callsdiscover_plugins()once andregister_from_config()once with the loaded config andaccept_hooks=False.register_from_configexception doesn't propagate out ofmain()(startup must not be blocked by a hook-registration failure).tests/tui_gateway/suite locally (261 tests, 23 files) — all green, no regressions.scripts/run_tests.shagainst the new file plus the two otherentry.py-adjacent test files — all passing.Fixes the TUI shell-hooks gap noted in passing during an internal audit of Hermes's three startup paths (CLI / gateway / TUI) for this exact call.