mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-12 22:33:48 +00:00
Fixed the source counter of an answer doing nothing when clicked
This commit is contained in:
4 files changed
+44
-3
No files matched your search
@@ -48,7 +48,7 @@
|
||||
{
|
||||
<MudTooltip Text="@T("Number of sources")" Placement="Placement.Bottom">
|
||||
<MudBadge Content="@this.Content.Sources.Count" Color="Color.Primary" Overlap="true" BadgeClass="sources-card-header">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Link"/>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Link" Disabled="@(!this.HasSourcesToShow)" OnClick="@this.ShowSources"/>
|
||||
</MudBadge>
|
||||
</MudTooltip>
|
||||
}
|
||||
@@ -223,7 +223,7 @@
|
||||
}
|
||||
@if (textContent.Sources.Count > 0)
|
||||
{
|
||||
<SourcesList Sources="@textContent.Sources"/>
|
||||
<SourcesList @ref="this.sourcesList" Sources="@textContent.Sources"/>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ public partial class ContentBlockComponent : MSGComponentBase
|
||||
private IReadOnlyList<MessageTable> cachedMessageTables = [];
|
||||
private char csvSeparator = ',';
|
||||
private ElementReference mathContentContainer;
|
||||
private SourcesList? sourcesList;
|
||||
private string lastMathRenderSignature = string.Empty;
|
||||
private bool hasActiveMathContainer;
|
||||
private bool isDisposed;
|
||||
@@ -815,6 +816,25 @@ public partial class ContentBlockComponent : MSGComponentBase
|
||||
this.Content.FileAttachments = [.. result];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the sources of this block stand below the answer, where the counter can take the reader.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The same condition the block itself renders the list under. While an answer is still coming
|
||||
/// in, its sources may already be known, but there is nothing on the page yet to scroll to --
|
||||
/// so the counter says it cannot do anything rather than doing nothing when clicked.
|
||||
/// </remarks>
|
||||
private bool HasSourcesToShow => this.Content is { InitialRemoteWait: false, IsStreaming: false, Sources.Count: > 0 };
|
||||
|
||||
/// <summary>
|
||||
/// Takes the reader from the source counter down to the sources themselves.
|
||||
/// </summary>
|
||||
private async Task ShowSources()
|
||||
{
|
||||
if (this.sourcesList is not null)
|
||||
await this.sourcesList.ScrollIntoViewAsync();
|
||||
}
|
||||
|
||||
protected override async ValueTask DisposeResourcesAsync()
|
||||
{
|
||||
if (this.isDisposed)
|
||||
|
||||
Reference in new issue
Block a user