Skip to content

AI Client: pass event dispatcher to Prompt Builder#11341

Open
soderlind wants to merge 1 commit intoWordPress:trunkfrom
soderlind:ai/event-dispatcher
Open

AI Client: pass event dispatcher to Prompt Builder#11341
soderlind wants to merge 1 commit intoWordPress:trunkfrom
soderlind:ai/event-dispatcher

Conversation

@soderlind
Copy link

This patch fixes AI Client event dispatching so lifecycle actions fire as intended.

What was fixed

  • The helper function now passes the configured global event dispatcher into the prompt builder.
  • The WordPress prompt builder now accepts an optional event dispatcher and forwards it to the underlying SDK prompt builder.
  • Constructor fallback behavior was updated so the dispatcher is still preserved if prompt parsing throws and the fallback builder instance is created.

Files changed

  • ai-client.php
  • class-wp-ai-client-prompt-builder.php

Tests added

  • Added regression test verifying helper-level wiring of dispatcher:
    • wpAiClientPromptBuilder.php
  • Added regression test verifying constructor-level forwarding of dispatcher:
    • wpAiClientPromptBuilder.php

Trac ticket: https://core.trac.wordpress.org/ticket/64938

Use of AI Tools

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Opus 4.6
Used for: Initial code skeleton and test suggestions; final implementation and tests were reviewed and edited by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props pers.

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

@soderlind
Copy link
Author

@jeffpaul ^^

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.

1 participant