Improved the coding assistant by adding a button to delete a context (#90)

This commit is contained in:
Thorsten Sommer 2024-08-23 11:23:36 +02:00 committed by GitHub
parent 3fd0d4d5c1
commit a6c5b3de23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 44 additions and 1 deletions

View File

@ -5,7 +5,8 @@
@for (var contextIndex = 0; contextIndex < this.codingContexts.Count; contextIndex++)
{
var codingContext = this.codingContexts[contextIndex];
<ExpansionPanel HeaderText="@codingContext.Id" HeaderIcon="@Icons.Material.Filled.Code">
var index = contextIndex;
<ExpansionPanel HeaderText="@codingContext.Id" HeaderIcon="@Icons.Material.Filled.Code" ShowEndButton="@true" EndButtonColor="Color.Error" EndButtonIcon="@Icons.Material.Filled.Delete" EndButtonTooltip="Delete context" EndButtonClickAsync="@(() => this.DeleteContext(index))">
<CodingContextItem @bind-CodingContext="@codingContext"/>
</ExpansionPanel>
}

View File

@ -105,6 +105,18 @@ public partial class AssistantCoding : AssistantBaseCore
});
}
private ValueTask DeleteContext(int index)
{
if(this.codingContexts.Count < index + 1)
return ValueTask.CompletedTask;
this.codingContexts.RemoveAt(index);
this.form?.ResetValidation();
this.StateHasChanged();
return ValueTask.CompletedTask;
}
private async Task GetSupport()
{
await this.form!.Validate();

View File

@ -3,6 +3,20 @@
<div class="d-flex align-center">
<MudIcon Icon="@this.HeaderIcon" Size="@this.IconSize" Color="@this.IconColor" class="mr-3"/>
<MudText Typo="Typo.h6">@this.HeaderText</MudText>
@if (this.ShowEndButton)
{
<MudSpacer/>
if (!string.IsNullOrWhiteSpace(this.EndButtonTooltip))
{
<MudTooltip Text="@this.EndButtonTooltip">
<MudIconButton Icon="@this.EndButtonIcon" Color="@this.EndButtonColor" Size="Size.Medium" OnClick="async () => await this.EndButtonClickAsync()"/>
</MudTooltip>
}
else
{
<MudIconButton Icon="@this.EndButtonIcon" Color="@this.EndButtonColor" Size="Size.Medium" OnClick="async () => await this.EndButtonClickAsync()"/>
}
}
</div>
</TitleContent>
<ChildContent>

View File

@ -21,4 +21,19 @@ public partial class ExpansionPanel : ComponentBase
[Parameter]
public bool IsExpanded { get; set; }
[Parameter]
public bool ShowEndButton { get; set; }
[Parameter]
public Func<ValueTask> EndButtonClickAsync { get; set; } = () => ValueTask.CompletedTask;
[Parameter]
public string EndButtonIcon { get; set; } = Icons.Material.Filled.Delete;
[Parameter]
public Color EndButtonColor { get; set; } = Color.Error;
[Parameter]
public string EndButtonTooltip { get; set; } = string.Empty;
}

View File

@ -1,6 +1,7 @@
# v0.8.12, build 174
- Added an e-mail writing assistant.
- Added the possibility to preselect some e-mail writing assistant options.
- Improved the coding assistant by adding a button to delete a context.
- Improved chat page by scrolling to the bottom after loading (configurable; default is on).
- Improved all assistants to provide a button to copy their respective result to the clipboard.
- Improved the content validation for the agenda assistant.