Allow AI to validate changes before publishing

Created on 22 July 2025, 4 days ago

Overview

Inspired by 🐛 XB AI: uri-reference type links not getting generated Active and Iteration agent on created components Active .

Proposed resolution

What if there was a way the AI could ask the server to validate WITHOUT attempting to publish so that it can see the errors and iterate on it.

User interface changes

📌 Task
Status

Active

Version

1.0

Component

AI

Created by

🇺🇸United States tim.plunkett Philadelphia

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

Comments & Activities

  • Issue created by @tim.plunkett
  • 🇺🇸United States tim.plunkett Philadelphia

    Note that this should also remove the hardcoded workaround for URI that was included in 🐛 XB AI: uri-reference type links not getting generated Active

  • 🇮🇳India utkarsh_33

    So here is what I tried. In the ‘set_component_structure’ tool where we get the component structure generated by the AI I tried to pre-validate the components that are created by the AI using ApiAutoSaveController::post where I edited the `field_xb_demo` that is a part of the $all_auto_saves’s data array. This is by default populated from the UI changes that we make(example if we add 2 components in the UI then those 2 components are a part of this array).
    The array structure looks something like :-

    [
       'uuid' => 'da3155db-cda8-4b1a-81e1-5cf501c2065b',
       'inputs' => '{"text":"Press","href":      {"uri":"https:\\/\\/www.drupal.org","options":[]}}',
       'component_id' => 'sdc.xb_test_sdc.my-cta',
       'component_version' => '9454c3bca9bbbf4b',
       'parent_uuid' => null,
       'slot' => null,
       'label' => null
    ]

    Where I tried to validate the props for the elements that we create and randomly coding rest of the values as arbitrary values.
    What I tried was add a list of arrays with there props set against the input value in the array structure defined above and then letting the auto save do the rest of the stuff.
    The response for the `post` method that I always got was {"message":"Successfully published 0 items."} which should not be the case as I am populating wrong prop data as a part of 1 component in the $all_auto_saves’s data array.
    Now the real question is am I going in the right direction or I need to try something else? I don’t have much idea about how the Autosave manager works so it would be helpful to get some insights for it.
    Also we might need or use any existing api which can validate the component structure before returning the response to the client side as it would not be possible for us to re-iterate in case we get some error on the client side. If we can do that in the backend then it would be easier for use to re-iterate.
    Just for the context we get the following structure from the AI tool in ‘set_component_structure’/SetAIGeneratedComponentStructure.php file:-

    reference_nodepath: [1, 0]
    placement: above
    components:
     - js.text:
       props:
        text: "Subscribe to our newsletter and be the first to know about exclusive deals and new arrivals."
        textColor: "Dark"
        textSize: "Normal"
     - js.button:
       props:
        text: "Subscribe Now"
        variant: "Solid"
        link: "#"
    
  • 🇺🇸United States tedbow Ithaca, NY, USA

    @utkarsh_33 can you push up the local work you have for #3 to branch? It would really helpful for me and/or others to help. Thanks

  • @utkarsh_33 opened merge request.
Production build 0.71.5 2024