Skip to content

fix(tui): register shell hooks at TUI gateway startup - #43828

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/tui-shell-hooks
Closed

fix(tui): register shell hooks at TUI gateway startup#43828
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/tui-shell-hooks

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

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

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • tui_gateway/entry.py: Add register_from_config(load_config(), accept_hooks=False) after the gateway.ready event, wrapped in try/except so failures never block TUI startup. This matches the same delegation pattern used by gateway/run.py (~L4667).
  • tests/tui_gateway/test_shell_hook_registration.py: Two tests verifying (1) register_from_config is called with accept_hooks=False at startup, and (2) TUI startup continues normally if hook registration fails.

Why this matters

Users configure shell hooks (e.g. pre_tool_call to 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

  • New tests pass (tests/tui_gateway/test_shell_hook_registration.py)
  • Existing TUI gateway tests pass
  • Syntax check passes

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
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #13854 — same fix (register shell hooks at tui_gateway startup). #13854 is the earliest open canonical; competing #34112/#41464; #43826 is an identical same-batch twin. Fixes #43823.

@liuhao1024

Copy link
Copy Markdown
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 (tui_gateway/entry.py + test). Keeping #43826 as the representative PR.

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.

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

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Shell hooks (config.yaml hooks:) are never registered in the desktop TUI entry point

2 participants