Skip to content
uifiles
Browse components
ChatComponent

Reasoning

Collapsible "thinking" block for AI reasoning/thought tokens. ReasoningTrigger shows a shimmering "Thinking..." while isStreaming, then "Thought for N seconds" (duration measured automatically or passed in); ReasoningContent renders the reasoning text as markdown with Streamdown. Auto-opens when streaming starts and auto-closes one second after it ends; defaultOpen={false} disables the auto-open, a reader's manual toggle is respected, and a controlled parent receives both requests through onOpenChange. Use it above a message response when the model exposes reasoning.

pnpm dlx shadcn@latest add @uifiles/reasoning

Streaming

Opens itself while the thought streams in and closes one second after it ends.

Finished, open

A duration was supplied, so the trigger reads how long the model thought. Open by default; the fence, table and formula scroll in their own boxes.

The user wants a caching strategy for a profile page.

  • Profile data changes rarely, so a short revalidation window is fine.
  • no-store would hit the origin on every request.
  • force-cache would serve stale names after a rename.

Recommend revalidate: 60 and mention revalidateTag for instant invalidation on edit.

Checking the route config before answering:

ts
export const revalidate = 60 // and revalidateTag("profile") in the rename action
Caching strategyFreshness guaranteeOrigin loadRecommended for
no-storeAlways freshEvery requestPersonalized dashboards
revalidate: 60Up to 60s staleOnce a minuteProfile pages
force-cacheUntil redeployOnce per buildReference data

If a model predicted which profiles get renamed, its regularized logistic loss would be:

L(θ)=−1n∑i=1n[yilog⁡σ(θ⊤xi)+(1−yi)log⁡(1−σ(θ⊤xi))]+λ∥θ∥22\mathcal{L}(\theta) = -\frac{1}{n} \sum_{i=1}^{n} \left[ y_i \log \sigma(\theta^\top x_i) + (1 - y_i) \log\left(1 - \sigma(\theta^\top x_i)\right) \right] + \lambda \lVert \theta \rVert_2^2

Not worth it for a profile page: a 60 second window is simpler.

Finished, collapsed

No duration, so the trigger only says the model thought. Collapsed until opened.