Add "Open in chat" button functionality to ERI assistant

This commit is contained in:
Thorsten Sommer 2026-07-03 14:43:55 +02:00
parent 2f1849ce75
commit 6336a4877e
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -292,7 +292,17 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
}
}
protected override IReadOnlyList<IButtonData> FooterButtons => [];
protected override IReadOnlyList<IButtonData> FooterButtons =>
[
new ButtonData
{
Text = T("Open in chat"),
Icon = Icons.Material.Filled.Chat,
Color = Color.Default,
AsyncAction = this.OpenInChat,
DisabledActionParam = () => !this.CanOpenInChat,
},
];
protected override bool ShowEntireChatThread => true;
@ -308,6 +318,22 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
{
SystemPrompt = this.SystemPrompt,
};
/// <summary>
/// Indicates whether the generated ERI conversation can be opened in the chat view.
/// </summary>
private bool CanOpenInChat => !this.IsProcessing && this.ChatThread is { Blocks.Count: > 0 };
/// <summary>
/// Opens the generated ERI conversation in the chat view when a finished conversation is available.
/// </summary>
private async Task OpenInChat()
{
if (!this.CanOpenInChat)
return;
await this.SendToAssistant(Tools.Components.CHAT, default);
}
protected override void ResetForm()
{
@ -1241,6 +1267,5 @@ public partial class AssistantERI : AssistantBaseCore<SettingsDialogERIServer>
like Docker.
""", true);
await this.AddAIResponseAsync(time);
await this.SendToAssistant(Tools.Components.CHAT, default);
}
}