Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Pass global event dispatcher into SDK PromptBuilder#67

Open
shadyvb wants to merge 1 commit into
WordPress:trunkfrom
shadyvb:fix/issue-66-pass-event-dispatcher-to-prompt-builder
Open

Pass global event dispatcher into SDK PromptBuilder#67
shadyvb wants to merge 1 commit into
WordPress:trunkfrom
shadyvb:fix/issue-66-pass-event-dispatcher-to-prompt-builder

Conversation

@shadyvb

@shadyvb shadyvb commented Mar 22, 2026

Copy link
Copy Markdown

Fixes #66

Prompt_Builder constructed the vendored PromptBuilder without the optional EventDispatcherInterface, so BeforeGenerateResultEvent / AfterGenerateResultEvent never reached WordPress hooks.

Wire AiClient::getEventDispatcher() into the wrapper so wp_ai_client_before_generate_result and wp_ai_client_after_generate_result fire after AI_Client::init().

Adds a regression test asserting the inner builder shares the global dispatcher.

Prompt_Builder constructed the vendored PromptBuilder without the optional EventDispatcherInterface, so BeforeGenerateResultEvent / AfterGenerateResultEvent never reached WordPress hooks.

Wire AiClient::getEventDispatcher() into the wrapper so wp_ai_client_before_generate_result and wp_ai_client_after_generate_result fire after AI_Client::init().

Adds a regression test asserting the inner builder shares the global dispatcher.

Fixes WordPress#66

Made-with: Cursor
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: shadyvb <shadyvb@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@shadyvb

shadyvb commented Mar 25, 2026

Copy link
Copy Markdown
Author

@felixarntz Any chance we can merge this is for parity with core?

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.

Lifecycle events wp_ai_client_before_generate_result and wp_ai_client_after_generate_result never fire

1 participant