Skip to content

Add /hooks browser for lifecycle hooks#19882

Merged
abhinav-oai merged 85 commits into
mainfrom
abhinav/hooks-browser-menu
Apr 30, 2026
Merged

Add /hooks browser for lifecycle hooks#19882
abhinav-oai merged 85 commits into
mainfrom
abhinav/hooks-browser-menu

Conversation

@abhinav-oai
Copy link
Copy Markdown
Collaborator

@abhinav-oai abhinav-oai commented Apr 27, 2026

Why

hooks/list and hooks/config/write give us read/write access to hooks and their state. This hooks up the TUI as a client so users can inspect and manage that state directly.

What

  • add a two-page /hooks browser in the TUI: an event overview with installed/active counts, followed by a per-event handler page with toggle controls and detail rendering
  • thread managed-state metadata through hook discovery and hooks/list so the UI can label admin-managed hooks and suppress toggles for them
  • persist hook toggles through the existing config-write path and add snapshot coverage for the event list, handler list, managed-hook, and empty states

Stack

  1. Discover hooks bundled with plugins #19705
  2. Add hooks/list app-server RPC #19778
  3. Add persisted hook enablement state #19840
  4. This PR - Add /hooks browser for lifecycle hooks #19882

Reviewer Notes

  • Main UI logic is in codex-rs/tui/src/bottom_pane/hooks_browser_view.rs; most of the diff is the new view plus its snapshot coverage
  • Request / write plumbing for opening the browser and persisting toggles is in codex-rs/tui/src/app/background_requests.rs and codex-rs/tui/src/chatwidget/hooks.rs
  • Outside the TUI, the only behavioral change in this PR is threading is_managed through hook discovery and hooks/list so managed hooks render as non-toggleable
  • The codex-rs/tui/src/status/snapshots/ churn is unrelated merge fallout from the stacked base branch's newer permission-label rendering

@abhinav-oai abhinav-oai changed the title Add /hooks browser Add /hooks browser for lifecycle hooks Apr 27, 2026
Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request Apr 27, 2026
@abhinav-oai abhinav-oai marked this pull request as ready for review April 29, 2026 17:26
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8edff9fec9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/app/background_requests.rs Outdated
abhinav-oai added a commit that referenced this pull request Apr 29, 2026
## Why

We need a way to list the available hooks to expose via the TUI and App
so users can view and manage their hooks

## What

- Adds `hooks/list` for one or more `cwd` values that returns discovered
hook metadata

## Stack

1. #19705
2. This PR - #19778
3. #19840
4. #19882

## Review Notes

The generated schema files account for most of the raw diff, these files
have the core change:

- `hooks/src/engine/discovery.rs` builds the inventory entries during
hook discovery while leaving runtime handlers focused on execution.
- `app-server/src/codex_message_processor.rs` wires `hooks/list` into
the app-server flow for each requested `cwd`.
- `app-server-protocol/src/protocol/v2.rs` defines the new v2
request/response payloads exposed on the wire.

### Core Changes

`core/src/plugins/manager.rs` adds `plugins_for_layer_stack(...)` so
`skills/list` and `hooks/list`can resolve plugin state for each
requested `cwd`

---------

Co-authored-by: Codex <noreply@openai.com>
abhinav-oai added a commit that referenced this pull request Apr 30, 2026
## Why

After `hooks/list` exposes the hook inventory, clients need a way to
persist user hook preferences, make those changes effective in
already-open sessions, and distinguish user-controllable hooks from
managed requirements without adding another bespoke app-server write
API.

## What

- Extends `hooks/list` entries with effective `enabled` state.
- Persists user-level hook state under `hooks.state.<hook-id>` so the
model can grow beyond a single boolean over time.
- Uses the existing `config/batchWrite` path for hook state updates
instead of introducing a dedicated hook write RPC.
- Refreshes live session hook engines after config writes so
already-open threads observe updated enablement without a restart.

## Stack

1. #19705
2. #19778
3. This PR - #19840
4. #19882

## Reviewer Notes

The generated schema files account for much of the raw diff. The core
behavior is in:

- `hooks/src/config_rules.rs`, which resolves per-hook user state from
the config layer stack.
- `hooks/src/engine/discovery.rs`, which projects effective enablement
into `hooks/list` from source-derived managedness.
- `config/src/hook_config.rs`, which defines the new `hooks.state`
representation.
- `core/src/session/mod.rs`, which rebuilds live hook state after user
config reloads.

---------

Co-authored-by: Codex <noreply@openai.com>
Base automatically changed from dev/abhinav/hooks-config-write to main April 30, 2026 04:46
@abhinav-oai abhinav-oai requested a review from a team as a code owner April 30, 2026 04:46
Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Did a quick smoke test adding PreToolUse hooks and disabling/enabling it.

Approved!

@abhinav-oai abhinav-oai removed the request for review from a team April 30, 2026 17:37
…-menu

# Conflicts:
#	codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs
@abhinav-oai abhinav-oai merged commit 93d53f6 into main Apr 30, 2026
35 of 36 checks passed
@abhinav-oai abhinav-oai deleted the abhinav/hooks-browser-menu branch April 30, 2026 18:58
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants