Reasoning

A collapsible block that streams a model's thinking.

Reasoning is new in v0.4.0. It shows a model's reasoning in a collapsible block: open while IsStreaming is true, labelled "Thinking…", then folded to "Thought for N seconds" when streaming ends. The user can open it again with a click.

Installation

bash
shellui add reasoning

Usage

Streaming

Append to Text as chunks arrive and call StateHasChanged(). Set IsStreaming while they arrive and Duration when they stop.

<div class="w-full max-w-xl space-y-3">
    <Button Variant="ButtonVariant.Outline" OnClick="RunAsync" Disabled="streaming">@(streaming ? "Thinking…" : "Run")</Button>
    <Reasoning Text="@text" IsStreaming="streaming" Duration="duration" />
</div>

@code {
    private string? text = "Press Run to stream a model's reasoning into this block.";
    private bool streaming;
    private TimeSpan? duration;

    private async Task RunAsync()
    {
        text = "";
        duration = null;
        streaming = true;
        var started = DateTime.UtcNow;
        foreach (var word in "The user wants to know how dialogs keep focus. I should search the docs for the focus trap, then summarise what Tab does inside an open dialog.".Split(' '))
        {
            text += word + " ";
            StateHasChanged();
            await Task.Delay(90);
        }
        streaming = false;
        duration = DateTime.UtcNow - started;
    }
}

Title and child content

Title replaces the label, and child content is rendered after Text, so the body can hold markup. DefaultOpen opens it on first render.

  1. Find the pages that mention the focus trap.
  2. Read the Dialog accessibility section.
  3. Answer with a short example.
<div class="w-full max-w-xl space-y-3">
    <Reasoning Title="Plan" DefaultOpen="true">
        <ol class="list-decimal space-y-1 pl-5">
            <li>Find the pages that mention the focus trap.</li>
            <li>Read the Dialog accessibility section.</li>
            <li>Answer with a short example.</li>
        </ol>
    </Reasoning>
    <Reasoning Text="Checked the release notes for 0.4.0." Duration="TimeSpan.FromSeconds(3)" />
</div>

Behaviour

  • On first render the block is open if DefaultOpen or IsStreaming is set.
  • When IsStreaming changes, the block follows it: it opens when streaming starts and closes when it ends. A click toggles it in between.
  • The label is Title if set; otherwise "Thinking…" while streaming, "Thought for N seconds" once Duration is set (rounded, at least 1 second), and "Reasoning" before either.

API Reference

Parameter Type Default Description
Text string? null The reasoning text; line breaks are kept
ChildContent RenderFragment? null Markup shown after Text
IsStreaming bool false Opens the block and pulses the label while true; closes it when it turns false
Duration TimeSpan? null How long the model thought, shown once streaming ends
Title string? null Replaces the "Thinking…" / "Thought for …" label
DefaultOpen bool false Opens the block on first render
Class string? null Additional CSS classes

Accessibility

  • The header is a <button> with aria-expanded, so screen readers announce whether the reasoning is shown
  • Pair it with Tool Call and Chat for an agent UI

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.