Repository navigation
Conversation
Draft proposal for closing the gap where Codex has no hook event that fires while a reply is streaming (only Stop, once, at turn end) — matching what Claude Code and the newly-merged Qwen Code MessageDisplay hook (QwenLM/qwen-code#6489) already provide on their own hook systems. Not yet submitted as an issue/PR; draft for review first.
Fixes from a critical review pass: - Flag docs/contributing.md's invitation-only policy up front — the actual next step is a lightweight issue, not a PR or this level of design doc as a first move. - Disambiguate the legacy_notify.rs precedent: only the detached execution primitive is reused, not its lack of matcher/trust config (an earlier draft read as self-contradictory on this point). - Correct "one insertion point" to two call sites (plan-mode text flows through a separate function) — the original framing would have shipped a bug dropping narration during plan-mode turns. - Expand the "~9 mechanical match-arm sites" list with several missed sites (analytics, TUI hooks browser + transcript rendering, a second independently-tested schema-fixture pipeline, snapshot fixtures). - Correct the docs/config.md location claim; no file in this repo documents individual hook events today. - Note real tokio concurrency around turns/subagents that the original "small buffer" sizing for debounce state understated. - Expand the motivation section so it's self-contained context for another agent/reviewer, describing Claude Code's and Qwen Code's MessageDisplay hooks and this proposal's purpose without requiring prior conversation context.
Adds the new HookEventName::MessageDisplay variant (protocol crate) and the matching TOML matcher-group field on HookEventsToml plus a new top-level [hooks] message_display_debounce_ms config field (config crate), threaded through into Config and the regenerated config.schema.json. Additive/backward-compatible only; per docs/proposals/message-display-hook.md. Co-Authored-By: Claude Sonnet 5 <[email protected]>
New hooks/src/events/message_display.rs: a per-turn MessageDisplayHandle that debounces (~200ms, configurable) cumulative-text deliveries per streamed item, bypasses the debounce for the final delivery, caps concurrently in-flight child processes with a semaphore, and independently bounds each child's stdin write (guarding openai#27550) since it deliberately does not reuse command_runner's blocking-wait execution path (see the proposal doc §1 disambiguation: discovery, matcher parsing, and trust-on-first-use are fully reused; only the per-invocation execution primitive is replaced, modeled on legacy_notify.rs's spawn-and-don't-wait shape). Also wires MessageDisplay through every mechanical exhaustive-match site the HookEventName enum touches in this crate: dispatcher matcher-class arms, event-name/scope labels, ConfiguredHandler's label, the input-only JSON schema (HookEventNameWire + MessageDisplayCommandInput, regenerated fixture), and HooksConfig/ClaudeHooksEngine's construction to thread the new debounce config value through. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Adds MessageDisplay to the v2 HookEventName enum mirror and to ManagedHooksRequirements (plus its config_processor.rs mapping), which the compiler's exhaustiveness check on the ManagedHooksRequirementsToml destructure in app-server/src/request_processors/config_processor.rs flagged as a required update the design doc's own site enumeration had missed. Regenerates the TS/JSON schema fixtures both `write_hooks_schema_fixtures` and `write_schema_fixtures` produce. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Builds a per-turn MessageDisplayHandle (None when no handlers are configured, so the token-streaming hot path is a single Option check) in run_turn and threads it through both real dispatch call sites the design doc identifies: emit_streamed_assistant_text_delta's plain path and handle_plan_segments' Normal-segment path (plan-mode turns route through the latter and would otherwise narrate nothing). Deviates from the doc's own §2/§3 plan in one respect: rather than threading an `is_final: bool` through emit_streamed_assistant_text_delta itself, MessageDisplayHandle tracks per-item cumulative text internally and exposes a separate finish_item(), called unconditionally by the two flush wrappers (flush_assistant_text_segments_for_item/_all - the latter has two call sites in run_turn, one more than the doc counted). Tracing the existing early-return guards showed the doc's original plan would silently drop the final MessageDisplay delivery whenever a flush round parses no fresh text, which is the common case since most items already streamed their last chunk via a prior delta. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Mechanical exhaustiveness fixes the compiler surfaced beyond the design doc's own enumeration: analytics' metric event-name mapping, the sample thread-manager binary's direct Config literal, and a test-only hook_event_label match in tui/src/chatwidget/tests/helpers.rs. Also fills in the two TUI sites needing real copy rather than plain enumeration: hooks_browser_view's event_description gets user-facing text for the /hooks browser, and hook_cell's hook_event_label gets a label (not a panic) even though MessageDisplay never actually emits HookStarted/HookCompleted, confirming the doc's own suspicion that this site doesn't need real behavior, just a safe stub. Regenerates the 4 insta snapshots that enumerate all HookEventName variants (3 in bottom_pane/hooks_browser_view, 1 in chatwidget/hooks_popup_shows_list_diagnostics - the latter not called out by name in the design doc, which only gestured at "chatwidget snapshots" generally). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Short status update at the top of the proposal recording that the §5 "smallest defensible first PR" scope is implemented on this branch, plus the one place implementation diverged from the doc's own §2/§3 plan and why. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Closed
This was referenced Jul 15, 2026
Closed
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.
Summary
MessageDisplayhook event so mid-turn assistant replies can be observed while streaming (today onlyStop, once per turn, is available) — matching Claude Code's and the newly-merged Qwen CodeMessageDisplayhook.docs/proposals/message-display-hook.md.app-serversocket directly, which needs manualcodex app-server daemon start+codex --remote unix://setup. A native hook removes that friction, same as it already works for Claude Code and Qwen Code.What's implemented
HookEventName::MessageDisplay(protocol/src/protocol.rs), plumbed through every exhaustive match site (config schema, discovery, dispatcher, analytics, TUI hooks browser, app-server v2 wire types, schema fixtures).hooks/src/events/message_display.rs: detached, fire-and-forget dispatch (reuses existing TOML matcher-group discovery + trust-on-first-use approval — only the per-invocation execution step is detached) with a true silence-based debounce, a cap on concurrently in-flight child processes, and an independently-bounded stdin write.[hooks] message_display_debounce_ms(default 200ms); a final (is_final: true) delivery always bypasses the debounce.core/src/session/turn.rs(plain path + plan-mode path).core/config.schema.json) and TUI snapshot fixtures.This is NOT going to upstream directly
Per
docs/contributing.md,openai/codexonly accepts invited PRs — this stays on my own fork. It's the working reference for a lightweight issue I may open upstream, and/or just a personal patch for my own use in the meantime.Test plan
cargo test -p codex-config -p codex-protocol -p codex-hooks -p codex-tui— all pass, including new coverage for debounce coalescing,is_finalbypassing the debounce, and the zero-cost no-handlers-configured path.codex-coreintegration suites (hooks,hooks_mcp,compact,token_budget, plan-mode) plus the full--libunit suite — all pass.cargo clippy --all-targets -D warningsclean on every touched crate.