Add per-answer thinking disclosure

This commit is contained in:
Peer Hogeterp committed 2026-09-10 15:37:43 +02:00
1 parent c7b42bee96
commit bbbcdddc91
29 files changed
+360 -37

No files matched your search

@@ -127,6 +127,7 @@ public partial class ContentBlockComponent : MSGComponentBase
private bool hasActiveMathContainer;
private bool isDisposed;
private bool showToolTrace;
private bool showThinking;
private readonly HashSet<int> expandedToolInvocations = [];
/// <summary>
@@ -139,6 +140,10 @@ public partial class ContentBlockComponent : MSGComponentBase
/// </remarks>
private bool CanExport => this.Content is { InitialRemoteWait: false, IsStreaming: false } && this.Content.TryGetMarkdownText(out _);
private bool HasThinking => this.Role is ChatRole.AI &&
this.Content is ContentText { Thinking: var thinking } &&
!string.IsNullOrWhiteSpace(thinking);
/// <summary>
/// The tables this block holds so that the export menu can offer each of them.
/// </summary>
@@ -305,11 +310,14 @@ public partial class ContentBlockComponent : MSGComponentBase
var textValue = text.Text;
hash.Add(textValue.Length);
hash.Add(textValue.GetHashCode(StringComparison.Ordinal));
hash.Add(text.Thinking.Length);
hash.Add(text.Thinking.GetHashCode(StringComparison.Ordinal));
hash.Add(text.Sources.Count);
hash.Add(text.ToolInvocations.Count);
hash.Add(text.ToolRuntimeStatus.IsRunning);
hash.Add(text.ToolRuntimeStatus.Message);
hash.Add(this.showToolTrace);
hash.Add(this.showThinking);
hash.Add(this.expandedToolInvocations.Count);
foreach (var expandedInvocation in this.expandedToolInvocations.Order())
hash.Add(expandedInvocation);
@@ -380,6 +388,10 @@ public partial class ContentBlockComponent : MSGComponentBase
private void ToggleToolTrace() => this.showToolTrace = !this.showToolTrace;
private void ToggleThinking() => this.showThinking = !this.showThinking;
private string GetThinkingTooltip() => this.showThinking ? this.T("Hide thinking") : this.T("Show thinking");
private bool IsToolInvocationExpanded(int order) => this.expandedToolInvocations.Contains(order);
private void ToggleToolInvocation(int order)
@@ -832,4 +844,4 @@ public partial class ContentBlockComponent : MSGComponentBase
await this.DisposeMathContainerIfNeededAsync();
}
}
}