- @* Message list: scrollable area that grows to fill available space.
- The @ref directive captures a reference to this DOM element so we can
- scroll it programmatically via JavaScript interop. *@
+ @* Message list: scrollable area that grows to fill available space. *@
@if (_messages.Count == 0)
{
@@ -48,14 +51,23 @@
else
{
@* Render each message as a MudPaper card.
- @foreach iterates the list; Blazor re-renders this block when _messages changes.
The CSS class changes based on Role to align user messages right, assistant left. *@
@foreach (var message in _messages)
{
- @message.Content
+ @if (message.Role == "assistant" && string.IsNullOrEmpty(message.Content) && _isStreaming)
+ {
+ @* Thinking indicator: shown while waiting for the first token.
+ MudProgressCircular gives an animated spinner that disappears
+ once the first text delta arrives. *@
+
+ }
+ else
+ {
+ @message.Content
+ }
}
@@ -63,26 +75,25 @@
@* Input area: pinned at the bottom of the chat container.
- MudTextField with an Adornment provides the send button inside the text field,
- similar to ChatGPT's input design. *@
+ Disabled attribute prevents interaction while the assistant is streaming. *@
+ AutoFocus="true"
+ Disabled="_isStreaming" />
@code {
// The conversation messages, displayed in the message list.
- // Using a simple List