Skip to content

Introduce prompt management - #949

Draft
chrfritsch wants to merge 16 commits into
8.4.xfrom
prompt-management
Draft

Introduce prompt management#949
chrfritsch wants to merge 16 commits into
8.4.xfrom
prompt-management

Conversation

@chrfritsch

Copy link
Copy Markdown
Member

Make sure these boxes are checked before submitting your pull request - thank you!

  • All coding styles are fulfilled. (How to check for cs issues?)
  • All tests are running locally. (How to run the test?)
  • Necessary update hooks are provided.
  • User roles have correct access for new introduced permission.
  • Every thunder module has a README.md in its root. Follow this guidelines, but we don't need every topic.
  • Code is covered with well-balanced amount of inline comments.
  • New features or changes are documented.

If you are really awesome, then your feature is covered by additional tests. Well done!

Christian Fritsch and others added 16 commits August 12, 2026 13:16
* Add prompt testing

* fix

* added save button and model selector

* add suggestion field widget

* add dependencies

* Fix PHPStan errors in thunder_ai_prompt_management

Resolves the 19 static analysis errors that failed the deprecation
testing CI job (missing return types, undefined methods/properties on
generic entity interfaces, an unhandled match branch, and a return
type mismatch).

* Fix coding style violations in thunder_ai_prompt_management

Resolves the errors from the drupal-coder coding style check: a
same-namespace use statement, missing match() spacing, an over-long
line, undocumented parameters, and an unused import.

* Require drupal/field_widget_actions ^1.4 explicitly

field_widget_actions was only a transitive dependency, so a fresh
composer resolve (this distribution ships no composer.lock) could
land on 1.3.0, which lacks the #validate/clearErrorsForAction wiring
that AiTaskSuggestion relies on to suppress unrelated required-field
errors on AJAX suggestion requests. That is what broke the "kernel"
CI job: AiTaskSuggestionTest asserted on a #validate key that 1.3.0
never sets.

---------

Co-authored-by: Christian Fritsch <christian.fritsch@burda.com>
Optional chaining (?.) isn't supported by the project's pinned
eslint/parser, causing a parse error that hid the further issues
below it. Replaced it with plain && checks, named the wrapping IIFE,
and renamed the summary callback's parameter to stop it shadowing
the outer attach(context) parameter.
CI's prettier defaults to arrowParens: always (my local
eslint-config-drupal bundles an older prettier defaulting to
"avoid"), so the single-param arrow needs parens.
- Fix a real int/string type-mismatch bug in
  AIPromptAccessControlHandler::checkAccess() (entity->getOwnerId()
  is int, account->id() is string, so the strict === always failed
  for real users) - caught after fixing the test below.
- Fix AIPromptAccessControlHandlerTest to not let its "own" prompt
  owner become uid 1, which bypasses access checks as the superuser
  and made the update/delete own-vs-any assertions vacuous.
- Guard AIPromptTestForm against a stale entity_context referencing
  an uninstalled/renamed entity type (getDefinition() no longer
  throws).
- Replace leftover "example" scaffold text in AiTaskForm messages and
  AiTask's property docblocks with actual AI task wording.
- Switch AIPromptForm to AutowireTrait + promoted properties instead
  of a manual constructor/create().
- Extract the "type.bundle" string decoding shared by
  EntityContextWidget and AIPromptTestForm into one static helper.
- Memoize AiTaskSuggestion::loadPrompts() per task/type/bundle to
  avoid re-querying once per delta on multi-value fields.
- Switch form.js to an arrow-function IIFE per JS conventions.
- Condense multi-line rationale comments down to one line per the
  project's comment convention.
The drupal-coder check fails on any phpcs finding, warnings included,
so the condensed one-line comments from the previous commit still
needed trimming to stay under 80 characters.
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.

2 participants