Show plugin hooks in plugin details (#21447)

Supersedes the abandoned #19859, rebuilt on latest `main`.

# Why

PR #19705 adds discovery for hooks bundled with plugins, but `/plugins`
still only shows skills, apps, and MCP servers. This follow-up makes
bundled hooks visible in the same plugin detail view so users can
inspect the full plugin surface in one place.

We also need `PluginHookSummary` to populate Plugin Hooks in the app;
`hooks/list` is not enough there because plugin detail needs to show
hooks for disabled plugins too.

# What

- extend `plugin/read` with `PluginHookSummary` entries for bundled
hooks
- summarize plugin hooks while loading plugin details
- render a `Hooks` row in the `/plugins` detail popup

<img width="3456" height="848" alt="CleanShot 2026-04-27 at 11 45 34@2x"
src="https://github.com/user-attachments/assets/fe3a38d6-a260-4351-8513-fb04c93d725b"
/>
This commit is contained in:
Abhinav authored and GitHub committed 2026-05-07 00:21:14 -07:00
1 parent 898f5bfeaa
commit 40e282849c
23 files changed
+436 -25

No files matched your search

+33
View File
@@ -1,4 +1,5 @@
mod config_rules;
mod declarations;
mod engine;
pub(crate) mod events;
mod legacy_notify;
@@ -7,6 +8,11 @@ mod registry;
mod schema;
mod types;
use codex_protocol::protocol::HookEventName;
pub use config_rules::hook_states_from_stack;
pub use declarations::PluginHookDeclaration;
pub use declarations::plugin_hook_declarations;
pub use engine::HookListEntry;
/// Hook event names as they appear in hooks JSON and config files.
pub const HOOK_EVENT_NAMES: [&str; 8] = [
@@ -70,3 +76,30 @@ pub use types::HookResult;
pub use types::HookToolInput;
pub use types::HookToolInputLocalShell;
pub use types::HookToolKind;
/// Returns the hook event label used in persisted hook-state keys.
pub fn hook_event_key_label(event_name: HookEventName) -> &'static str {
match event_name {
HookEventName::PreToolUse => "pre_tool_use",
HookEventName::PermissionRequest => "permission_request",
HookEventName::PostToolUse => "post_tool_use",
HookEventName::PreCompact => "pre_compact",
HookEventName::PostCompact => "post_compact",
HookEventName::SessionStart => "session_start",
HookEventName::UserPromptSubmit => "user_prompt_submit",
HookEventName::Stop => "stop",
}
}
/// Builds the persisted config-state key for one discovered hook handler.
pub fn hook_key(
key_source: &str,
event_name: HookEventName,
group_index: usize,
handler_index: usize,
) -> String {
format!(
"{key_source}:{}:{group_index}:{handler_index}",
hook_event_key_label(event_name)
)
}