Align the prompt refinement action with the assistant button pattern

This commit is contained in:
Thorsten Sommer committed 2026-09-22 19:53:45 +02:00
1 parent f94af9c07d
commit 002fc28fe8
1 file changed
+13 -2
@@ -104,10 +104,11 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<SettingsDialog
new ButtonData new ButtonData
{ {
Text = T("Improve further"), Text = T("Improve further"),
Tooltip = T("Moves the optimized prompt into the prompt field so you can optimize it again."),
Icon = Icons.Material.Filled.Input, Icon = Icons.Material.Filled.Input,
Color = Color.Default, Color = Color.Default,
AsyncAction = this.UseOptimizedPromptAsInput, AsyncAction = this.UseOptimizedPromptAsInput,
DisabledActionParam = () => string.IsNullOrWhiteSpace(this.optimizedPrompt), DisabledActionParam = () => !this.CanImproveFurther,
}, },
new SendToButton new SendToButton
{ {
@@ -253,6 +254,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<SettingsDialog
private bool ShowUpdatedPromptGuidelinesIndicator => !this.useCustomPromptGuide && this.hasUpdatedDefaultRecommendations; private bool ShowUpdatedPromptGuidelinesIndicator => !this.useCustomPromptGuide && this.hasUpdatedDefaultRecommendations;
private bool CanPreviewCustomPromptGuide => this.useCustomPromptGuide && this.customPromptGuideFiles.Count > 0; private bool CanPreviewCustomPromptGuide => this.useCustomPromptGuide && this.customPromptGuideFiles.Count > 0;
private bool CanImproveFurther => !this.IsProcessing && !string.IsNullOrWhiteSpace(this.optimizedPrompt);
private string CustomPromptGuideFileName => this.customPromptGuideFiles.Count switch private string CustomPromptGuideFileName => this.customPromptGuideFiles.Count switch
{ {
0 => T("No file selected"), 0 => T("No file selected"),
@@ -472,9 +474,18 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<SettingsDialog
this.optimizedPrompt = string.Empty; this.optimizedPrompt = string.Empty;
} }
/// <summary>
/// Moves the optimized prompt into the input field so the user can optimize it once more.
/// </summary>
/// <remarks>
/// The finished run is dropped along the way. Keeping it would append the next optimization to
/// the chat thread of the previous one, and the earlier proposal would stay on screen next to
/// the prompt it was already turned into. The recommendations and every selection stay as they
/// are, though: they are what the user works with while refining the prompt.
/// </remarks>
private Task UseOptimizedPromptAsInput() private Task UseOptimizedPromptAsInput()
{ {
if (string.IsNullOrWhiteSpace(this.optimizedPrompt)) if (!this.CanImproveFurther)
return Task.CompletedTask; return Task.CompletedTask;
this.inputPrompt = this.optimizedPrompt; this.inputPrompt = this.optimizedPrompt;