Introduce prompt management - #949
Draft
chrfritsch wants to merge 16 commits into
Draft
Conversation
* 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.
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.
Make sure these boxes are checked before submitting your pull request - thank you!
If you are really awesome, then your feature is covered by additional tests. Well done!