fix(tui): register shell hooks at TUI gateway startup - #43828
Closed
liuhao1024 wants to merge 1 commit into
Closed
Conversation
Shell hooks (pre_tool_call, post_tool_call, etc.) configured in config.yaml were silently ignored in Desktop/TUI sessions because tui_gateway/entry.py never called register_from_config(). The CLI (hermes_cli/main.py) and gateway (gateway/run.py) both register hooks at startup, but the TUI entry point was missing this step. Add register_from_config(load_config(), accept_hooks=False) after the gateway.ready event, matching the gateway's delegation pattern. The call is wrapped in try/except so hook-registration failures never block TUI startup. Fixes NousResearch#43823
Collaborator
13 tasks
Contributor
Author
|
Closing as a self-duplicate — this was opened in the same batch run as #43826, which covers the identical fix with the same files ( Note: alt-glitch flagged this as a duplicate of #13854 (canonical, +108 lines by witt3rd), which is the earliest open fix. #43826 adds a more focused implementation (+74 lines) with dedicated tests. |
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 does this PR do?
Registers declarative shell hooks (
pre_tool_call,post_tool_call, etc.) at TUI gateway startup so they fire in Desktop/TUI sessions, matching CLI and gateway behaviour.Related Issue
Fixes #43823
Type of Change
Changes Made
tui_gateway/entry.py: Addregister_from_config(load_config(), accept_hooks=False)after thegateway.readyevent, wrapped intry/exceptso failures never block TUI startup. This matches the same delegation pattern used bygateway/run.py(~L4667).tests/tui_gateway/test_shell_hook_registration.py: Two tests verifying (1)register_from_configis called withaccept_hooks=Falseat startup, and (2) TUI startup continues normally if hook registration fails.Why this matters
Users configure shell hooks (e.g.
pre_tool_callto block dangerous commands) as a security surface. The CLI and gateway both register these hooks at startup, but the TUI/Desktop entry point never did — so hooks were silently ignored in Desktop sessions. A user could configure a blocking hook, see no error, and believe they were protected when they weren't.Testing
tests/tui_gateway/test_shell_hook_registration.py)