CKEditor AI Tools configuration form removes first model of first provider.
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3561034. -->
Reported by: [chrislarrycarl](https://www.drupal.org/user/3455137)
Related to !1140
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When building the options list for the "AI provider" select input the buildConfigurationForm() function within the plugin removes the first model for the first provider.</p>
<p>This occurs because the options array returned by the getSimpleProviderModelOptions() method call has both an array_shift() and array_splice() applied to it removing the empty "- None -" option as well as the first model from the first provider. The select input render array has its own #empty_option configured so the default empty option is not needed.</p>
<p>The code is the same for all affected plugins and includes these lines within the plugin's buildConfigurationForm() method:</p>
<pre> $options = $this->aiProviderManager->getSimpleProviderModelOptions('chat');<br> array_shift($options);<br> array_splice($options, 0, 1);</pre><p>The following plugins are affected by this:</p>
<p>Path: ai/modules/ai_ckeditor/src/Plugin/AiCKEditor/<br>
Namespace: Drupal\ai_ckeditor\Plugin\AICKEditor</p>
<p>- Completion.php Lines 36-38<br>
- ModifyPrompt.php Lines 36-38<br>
- ReformatHTML.php Lines 36-38<br>
- SpellFix.php Lines 39-41<br>
- Summarize.php Lines 36-38<br>
- Tone.php Lines 76-78<br>
- Translate.php Lines 87-89</p>
<h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4>
<p>Please provide information like AI modules enabled, which AI provider, browser, etc.</p>
<p>- Install AI v1.2.3<br>
- Configure one or more providers<br>
- Edit an editor config /admin/config/content/formats<br>
- Under "CKEditor 5 plugin settings" click "AI tools"<br>
- Click to expand any impacted option (Translate, Generate with AI, Tone, etc.)<br>
- Click select list input for "AI provider", first model for the first provider will be missing as an option</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>I was able to fix this issue locally by removing the array function calls and adding a value of FALSE for the empty parameter so that the "- None-" empty option isn't included in the list of options returned from getSimpleProviderModelOptions().</p>
<pre> $options = $this->aiProviderManager->getSimpleProviderModelOptions('chat', FALSE);</pre>
issue