Improve UX to avoid data loss and support moderation

Created on 8 September 2025, about 1 month ago

Problem/Motivation

The current UX can lead to data loss on the edit form when the editor is not aware that pressing the "Generate references with AI" button will lose all changes on the edit form.

Current UX:

  • There is a "Generate references with AI" button on the node edit form.
  • When a user presses the "Generate references with AI" button, they are taken away from the node edit form.
  • On the AI Auto Reference form, the user can select reference suggestions to apply to the node.
  • When the user submits the AI Auto Reference form, the node is saved. This save overrides any changes that were made on the node edit form before pressing the "Generate references with AI" button.
  • The user is redirected back to the node edit which is built for the update node object.

Proposed resolution

  • Add a new configuration option for "Display a button on the node edit form" to the module's configuration (ai_auto_reference.settings) on "/admin/config/content/ai-autoreference-settings".
    • This would default to enabled to preserve the original implementation.
    • This new configuration is not needed if it is decided to completely remove the button on the node edit form. This is the recommended since it will avoid any future bugs.
  • Create a new node link template, route, and local task available at "/node/123/ai-autoreference":
    • Implement hook_entity_type_alter to add a new link template for "ai-autoreference". Code:$entity_type->setLinkTemplate('ai-autoreference', $entity_type->getLinkTemplate('canonical') . '/ai-autoreference');
    • Create a route subscriber with an alterRoutes() to dynamically create the route for the entity link template 'ai-autoreference':
      • Set "load_latest_revision" as TRUE so that the latest translation affected version is loaded for the route parameter.
      • Set "_admin_route" to the same as the "entity.node.edit_form" route.
    • Create a local task for the new route.
  • Decouple the apply form from the batch processing and node edit form "Generate references with AI" button:
    • Remove build form argument for $configuration and inject the service "ai_auto_reference.settings" to the form class instead
    • Do not depend on the request query for the AI suggestions
    • Initial form build should be just the "Generate references with AI" button.
    • When the "Generate references with AI" button is submitted:
      • The form submit uses a batch process to get the suggestions.
      • The form rebuilds with the suggestions for the user to select and an "Apply" button to save them.
      • When the "Apply" button is submitted: The suggested field values are applied and a new revision is saved with the author as the current user and a log message as "Applied AI generated references". This should be a real new revision using the NodeStorage::createRevision().

Remaining tasks

  1. Create a PR with the proposed solution
  2. Finalize a solution
  3. Update any documentation

User interface changes

  • A new configuration option to have the "Generate references with AI" form on a separate node tab.

API changes

None

Data model changes

None

✨ Feature request
Status

Active

Version

1.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States recrit

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024