Add interactive refinement capability to Field Widget Actions
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3547306. --> Reported by: [ezeedub](https://www.drupal.org/user/633844) Related to !893 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Currently, Field Widget Actions provide excellent automation for content generation, but once an automator generates content, users have limited options for refinement without manually editing or re-running the entire automator process. This creates a gap between fully automated content generation and user-controlled refinement.</p> <p>Users often want to iteratively improve AI-generated content with additional context or refinement instructions (e.g., "make it shorter", "more formal", "add statistics") without losing the original automator's constraints and context. The existing <code>prompt_content_suggestion</code> plugin shows the value of layered prompting, but this is limited to that specific plugin.</p> <p>This enhancement would bridge the gap between static automators and full chatbot interactions, providing a middle-ground solution for content creators.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Add an <strong>Interactive Refinement</strong> capability to Field Widget Actions that can work universally with existing automators. Building on the recent <code>returnsSuggestions</code> helper method, introduce a <code>refinableSuggestions</code> approach that:</p> <ol> <li><strong>Intercepts automator results</strong> before applying to fields</li> <li><strong>Displays generated content</strong> in a modal with refinement interface</li> <li><strong>Allows iterative refinement</strong> through additional prompts while preserving original automator constraints (character limits, token evaluations, field-specific rules)</li> <li><strong>Provides Accept/Refine/Cancel actions</strong> for user control</li> <li><strong>Maintains configuration inheritance</strong> - re-evaluates tokens and honors original field configuration on each iteration</li> </ol> <p><strong>Implementation approach:</strong></p> <ul> <li>New base method <code>refinableSuggestions()</code> in <code>FieldWidgetActionBase</code></li> <li>Optional configuration to enable interactive refinement per field widget action</li> <li>Preserve all existing automator functionality (non-breaking)</li> <li>Leverage existing AI provider infrastructure and modal patterns</li> </ul> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <ol> <li>Community discussion and architectural feedback</li> <li>Design the <code>refinableSuggestions()</code> API</li> <li>Implement base interactive refinement functionality</li> <li>Add configuration options for enabling per field widget action</li> <li>Create JavaScript interface for iterative chat-style refinement</li> <li>Ensure proper form state management across refinement iterations</li> <li>Add comprehensive tests</li> <li>Documentation and examples</li> </ol> <h3>Optional: Other details as applicable</h3> <p><strong>User interface changes:</strong></p> <ul> <li>New modal interface for interactive content refinement</li> <li>Configuration checkbox to enable refinement per field widget action</li> <li>Iterative chat-style interface with prompt input and Accept/Refine/Cancel buttons</li> </ul> <p><strong>API changes:</strong></p> <ul> <li>New <code>refinableSuggestions()</code> method in <code>FieldWidgetActionBase</code></li> <li>Enhanced form state management for refinement sessions</li> <li>Extended AJAX handling for iterative workflows</li> </ul> <p><strong>Backward compatibility:</strong></p> <ul> <li>All existing automators continue to work unchanged</li> <li>Interactive refinement is opt-in via configuration</li> <li>No breaking changes to existing Field Widget Action APIs</li> </ul> <p><strong>Related work:</strong> This builds upon the existing <code>prompt_content_suggestion</code> plugin's layered prompting approach and the recent<br> <code>returnsSuggestions</code> helper method, extending these patterns to work universally with any automator.</p>
issue