You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/10/09 01:07:06 UTC

(maka) 01/01: fix(ui): shorten context usage tooltips

This is an automated email from the ASF dual-hosted git repository.

Astro-Han pushed a commit to branch fix/ui-context-usage-copy
in repository https://gitbox.apache.org/repos/asf/maka.git

commit 094816f70cd2749c351e87a5fe986ec8ee78cbfa
Author: AstroHan <le...@outlook.com>
AuthorDate: Fri Oct 9 11:03:35 2026 +1000

    fix(ui): shorten context usage tooltips
    
    Keep the percentage and compact counts while removing redundant context-window wording and unknown-limit explanations across locales. Retain Astryx's existing width and wrapping instead of introducing a tooltip-specific CSS exception.
    
    Generated-by: Maka
---
 .../ui/src/__tests__/conversation-copy.test.ts     | 45 +++++++++++++++-------
 packages/ui/src/conversation-copy.ts               | 21 +++++-----
 2 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/packages/ui/src/__tests__/conversation-copy.test.ts b/packages/ui/src/__tests__/conversation-copy.test.ts
index 3483a85152..8461846b34 100644
--- a/packages/ui/src/__tests__/conversation-copy.test.ts
+++ b/packages/ui/src/__tests__/conversation-copy.test.ts
@@ -48,49 +48,66 @@ test('explains why folder-reference messages cannot be edited and resent', () =>
 test('context usage explains missing data without exposing provider internals', () => {
   assert.equal(
     getConversationCopy('zh-CN').messages.systemNotes.contextUsageUnavailable,
-    '暂无用量数据',
+    '暂无上下文用量数据',
+  );
+  assert.equal(
+    getConversationCopy('zh-TW').messages.systemNotes.contextUsageUnavailable,
+    '暫無上下文用量資料',
   );
   assert.equal(
     getConversationCopy('en').messages.systemNotes.contextUsageUnavailable,
-    'No usage data is available for this request.',
+    'No context usage data',
   );
 });
 
-test('context usage tooltip leads with the measured share', () => {
+test('context usage tooltip keeps the percentage and compact counts across locales', () => {
+  assert.equal(
+    getConversationCopy('zh-CN').messages.systemNotes.contextUsageShare(37_200, 272_000),
+    '上下文:14%(37.2K / 272K token)',
+  );
+  assert.equal(
+    getConversationCopy('zh-TW').messages.systemNotes.contextUsageShare(37_200, 272_000),
+    '上下文:14%(37.2K / 272K token)',
+  );
+  assert.equal(
+    getConversationCopy('en').messages.systemNotes.contextUsageShare(37_200, 272_000),
+    'Context: 14% (37.2K / 272K tokens)',
+  );
   assert.equal(
     getConversationCopy('zh-CN').messages.systemNotes.contextUsageShare(12_345, 128_000),
-    '上下文窗口:已用 10%(12.3K / 128K token)',
+    '上下文:10%(12.3K / 128K token)',
   );
   assert.equal(
     getConversationCopy('en').messages.systemNotes.contextUsageShare(12_345, 128_000),
-    'Context window: 10% used (12.3K / 128K tokens).',
+    'Context: 10% (12.3K / 128K tokens)',
   );
-  // Million-scale windows collapse to the M tier, mirroring the "1M context" marketing term.
   assert.equal(
     getConversationCopy('zh-CN').messages.systemNotes.contextUsageShare(44_060, 1_048_576),
-    '上下文窗口:已用 4%(44.1K / 1M token)',
+    '上下文:4%(44.1K / 1M token)',
   );
   assert.equal(
     getConversationCopy('en').messages.systemNotes.contextUsageShare(44_060, 1_048_576),
-    'Context window: 4% used (44.1K / 1M tokens).',
+    'Context: 4% (44.1K / 1M tokens)',
   );
-  // Compact counts are lossy: near-full usage can render identical numerator
-  // and denominator while the percentage still differs. Pinned on purpose —
-  // the percentage is the authoritative figure, the counts are for scale.
+  // Rounded counts can match even when usage is below 100%; retain the percentage.
   assert.equal(
     getConversationCopy('zh-CN').messages.systemNotes.contextUsageShare(1_000_000, 1_048_576),
-    '上下文窗口:已用 95%(1M / 1M token)',
+    '上下文:95%(1M / 1M token)',
   );
 });
 
 test('context usage tooltip keeps measured usage when the limit is unknown', () => {
   assert.equal(
     getConversationCopy('zh-CN').messages.systemNotes.contextUsageNoWindow(12_345),
-    '已用 12.3K token;上下文窗口上限未知',
+    '上下文:12.3K token',
+  );
+  assert.equal(
+    getConversationCopy('zh-TW').messages.systemNotes.contextUsageNoWindow(12_345),
+    '上下文:12.3K token',
   );
   assert.equal(
     getConversationCopy('en').messages.systemNotes.contextUsageNoWindow(12_345),
-    'This request used 12.3K tokens; no context limit is available for this model.',
+    'Context: 12.3K tokens',
   );
 });
 
diff --git a/packages/ui/src/conversation-copy.ts b/packages/ui/src/conversation-copy.ts
index acc785c7a3..0123bc7b72 100644
--- a/packages/ui/src/conversation-copy.ts
+++ b/packages/ui/src/conversation-copy.ts
@@ -537,10 +537,9 @@ const CONVERSATION_COPY = {
           '已经压缩过历史,供应商仍然说这次请求太大。剩下的部分还包含系统提示、工具定义、摘要和最近的原文,缩短这条消息是你能控制的那一半。',
         contextUsageLabel: '用量',
         contextUsageShare: (used, window) =>
-          `上下文窗口:已用 ${Math.round((used / window) * 100)}%(${formatCompactTokenCount(used)} / ${formatCompactTokenCount(window)} token)`,
-        contextUsageNoWindow: (used) =>
-          `已用 ${formatCompactTokenCount(used)} token;上下文窗口上限未知`,
-        contextUsageUnavailable: '暂无用量数据',
+          `上下文:${Math.round((used / window) * 100)}%(${formatCompactTokenCount(used)} / ${formatCompactTokenCount(window)} token)`,
+        contextUsageNoWindow: (used) => `上下文:${formatCompactTokenCount(used)} token`,
+        contextUsageUnavailable: '暂无上下文用量数据',
         contextUsageOpen: '打开用量追踪',
         stepLimit: '已达到本轮工具步骤上限,任务可能尚未完成。发送“继续”即可接着处理。',
       },
@@ -662,10 +661,9 @@ const CONVERSATION_COPY = {
           '已經壓縮過歷史,供應商仍然說這次請求太大。剩下的部分還包含系統提示、工具定義、摘要和最近的原文,縮短這則訊息是你能控制的那一半。',
         contextUsageLabel: '用量',
         contextUsageShare: (used, window) =>
-          `上下文視窗:已用 ${Math.round((used / window) * 100)}%(${formatCompactTokenCount(used)} / ${formatCompactTokenCount(window)} token)`,
-        contextUsageNoWindow: (used) =>
-          `已用 ${formatCompactTokenCount(used)} token;上下文視窗上限未知`,
-        contextUsageUnavailable: '暫無用量資料',
+          `上下文:${Math.round((used / window) * 100)}%(${formatCompactTokenCount(used)} / ${formatCompactTokenCount(window)} token)`,
+        contextUsageNoWindow: (used) => `上下文:${formatCompactTokenCount(used)} token`,
+        contextUsageUnavailable: '暫無上下文用量資料',
         contextUsageOpen: '開啟用量追蹤',
         stepLimit: '已達到本輪工具步驟上限,任務可能尚未完成。傳送“繼續”即可接著處理。',
       },
@@ -784,10 +782,9 @@ const CONVERSATION_COPY = {
           'History was compacted and the provider still called this request too large. What remains also carries the system prompt, the tool schemas, the summary and the recent tail; shortening this message is the part you control.',
         contextUsageLabel: 'Usage',
         contextUsageShare: (used, window) =>
-          `Context window: ${Math.round((used / window) * 100)}% used (${formatCompactTokenCount(used)} / ${formatCompactTokenCount(window)} tokens).`,
-        contextUsageNoWindow: (used) =>
-          `This request used ${formatCompactTokenCount(used)} tokens; no context limit is available for this model.`,
-        contextUsageUnavailable: 'No usage data is available for this request.',
+          `Context: ${Math.round((used / window) * 100)}% (${formatCompactTokenCount(used)} / ${formatCompactTokenCount(window)} tokens)`,
+        contextUsageNoWindow: (used) => `Context: ${formatCompactTokenCount(used)} tokens`,
+        contextUsageUnavailable: 'No context usage data',
         contextUsageOpen: 'Open usage trace',
         stepLimit: 'Reached the configured step limit. The task may be incomplete. Send “continue” to resume.',
       },


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org