From 91a28d949fdb318c3d9582c8eaed6adafcdf80c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Tue, 28 Apr 2026 11:11:19 +0800 Subject: [PATCH] Restore context percentages in the desktop inspector The context tab needs both absolute token counts and percent-of-window values to stay scannable. Category rows now show the percent next to each token count, and the free-space summary card also reports remaining percent. Constraint: Keep the compact terminal-inspired layout while restoring the numeric detail users rely on. Confidence: high Scope-risk: narrow Tested: cd desktop && bun run lint Tested: git diff --check Tested: agent-browser smoke test on http://127.0.0.1:2024/ for /context percentages Not-tested: Packaged Tauri build. --- .../chat/LocalSlashCommandPanel.tsx | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/desktop/src/components/chat/LocalSlashCommandPanel.tsx b/desktop/src/components/chat/LocalSlashCommandPanel.tsx index 3f7b83f0..71fc6408 100644 --- a/desktop/src/components/chat/LocalSlashCommandPanel.tsx +++ b/desktop/src/components/chat/LocalSlashCommandPanel.tsx @@ -375,36 +375,37 @@ function CategoryBreakdown({ categories, rawMaxTokens, t }: { categories: Contex
{t('slash.inspector.context.categoryTitle')}
- {visibleCategories.map((category) => { - const percent = rawMaxTokens > 0 ? (category.tokens / rawMaxTokens) * 100 : 0 - const muted = isCapacityCategory(category) - return ( -
-
-
- - {category.name} - + {visibleCategories.map((category) => { + const percent = rawMaxTokens > 0 ? (category.tokens / rawMaxTokens) * 100 : 0 + const muted = isCapacityCategory(category) + return ( +
+
+
+ + {category.name} + +
+
+
{formatNumber(category.tokens)}
+
{formatPercent(percent)}
+
-
-
{formatNumber(category.tokens)}
+
+
-
-
-
-
- ) - })} + ) + })}
) @@ -459,6 +460,7 @@ function McpServerIcon({ status }: { status: string }) { function ContextOverview({ context, categories, t }: { context: SessionContextSnapshot; categories: ContextCategory[]; t: Translate }) { const usedPercent = Math.min(100, Math.max(0, context.percentage)) const freeTokens = Math.max(0, context.rawMaxTokens - context.totalTokens) + const freePercent = context.rawMaxTokens > 0 ? (freeTokens / context.rawMaxTokens) * 100 : 0 return (
@@ -476,7 +478,7 @@ function ContextOverview({ context, categories, t }: { context: SessionContextSn
- +