dsh-recent-usage-metrics 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.3
2
+
3
+ - 输出 Token 列的悬浮提示里,输入 token 改为带千分位的完整数字(`370,683 tok`),
4
+ 不再是缩写。单元格本身仍缩写以保持对齐,提示存在的意义正是补回被缩写省掉的精度。
5
+
1
6
  ## 0.3.2
2
7
 
3
8
  - 修复:速度列的悬浮提示常常拿不到模型名,或显示成别的模型。
package/README.en.md CHANGED
@@ -151,7 +151,7 @@ Every drawer column and every header carries a hint:
151
151
  | --- | --- |
152
152
  | Clock column | the full timestamp `11-06 10:47:41.828` |
153
153
  | Speed column | the model that served that row |
154
- | Tokens column | input tokens and cache hit rate |
154
+ | Tokens column | input tokens (with thousands separators, e.g. `370,683 tok`) and cache hit rate |
155
155
  | Headers | what the column measures (the `#` header draws the four state glyphs) |
156
156
 
157
157
  The hints are a real overlay rather than `title`: `title` can only show plain text, and the
package/README.md CHANGED
@@ -135,7 +135,7 @@ DSH 的极客级请求指标。它在 **设置 → 通用 → 性能与用量**
135
135
  | --- | --- |
136
136
  | 时间列 | 完整时间戳 `11-06 10:47:41.828` |
137
137
  | 速度列 | 该行使用的模型 |
138
- | 输出 Token 列 | 输入 token 与缓存命中率 |
138
+ | 输出 Token 列 | 输入 token(带千分位,如 `370,683 tok`)与缓存命中率 |
139
139
  | 表头 | 该列的含义(`#` 一列用图标展示四种状态) |
140
140
 
141
141
  提示是自建的浮层而不是 `title`:`title` 只能显示纯文本,而 `#` 列的说明要画出图标。
package/client/client.js CHANGED
@@ -1529,6 +1529,29 @@ window.__ModuleLoader__.load({
1529
1529
  return approximate ? t('approxTokensUnit', { value: rounded }) : t('tokensUnit', { value: rounded })
1530
1530
  }
1531
1531
 
1532
+ /**
1533
+ * A whole token count with thousands separators, for a hover hint.
1534
+ *
1535
+ * The cell itself has to stay narrow, so it abbreviates (`4.9k tok`). The hint has room, and
1536
+ * a reader comparing an input of 370683 against one of 1914 needs the exact digits — `370k`
1537
+ * and `371k` would hide the difference.
1538
+ *
1539
+ * The separator is a comma in both languages this plugin ships, so it is written out rather
1540
+ * than derived from the host locale: that keeps the hint identical in zh and en, and avoids
1541
+ * depending on a locale tag the slot props do not provide.
1542
+ */
1543
+ function tokensExact(value, t) {
1544
+ if (value === null || value === undefined || !Number.isFinite(value)) return t('none')
1545
+ const digits = String(Math.round(Math.abs(value)))
1546
+ let grouped = ''
1547
+ for (let i = 0; i < digits.length; i += 1) {
1548
+ const fromEnd = digits.length - i
1549
+ grouped += digits[i]
1550
+ if (fromEnd > 1 && (fromEnd - 1) % 3 === 0) grouped += ','
1551
+ }
1552
+ return t('tokensUnit', { value: value < 0 ? `-${grouped}` : grouped })
1553
+ }
1554
+
1532
1555
  function clockText(at) {
1533
1556
  const date = new Date(at)
1534
1557
  if (Number.isNaN(date.getTime())) return '—'
@@ -1650,7 +1673,11 @@ window.__ModuleLoader__.load({
1650
1673
  /** The tokens column's hint: the input side, which the cell itself does not show. */
1651
1674
  function tokensHintText(row, t) {
1652
1675
  const none = t('none')
1653
- const input = row.context === null || row.context === undefined ? none : tokensText(row.context, false, t)
1676
+ /*
1677
+ * The input is spelled out with thousands separators; the cell above it abbreviates. The
1678
+ * hint exists precisely for the cases where the abbreviation loses information.
1679
+ */
1680
+ const input = row.context === null || row.context === undefined ? none : tokensExact(row.context, t)
1654
1681
  const hit =
1655
1682
  row.cacheHit === null || row.cacheHit === undefined
1656
1683
  ? none
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-recent-usage-metrics",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Geek level for the Performance & usage setting: a live reading of the newest request (first-token latency, speed, tokens, total, amortised) plus a drawer listing the last ten, all derived from the shipped Statistics view data",
5
5
  "repository": {
6
6
  "type": "git",