Description
The context usage indicator in the TUI (the progress circle button showing "used" percentage in the right panel) always shows 0%, regardless of how much conversation has occurred.
Root Cause Analysis
The issue is in the build\ function (which computes session context) in the bundled frontend code. The chain is:
-
build\ computes usage from the model's context limit:
const limit = model?.limit.context; // line 130424
usage: limit ? Math.round(total2 / limit * 100) : null // line 130435
-
When model.limit is undefined (server doesn't return it), limit becomes undefined, usage is set to null.
-
SessionContextUsage component renders:
percentage: context()?.usage ?? 0 // null → 0
-
ProgressCircle shows 0%:
const clampedPercentage = Math.max(0, Math.min(100, 0 || 0)); // = 0
Two Possible Causes
-
Server API doesn't return limit.context — The model.limit field at line 75945 is passed straight through from the server's model list API response (sdk.model.list()). If the server doesn't include limit: { context: <number> } in the model data, limit is undefined.
-
Server doesn't send token data in session.step.ended — At line 78140, event.data.tokens populates the assistant message. If this is empty, tokenTotal returns 0, lastAssistantWithTokens skips the message, and build\ returns undefined → 0%.
Additional crash risk
The same model.limit is accessed without null safety in ModelTooltip component (line 136394):
props.model.limit.context.toLocaleString() // crashes if model.limit is undefined
Suggested Fix
In build\, add a fallback for model.limit:
const limit = model?.limit?.context ?? 0;
And in ModelTooltip:
props.model.limit?.context?.toLocaleString() ?? "unknown"
But the real fix should be on the server side to ensure model.limit.context is always populated with the correct context window size for each model.
Description
The context usage indicator in the TUI (the progress circle button showing "used" percentage in the right panel) always shows 0%, regardless of how much conversation has occurred.
Root Cause Analysis
The issue is in the
build\function (which computes session context) in the bundled frontend code. The chain is:build\computesusagefrom the model's context limit:When
model.limitisundefined(server doesn't return it),limitbecomesundefined,usageis set tonull.SessionContextUsagecomponent renders:ProgressCircleshows 0%:Two Possible Causes
Server API doesn't return
limit.context— Themodel.limitfield at line 75945 is passed straight through from the server's model list API response (sdk.model.list()). If the server doesn't includelimit: { context: <number> }in the model data,limitisundefined.Server doesn't send token data in
session.step.ended— At line 78140,event.data.tokenspopulates the assistant message. If this is empty,tokenTotalreturns 0,lastAssistantWithTokensskips the message, andbuild\returnsundefined→ 0%.Additional crash risk
The same
model.limitis accessed without null safety inModelTooltipcomponent (line 136394):Suggested Fix
In
build\, add a fallback formodel.limit:And in
ModelTooltip:But the real fix should be on the server side to ensure
model.limit.contextis always populated with the correct context window size for each model.