Back to components

AI Interfaces

Context Window Meter

A token allocation breakdown for system instructions, conversation history, and retrieved sources.

tokenscontextobservability

Installation

Copy and paste the code into your project.

Accessibility notes

Every segment has a visible label and token value, so the chart is supplementary rather than essential.

Context window

25.4k / 32k

79% used
System
4.2k
Conversation
12.8k
Sources
8.4k

6.6k tokens available for response

Preview accent

TypeScript
const segments = [
  { label: "System", tokens: "4.2k", width: "w-[18%]", color: "bg-[#40E0D0]" },
  { label: "Conversation", tokens: "12.8k", width: "w-[38%]", color: "bg-[#a78bfa]" },
  { label: "Sources", tokens: "8.4k", width: "w-[27%]", color: "bg-[#fb923c]" },
];

export function ContextWindowMeter() {
  return (
    <section className="w-full max-w-sm rounded-xl border border-white/12 bg-[#0b0f14]/92 p-5 shadow-2xl">
      <div className="flex items-end justify-between gap-4">
        <div><p className="text-xs font-semibold uppercase tracking-[0.18em] text-[#40E0D0]">Context window</p><h3 className="mt-2 text-2xl font-black tabular-nums text-white">25.4k <span className="text-sm font-semibold text-slate-500">/ 32k</span></h3></div>
        <span className="rounded-full bg-[#fb923c]/12 px-2.5 py-1 text-xs font-bold text-[#fdba74]">79% used</span>
      </div>
      <div className="mt-5 flex h-2.5 gap-1 overflow-hidden rounded-full bg-white/[0.06]" aria-hidden="true">
        {segments.map((segment) => <span key={segment.label} className={`${segment.width} ${segment.color} rounded-full`} />)}
      </div>
      <dl className="mt-4 grid grid-cols-3 gap-2">
        {segments.map((segment) => <div key={segment.label} className="rounded-lg border border-white/8 bg-white/[0.035] p-2.5"><dt className="text-[0.65rem] text-slate-500">{segment.label}</dt><dd className="mt-1 text-xs font-bold tabular-nums text-slate-200">{segment.tokens}</dd></div>)}
      </dl>
      <p className="mt-4 flex items-center gap-2 text-xs text-slate-400"><span className="h-1.5 w-1.5 rounded-full bg-[#40E0D0]" /> 6.6k tokens available for response</p>
    </section>
  );
}
Usage
<ContextWindowMeter />

Related components

Context compression

Compaction preview

−7.5k tokens
  • Decisions

    1.8k

    Keep
  • Discussion

    8.4k → 1.2k

    Summarize
  • Duplicates

    2.1k

    Drop
Projected context5.4k / 16k

AI Interfaces

Context Compression Preview

Advanced

A compaction preflight showing which conversation sections will be kept, summarized, or dropped.

contextcompressiontokens
View component

Context window

Token allocation

23.9kof 32k

  • System
    4.2k
  • History
    9.8k
  • Retrieval
    5.1k
  • Response
    4.8k

8.1k tokens remain for tools, retries, and safety margin.

AI Interfaces

Token Budget Allocator

Intermediate

A context-window planner showing how instructions, history, retrieval, and response capacity consume tokens.

tokenscontextbudget
View component

Agent memory

Eduardo workspace

3 saved
  • Prefers compact dashboards
  • Uses eval scorecards
  • Ships with dark themes

AI Interfaces

Agent Memory Card

Intermediate

A compact memory summary card for personalized agents and workspace context.

agentmemorycontext
View component