Canvas AI: CanvasAiComponentDescriptionSettingsForm redirects to 'canvas.api.config.list' after submission
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3558241. --> Reported by: [akhil babu](https://www.drupal.org/user/3632866) Related to !331 !524 >>> <p>--- AI TRACKER METADATA ---<br> <strong>Update Summary: </strong>Simple approach to bringing advanced metadata into Canvas AI<br> <strong>Check-in Date: </strong>MM/DD/YYYY (US format) [When we should see progress/get an update]<br> <strong>Due Date:</strong> MM/DD/YYYY (US format) [When the issue should be fully completed]<br> <strong>Blocked by:</strong> [#XXXXXX] (New issues on new lines)<br> <strong>Additional Collaborators:</strong> @username1, @username2<br> AI Tracker found here: <a href="https://www.drupalstarforge.ai/" title="AI Tracker">https://www.drupalstarforge.ai/</a><br> --- END METADATA ---</p> <h3 id="overview">Overview</h3> <p><code>CanvasAiPageBuilderHelper::getAllComponentsKeyedBySource()</code> can be called multiple times when the <em>Canvas AI Component Description Settings Form</em> is viewed/saved or when the <em>get_component_context</em> tool is used by the Canvas AI Page Builder agent. This method fetches all available components from canvas.api.config.list for further processing.</p> <p>In the initial implementation, the controller method <code>ApiConfigControllers::list </code>was directly invoked from getAllComponentsKeyedBySource() to fetch the available components. This was later replaced with a sub-request in <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3545477" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3545477</a></span> for better cacheability.</p> <p>However, this sub-request interferes with the <em>Canvas AI Component Description Settings Form</em>, causing the following issues:</p> <ul> <li>The form title is not getting rendered.</li> <li>The user gets redirected to the canvas.api.config.list route once the form is submitted.</li> </ul> <p>Debugging showed that Form API considers the sub-request route as the redirect path when submitting the form. One way to fix this issue was to set an explicit redirect to the form route (<code>$form_state-&gt;setRedirect('canvas_ai.component_description_settings');</code>) or disable the redirect completely (<code>$form_state-&gt;disableRedirect()</code>). While this works, it has the following disadvantages:</p> <ul> <li>The title of the form still does not get rendered.</li> <li>The status message (&ldquo;The configuration has been saved&rdquo;) does not get displayed after the form is submitted, even if the message is explicitly added in the submit handler.</li> </ul> <h3 id="proposed-resolution">Proposed resolution</h3> <p>I think the sub-request can be eliminated altogether, and we can switch back to calling the controller method directly. Then we can cache the results using the component:list cache tag so that it gets invalidated every time components are updated.</p> <h3 id="ui-changes">User interface changes</h3> > Related issue: [Issue #3573571](https://www.drupal.org/node/3573571)
issue