Reasoning

The agent's thinking as it streams. A line that reads "Thinking" and opens while the model thinks, then reads "Thought" and closes when it is done; the thinking itself sits inside, and the line can show how long it took.

Usage

Reasoning

Why is the checkout deploy so slow?
The deploy log has three phases. Install takes 38s and next build takes 52s, both normal for this repo. Image optimization takes 3m 50s. It reruns on every deploy because its cache key includes the commit hash, so the cache never hits.

Image optimization is the bottleneck. Key its cache on the lockfile and the image directory instead of the commit hash, and the deploy should take under two minutes.

import { NgTemplateOutlet } from '@angular/common';import {  Component,  DestroyRef,  ViewEncapsulation,  type WritableSignal,  computed,  inject,  signal,} from '@angular/core';

A pattern, not a component: it is built with the Trace, a Collapsible for the thinking, in a Message. The streaming here is replayed on a timer.

Anatomy

import {  ScTrace, ScTraceLine, ScTraceIcon, ScTraceTitle,  ScTraceCollapsible, ScTraceCollapsibleTrigger,  ScTraceCollapsiblePanelContent,  ScCollapsible, ScCollapsibleTrigger, ScCollapsiblePanel,} from '@semantic-components/ui';
<div scTrace>  <div scCollapsible scTraceCollapsible [open]="open()">    <button scCollapsibleTrigger scTraceCollapsibleTrigger>      <span scTraceLine [status]="running() ? 'running' : undefined">        <span scTraceIcon>…</span>        <span scTraceTitle>Thought</span>      </span>    </button>    <div scCollapsiblePanel>      <div scTraceCollapsiblePanelContent>…</div>    </div>  </div></div>

Open state

  • Until the first words arrive, it is a plain line: nothing to open before the model has written anything.
  • Then it opens while the model thinks and closes when it finishes — unless the person opened or closed it: their choice wins. The Collapsible's open is your choice, else the running state.
  • The streamed text goes in a live region (here aria-live="polite" on the trace), so "Thinking" and "Thought" are announced.

Examples

How long it thought, in a description after the title: measure it on the server and send it with the message.

Duration

import { Component, ViewEncapsulation } from '@angular/core';import {  ScCollapsible,  ScCollapsiblePanel,  ScCollapsibleTrigger,  ScTrace,  ScTraceCollapsible,  ScTraceCollapsiblePanelContent,  ScTraceCollapsibleTrigger,  ScTraceDescription,

Some models send several reasoning parts in one message: each one is a line in the same trace, with its own open state.

Several parts

import { NgTemplateOutlet } from '@angular/common';import {  Component,  DestroyRef,  ViewEncapsulation,  computed,  inject,  input,  signal,} from '@angular/core';

RTL

لماذا نشر صفحة الدفع بطيء جدًا؟
يمر سجل النشر بثلاث مراحل. التثبيت والبناء في الوقت المعتاد. تحسين الصور يستغرق ٣ دقائق و٥٠ ثانية، ويُعاد في كل نشر لأن مفتاح ذاكرته المؤقتة يتضمن معرّف الإيداع.

تحسين الصور هو عنق الزجاجة. اجعل مفتاح ذاكرته المؤقتة ملف القفل ومجلد الصور بدل معرّف الإيداع، وسيستغرق النشر أقل من دقيقتين.

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScBubble,  ScBubbleContent,  ScCollapsible,  ScCollapsiblePanel,  ScCollapsibleTrigger,  ScMessage,  ScMessageContent,

API reference

See the Trace and the Collapsible.