The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(assistant-ui): remove unused token stats components and restore stopped run slot
Steven Enamakelaea764ae7d56
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex 2875b3e36d..c3d702a3a4 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -1478,7 +1478,7 @@ const AssistantMessage: FC = () => {}}}</MessagePrimitive.GroupedParts>- {false && stopped && <StoppedRunSlot />}+ {stopped && <StoppedRunSlot />}<MessageError /><ChatErrorNotice /></div>diff --git a/app/src/components/chat/ComposerTokenStats.test.tsx b/app/src/components/chat/ComposerTokenStats.test.tsxdeleted file mode 100644index e130e456de..0000000000--- a/app/src/components/chat/ComposerTokenStats.test.tsx+++ /dev/null@@ -1,161 +0,0 @@-import { configureStore } from '@reduxjs/toolkit';-import { fireEvent, render, screen, within } from '@testing-library/react';-import { Provider } from 'react-redux';-import { describe, expect, it, vi } from 'vitest';--import chatRuntimeReducer, { recordChatTurnUsage } from '../../store/chatRuntimeSlice';-import ComposerTokenStats from './ComposerTokenStats';--vi.mock('../../lib/i18n/I18nContext', () => ({ useT: () => ({ t: (k: string) => k }) }));--function renderWithUsage(- payloads: Array<Parameters<typeof recordChatTurnUsage>[0]>,- props?: { model?: string | null; threadId?: string | null }-) {- const store = configureStore({ reducer: { chatRuntime: chatRuntimeReducer } });- for (const p of payloads) store.dispatch(recordChatTurnUsage(p));- return render(- <Provider store={store}>- <ComposerTokenStats {...props} />- </Provider>- );-}--const oneTurn = [- {- inputTokens: 1200,- outputTokens: 300,- cachedTokens: 50,- costUsd: 0.0123,- contextWindow: 200_000,- },-];--describe('<ComposerTokenStats />', () => {- it('renders nothing before any turn when no model is known', () => {- const { container } = renderWithUsage([]);- expect(container).toBeEmptyDOMElement();- });-- it('renders the clickable context row before the first turn when a model is known', () => {- renderWithUsage([], { model: 'reasoning-v1' });- const row = screen.getByRole('button');- expect(row).toHaveTextContent('token.ctxLabel');- });-- it('keeps the inline row minimal: context window and cost only', () => {- renderWithUsage(oneTurn, { model: 'reasoning-v1' });- const row = screen.getByRole('button');- // Context window uses the real reported window (200K), not just a default.- expect(row).toHaveTextContent('token.ctxLabel');- expect(row).toHaveTextContent('200K');- // Cost inline.- expect(row).toHaveTextContent('$0.012');- // Tokens (in/out) are NOT inline — they live in the popover.- expect(row).not.toHaveTextContent('token.inLabel');- expect(row).not.toHaveTextContent('token.outLabel');- // The model id is NOT inline (it lives in the popover).- expect(row).not.toHaveTextContent('reasoning-v1');- });-- it('toggles the breakdown on click and shows explicit labelled rows + tooltips + model', () => {- renderWithUsage(oneTurn, { model: 'reasoning-v1' });- expect(screen.queryByTestId('composer-token-breakdown')).not.toBeInTheDocument();-- fireEvent.click(screen.getByRole('button'));- const bd = screen.getByTestId('composer-token-breakdown');- // Explicit, spelled-out labels with explanatory tooltips.- expect(within(bd).getByText('token.popInput')).toHaveAttribute('title', 'token.tipInput');- expect(within(bd).getByText('token.popOutput')).toHaveAttribute('title', 'token.tipOutput');- expect(within(bd).getByText('token.popCacheHit')).toHaveAttribute('title', 'token.tipCacheHit');- // Cache hit shows a hit-rate percentage: 50 cached / 1200 input ≈ 4%.- expect(within(bd).getByText(/50 \(4%\)/)).toBeInTheDocument();- // Model id surfaced inside the popover.- expect(within(bd).getByText('reasoning-v1')).toBeInTheDocument();-- // Clicking again closes it.- fireEvent.click(screen.getByRole('button'));- expect(screen.queryByTestId('composer-token-breakdown')).not.toBeInTheDocument();- });-- it('highlights the context segment while the breakdown is open', () => {- renderWithUsage(oneTurn);- const ctx = screen.getByText(/token\.ctxLabel/);- expect(ctx.className).not.toMatch(/bg-primary/);- fireEvent.click(screen.getByRole('button'));- expect(ctx.className).toMatch(/bg-primary/);- });-- it('closes on Escape and on an outside click', async () => {- renderWithUsage(oneTurn);- fireEvent.click(screen.getByRole('button'));- expect(screen.getByTestId('composer-token-breakdown')).toBeInTheDocument();- fireEvent.keyDown(document, { key: 'Escape' });- expect(screen.queryByTestId('composer-token-breakdown')).not.toBeInTheDocument();-- fireEvent.click(screen.getByRole('button'));- expect(screen.getByTestId('composer-token-breakdown')).toBeInTheDocument();- // Radix's dismissable layer treats an outside interaction as pointerdown- // *followed by* a click (not a bare `mousedown`, the hand-rolled listener- // this used to have) and defers attaching its listener by one macrotask- // (`setTimeout(…, 0)`) so the same pointerdown that opened the popover- // can't immediately close it again — see the same pattern documented in- // ui/ModalShell.test.tsx.- await new Promise(resolve => setTimeout(resolve, 0));- fireEvent.pointerDown(document.body);- fireEvent.click(document.body);- expect(screen.queryByTestId('composer-token-breakdown')).not.toBeInTheDocument();- });-- it('breaks down spend per agent: orchestrator (derived) + sub-agents', () => {- renderWithUsage([- {- inputTokens: 500,- outputTokens: 100,- costUsd: 0.01,- subAgents: [{ agentId: 'researcher', inputTokens: 200, outputTokens: 40, costUsd: 0.004 }],- },- ]);- fireEvent.click(screen.getByRole('button'));- const bd = screen.getByTestId('composer-token-breakdown');- // Orchestrator row = totals − sub-agents: tokens 600−240=360, cost 0.01−0.004=0.006.- // Scope to the row's <li> because the orchestrator-only context numerator (#4271)- // is also 360 for a single turn, so an unscoped /360/ matches twice.- const orchRow = within(bd).getByText('token.orchestrator').closest('li') as HTMLElement;- expect(within(orchRow).getByText(/360/)).toBeInTheDocument();- expect(within(orchRow).getByText(/\$0\.006/)).toBeInTheDocument();- // Sub-agent row: 200 + 40 = 240 combined tokens, its own cost.- const subRow = within(bd).getByText('researcher').closest('li') as HTMLElement;- expect(within(subRow).getByText(/240/)).toBeInTheDocument();- expect(within(subRow).getByText(/\$0\.004/)).toBeInTheDocument();- // Context-usage row shows the orchestrator-only numerator (360), not the- // combined 600 (parent + sub-agent), so the gauge can't overflow (#4271).- const ctxRow = within(bd).getByText('token.popContext').closest('div') as HTMLElement;- expect(within(ctxRow).getByText(/\b360\b/)).toBeInTheDocument();- expect(within(ctxRow).queryByText(/\b600\b/)).toBeNull();- });-- it('reads the active thread bucket when a threadId is provided', () => {- // Two threads with different usage; the footer must reflect the selected one.- renderWithUsage(- [- { inputTokens: 999, outputTokens: 999, costUsd: 0.5, threadId: 'thr-other' },- { inputTokens: 1200, outputTokens: 300, costUsd: 0.0123, threadId: 'thr-active' },- ],- { threadId: 'thr-active' }- );- fireEvent.click(screen.getByRole('button'));- const bd = screen.getByTestId('composer-token-breakdown');- // Active thread's input tokens (1.2K), not the other thread's 999.- expect(within(bd).getByText('1.2K')).toBeInTheDocument();- expect(within(bd).queryByText('999')).not.toBeInTheDocument();- });-- it('shows the orchestrator row and a no-sub-agents note when none ran', () => {- renderWithUsage([{ inputTokens: 100, outputTokens: 20, costUsd: 0.001 }]);- fireEvent.click(screen.getByRole('button'));- const bd = screen.getByTestId('composer-token-breakdown');- expect(within(bd).getByText('token.orchestrator')).toBeInTheDocument();- expect(within(bd).getByText('token.noSubAgents')).toBeInTheDocument();- });-});diff --git a/app/src/components/chat/ComposerTokenStats.tsx b/app/src/components/chat/ComposerTokenStats.tsxdeleted file mode 100644index d793e0cd55..0000000000--- a/app/src/components/chat/ComposerTokenStats.tsx+++ /dev/null@@ -1,236 +0,0 @@-import { useState } from 'react';--import { useT } from '../../lib/i18n/I18nContext';-import { emptySessionTokenUsage, type SubAgentUsage } from '../../store/chatRuntimeSlice';-import { useAppSelector } from '../../store/hooks';-import { Button, PopoverContent, PopoverRoot, PopoverTrigger } from '../ui';-import Tooltip from '../ui/Tooltip';--/** Fallback context window when the core hasn't reported a real one yet. */-const DEFAULT_CONTEXT_WINDOW = 200_000;--function fmt(n: number): string {- if (!Number.isFinite(n) || n <= 0) return '0';- if (n < 1000) return String(Math.round(n));- if (n < 1_000_000) return `${(n / 1000).toFixed(n < 10_000 ? 1 : 0)}K`;- return `${(n / 1_000_000).toFixed(1)}M`;-}--/** Format a USD cost compactly: sub-cent values keep more precision. */-function fmtUsd(n: number): string {- if (!Number.isFinite(n) || n <= 0) return '$0.00';- if (n < 0.01) return `$${n.toFixed(4)}`;- if (n < 1) return `$${n.toFixed(3)}`;- return `$${n.toFixed(2)}`;-}--function ok(n: number): boolean {- return Number.isFinite(n) && n > 0;-}--/**- * One labelled row in the hover breakdown. The label carries a `title` tooltip- * explaining the metric, hinted with a dotted underline + help cursor.- */-function UsageRow({ label, tip, value }: { label: string; tip: string; value: string }) {- return (- <div className="flex justify-between gap-3">- <dt- title={tip}- className="cursor-help underline decoration-dotted decoration-content-faint underline-offset-2">- {label}- </dt>- <dd className="font-mono text-content">{value}</dd>- </div>- );-}--/** One agent's line in the per-agent breakdown: combined tokens · cost · runs. */-function AgentLine({- name,- tokens,- costUsd,- runs,-}: {- name: string;- tokens: number;- costUsd: number;- runs: number;-}) {- return (- <li className="flex items-center justify-between gap-3">- <span className="truncate text-content-secondary" title={name}>- {name}- </span>- <span className="whitespace-nowrap font-mono text-content">- {fmt(tokens)} · {fmtUsd(costUsd)} · {runs}×- </span>- </li>- );-}--interface ComposerTokenStatsProps {- /** Resolved model id, surfaced inside the breakdown popover. */- model?: string | null;- /**- * Active thread id. When set, the footer shows that thread's usage bucket- * (seeded from persisted transcripts + live turns); otherwise it falls back- * to the global app-session aggregate.- */- threadId?: string | null;-}--const EMPTY_USAGE = emptySessionTokenUsage();--export default function ComposerTokenStats({ model, threadId }: ComposerTokenStatsProps = {}) {- const { t } = useT();- const usage = useAppSelector(state =>- threadId- ? (state.chatRuntime.usageByThread[threadId] ?? EMPTY_USAGE)- : state.chatRuntime.sessionTokenUsage- );- // The breakdown is click-toggled (not hover). `PopoverRoot` below owns- // outside-click and Escape dismissal, and focus management, in place of the- // hand-rolled `mousedown`/`keydown` document listeners this used to carry.- const [open, setOpen] = useState(false);-- const inTok = usage.inputTokens || 0;- const outTok = usage.outputTokens || 0;- const cachedTok = usage.cachedTokens || 0;- const turns = usage.turns || 0;- const costUsd = usage.costUsd || 0;- const subAgents: SubAgentUsage[] = Object.values(usage.subAgents ?? {});-- // Render as soon as a model is resolved (even before the first turn) so the- // clickable usage row is always present in the footer; the context segment- // shows 0% until the first turn reports usage.- if (turns === 0 && !model) return null;-- const contextWindow = ok(usage.contextWindow) ? usage.contextWindow : DEFAULT_CONTEXT_WINDOW;- const contextUsed = usage.lastTurnContextUsed || 0;- const contextPct = Math.min(100, Math.round((contextUsed / contextWindow) * 100));-- const showCost = ok(costUsd);-- // Orchestrator (the parent/main agent) spend = session totals minus everything- // attributed to sub-agents. Derived here so no extra backend data is needed.- const subTotals = subAgents.reduce(- (acc, s) => ({- tokens: acc.tokens + s.inputTokens + s.outputTokens,- cost: acc.cost + s.costUsd,- }),- { tokens: 0, cost: 0 }- );- const orchestratorTokens = Math.max(0, inTok + outTok - subTotals.tokens);- const orchestratorCost = Math.max(0, costUsd - subTotals.cost);-- const parts: React.ReactNode[] = [];-- // Inline footer is intentionally minimal: just context usage · cost. The full- // token breakdown (in/out/cached, per-agent) lives in the click-open popover.- // The context counter is always shown (primary metric + toggle hint) and is- // highlighted while the breakdown is open.- parts.push(- <span- key="ctx"- title={t('token.contextWindow')}- className={- open ? 'rounded bg-primary-500/15 px-1 text-primary-700 dark:text-primary-300' : undefined- }>- {t('token.ctxLabel')} {contextPct}% ({fmt(contextUsed)}/{fmt(contextWindow)})- </span>- );- if (showCost) {- parts.push(- <span key="cost" title={t('token.costTitle')}>- {fmtUsd(costUsd)}- </span>- );- }-- if (parts.length === 0) return null;-- return (- <PopoverRoot open={open} onOpenChange={setOpen}>- <div className="relative flex min-w-0 items-center">- {/* Hover hint that the compact row is interactive; click opens the full- breakdown. The hint is suppressed while the popover is already open. */}- <Tooltip label={open ? '' : t('token.clickForDetails')} side="top">- <PopoverTrigger asChild>- <Button- variant="tertiary"- aria-label={t('token.sessionUsageTitle')}- className="h-auto! min-w-0 flex-wrap gap-1.5 p-0! text-[10px] font-mono text-content-faint hover:bg-transparent select-none">- {parts.map((part, i) => (- <span key={i} className="contents">- {part}- </span>- ))}- </Button>- </PopoverTrigger>- </Tooltip>- <PopoverContent- data-testid="composer-token-breakdown"- aria-label={t('token.sessionUsageTitle')}- side="top"- align="start"- sideOffset={6}- className="w-64 p-2.5 text-[11px] shadow-lg">- <div className="mb-1.5 font-semibold text-content">{t('token.sessionUsageTitle')}</div>- {model && (- <div className="mb-1.5 truncate font-mono text-content-faint" title={model}>- {model}- </div>- )}- <dl className="space-y-0.5 text-content-secondary">- <UsageRow label={t('token.popInput')} tip={t('token.tipInput')} value={fmt(inTok)} />- <UsageRow label={t('token.popOutput')} tip={t('token.tipOutput')} value={fmt(outTok)} />- {ok(cachedTok) && (- <UsageRow- label={t('token.popCacheHit')}- tip={t('token.tipCacheHit')}- value={`${fmt(cachedTok)} (${- inTok > 0 ? Math.min(100, Math.round((cachedTok / inTok) * 100)) : 0- }%)`}- />- )}- <UsageRow- label={t('token.popContext')}- tip={t('token.contextWindow')}- value={`${contextPct}% (${fmt(contextUsed)}/${fmt(contextWindow)})`}- />- <UsageRow- label={t('token.costLabel')}- tip={t('token.costTitle')}- value={fmtUsd(costUsd)}- />- </dl>- <div className="mt-2 border-t border-line-subtle pt-1.5">- <div className="mb-1 font-semibold text-content">{t('token.byAgentHeading')}</div>- <ul className="space-y-0.5 text-content-secondary">- {/* Orchestrator first, then each sub-agent archetype. */}- <AgentLine- name={t('token.orchestrator')}- tokens={orchestratorTokens}- costUsd={orchestratorCost}- runs={turns}- />- {subAgents.map(sub => (- <AgentLine- key={sub.agentId}- name={sub.agentId}- tokens={sub.inputTokens + sub.outputTokens}- costUsd={sub.costUsd}- runs={sub.runs}- />- ))}- </ul>- {subAgents.length === 0 && (- <div className="mt-0.5 text-content-faint">{t('token.noSubAgents')}</div>- )}- </div>- </PopoverContent>- </div>- </PopoverRoot>- );-}diff --git a/app/src/features/conversations/components/composer/ContextWindowPill.test.ts b/app/src/features/conversations/components/composer/ContextWindowPill.test.tsdeleted file mode 100644index 751b7516ae..0000000000--- a/app/src/features/conversations/components/composer/ContextWindowPill.test.ts+++ /dev/null@@ -1,78 +0,0 @@-import { describe, expect, it } from 'vitest';--import { emptySessionTokenUsage } from '../../../../store/chatRuntimeSlice';-import { cacheHitLabel, contextUsageFromTokenUsage } from './ContextWindowPill';--describe('contextUsageFromTokenUsage', () => {- it('keeps cached input separate from fresh input', () => {- expect(- contextUsageFromTokenUsage({- ...emptySessionTokenUsage(),- inputTokens: 1_000,- cachedTokens: 400,- outputTokens: 250,- costUsd: 0.02,- contextWindow: 128_000,- lastTurnContextUsed: 900,- })- ).toEqual({- used: 900,- limit: 128_000,- input: 600,- cachedInput: 400,- output: 250,- costUsd: 0.02,- });- });-- it('preserves an unknown context limit as zero', () => {- expect(contextUsageFromTokenUsage(emptySessionTokenUsage()).limit).toBe(0);- });-- it('uses the selected model context window instead of stale turn usage', () => {- const usage = { ...emptySessionTokenUsage(), contextWindow: 200_000 };- expect(contextUsageFromTokenUsage(usage, 128_000).limit).toBe(128_000);- expect(contextUsageFromTokenUsage(usage, null).limit).toBe(0);- });-});--describe('cacheHitLabel', () => {- // These assert the STRING the "Cached input" row renders, not the- // `cachedInput` field. A field assertion passes while the row is still an- // absolute count, which is the bug (#6461) — so it would be vacuous.- it('renders cache reads as a share of the turn total input', () => {- // 400 cached out of 1000 reported input. Note the denominator is- // `input + cachedInput`, NOT `input` (600) — against `input` this would- // read 67%.- expect(cacheHitLabel({ input: 600, cachedInput: 400 })).toBe('40%');- });-- it('renders an em dash, not 0%, when no input has been reported', () => {- expect(cacheHitLabel({ input: 0, cachedInput: 0 })).toBe('—');- expect(cacheHitLabel(contextUsageFromTokenUsage(emptySessionTokenUsage()))).toBe('—');- });-- it('renders 0% for a reported turn that got no cache hit', () => {- // Distinct from the em dash above: this turn measured a real 0% hit rate.- expect(cacheHitLabel({ input: 1_000, cachedInput: 0 })).toBe('0%');- });-- it('rounds a negligible cache hit down to 0% rather than up', () => {- expect(cacheHitLabel({ input: 999, cachedInput: 1 })).toBe('0%');- });-- it('never exceeds 100% when a provider over-reports cached input', () => {- // `cachedTokens` (500) > `inputTokens` (100). `contextUsageFromTokenUsage`- // floors `input` at 0, so the share lands on 100% instead of 500%. This is- // the reachable form of the over-report; the `Math.min` in `cacheHitLabel`- // is unreachable through this path because the denominator contains the- // numerator.- const usage = contextUsageFromTokenUsage({- ...emptySessionTokenUsage(),- inputTokens: 100,- cachedTokens: 500,- });- expect(usage.input).toBe(0);- expect(cacheHitLabel(usage)).toBe('100%');- });-});diff --git a/app/src/features/conversations/components/composer/ContextWindowPill.tsx b/app/src/features/conversations/components/composer/ContextWindowPill.tsxdeleted file mode 100644index 6dbd6ff3b4..0000000000--- a/app/src/features/conversations/components/composer/ContextWindowPill.tsx+++ /dev/null@@ -1,149 +0,0 @@-import {- Tooltip,- TooltipContent,- TooltipProvider,- TooltipTrigger,-} from '@/components/assistant-ui/ui/tooltip';-import { GaugeIcon } from 'lucide-react';--import { useT } from '../../../../lib/i18n/I18nContext';-import type { SessionTokenUsage } from '../../../../store/chatRuntimeSlice';--/**- * Token accounting for the current thread.- *- * Every field is what the *provider* reports, not a local estimate, which is- * why `cachedInput` is tracked apart from `input`: a cache read is billed at a- * fraction of a fresh read, so a turn's cost cannot be derived from a single- * token count.- */-export type ContextUsage = {- /** Tokens currently occupying the window. */- used: number;- /** Size of the window for the selected model. */- limit: number;- input: number;- cachedInput: number;- output: number;- /** Accumulated spend for the thread, in USD. */- costUsd: number;-};--/** Map the authoritative Redux token bucket onto the compact meter shape. */-export function contextUsageFromTokenUsage(- usage: SessionTokenUsage,- selectedModelContextWindow?: number | null-): ContextUsage {- const cachedInput = Math.max(0, usage.cachedTokens || 0);- return {- used: Math.max(0, usage.lastTurnContextUsed || 0),- limit:- selectedModelContextWindow === undefined- ? Math.max(0, usage.contextWindow || 0)- : Math.max(0, selectedModelContextWindow ?? 0),- // `inputTokens` includes provider-reported cache reads. Keep fresh input- // and cached input in distinct rows instead of counting cache hits twice.- input: Math.max(0, (usage.inputTokens || 0) - cachedInput),- cachedInput,- output: Math.max(0, usage.outputTokens || 0),- costUsd: Math.max(0, usage.costUsd || 0),- };-}--const compact = (n: number): string =>- n >= 1000 ? `${(n / 1000).toFixed(n >= 10_000 ? 0 : 1)}k` : String(n);--/**- * Cache reads as a share of the thread's input, or an em dash when no input has- * been reported yet.- *- * A share rather than a count because the two rows are disjoint:- * `contextUsageFromTokenUsage` has already subtracted the cached portion out of- * `input`, so rendering both as absolutes read as if the cache were larger than- * the input it came from. The denominator is therefore the ORIGINAL input total- * (`input + cachedInput`, i.e. `SessionTokenUsage.inputTokens`) — not `input`,- * which would let the ratio exceed 100%, and not `limit`, which a thread's- * cumulative input outgrows after a few turns.- *- * An em dash rather than `0%` when nothing has been reported: `0%` asserts a- * measured miss rate that no turn ever produced. `0%` on a turn that *did*- * report input and got no cache hit is correct and shows.- *- * The clamp is defence in depth only, and is unreachable by construction here —- * the denominator contains the numerator. It guards a caller that builds a- * `ContextUsage` by hand with a negative `input`; the provider-reported- * over-report (`cachedTokens > inputTokens`) is already absorbed upstream by the- * `Math.max(0, …)` on `input` and lands on 100%.- */-export function cacheHitLabel(usage: Pick<ContextUsage, 'input' | 'cachedInput'>): string {- const total = usage.input + usage.cachedInput;- if (total <= 0) return '—';- return `${Math.min(100, Math.round((usage.cachedInput / total) * 100))}%`;-}--const Row = ({ label, value }: { label: string; value: string }) => (- <div className="flex items-baseline justify-between gap-6">- <span className="text-muted-foreground">{label}</span>- <span className="tabular-nums">{value}</span>- </div>-);--/**- * How full the context window is, with the cost and token breakdown behind a- * hover.- *- * The pill shows the one number that changes a decision in the moment — how- * much room is left — and keeps the accounting out of the way until asked for.- * A bar rather than a percentage because the useful reading is "am I near the- * end", not the exact figure.- */-export function ContextWindowPill({ usage }: { usage: ContextUsage }) {- const { t } = useT();- const limitKnown = usage.limit > 0;- const ratio = limitKnown ? Math.min(1, usage.used / usage.limit) : 0;- // Amber past three quarters, red past nine tenths: the points where the next- // long turn starts being at risk of truncation.- const tone = ratio > 0.9 ? 'bg-coral-500' : ratio > 0.75 ? 'bg-amber-500' : 'bg-primary-500';-- return (- <TooltipProvider>- <Tooltip>- <TooltipTrigger- render={- <button- type="button"- aria-label={t('conversations.composer.context.title')}- className="text-muted-foreground hover:text-foreground hover:bg-muted flex h-7 shrink-0 items-center gap-1.5 rounded-full px-2.5 text-xs transition-colors">- <GaugeIcon className="size-3.5" />- <span className="tabular-nums">- {compact(usage.used)}/{limitKnown ? compact(usage.limit) : '—'}- </span>- <span className="bg-muted h-1 w-8 overflow-hidden rounded-full">- <span- className={`block h-full rounded-full ${tone}`}- style={{ width: limitKnown ? `${Math.max(2, ratio * 100)}%` : '0%' }}- />- </span>- </button>- }- />- {/* The vendored `TooltipContent` is an `inline-flex` row with `items-center`,- which would sit the heading beside the rows instead of above them. */}- <TooltipContent side="top" className="min-w-52 flex-col items-stretch gap-0 p-2.5 text-xs">- <p className="mb-1.5 font-medium">{t('conversations.composer.context.title')}</p>- <div className="flex flex-col gap-1">- <Row label={t('conversations.composer.context.input')} value={compact(usage.input)} />- <Row label={t('conversations.composer.context.cached')} value={cacheHitLabel(usage)} />- <Row label={t('conversations.composer.context.output')} value={compact(usage.output)} />- <Row- label={t('conversations.composer.context.cost')}- value={`$${usage.costUsd.toFixed(3)}`}- />- </div>- </TooltipContent>- </Tooltip>- </TooltipProvider>- );-}--export default ContextWindowPill;