Skip to content

Commit 3aae5d8

Browse files
abhinav-oaicopyberry
authored andcommitted
Expose execution mode in hook listings (#37538)
## What changed - Add `executionMode` to `HookMetadata` returned by `hooks/list`, with `sync` as the default for compatibility. - Propagate each discovered hook's `sync` or `async` mode through the app-server protocol and generated schemas. - Show the execution mode in the TUI hooks browser. ## Testing - Cover async and default-sync modes in `hooks/list` tests and TUI snapshots. GitOrigin-RevId: 9c9f2890798fe417face76c15847616b2dea9db4
1 parent 6f647ca commit 3aae5d8

23 files changed

Lines changed: 75 additions & 3 deletions

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/schema/json/v2/HooksListResponse.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

codex-rs/app-server-protocol/schema/typescript/v2/HookMetadata.ts

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codex-rs/app-server-protocol/src/protocol/v2/hook.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ v2_enum_from_core!(
2828
);
2929

3030
v2_enum_from_core!(
31+
#[derive(Default)]
3132
pub enum HookExecutionMode from CoreHookExecutionMode {
32-
Sync, Async
33+
#[default]
34+
Sync,
35+
Async
3336
}
3437
);
3538

codex-rs/app-server-protocol/src/protocol/v2/plugin.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::AppSummary;
22
use super::HookEventName;
3+
use super::HookExecutionMode;
34
use super::HookHandlerType;
45
use super::HookSource;
56
use super::HookTrustStatus;
@@ -524,6 +525,8 @@ pub struct HookMetadata {
524525
pub key: String,
525526
pub event_name: HookEventName,
526527
pub handler_type: HookHandlerType,
528+
#[serde(default)]
529+
pub execution_mode: HookExecutionMode,
527530
pub matcher: Option<String>,
528531
pub command: Option<String>,
529532
pub timeout_sec: u64,

codex-rs/app-server/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,8 @@ For linked Git worktrees, project hook declarations come from the matching `.cod
19261926

19271927
Hooks are returned even when disabled so clients can render and re-enable them. User-controlled state lives under `hooks.state`. Managed hooks are non-configurable, and user entries for managed hook keys are ignored during loading.
19281928

1929+
`executionMode` reports how a command hook runs. `sync` hooks participate in the current operation, while `async` hooks run in the background and deliver informational output through the existing steer-based injection path. Output is injected immediately into an active turn or persisted without starting a new turn when the session is idle.
1930+
19291931
For unmanaged hooks, `currentHash` and `trustStatus` describe whether the current definition is first-seen, approved, or changed since approval. Only trusted unmanaged hooks become runnable. Hook keys combine the source identity with a trailing event/group/handler selector that is currently positional.
19301932

19311933
```json
@@ -1948,6 +1950,7 @@ For unmanaged hooks, `currentHash` and `trustStatus` describe whether the curren
19481950
"key": "/Users/me/.codex/config.toml:pre_tool_use:0:0",
19491951
"eventName": "pre_tool_use",
19501952
"handlerType": "command",
1953+
"executionMode": "sync",
19511954
"isManaged": false,
19521955
"matcher": "Bash",
19531956
"command": "python3 /Users/me/hook.py",

codex-rs/app-server/src/request_processors/catalog_processor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fn hooks_to_info(hooks: &[codex_hooks::HookListEntry]) -> Vec<HookMetadata> {
7070
key: hook.key.clone(),
7171
event_name: hook.event_name.into(),
7272
handler_type: hook.handler_type.into(),
73+
execution_mode: hook.execution_mode.into(),
7374
matcher: hook.matcher.clone(),
7475
command: hook.command.clone(),
7576
timeout_sec: hook.timeout_sec,

0 commit comments

Comments
 (0)