Skip to content

Pass global event dispatcher into SDK PromptBuilder#67

Open
shadyvb wants to merge 1 commit intoWordPress: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 intoWordPress:trunkfrom
shadyvb:fix/issue-66-pass-event-dispatcher-to-prompt-builder

Conversation

@shadyvb
Copy link
Copy Markdown

@shadyvb shadyvb commented Mar 22, 2026

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
Copy link
Copy Markdown
Author

shadyvb commented Mar 25, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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