Context

How much of the model's context window the conversation has used.

Usage

Context

import { Component, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScPreviewCard,  ScPreviewCardPortal,  ScPreviewCardProvider,  ScPreviewCardTrigger,  ScProgress,  ScProgressRange,  ScProgressTrack,

A Preview Card (shadcn's Hover Card) on a button, with a Progress bar and the breakdown: input, output, reasoning.

Anatomy

import {  ScPreviewCardProvider, ScPreviewCardTrigger, ScPreviewCardPortal, ScPreviewCard,  ScProgress, ScProgressTrack, ScProgressRange, ScButton,} from '@semantic-components/ui';
<div scPreviewCardProvider>  <button scButton scPreviewCardTrigger variant="outline" size="sm">    {{ percent }}% context  </button>  <ng-template scPreviewCardPortal>    <div scPreviewCard class="flex w-64 flex-col gap-3">      …      <div scProgress [value]="percent" aria-label="Context used">        <div scProgressTrack><div scProgressRange></div></div>      </div>    </div>  </ng-template></div>

Accessibility

A preview card is for the eyes only: it opens on hover and focus, but it is not announced. The button's own text carries what matters ("8% context"); the breakdown is extra. If it must be read too, use a Popover instead, opened on click.

Limit

The usage comes with the agent's message, once its stream ends; the limit is the model's context window, which the stream does not send: set it from the model you use.

Examples

RTL

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScButton,  ScPreviewCard,  ScPreviewCardPortal,  ScPreviewCardProvider,  ScPreviewCardTrigger,  ScProgress,  ScProgressRange,

API reference

See the Preview Card and the Progress.