diff --git a/src/lib/layout/LeafPane.tsx b/src/lib/layout/LeafPane.tsx index 2e0a3ce..0cef00a 100644 --- a/src/lib/layout/LeafPane.tsx +++ b/src/lib/layout/LeafPane.tsx @@ -12,9 +12,9 @@ import { type LeafNode, resolveFontSize, type LeafShellSpec } from "./tree"; import { useOrchestration } from "./orchestration"; import { contextLabel, - contextPercent, contextColor, contextFraction, + formatTokens, } from "../../lib/usage"; import XtermPane from "../../components/XtermPane"; import type { SpawnSpec } from "../../ipc"; @@ -597,12 +597,12 @@ export default function LeafPane({ leaf }: { leaf: LeafNode }) { - {contextPercent(ctx)}% + {formatTokens(ctx.contextTokens)} )} diff --git a/src/lib/usage.ts b/src/lib/usage.ts index f4584f1..6fb2530 100644 --- a/src/lib/usage.ts +++ b/src/lib/usage.ts @@ -4,18 +4,18 @@ import type { SessionContext } from "../ipc"; -const WINDOW_STANDARD = 200_000; const WINDOW_LARGE = 1_000_000; /** - * Context-window size for a session. The transcript's model id doesn't encode - * the 200k-vs-1M variant, so we infer: a session whose prompt has already - * exceeded 200k must be running the 1M-context window. Approximate near the - * boundary, but correct for the cases that matter (a small session reads - * against 200k; a large one against 1M). + * Assumed context window. The transcript does NOT record whether a session + * runs the 200k or 1M window (the model id is bare, e.g. `claude-opus-4-7` — + * the `[1m]` that claude's /context shows is display-only), so the % can't be + * computed reliably. We assume 1M (the common case here) for the fill bar, and + * the indicator LABEL shows the absolute token count, which is accurate + * regardless of the real window — that's the figure to trust. */ -export function contextWindow(contextTokens: number): number { - return contextTokens > WINDOW_STANDARD ? WINDOW_LARGE : WINDOW_STANDARD; +export function contextWindow(_contextTokens: number): number { + return WINDOW_LARGE; } /** Fraction (0..1) of the inferred window currently occupied. */ @@ -41,9 +41,7 @@ export function formatTokens(n: number): string { return String(n); } -/** e.g. "~274k / 1M" for a tooltip. */ +/** e.g. "274k tokens · ~27% of 1M (last turn)" for a tooltip. */ export function contextLabel(s: SessionContext): string { - const w = contextWindow(s.contextTokens); - const wLabel = w >= 1_000_000 ? "1M" : "200k"; - return `~${formatTokens(s.contextTokens)} / ${wLabel}`; + return `${formatTokens(s.contextTokens)} tokens · ~${contextPercent(s)}% of 1M (last turn)`; }