From bcd53cdd8896ec42f6f4db6ac5c8fca965dfc419 Mon Sep 17 00:00:00 2001 From: Govind Tiwari <108tiwari.g@gmail.com> Date: Thu, 30 Jul 2026 00:14:19 +0530 Subject: [PATCH] fix(tui): show context percentage relative to input limit Compaction triggers based on limit.input (when available), but the TUI context indicator used limit.context as the denominator. For models where limit.input < limit.context (e.g. gpt-5.6-sol via codex: input=372K vs context=500K), this caused compaction to start when the TUI showed only ~30-35% usage. Now uses limit.input when present, falling back to limit.context, so the displayed percentage reflects when compaction will actually fire. Fixes #38851 --- packages/tui/src/component/prompt/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/tui/src/component/prompt/index.tsx b/packages/tui/src/component/prompt/index.tsx index 00efcbed2887..9a692881cc97 100644 --- a/packages/tui/src/component/prompt/index.tsx +++ b/packages/tui/src/component/prompt/index.tsx @@ -272,7 +272,8 @@ export function Prompt(props: PromptProps) { if (tokens <= 0) return const model = sync.data.provider.find((item) => item.id === last.providerID)?.models[last.modelID] - const pct = model?.limit.context ? `${Math.round((tokens / model.limit.context) * 100)}%` : undefined + const limit = model?.limit.input ?? model?.limit.context + const pct = limit ? `${Math.round((tokens / limit) * 100)}%` : undefined const cost = session?.cost ?? 0 return { context: pct ? `${Locale.number(tokens)} (${pct})` : Locale.number(tokens),