dsh-ws-recency 0.29.0 → 0.30.0
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/README.md +18 -14
- package/client.js +467 -137
- package/index.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,13 +59,14 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
59
59
|
所以本插件把归档会话也列进**回收站面板**(侧栏面板列表里的「回收站」,与「插件」「自动化任务」同一排):
|
|
60
60
|
|
|
61
61
|
- 面板分两段:**已删除的会话**(插件的回收站条目)和**已归档的会话**(宿主的归档集合),都带条数;
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
62
|
+
- **卡片网格(0.30.0)**:条目排成自适应多列卡片(最小 300px,窄面板自动退回单列),不再是整行铺满。卡片只有标题、数字、路径三行,操作收进卡片右下角一行,鼠标悬停或键盘聚焦时才浮现;
|
|
63
|
+
- 归档卡片显示标题(取投影缓存里的标题,没有就退回第一条 prompt,再没有就退回会话 id)、所属工作区、体积、最后活动时间、原始目录;空白草稿会标「空白草稿」;
|
|
64
|
+
- 每张卡片三个图标动作(悬停可看名称):
|
|
65
|
+
- **取消归档**(↻):摘掉归档标记,会话回到原工作区的原位置;若它的槽位已经不在了(工作区被删过),会按 cwd 重新挂到同名工作区,挂不上会在提示里说明;
|
|
66
|
+
- **移到回收站**(🗑):走下面那套正常删除,日志改名搬进 `.trash/ws-recency/`,之后仍可恢复;
|
|
67
|
+
- **彻底删除**(✕,红色):先移进回收站再立即清空,和回收站的「彻底删除」是同一条路径(二次确认);
|
|
67
68
|
- 宿主的归档集合变动会通过它的 workspace feed 推到浏览器,所以取消归档后侧栏会自己把行放回去,不用刷新界面。
|
|
68
|
-
- **记录失效的行(0.27.0
|
|
69
|
+
- **记录失效的行(0.27.0)**:如果日志目录被外部删掉(手工删除、磁盘清理、别的工具清理),归档标记会留下来。这时这张卡片只留一个 **移出归档**:只清掉归档标记、工作区槽位和投影缓存,**不删除任何文件**,确认框里也写明了这一点。日志还存在的会话不会出现这个动作。
|
|
69
70
|
|
|
70
71
|
### 删除(宿主没有的,本插件补上)
|
|
71
72
|
|
|
@@ -96,13 +97,16 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
96
97
|
会话下方统计条上的「用量分析」,或会话「…」菜单 →「Token 消耗统计」:
|
|
97
98
|
|
|
98
99
|
- **真实账单**(每步记录的 usage):步数、输入(未缓存)、缓存命中、输出、合计;
|
|
99
|
-
- **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs
|
|
100
|
-
- **参数 /
|
|
101
|
-
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58
|
|
102
|
-
- **调用次数**:每条横条右侧带「N
|
|
103
|
-
-
|
|
104
|
-
- **两个 tab
|
|
105
|
-
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token
|
|
100
|
+
- **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs 每个工具,每个来源一条横条,按占用长度直观对比。**颜色表示工具族**(命令执行 / 文件操作 / 网络检索 / 子代理 / 其它),每族一个固定色、明艳度不随排名变化,工具名下方有族名小字,图上也有族图例;
|
|
101
|
+
- **参数 / 结果两段**:每个工具那条横条拆成「参数」(浅段,模型自己写的命令 / 文件内容)和「结果」(深段,环境返回的内容),一眼看出贵在输入还是贵在输出。图例在图右上角,悬停柱子也会给出具体拆分;
|
|
102
|
+
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58%;
|
|
103
|
+
- **调用次数**:每条横条右侧带「N 次」;图表有一行列头(token / 占比 / 调用)对齐五列;
|
|
104
|
+
- **摘要卡片**:合计(高亮)+ 步数 + 输入(未缓存)+ 缓存命中 + 输出,合计排第一;
|
|
105
|
+
- **两个 tab**:摘要卡片常驻顶部,下面按「分布统计 / 放大归因」分页,打开时记住上次停留的 tab;
|
|
106
|
+
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3% 账单),这样小数字才能读出结论。压缩之后旧内容不再重读,放大窗口会从压缩点截断。
|
|
107
|
+
- **上下文拐点(0.30.0)**:曲线上的圆点标出上下文涨得最陡的步,颜色表示段内排名(第 1 红、第 2 黄、第 3 蓝),悬停圆点或下方的数字,两边一起高亮。**按压缩分段**:压缩会重置上下文,跨压缩点比较涨幅没有意义,所以每段各自取涨幅最大的三步;压缩点用一条淡竖线标在曲线上。下面按「第 N 段」一行排开该段的三个拐点(步号 + 涨幅),各段共用同一套列宽,数字右对齐——一眼看出哪一段开始放大、放大了多少。
|
|
108
|
+
|
|
109
|
+
面板底部只有一条口径说明(原来两个 tab 各有一条相同的话)。
|
|
106
110
|
|
|
107
111
|
口径说明:prompt 的 token 是「整段上下文每一步都计费」,没法精确归属到某一条消息,所以「主 agent / 工具」的拆分是按内容长度估算(中文≈1 token/字,英文≈4 字符/token),用来比较占比;**总量是真的**。放大排行里的块大小同样是估算,但账单总量、每步上下文、放大倍数的分母都来自真实 usage。思维链通常不回传给模型,因此不计入放大排行。数据从会话日志算,跨重启也能看。大会话第一次打开约 1–2 秒(29MB 日志实测 1.2 秒),10 秒内重复打开走缓存。
|
|
108
112
|
|
|
@@ -201,7 +205,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
201
205
|
或固定版本的预构建包:
|
|
202
206
|
|
|
203
207
|
```powershell
|
|
204
|
-
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.
|
|
208
|
+
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.30.0/dsh-ws-recency-0.30.0.tgz
|
|
205
209
|
```
|
|
206
210
|
|
|
207
211
|
装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
|
package/client.js
CHANGED
|
@@ -131,6 +131,8 @@
|
|
|
131
131
|
".wsr-modal-tools{display:flex;align-items:center;gap:8px;flex:none}",
|
|
132
132
|
".wsr-modal-body{padding:14px;overflow:auto;display:flex;flex-direction:column;gap:12px;font-size:12px}",
|
|
133
133
|
".wsr-stats-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}",
|
|
134
|
+
".wsr-stats-card-primary{box-shadow:inset 0 0 0 1px rgba(79,124,255,.45)}",
|
|
135
|
+
".wsr-stats-card-primary .wsr-stats-value{color:#7aa2ff}",
|
|
134
136
|
".wsr-stats-card{background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));border-radius:8px;padding:8px 10px}",
|
|
135
137
|
".wsr-stats-value{font-size:15px;font-weight:600}",
|
|
136
138
|
".wsr-stats-label{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
@@ -191,6 +193,33 @@
|
|
|
191
193
|
".wsr-page-head{display:flex;align-items:center;gap:8px}",
|
|
192
194
|
".wsr-page-heading{flex:1;font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary)}",
|
|
193
195
|
".wsr-page-list{display:flex;flex-direction:column;gap:6px}",
|
|
196
|
+
".wsr-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:8px}",
|
|
197
|
+
".wsr-card-grid .wsr-card-head{flex-wrap:wrap}",
|
|
198
|
+
".wsr-card-grid .wsr-card-actions{flex-wrap:wrap}",
|
|
199
|
+
/* Icon actions: 24px instead of a text button, so the title keeps its width. */
|
|
200
|
+
".wsr-icon-btn{width:24px;height:24px;padding:0;display:inline-flex;align-items:center;justify-content:center;border:.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.16));border-radius:6px;background:0 0;color:var(--dsw-alias-label-secondary);cursor:pointer;flex:none}",
|
|
201
|
+
".wsr-icon-btn:hover{background:var(--dsw-alias-bg-layer-3,rgba(255,255,255,.08));color:var(--dsw-alias-label-primary)}",
|
|
202
|
+
/* The destructive action keeps the same frame as the others and only its glyph is
|
|
203
|
+
red: a red border made one icon in a row of three shout louder than its size. */
|
|
204
|
+
".wsr-icon-btn-danger{color:var(--dsw-alias-state-error-primary,#d9534f)}",
|
|
205
|
+
".wsr-icon-btn-danger:hover{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#d9534f) 14%,transparent);color:var(--dsw-alias-state-error-primary,#d9534f)}",
|
|
206
|
+
".wsr-card-glyph{flex:none;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px}",
|
|
207
|
+
".wsr-card-glyph-danger{color:var(--dsw-alias-state-error-primary,#d9534f)}",
|
|
208
|
+
".wsr-card-glyph-muted{color:var(--dsw-alias-label-tertiary)}",
|
|
209
|
+
".wsr-card-glyph-warning{color:#d99a2b}",
|
|
210
|
+
".wsr-card-danger{flex:none;display:flex;align-items:center}",
|
|
211
|
+
/* Every icon button is the same 24px frame; the glyph inside keeps a 14px box
|
|
212
|
+
so differing artwork aspects cannot change the button's size. */
|
|
213
|
+
".wsr-icon-btn-glyph{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px}",
|
|
214
|
+
".wsr-icon-btn-glyph>svg{display:block}",
|
|
215
|
+
/* The actions are one flex row on the title line, so a single layout does the
|
|
216
|
+
alignment: no second right edge to reconcile. They keep out of the way until
|
|
217
|
+
the card is hovered or holds focus. */
|
|
218
|
+
/* Every action is one right-aligned row pinned to the card's bottom edge: it is a
|
|
219
|
+
real row in the card's column flow (so it never covers the path) and
|
|
220
|
+
`margin-top:auto` keeps it against the bottom when the card has spare height. */
|
|
221
|
+
".wsr-card .wsr-card-actions-row{display:flex;justify-content:flex-end;align-items:center;gap:6px;min-height:24px;margin-top:auto;opacity:0;transition:opacity .12s}",
|
|
222
|
+
".wsr-card:hover .wsr-card-actions-row,.wsr-card:focus-within .wsr-card-actions-row{opacity:1}",
|
|
194
223
|
".wsr-page-row{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border-radius:8px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04))}",
|
|
195
224
|
".wsr-card{display:flex;flex-direction:column;gap:8px;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.08));border-radius:10px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04))}",
|
|
196
225
|
".wsr-card-head{display:flex;align-items:center;gap:10px;min-width:0}",
|
|
@@ -234,19 +263,23 @@
|
|
|
234
263
|
".wsr-chart{display:flex;flex-direction:column;gap:6px}",
|
|
235
264
|
".wsr-chart-head{display:flex;align-items:center;justify-content:space-between;gap:10px}",
|
|
236
265
|
".wsr-chart-title{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
237
|
-
".wsr-chart-row{display:grid;grid-template-columns:120px 1fr 64px 56px;align-items:center;gap:8px}",
|
|
238
266
|
".wsr-chart-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}",
|
|
267
|
+
".wsr-chart-row{display:grid;grid-template-columns:120px 1fr 64px 56px 48px;align-items:center;gap:8px}",
|
|
268
|
+
".wsr-chart-family{font-size:10px;color:var(--dsw-alias-label-tertiary);margin-top:-2px}",
|
|
269
|
+
".wsr-family-legend{padding-bottom:4px}",
|
|
239
270
|
".wsr-chart-track{height:8px;border-radius:4px;background:rgba(255,255,255,.06);overflow:hidden;display:flex}",
|
|
240
271
|
".wsr-chart-fill{height:100%;border-radius:0;min-width:0}",
|
|
241
272
|
".wsr-chart-group{display:flex;height:100%;min-width:2px;border-radius:4px;overflow:hidden}",
|
|
242
273
|
".wsr-chart-swatch{width:8px;height:8px;border-radius:2px;background:hsl(217, 88%, 50%)}",
|
|
243
|
-
".wsr-chart-swatch-dim{background:hsl(217,
|
|
274
|
+
".wsr-chart-swatch-dim{background:hsl(217, 32%, 84%)}",
|
|
244
275
|
".wsr-chart-legend{display:flex;flex-wrap:wrap;gap:10px;align-items:center}",
|
|
245
276
|
".wsr-chart-legend-item{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
246
277
|
".wsr-chart-legend-text{white-space:nowrap}",
|
|
247
278
|
".wsr-chart-value{text-align:right;font-variant-numeric:tabular-nums}",
|
|
248
279
|
".wsr-chart-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}",
|
|
249
280
|
".wsr-chart-calls{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:10px;font-variant-numeric:tabular-nums}",
|
|
281
|
+
".wsr-chart-headrow{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
282
|
+
".wsr-chart-value-head,.wsr-chart-share-head,.wsr-chart-calls-head{text-align:right}",
|
|
250
283
|
".wsr-stats-details{display:flex;flex-direction:column;gap:8px}",
|
|
251
284
|
".wsr-stats-table{display:flex;flex-direction:column}",
|
|
252
285
|
".wsr-stats-row{display:grid;grid-template-columns:1.4fr .6fr .8fr .8fr .8fr .6fr;gap:6px;padding:6px 4px;border-bottom:.5px solid rgba(255,255,255,.06)}",
|
|
@@ -272,10 +305,33 @@
|
|
|
272
305
|
".wsr-context-chart{display:flex;align-items:flex-end;gap:2px;height:54px;padding-top:4px;border-bottom:.5px solid rgba(255,255,255,.08)}",
|
|
273
306
|
".wsr-context-bar{flex:1;min-width:1px;border-radius:1px 1px 0 0;background:linear-gradient(180deg,rgba(79,124,255,.9),rgba(79,124,255,.3))}",
|
|
274
307
|
".wsr-context-caption{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
275
|
-
".wsr-context-jump{position:relative}",
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
".wsr-context-
|
|
308
|
+
".wsr-context-jump{position:relative;cursor:pointer}",
|
|
309
|
+
/* Where a compaction rewrote the window: the curve restarts, and the
|
|
310
|
+
divider keeps that drop from reading as a rendering glitch. */
|
|
311
|
+
".wsr-context-break{box-shadow:-1px 0 0 rgba(255,255,255,.35)}",
|
|
312
|
+
".wsr-context-jump-hit{position:absolute;left:50%;top:-9px;width:22px;height:22px;margin-left:-11px;display:flex;align-items:center;justify-content:center;border-radius:50%;cursor:pointer}",
|
|
313
|
+
".wsr-context-jump-dot{width:6px;height:6px;border-radius:50%;background:#d99a2b;transition:transform .12s,box-shadow .12s}",
|
|
314
|
+
".wsr-context-jump-hit[data-wsr-rank=\"1\"] .wsr-context-jump-dot{background:#f0553d}",
|
|
315
|
+
".wsr-context-jump-hit[data-wsr-rank=\"2\"] .wsr-context-jump-dot{background:#f5c542}",
|
|
316
|
+
".wsr-context-jump-hit[data-wsr-rank=\"3\"] .wsr-context-jump-dot{background:#4f9df7}",
|
|
317
|
+
".wsr-context-jump-hit-hot .wsr-context-jump-dot{transform:scale(1.8);box-shadow:0 0 0 4px rgba(217,154,43,.25)}",
|
|
318
|
+
".wsr-context-jump:hover .wsr-context-bar-inner{filter:brightness(1.15)}",
|
|
319
|
+
".wsr-context-jumps{display:grid;grid-template-columns:44px repeat(3,minmax(0,1fr));column-gap:16px;row-gap:3px;font-size:11px;color:var(--dsw-alias-label-secondary)}",
|
|
320
|
+
".wsr-context-jumps-single{grid-template-columns:repeat(3,minmax(0,1fr))}",
|
|
321
|
+
/* The segment wrapper dissolves into the list grid, so every marker sits
|
|
322
|
+
in a real column and the step/rise edges line up across segments
|
|
323
|
+
whatever the numbers are. */
|
|
324
|
+
".wsr-context-jump-group{display:contents}",
|
|
325
|
+
".wsr-context-jump-segment{grid-column:1;color:var(--dsw-alias-label-tertiary)}",
|
|
326
|
+
".wsr-context-jump-row{display:grid;grid-template-columns:8px auto 1fr;align-items:center;gap:5px;padding:1px 5px;border-radius:4px;transition:background .12s,color .12s}",
|
|
327
|
+
".wsr-context-jump-rank{display:inline-flex;align-items:center}",
|
|
328
|
+
".wsr-context-jump-rank-dot{width:6px;height:6px;border-radius:50%;background:#d99a2b}",
|
|
329
|
+
".wsr-context-jump-row[data-wsr-rank=\"1\"] .wsr-context-jump-rank-dot{background:#f0553d}",
|
|
330
|
+
".wsr-context-jump-row[data-wsr-rank=\"2\"] .wsr-context-jump-rank-dot{background:#f5c542}",
|
|
331
|
+
".wsr-context-jump-row[data-wsr-rank=\"3\"] .wsr-context-jump-rank-dot{background:#4f9df7}",
|
|
332
|
+
".wsr-context-jump-step{white-space:nowrap}",
|
|
333
|
+
".wsr-context-jump-rise{text-align:right;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary)}",
|
|
334
|
+
".wsr-context-jump-row-hot{background:rgba(217,154,43,.16);color:var(--dsw-alias-label-primary)}",
|
|
279
335
|
".wsr-kind-legend{display:flex;flex-wrap:wrap;gap:10px}",
|
|
280
336
|
".wsr-kind{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
281
337
|
".wsr-kind-dot{width:8px;height:8px;border-radius:2px;flex:none}",
|
|
@@ -287,8 +343,8 @@
|
|
|
287
343
|
".wsr-amplified-meta{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
288
344
|
".wsr-amplified-value{text-align:right;font-weight:600;font-variant-numeric:tabular-nums;font-size:12px}",
|
|
289
345
|
".wsr-amplified-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:11px;font-variant-numeric:tabular-nums}",
|
|
290
|
-
".wsr-amplified-if{grid-column:1 / -1;font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
291
346
|
".wsr-amplified-empty{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
347
|
+
".wsr-stats-footnote{padding-top:6px;border-top:.5px solid rgba(255,255,255,.06)}",
|
|
292
348
|
".wsr-toggle{width:100%;height:28px;padding:0 12px 0 calc(28px + var(--dsh-workspace-indent,0px));cursor:pointer;text-align:left;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;font-size:12px}",
|
|
293
349
|
".wsr-toggle:hover{color:var(--dsw-alias-label-secondary)}",
|
|
294
350
|
'[' + STATE_ATTR + '="running"] [class*="_title"]{color:#4f8ef7}',
|
|
@@ -358,12 +414,15 @@
|
|
|
358
414
|
"stats.col.source": "\u6765\u6e90",
|
|
359
415
|
"stats.col.calls": "\u8c03\u7528",
|
|
360
416
|
"stats.callsShort": "{n} 次",
|
|
417
|
+
"stats.col.tokensShort": "token",
|
|
418
|
+
"stats.col.shareShort": "占比",
|
|
361
419
|
"stats.col.args": "\u53c2\u6570",
|
|
362
420
|
"stats.col.results": "\u7ed3\u679c",
|
|
363
421
|
"stats.col.total": "\u4f30\u7b97",
|
|
364
422
|
"stats.col.share": "\u5360\u6bd4",
|
|
365
423
|
"stats.note": "\u5408\u8ba1\u6765\u81ea\u6bcf\u6b65\u8bb0\u5f55\u7684\u771f\u5b9e usage\uff08\u7f13\u5b58\u547d\u4e2d + \u8f93\u5165 + \u8f93\u51fa\uff09\uff1b\u672c\u8868\u6309\u6765\u6e90\u7684\u62c6\u5206\u662f\u6309\u5185\u5bb9\u957f\u5ea6\u4f30\u7b97\uff08\u4e2d\u6587\u7ea6 1 token/\u5b57\uff0c\u82f1\u6587\u7ea6 4 \u5b57\u7b26/token\uff09\uff0c\u7528\u4e8e\u6bd4\u8f83\u5360\u6bd4\uff0c\u4e0d\u662f\u8ba1\u8d39\u53e3\u5f84\u3002",
|
|
366
424
|
"stats.agentDetail": "主 agent 构成:思考 {reasoning} · 回复 {text} · 用户消息 {user} · 系统提示 {system}",
|
|
425
|
+
"stats.split": "输入 {input} · 缓存命中 {cache} · 输出 {output}",
|
|
367
426
|
"stats.diagnose.unmounted": "\n\n(宿主半已加载,但统计路由没挂上——重启应用再试)",
|
|
368
427
|
"stats.diagnose.noHost": "\n\n(宿主半未加载:需要重启应用加载新版本)",
|
|
369
428
|
"menu.move": "移动到工作区…",
|
|
@@ -464,15 +523,24 @@
|
|
|
464
523
|
"archive.workspace": "工作区",
|
|
465
524
|
"move.failed": "移动失败:",
|
|
466
525
|
"stats.chart": "消耗分布",
|
|
526
|
+
"stats.family.shell": "命令执行",
|
|
527
|
+
"stats.family.files": "文件操作",
|
|
528
|
+
"stats.family.web": "网络检索",
|
|
529
|
+
"stats.family.agents": "子代理/协作",
|
|
530
|
+
"stats.family.misc": "其它工具",
|
|
531
|
+
"stats.family.other": "未归类",
|
|
467
532
|
"composer.analysis": "用量分析",
|
|
468
533
|
"stats.legend.args": "参数(模型写的)",
|
|
469
534
|
"stats.legend.results": "结果(环境返回的)",
|
|
535
|
+
"stats.barTooltip": "{name} 共 {total}:参数 {args}({argsShare}),结果 {results}({resultsShare})",
|
|
470
536
|
"stats.argModeNote": "当前把工具参数计入主 agent:每个工具只算返回结果,表格里「参数」列显示为淡色(那些 token 记在主 agent 那一行)。",
|
|
471
537
|
"stats.amplified.title": "放大成本(账单归因)",
|
|
472
538
|
"stats.amplified.summary": "账单 {bill} token;可归因内容经重读放大后占 {share}({attributed})",
|
|
473
539
|
"stats.amplified.contextCaption": "每步上下文(面积≈账单):越早进入的内容被重读越多",
|
|
474
540
|
"stats.amplified.point": "第 {step} 步 · {context}",
|
|
475
541
|
"stats.amplified.jump": "第 {step} 步上下文涨了 {rise}",
|
|
542
|
+
"stats.amplified.jumpStep": "第 {step} 步",
|
|
543
|
+
"stats.amplified.segment": "第 {segment} 段",
|
|
476
544
|
"stats.amplified.jumpFrom": "({name} 进来 {tokens})",
|
|
477
545
|
"stats.amplified.meta": "第 {entry} 步进入 · {tokens} token × {remaining} 次重读",
|
|
478
546
|
"stats.amplified.whatIf": "若压到 20%,可省 {save}({share})",
|
|
@@ -528,12 +596,15 @@
|
|
|
528
596
|
"stats.col.source": "source",
|
|
529
597
|
"stats.col.calls": "calls",
|
|
530
598
|
"stats.callsShort": "{n}x",
|
|
599
|
+
"stats.col.tokensShort": "tokens",
|
|
600
|
+
"stats.col.shareShort": "share",
|
|
531
601
|
"stats.col.args": "args",
|
|
532
602
|
"stats.col.results": "results",
|
|
533
603
|
"stats.col.total": "estimate",
|
|
534
604
|
"stats.col.share": "share",
|
|
535
605
|
"stats.note": "Totals come from the recorded per-step usage (cache read + input + output). The per-source split is estimated from content length (about 1 token per CJK character, 4 characters per token otherwise) so the shares are comparable, not billable.",
|
|
536
606
|
"stats.agentDetail": "Agent composition: reasoning {reasoning} \u00b7 reply {text} \u00b7 user messages {user} \u00b7 system prompt {system}",
|
|
607
|
+
"stats.split": "input {input} \u00b7 cache hit {cache} \u00b7 output {output}",
|
|
537
608
|
"stats.diagnose.unmounted": "\n\n(the host half is loaded but the statistics route did not mount - restart the app and retry)",
|
|
538
609
|
"stats.diagnose.noHost": "\n\n(the host half is not loaded: restart the app to pick up the new version)",
|
|
539
610
|
"menu.move": "Move to workspace\u2026",
|
|
@@ -633,15 +704,24 @@
|
|
|
633
704
|
"archive.workspace": "workspace",
|
|
634
705
|
"move.failed": "Move failed: ",
|
|
635
706
|
"stats.chart": "Where the tokens went",
|
|
707
|
+
"stats.family.shell": "shell",
|
|
708
|
+
"stats.family.files": "files",
|
|
709
|
+
"stats.family.web": "web",
|
|
710
|
+
"stats.family.agents": "subagents",
|
|
711
|
+
"stats.family.misc": "other tools",
|
|
712
|
+
"stats.family.other": "unclassified",
|
|
636
713
|
"composer.analysis": "Usage analysis",
|
|
637
714
|
"stats.legend.args": "arguments (written by the model)",
|
|
638
715
|
"stats.legend.results": "results (returned by the environment)",
|
|
716
|
+
"stats.barTooltip": "{name}: {total} total - arguments {args} ({argsShare}), results {results} ({resultsShare})",
|
|
639
717
|
"stats.argModeNote": "Tool arguments currently count towards the agent: each tool shows only its results, and the table's \"args\" column is faded because those tokens sit on the agent's row.",
|
|
640
718
|
"stats.amplified.title": "Amplified cost (what the bill pays for)",
|
|
641
719
|
"stats.amplified.summary": "Bill {bill} tokens; attributable content amplifies to {share} ({attributed})",
|
|
642
720
|
"stats.amplified.contextCaption": "Context per step (area ≈ bill): earlier content is re-read more",
|
|
643
721
|
"stats.amplified.point": "step {step} · {context}",
|
|
644
722
|
"stats.amplified.jump": "step {step} grew by {rise}",
|
|
723
|
+
"stats.amplified.jumpStep": "step {step}",
|
|
724
|
+
"stats.amplified.segment": "seg {segment}",
|
|
645
725
|
"stats.amplified.jumpFrom": "({name} brought {tokens})",
|
|
646
726
|
"stats.amplified.meta": "entered at step {entry} · {tokens} tokens × {remaining} re-reads",
|
|
647
727
|
"stats.amplified.whatIf": "at 20%, saves {save} ({share})",
|
|
@@ -1951,7 +2031,14 @@
|
|
|
1951
2031
|
*/
|
|
1952
2032
|
function chartBar(entry, largest) {
|
|
1953
2033
|
var line = statsDiv("wsr-chart-row");
|
|
1954
|
-
|
|
2034
|
+
var labelCell = statsDiv("wsr-chart-label", entry.name);
|
|
2035
|
+
/* The colour now means a family, so the name cell says which one: a
|
|
2036
|
+
colour without a caption is a riddle, not an encoding. It lives in
|
|
2037
|
+
the name cell so the five-column grid stays intact. */
|
|
2038
|
+
if (typeof entry.family === "string" && entry.family !== "") {
|
|
2039
|
+
labelCell.appendChild(statsDiv("wsr-chart-family", t("stats.family." + entry.family)));
|
|
2040
|
+
}
|
|
2041
|
+
line.appendChild(labelCell);
|
|
1955
2042
|
var track = statsDiv("wsr-chart-track");
|
|
1956
2043
|
var group = statsDiv("wsr-chart-group");
|
|
1957
2044
|
var width = largest > 0 ? (entry.value / largest) * 100 : 0;
|
|
@@ -1963,75 +2050,85 @@
|
|
|
1963
2050
|
if (argsPart > 0) {
|
|
1964
2051
|
var argsSeg = statsDiv("wsr-chart-fill wsr-bar-args");
|
|
1965
2052
|
argsSeg.style.width = argsPart.toFixed(2) + "%";
|
|
1966
|
-
argsSeg.style.background = sourceColorDim(entry.hue
|
|
2053
|
+
argsSeg.style.background = sourceColorDim(entry.hue);
|
|
1967
2054
|
group.appendChild(argsSeg);
|
|
1968
2055
|
}
|
|
1969
2056
|
var resultsSeg = statsDiv("wsr-chart-fill wsr-bar-results");
|
|
1970
2057
|
resultsSeg.style.width = (100 - argsPart).toFixed(2) + "%";
|
|
1971
|
-
resultsSeg.style.background = sourceColor(entry.hue
|
|
2058
|
+
resultsSeg.style.background = sourceColor(entry.hue);
|
|
1972
2059
|
group.appendChild(resultsSeg);
|
|
2060
|
+
/* What the two shades mean, on the thing that has them: the legend is
|
|
2061
|
+
a row away and reads like a second chart header. */
|
|
2062
|
+
if (argsPart > 0) {
|
|
2063
|
+
group.setAttribute("title", t("stats.barTooltip", {
|
|
2064
|
+
name: entry.name,
|
|
2065
|
+
total: formatTokens(entry.value),
|
|
2066
|
+
args: formatTokens(entry.args || 0),
|
|
2067
|
+
argsShare: formatShare((entry.value > 0 ? (entry.args || 0) / entry.value : 0)),
|
|
2068
|
+
results: formatTokens(entry.results || 0),
|
|
2069
|
+
resultsShare: formatShare((entry.value > 0 ? (entry.results || 0) / entry.value : 0)),
|
|
2070
|
+
}));
|
|
2071
|
+
}
|
|
1973
2072
|
track.appendChild(group);
|
|
1974
2073
|
line.appendChild(track);
|
|
1975
2074
|
line.appendChild(statsDiv("wsr-chart-value", formatTokens(entry.value)));
|
|
1976
2075
|
line.appendChild(statsDiv("wsr-chart-share", formatShare(entry.share)));
|
|
1977
2076
|
/* The count the chart cannot draw: a bar says how heavy a source is,
|
|
1978
2077
|
the call count says how often it got there. The details table used to
|
|
1979
|
-
be the only place for it.
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
2078
|
+
be the only place for it. It always renders (empty for rows without
|
|
2079
|
+
a count) so the five-column grid stays aligned. */
|
|
2080
|
+
line.appendChild(statsDiv(
|
|
2081
|
+
"wsr-chart-calls",
|
|
2082
|
+
typeof entry.calls === "number" && entry.calls > 0 ? t("stats.callsShort", { n: String(entry.calls) }) : "",
|
|
2083
|
+
));
|
|
1983
2084
|
return line;
|
|
1984
2085
|
}
|
|
1985
2086
|
|
|
1986
2087
|
/**
|
|
1987
|
-
* Colour identity for a source.
|
|
2088
|
+
* Colour identity for a source, by tool family.
|
|
1988
2089
|
*
|
|
1989
|
-
* The
|
|
1990
|
-
*
|
|
1991
|
-
*
|
|
1992
|
-
*
|
|
1993
|
-
*
|
|
2090
|
+
* The colour answers one question - what kind of work is this - so the
|
|
2091
|
+
* hue is the family, not the tool: five named families with a fixed
|
|
2092
|
+
* vividness, and unknown tools fall back to the same neutral instead of a
|
|
2093
|
+
* hash. Ranking no longer modulates anything: a faded tail colour told the
|
|
2094
|
+
* reader nothing they could act on.
|
|
1994
2095
|
*/
|
|
1995
|
-
var
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
subagent: 250, subagent_fork: 250, workflow: 250, spawn_teammate: 250, send_message: 250, wait_agent: 250,
|
|
2002
|
-
ask_user_question: 12, present: 12,
|
|
2003
|
-
skill: 60, create_goal: 60, update_goal: 60,
|
|
2004
|
-
};
|
|
2005
|
-
var TOOL_PREFIX_HUES = [
|
|
2006
|
-
["mcp__", 235],
|
|
2007
|
-
["browser_", 0],
|
|
2008
|
-
["univer_", 175],
|
|
2009
|
-
["weknora_", 300],
|
|
2010
|
-
["job_", 330],
|
|
2011
|
-
["team_", 250],
|
|
2096
|
+
var TOOL_FAMILIES = [
|
|
2097
|
+
{ key: "shell", hue: 32, tools: ["pwsh", "powershell", "shell", "bash", "command", "cmd", "run_code"], prefixes: [] },
|
|
2098
|
+
{ key: "files", hue: 152, tools: ["read", "write", "edit", "grep", "glob", "str_replace_editor", "ls", "delete", "move_file"], prefixes: ["univer_"] },
|
|
2099
|
+
{ key: "web", hue: 205, tools: ["web_fetch", "web_search", "platform_search", "multi_search", "advanced_search", "domain_search", "video_search", "browser_"], prefixes: ["browser_"] },
|
|
2100
|
+
{ key: "agents", hue: 268, tools: ["subagent", "subagent_fork", "workflow", "spawn_teammate", "send_message", "wait_agent", "task"], prefixes: ["team_"] },
|
|
2101
|
+
{ key: "misc", hue: 330, tools: ["todo_write", "todo_read", "todo", "job_output", "job_list", "job_kill", "skill", "create_goal", "update_goal", "ask_user_question", "present", "weknora_"], prefixes: ["job_", "weknora_", "mcp__"] },
|
|
2012
2102
|
];
|
|
2103
|
+
/** The neutral an unknown tool gets: no family, no claim of one. */
|
|
2104
|
+
var TOOL_FAMILY_NEUTRAL = { key: "other", hue: 210 };
|
|
2013
2105
|
|
|
2014
|
-
function
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2106
|
+
function toolFamily(name) {
|
|
2107
|
+
if (typeof name !== "string" || name === "") return TOOL_FAMILY_NEUTRAL;
|
|
2108
|
+
var key = name.toLowerCase();
|
|
2109
|
+
for (var i = 0; i < TOOL_FAMILIES.length; i += 1) {
|
|
2110
|
+
var family = TOOL_FAMILIES[i];
|
|
2111
|
+
if (family.tools.indexOf(key) !== -1) return family;
|
|
2112
|
+
for (var p = 0; p < family.prefixes.length; p += 1) {
|
|
2113
|
+
if (key.indexOf(family.prefixes[p]) === 0) return family;
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
return TOOL_FAMILY_NEUTRAL;
|
|
2018
2117
|
}
|
|
2019
2118
|
|
|
2020
2119
|
function sourceHue(name) {
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
return
|
|
2120
|
+
return toolFamily(name).hue;
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
/** The hue of a family key, for the legend swatches. */
|
|
2124
|
+
function hueOfFamily(key) {
|
|
2125
|
+
for (var i = 0; i < TOOL_FAMILIES.length; i += 1) if (TOOL_FAMILIES[i].key === key) return TOOL_FAMILIES[i].hue;
|
|
2126
|
+
return TOOL_FAMILY_NEUTRAL.hue;
|
|
2028
2127
|
}
|
|
2029
2128
|
|
|
2030
|
-
/**
|
|
2031
|
-
function sourceColor(hue
|
|
2032
|
-
|
|
2033
|
-
var lightness = Math.min(64, 50 + rank * 2);
|
|
2034
|
-
return "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)";
|
|
2129
|
+
/** One vividness for every family bar: colour means "which family", not "how big". */
|
|
2130
|
+
function sourceColor(hue) {
|
|
2131
|
+
return "hsl(" + hue + ", 72%, 58%)";
|
|
2035
2132
|
}
|
|
2036
2133
|
|
|
2037
2134
|
/**
|
|
@@ -2039,12 +2136,12 @@
|
|
|
2039
2136
|
*
|
|
2040
2137
|
* It has to be a real colour rather than an opacity: the segment sits on a
|
|
2041
2138
|
* solid bar of the same hue, so a translucent copy of it would composite
|
|
2042
|
-
* back to exactly the same colour and the split would be invisible.
|
|
2139
|
+
* back to exactly the same colour and the split would be invisible. The
|
|
2140
|
+
* gap between the two is deliberately wide - a 20-point lightness step read
|
|
2141
|
+
* as one smudged bar in the reported panel.
|
|
2043
2142
|
*/
|
|
2044
|
-
function sourceColorDim(hue
|
|
2045
|
-
|
|
2046
|
-
var lightness = Math.min(76, 66 + rank * 2);
|
|
2047
|
-
return "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)";
|
|
2143
|
+
function sourceColorDim(hue) {
|
|
2144
|
+
return "hsl(" + hue + ", 32%, 84%)";
|
|
2048
2145
|
}
|
|
2049
2146
|
|
|
2050
2147
|
var AMPLIFIED_KIND = {
|
|
@@ -2063,45 +2160,134 @@
|
|
|
2063
2160
|
* block's tokens times the number of later steps that re-read it. The
|
|
2064
2161
|
* host half computes that attribution; this only draws it.
|
|
2065
2162
|
*/
|
|
2066
|
-
/**
|
|
2163
|
+
/** Chart/list pairs whose jump markers highlight together on hover. */
|
|
2164
|
+
var jumpHoverHosts = [];
|
|
2165
|
+
/** Document-level listener for jump hover; registered once per panel open. */
|
|
2166
|
+
var jumpHoverBound = false;
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* Highlight one jump: the bar, its dot and the row that spells it out.
|
|
2170
|
+
*
|
|
2171
|
+
* Both the chart and the list live under the same section, so the pairing
|
|
2172
|
+
* is by `data-wsr-jump*` attributes rather than by DOM position (the chart
|
|
2173
|
+
* is downsampled and a bar may cover several steps).
|
|
2174
|
+
*/
|
|
2175
|
+
function highlightJumpRow(event) {
|
|
2176
|
+
var target = event !== undefined && event.currentTarget !== undefined ? event.currentTarget : null;
|
|
2177
|
+
if (target === null || typeof target.getAttribute !== "function") return;
|
|
2178
|
+
var step = target.getAttribute("data-wsr-jump-hit");
|
|
2179
|
+
if (step === null) return;
|
|
2180
|
+
for (var i = 0; i < jumpHoverHosts.length; i += 1) {
|
|
2181
|
+
var host = jumpHoverHosts[i];
|
|
2182
|
+
if (host.chart === null || typeof host.chart.querySelectorAll !== "function") continue;
|
|
2183
|
+
var rows = host.chart.querySelectorAll("[data-wsr-jump-row]");
|
|
2184
|
+
for (var r = 0; r < rows.length; r += 1) {
|
|
2185
|
+
rows[r].className = "wsr-context-jump-row" + (rows[r].getAttribute("data-wsr-jump-row") === step ? " wsr-context-jump-row-hot" : "");
|
|
2186
|
+
}
|
|
2187
|
+
var hits = host.chart.querySelectorAll("[data-wsr-jump-hit]");
|
|
2188
|
+
for (var h = 0; h < hits.length; h += 1) {
|
|
2189
|
+
hits[h].className = "wsr-context-jump-hit" + (hits[h].getAttribute("data-wsr-jump-hit") === step ? " wsr-context-jump-hit-hot" : "");
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
function clearJumpHighlight() {
|
|
2195
|
+
for (var i = 0; i < jumpHoverHosts.length; i += 1) {
|
|
2196
|
+
var host = jumpHoverHosts[i];
|
|
2197
|
+
if (host.chart === null || typeof host.chart.querySelectorAll !== "function") continue;
|
|
2198
|
+
var rows = host.chart.querySelectorAll("[data-wsr-jump-row]");
|
|
2199
|
+
for (var r = 0; r < rows.length; r += 1) rows[r].className = "wsr-context-jump-row";
|
|
2200
|
+
var hits = host.chart.querySelectorAll("[data-wsr-jump-hit]");
|
|
2201
|
+
for (var h = 0; h < hits.length; h += 1) hits[h].className = "wsr-context-jump-hit";
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* The steepest rise in each compaction segment.
|
|
2207
|
+
*
|
|
2208
|
+
* A compaction rewrites the window, so a rise measured across that boundary
|
|
2209
|
+
* compares two different conversations: each segment has to be ranked on its
|
|
2210
|
+
* own. One marker per segment answers "where did this segment start growing",
|
|
2211
|
+
* and it keeps the chart readable when a session compacted several times.
|
|
2212
|
+
*/
|
|
2067
2213
|
function contextJumps(amplified) {
|
|
2068
2214
|
var series = Array.isArray(amplified.series) ? amplified.series : [];
|
|
2069
2215
|
var blocks = Array.isArray(amplified.blocks) ? amplified.blocks : [];
|
|
2070
|
-
var
|
|
2216
|
+
var compactions = Array.isArray(amplified.compactions)
|
|
2217
|
+
? amplified.compactions.map(Number).sort(function (a, b) { return a - b; })
|
|
2218
|
+
: [];
|
|
2219
|
+
var segmentOf = function (step) {
|
|
2220
|
+
var segment = 1;
|
|
2221
|
+
for (var c = 0; c < compactions.length; c += 1) if (step > compactions[c]) segment += 1;
|
|
2222
|
+
return segment;
|
|
2223
|
+
};
|
|
2224
|
+
/* Rises grouped per segment; the step that starts a new segment has no
|
|
2225
|
+
rise to compare against the step before the rewrite. */
|
|
2226
|
+
var bySegment = {};
|
|
2071
2227
|
for (var i = 1; i < series.length; i += 1) {
|
|
2228
|
+
var from = Number(series[i - 1].step);
|
|
2229
|
+
var to = Number(series[i].step);
|
|
2230
|
+
if (segmentOf(from) !== segmentOf(to)) continue;
|
|
2072
2231
|
var rise = Number(series[i].context) - Number(series[i - 1].context);
|
|
2073
|
-
if (rise
|
|
2232
|
+
if (rise <= 0) continue;
|
|
2233
|
+
var segment = segmentOf(to);
|
|
2234
|
+
if (bySegment[segment] === undefined) bySegment[segment] = [];
|
|
2235
|
+
bySegment[segment].push({ step: to, rise: rise });
|
|
2074
2236
|
}
|
|
2075
|
-
|
|
2237
|
+
var total = compactions.length + 1;
|
|
2076
2238
|
var picked = [];
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
var
|
|
2091
|
-
|
|
2092
|
-
|
|
2239
|
+
/* Three markers per segment, not three for the whole session: after a
|
|
2240
|
+
rewrite the earlier segment cannot crowd out the later ones. The
|
|
2241
|
+
spacing only matters when many steps share one bar; on a short curve
|
|
2242
|
+
each bar is wide enough for neighbouring marks. */
|
|
2243
|
+
var spacing = Math.max(1, Math.round(series.length / 10));
|
|
2244
|
+
for (var s = 1; s <= total; s += 1) {
|
|
2245
|
+
var rises = bySegment[s];
|
|
2246
|
+
if (rises === undefined || rises.length === 0) continue;
|
|
2247
|
+
rises.sort(function (a, b) { return b.rise - a.rise; });
|
|
2248
|
+
var chosen = [];
|
|
2249
|
+
for (var r = 0; r < rises.length && chosen.length < 3; r += 1) {
|
|
2250
|
+
/* Two markers side by side read as one wide jump. */
|
|
2251
|
+
var close = false;
|
|
2252
|
+
for (var p = 0; p < chosen.length; p += 1) {
|
|
2253
|
+
if (Math.abs(chosen[p].step - rises[r].step) < spacing) close = true;
|
|
2254
|
+
}
|
|
2255
|
+
if (close) continue;
|
|
2256
|
+
chosen.push(rises[r]);
|
|
2093
2257
|
}
|
|
2094
|
-
var
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2258
|
+
for (var k = 0; k < chosen.length; k += 1) {
|
|
2259
|
+
var best = chosen[k];
|
|
2260
|
+
/* The entering block: the biggest one whose entry step is this one,
|
|
2261
|
+
or (downsampled curves) the last entry at or before it. */
|
|
2262
|
+
var block = null;
|
|
2263
|
+
for (var b = 0; b < blocks.length; b += 1) {
|
|
2264
|
+
var candidate = blocks[b];
|
|
2265
|
+
if (Number(candidate.entry) > best.step) continue;
|
|
2266
|
+
if (block === null || Number(candidate.entry) > Number(block.entry)) block = candidate;
|
|
2267
|
+
}
|
|
2268
|
+
var label = t("stats.amplified.jump", {
|
|
2269
|
+
step: String(best.step),
|
|
2270
|
+
rise: formatTokens(best.rise),
|
|
2271
|
+
});
|
|
2272
|
+
var blockName = "";
|
|
2273
|
+
if (block !== null && Number(block.entry) === best.step) {
|
|
2274
|
+
blockName = block.kind === "tool" ? String(block.name) : t("stats.agent");
|
|
2275
|
+
label += " " + t("stats.amplified.jumpFrom", {
|
|
2276
|
+
name: blockName,
|
|
2277
|
+
tokens: formatTokens(block.tokens),
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
picked.push({
|
|
2281
|
+
step: best.step,
|
|
2282
|
+
rise: best.rise,
|
|
2283
|
+
segment: s,
|
|
2284
|
+
/* Rank is within the segment; the row's segment number keeps two
|
|
2285
|
+
"first" markers apart when a session compacted more than once. */
|
|
2286
|
+
rank: k + 1,
|
|
2287
|
+
blockName: blockName,
|
|
2288
|
+
label: label,
|
|
2102
2289
|
});
|
|
2103
2290
|
}
|
|
2104
|
-
picked.push({ step: rise2.step, rise: rise2.rise, label: label });
|
|
2105
2291
|
}
|
|
2106
2292
|
return picked;
|
|
2107
2293
|
}
|
|
@@ -2127,37 +2313,89 @@
|
|
|
2127
2313
|
if (Number(series[i].context) > largest) largest = Number(series[i].context);
|
|
2128
2314
|
}
|
|
2129
2315
|
var chart = statsDiv("wsr-context-chart");
|
|
2130
|
-
/* Mark the
|
|
2131
|
-
large file shows up
|
|
2132
|
-
|
|
2133
|
-
instead of leaving the reader to compare 96 bars by eye. */
|
|
2316
|
+
/* Mark the steepest step of every compaction segment: a single read of a
|
|
2317
|
+
large file shows up as one tall rise, and after a rewrite the window
|
|
2318
|
+
starts over, so each segment is read on its own. */
|
|
2134
2319
|
var jumps = contextJumps(amplified);
|
|
2135
2320
|
var jumpByStep = {};
|
|
2136
2321
|
for (var jj = 0; jj < jumps.length; jj += 1) jumpByStep[jumps[jj].step] = jumps[jj];
|
|
2322
|
+
/* Where the window was rewritten: a faint divider makes the drop on the
|
|
2323
|
+
curve legible instead of looking like a glitch. */
|
|
2324
|
+
var breaks = {};
|
|
2325
|
+
var compactionAt = Array.isArray(amplified.compactions) ? amplified.compactions.map(Number) : [];
|
|
2326
|
+
for (var cb = 0; cb < compactionAt.length; cb += 1) breaks[compactionAt[cb]] = true;
|
|
2327
|
+
var openBreak = false;
|
|
2137
2328
|
for (var j = 0; j < series.length; j += 1) {
|
|
2138
2329
|
var bar = statsDiv("wsr-context-bar");
|
|
2139
2330
|
bar.style.height = Math.max(2, Math.round((Number(series[j].context) / largest) * 100)) + "%";
|
|
2140
|
-
|
|
2331
|
+
/* A compaction recorded at step N ends the segment at N: the first bar
|
|
2332
|
+
whose step is past it opens the next one. */
|
|
2333
|
+
var step = Number(series[j].step);
|
|
2334
|
+
var startsSegment = false;
|
|
2335
|
+
for (var cb2 = 0; cb2 < compactionAt.length; cb2 += 1) {
|
|
2336
|
+
if (step > compactionAt[cb2] && !openBreak) startsSegment = true;
|
|
2337
|
+
}
|
|
2338
|
+
if (startsSegment) {
|
|
2339
|
+
bar.className = "wsr-context-bar wsr-context-break";
|
|
2340
|
+
openBreak = true;
|
|
2341
|
+
}
|
|
2342
|
+
var jump = jumpByStep[step];
|
|
2141
2343
|
if (jump !== undefined) {
|
|
2142
|
-
bar.className = "wsr-context-bar wsr-context-jump";
|
|
2344
|
+
bar.className = "wsr-context-bar wsr-context-jump" + (startsSegment ? " wsr-context-break" : "");
|
|
2143
2345
|
bar.setAttribute("data-wsr-jump", String(jump.step));
|
|
2144
2346
|
bar.setAttribute("title", jump.label);
|
|
2145
|
-
|
|
2146
|
-
|
|
2347
|
+
/* A hover target that is big enough to hit: a 5px dot on a 3px bar
|
|
2348
|
+
is unraisable without aiming, and the label lives in the row
|
|
2349
|
+
below, so hovering the bar also lifts that row. */
|
|
2350
|
+
var hit = statsDiv("wsr-context-jump-hit");
|
|
2351
|
+
hit.setAttribute("data-wsr-jump-hit", String(jump.step));
|
|
2352
|
+
hit.setAttribute("data-wsr-rank", String(jump.rank));
|
|
2353
|
+
hit.appendChild(statsDiv("wsr-context-jump-dot"));
|
|
2354
|
+
hit.addEventListener("mouseenter", highlightJumpRow);
|
|
2355
|
+
hit.addEventListener("mouseleave", clearJumpHighlight);
|
|
2356
|
+
bar.appendChild(hit);
|
|
2147
2357
|
} else {
|
|
2148
|
-
bar.setAttribute("title", t("stats.amplified.point", { step: String(
|
|
2358
|
+
bar.setAttribute("title", t("stats.amplified.point", { step: String(step), context: formatTokens(series[j].context) }));
|
|
2149
2359
|
}
|
|
2150
2360
|
chart.appendChild(bar);
|
|
2151
2361
|
}
|
|
2152
2362
|
section.appendChild(chart);
|
|
2153
2363
|
section.appendChild(statsDiv("wsr-context-caption", t("stats.amplified.contextCaption")));
|
|
2154
2364
|
if (jumps.length > 0) {
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2365
|
+
/* One line per segment, its three rises inline. A row per rise took
|
|
2366
|
+
nine lines for a twice-compacted session and made the panel look
|
|
2367
|
+
like a table of numbers nobody compares row by row. */
|
|
2368
|
+
var segments = [];
|
|
2369
|
+
for (var js = 0; js < jumps.length; js += 1) {
|
|
2370
|
+
if (segments.indexOf(jumps[js].segment) === -1) segments.push(jumps[js].segment);
|
|
2371
|
+
}
|
|
2372
|
+
var multiSegment = segments.length > 1;
|
|
2373
|
+
var jumpList = statsDiv("wsr-context-jumps" + (multiSegment ? "" : " wsr-context-jumps-single"));
|
|
2374
|
+
for (var sg = 0; sg < segments.length; sg += 1) {
|
|
2375
|
+
var group = statsDiv("wsr-context-jump-group");
|
|
2376
|
+
if (multiSegment) {
|
|
2377
|
+
group.appendChild(statsDiv("wsr-context-jump-segment", t("stats.amplified.segment", { segment: String(segments[sg]) })));
|
|
2378
|
+
}
|
|
2379
|
+
for (var jl = 0; jl < jumps.length; jl += 1) {
|
|
2380
|
+
if (jumps[jl].segment !== segments[sg]) continue;
|
|
2381
|
+
var jumpRow = statsDiv("wsr-context-jump-row");
|
|
2382
|
+
jumpRow.setAttribute("data-wsr-jump-row", String(jumps[jl].step));
|
|
2383
|
+
jumpRow.setAttribute("data-wsr-rank", String(jumps[jl].rank));
|
|
2384
|
+
jumpRow.setAttribute("title", jumps[jl].label);
|
|
2385
|
+
var rankCell = statsDiv("wsr-context-jump-rank");
|
|
2386
|
+
rankCell.appendChild(statsDiv("wsr-context-jump-rank-dot"));
|
|
2387
|
+
jumpRow.appendChild(rankCell);
|
|
2388
|
+
jumpRow.appendChild(statsDiv("wsr-context-jump-step", t("stats.amplified.jumpStep", { step: String(jumps[jl].step) })));
|
|
2389
|
+
jumpRow.appendChild(statsDiv("wsr-context-jump-rise", "+" + formatTokens(jumps[jl].rise)));
|
|
2390
|
+
group.appendChild(jumpRow);
|
|
2391
|
+
}
|
|
2392
|
+
jumpList.appendChild(group);
|
|
2158
2393
|
}
|
|
2159
2394
|
section.appendChild(jumpList);
|
|
2160
2395
|
}
|
|
2396
|
+
/* The rows only make sense while the chart is on screen; hovering a
|
|
2397
|
+
bar or its row lifts both, which is what "挪上去更明显" means here. */
|
|
2398
|
+
jumpHoverHosts.push({ chart: chart, list: section });
|
|
2161
2399
|
|
|
2162
2400
|
var kinds = amplified.byKind || [];
|
|
2163
2401
|
if (kinds.length > 0) {
|
|
@@ -2193,37 +2431,34 @@
|
|
|
2193
2431
|
row.appendChild(main);
|
|
2194
2432
|
row.appendChild(statsDiv("wsr-amplified-value", formatTokens(block.amplified)));
|
|
2195
2433
|
row.appendChild(statsDiv("wsr-amplified-share", formatShare(block.share || 0)));
|
|
2196
|
-
if (Number(block.remaining) > 0 && Number(block.saving) > 0) {
|
|
2197
|
-
row.appendChild(statsDiv("wsr-amplified-if", t("stats.amplified.whatIf", {
|
|
2198
|
-
save: formatTokens(block.saving),
|
|
2199
|
-
share: formatShare(Number(block.saving) / (bill > 0 ? bill : 1)),
|
|
2200
|
-
})));
|
|
2201
|
-
}
|
|
2202
2434
|
list.appendChild(row);
|
|
2203
2435
|
}
|
|
2204
2436
|
section.appendChild(list);
|
|
2205
|
-
section.appendChild(statsDiv("wsr-stats-note", t("stats.amplified.note")));
|
|
2206
2437
|
return section;
|
|
2207
2438
|
}
|
|
2208
2439
|
|
|
2209
2440
|
function renderStats(body, stats) {
|
|
2210
2441
|
body.textContent = "";
|
|
2211
2442
|
while (body.firstChild !== null) body.removeChild(body.firstChild);
|
|
2443
|
+
/* A re-render replaces the DOM the hover handlers pointed at. */
|
|
2444
|
+
jumpHoverHosts.length = 0;
|
|
2212
2445
|
var totals = stats.totals || {};
|
|
2213
2446
|
var estimate = stats.estimate || {};
|
|
2214
2447
|
var agent = estimate.agent || {};
|
|
2215
2448
|
|
|
2449
|
+
/* Five cards as before, bill first: it is the number the rest of the
|
|
2450
|
+
panel explains, so it leads and carries the accent. */
|
|
2216
2451
|
var grid = document.createElement("div");
|
|
2217
2452
|
grid.className = "wsr-stats-grid";
|
|
2218
2453
|
var cards = [
|
|
2219
|
-
[t("stats.
|
|
2220
|
-
[t("stats.
|
|
2221
|
-
[t("stats.
|
|
2222
|
-
[t("stats.
|
|
2223
|
-
[t("stats.
|
|
2454
|
+
[t("stats.total"), formatTokens(totals.totalTokens), true],
|
|
2455
|
+
[t("stats.steps"), formatTokens(stats.steps), false],
|
|
2456
|
+
[t("stats.input"), formatTokens(totals.inputTokens), false],
|
|
2457
|
+
[t("stats.cache"), formatTokens(totals.cacheReadTokens), false],
|
|
2458
|
+
[t("stats.output"), formatTokens(totals.outputTokens), false],
|
|
2224
2459
|
];
|
|
2225
2460
|
for (var i = 0; i < cards.length; i += 1) {
|
|
2226
|
-
var card = statsDiv("wsr-stats-card");
|
|
2461
|
+
var card = statsDiv("wsr-stats-card" + (cards[i][2] === true ? " wsr-stats-card-primary" : ""));
|
|
2227
2462
|
card.appendChild(statsDiv("wsr-stats-value", cards[i][1]));
|
|
2228
2463
|
card.appendChild(statsDiv("wsr-stats-label", cards[i][0]));
|
|
2229
2464
|
grid.appendChild(card);
|
|
@@ -2271,19 +2506,51 @@
|
|
|
2271
2506
|
value: value,
|
|
2272
2507
|
share: shareOf(value),
|
|
2273
2508
|
hue: sourceHue(tool.name),
|
|
2509
|
+
family: toolFamily(tool.name).key,
|
|
2274
2510
|
rank: j + 1,
|
|
2275
2511
|
calls: tool.calls || 0,
|
|
2276
2512
|
args: args,
|
|
2513
|
+
results: results,
|
|
2277
2514
|
split: mode !== "agent" && args > 0 && results > 0,
|
|
2278
2515
|
});
|
|
2279
2516
|
}
|
|
2280
2517
|
|
|
2281
2518
|
/* The picture first: one bar per source, split into args and results. */
|
|
2282
|
-
var chart =
|
|
2519
|
+
var chart = document.createElement("div");
|
|
2520
|
+
chart.className = "wsr-chart";
|
|
2521
|
+
var familyOrder = [];
|
|
2522
|
+
var familySeen = {};
|
|
2523
|
+
for (var f = 0; f < entries.length; f += 1) {
|
|
2524
|
+
var fam = entries[f].family;
|
|
2525
|
+
if (typeof fam === "string" && fam !== "" && familySeen[fam] !== true) {
|
|
2526
|
+
familySeen[fam] = true;
|
|
2527
|
+
familyOrder.push(fam);
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
if (familyOrder.length > 0) {
|
|
2531
|
+
var familyLegend = statsDiv("wsr-kind-legend wsr-family-legend");
|
|
2532
|
+
for (var fl = 0; fl < familyOrder.length; fl += 1) {
|
|
2533
|
+
var famItem = statsDiv("wsr-kind");
|
|
2534
|
+
var famDot = statsDiv("wsr-kind-dot");
|
|
2535
|
+
famDot.style.background = sourceColor(hueOfFamily(familyOrder[fl]));
|
|
2536
|
+
famItem.appendChild(famDot);
|
|
2537
|
+
famItem.appendChild(statsDiv("", t("stats.family." + familyOrder[fl])));
|
|
2538
|
+
familyLegend.appendChild(famItem);
|
|
2539
|
+
}
|
|
2540
|
+
chart.appendChild(familyLegend);
|
|
2541
|
+
}
|
|
2283
2542
|
var chartHead = statsDiv("wsr-chart-head");
|
|
2284
2543
|
chartHead.appendChild(statsDiv("wsr-chart-title", t("stats.chart")));
|
|
2285
2544
|
if (mode !== "agent") chartHead.appendChild(chartLegend());
|
|
2286
2545
|
chart.appendChild(chartHead);
|
|
2546
|
+
/* A header row keeps the count column from reading as a stray number. */
|
|
2547
|
+
var callHead = statsDiv("wsr-chart-row wsr-chart-headrow");
|
|
2548
|
+
callHead.appendChild(statsDiv("wsr-chart-label", ""));
|
|
2549
|
+
callHead.appendChild(statsDiv("wsr-chart-track-head", ""));
|
|
2550
|
+
callHead.appendChild(statsDiv("wsr-chart-value-head", t("stats.col.tokensShort")));
|
|
2551
|
+
callHead.appendChild(statsDiv("wsr-chart-share-head", t("stats.col.shareShort")));
|
|
2552
|
+
callHead.appendChild(statsDiv("wsr-chart-calls-head", t("stats.col.calls")));
|
|
2553
|
+
chart.appendChild(callHead);
|
|
2287
2554
|
var largest = 1;
|
|
2288
2555
|
for (var m = 0; m < entries.length; m += 1) if (entries[m].value > largest) largest = entries[m].value;
|
|
2289
2556
|
for (var k = 0; k < entries.length; k += 1) chart.appendChild(chartBar(entries[k], largest));
|
|
@@ -2298,7 +2565,6 @@
|
|
|
2298
2565
|
user: formatTokens(agent.user),
|
|
2299
2566
|
system: formatTokens(agent.system),
|
|
2300
2567
|
})));
|
|
2301
|
-
distributionPanel.appendChild(statsDiv("wsr-stats-note", t("stats.note")));
|
|
2302
2568
|
|
|
2303
2569
|
var tabs = statsDiv("wsr-stats-tabs");
|
|
2304
2570
|
tabs.setAttribute("role", "tablist");
|
|
@@ -2345,6 +2611,9 @@
|
|
|
2345
2611
|
selectTab(initialTab);
|
|
2346
2612
|
body.appendChild(tabs);
|
|
2347
2613
|
body.appendChild(panels);
|
|
2614
|
+
/* One口径 note for the whole dialog: both views are estimates over the
|
|
2615
|
+
same logs, and repeating it under each view crowded out the numbers. */
|
|
2616
|
+
body.appendChild(statsDiv("wsr-stats-note wsr-stats-footnote", t("stats.note")));
|
|
2348
2617
|
}
|
|
2349
2618
|
|
|
2350
2619
|
function openStatsPanel(sessionId) {
|
|
@@ -3704,14 +3973,54 @@
|
|
|
3704
3973
|
* below. Both are "put away", so both are managed from here.
|
|
3705
3974
|
*/
|
|
3706
3975
|
/** One entry as a card: badge, title, the numbers that matter, and actions. */
|
|
3976
|
+
/**
|
|
3977
|
+
* An action as an icon button.
|
|
3978
|
+
*
|
|
3979
|
+
* Text buttons in the card header squeezed the title to an ellipsis; an
|
|
3980
|
+
* icon says the same thing in 24px, and the label moves into the title
|
|
3981
|
+
* attribute so it is still discoverable on hover.
|
|
3982
|
+
*/
|
|
3983
|
+
function iconButton(options) {
|
|
3984
|
+
var Icon = ui[options.icon];
|
|
3985
|
+
var label = options.label;
|
|
3986
|
+
var className = "wsr-icon-btn" + (options.danger === true ? " wsr-icon-btn-danger" : "");
|
|
3987
|
+
if (typeof Icon !== "function") {
|
|
3988
|
+
/* An older UI package without this glyph: keep the action usable. */
|
|
3989
|
+
return h("button", {
|
|
3990
|
+
type: "button",
|
|
3991
|
+
className: (options.danger === true ? "wsr-btn wsr-btn-danger" : "wsr-btn") + " wsr-icon-fallback",
|
|
3992
|
+
title: label,
|
|
3993
|
+
onClick: options.onClick,
|
|
3994
|
+
}, label);
|
|
3995
|
+
}
|
|
3996
|
+
/* One frame for every icon. The glyph artwork has its own intrinsic
|
|
3997
|
+
aspect (archive, trash and refresh outlines differ), so a raw `size`
|
|
3998
|
+
made neighbouring buttons look different sizes. */
|
|
3999
|
+
return h("button", {
|
|
4000
|
+
type: "button",
|
|
4001
|
+
className: className,
|
|
4002
|
+
title: label,
|
|
4003
|
+
"aria-label": label,
|
|
4004
|
+
onClick: options.onClick,
|
|
4005
|
+
}, h("span", { className: "wsr-icon-btn-glyph" }, h(Icon, { size: 14 })));
|
|
4006
|
+
}
|
|
4007
|
+
|
|
4008
|
+
/**
|
|
4009
|
+
* One entry as a card.
|
|
4010
|
+
*
|
|
4011
|
+
* The section heading already says "deleted" or "archived", so no badge
|
|
4012
|
+
* repeats it. Every action lives in one row at the bottom of the card,
|
|
4013
|
+
* right-aligned: one row is one right edge, so nothing can drift, and the
|
|
4014
|
+
* title keeps the full width.
|
|
4015
|
+
*/
|
|
3707
4016
|
function entryCard(options) {
|
|
4017
|
+
var safeActions = options.actions === null || options.actions === undefined ? [] : options.actions;
|
|
4018
|
+
var actions = [];
|
|
4019
|
+
for (var i = 0; i < safeActions.length; i += 1) actions.push(safeActions[i]);
|
|
4020
|
+
if (options.danger !== null && options.danger !== undefined) actions.push(options.danger);
|
|
3708
4021
|
return h("div", { className: "wsr-card", key: options.key, title: options.titleAttr || "" },
|
|
3709
4022
|
h("div", { className: "wsr-card-head" },
|
|
3710
|
-
options.badge !== null && options.badge !== undefined
|
|
3711
|
-
? h("span", { className: "wsr-card-badge " + (options.badgeClass || "") }, options.badge)
|
|
3712
|
-
: null,
|
|
3713
4023
|
h("div", { className: options.titleClass || "wsr-card-title" }, options.title),
|
|
3714
|
-
h("div", { className: "wsr-card-actions" }, options.actions),
|
|
3715
4024
|
),
|
|
3716
4025
|
options.chips.length > 0
|
|
3717
4026
|
? h("div", { className: "wsr-chips" }, options.chips.map(function (text, index) {
|
|
@@ -3721,6 +4030,9 @@
|
|
|
3721
4030
|
typeof options.path === "string" && options.path !== ""
|
|
3722
4031
|
? h("div", { className: "wsr-card-path" }, options.path)
|
|
3723
4032
|
: null,
|
|
4033
|
+
actions.length > 0
|
|
4034
|
+
? h("div", { className: "wsr-card-actions wsr-card-actions-row" }, actions)
|
|
4035
|
+
: null,
|
|
3724
4036
|
);
|
|
3725
4037
|
}
|
|
3726
4038
|
|
|
@@ -3813,27 +4125,26 @@
|
|
|
3813
4125
|
if (when !== "") chips.push(when);
|
|
3814
4126
|
var actions = [];
|
|
3815
4127
|
if (entry.restorable === true) {
|
|
3816
|
-
actions.push(
|
|
3817
|
-
|
|
3818
|
-
|
|
4128
|
+
actions.push(iconButton({
|
|
4129
|
+
icon: "IconRefreshOutlineRegular",
|
|
4130
|
+
label: t("trash.restore"),
|
|
3819
4131
|
onClick: function () { act(entry, "restore"); },
|
|
3820
|
-
}
|
|
4132
|
+
}));
|
|
3821
4133
|
}
|
|
3822
|
-
actions.push(h("button", {
|
|
3823
|
-
type: "button",
|
|
3824
|
-
className: "wsr-btn wsr-btn-danger",
|
|
3825
|
-
onClick: function () { act(entry, "purge"); },
|
|
3826
|
-
}, t("trash.purge")));
|
|
3827
4134
|
var hasTitle = typeof entry.title === "string" && entry.title !== "";
|
|
3828
4135
|
rows.push(entryCard({
|
|
3829
4136
|
key: entry.name,
|
|
3830
|
-
badge: entry.reason === "move" ? t("trash.reason.move") : t("trash.reason.delete"),
|
|
3831
|
-
badgeClass: entry.reason === "move" ? "wsr-card-badge-muted" : "wsr-card-badge-danger",
|
|
3832
4137
|
titleClass: hasTitle ? "wsr-card-title" : "wsr-card-title wsr-card-title-id",
|
|
3833
4138
|
title: hasTitle ? entry.title : (entry.sessionId === null ? entry.name : entry.sessionId),
|
|
3834
4139
|
titleAttr: entry.sessionId === null ? entry.name : entry.sessionId,
|
|
3835
4140
|
chips: chips,
|
|
3836
4141
|
path: entry.cwd,
|
|
4142
|
+
danger: iconButton({
|
|
4143
|
+
icon: "IconCloseOutlineRegular",
|
|
4144
|
+
label: t("trash.purge"),
|
|
4145
|
+
danger: true,
|
|
4146
|
+
onClick: function () { act(entry, "purge"); },
|
|
4147
|
+
}),
|
|
3837
4148
|
actions: actions,
|
|
3838
4149
|
}));
|
|
3839
4150
|
})(view.entries[i]);
|
|
@@ -3857,19 +4168,38 @@
|
|
|
3857
4168
|
var missing = entry.missing === true;
|
|
3858
4169
|
archivedRows.push(entryCard({
|
|
3859
4170
|
key: entry.sessionId,
|
|
3860
|
-
badge: missing ? t("archive.badgeMissing") : t("archive.badge"),
|
|
3861
|
-
badgeClass: missing ? "wsr-card-badge-warning" : "wsr-card-badge-muted",
|
|
3862
4171
|
titleClass: hasTitle ? "wsr-card-title" : "wsr-card-title wsr-card-title-id",
|
|
3863
4172
|
title: hasTitle ? entry.title : entry.sessionId,
|
|
3864
4173
|
titleAttr: entry.sessionId,
|
|
3865
4174
|
chips: chips,
|
|
3866
4175
|
path: typeof entry.workspacePath === "string" && entry.workspacePath !== "" ? entry.workspacePath : entry.cwd,
|
|
4176
|
+
/* The destructive action stays alone on the title line; the safe
|
|
4177
|
+
ones sit in the corner with the rest of the card actions. */
|
|
4178
|
+
danger: missing
|
|
4179
|
+
? null
|
|
4180
|
+
: iconButton({
|
|
4181
|
+
icon: "IconCloseOutlineRegular",
|
|
4182
|
+
label: t("archive.forget"),
|
|
4183
|
+
danger: true,
|
|
4184
|
+
onClick: function () { actArchived(entry, "forget"); },
|
|
4185
|
+
}),
|
|
3867
4186
|
actions: missing
|
|
3868
|
-
? [
|
|
4187
|
+
? [iconButton({
|
|
4188
|
+
icon: "IconArchiveOffOutlineRegular",
|
|
4189
|
+
label: t("archive.detach"),
|
|
4190
|
+
onClick: function () { actArchived(entry, "detach"); },
|
|
4191
|
+
})]
|
|
3869
4192
|
: [
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
4193
|
+
iconButton({
|
|
4194
|
+
icon: "IconRefreshOutlineRegular",
|
|
4195
|
+
label: t("archive.unarchive"),
|
|
4196
|
+
onClick: function () { actArchived(entry, "unarchive"); },
|
|
4197
|
+
}),
|
|
4198
|
+
iconButton({
|
|
4199
|
+
icon: "IconTrashOutlineRegular",
|
|
4200
|
+
label: t("archive.delete"),
|
|
4201
|
+
onClick: function () { actArchived(entry, "delete"); },
|
|
4202
|
+
}),
|
|
3873
4203
|
],
|
|
3874
4204
|
}));
|
|
3875
4205
|
})(archivedList[j]);
|
|
@@ -3882,7 +4212,7 @@
|
|
|
3882
4212
|
),
|
|
3883
4213
|
archivedList.length === 0
|
|
3884
4214
|
? h("div", { className: "wsr-page-note", key: "archive-empty" }, t("archive.empty"))
|
|
3885
|
-
: h("div", { className: "wsr-
|
|
4215
|
+
: h("div", { className: "wsr-card-grid", key: "archive-list" }, archivedRows),
|
|
3886
4216
|
h("div", { className: "wsr-page-note", key: "archive-note" }, t("archive.description")),
|
|
3887
4217
|
];
|
|
3888
4218
|
|
|
@@ -3910,7 +4240,7 @@
|
|
|
3910
4240
|
),
|
|
3911
4241
|
view.entries.length === 0
|
|
3912
4242
|
? h("div", { className: "wsr-page-note", key: "trash-empty" }, t("trash.empty"))
|
|
3913
|
-
: h("div", { className: "wsr-
|
|
4243
|
+
: h("div", { className: "wsr-card-grid", key: "trash-list" }, rows),
|
|
3914
4244
|
h("div", { className: "wsr-page-note", key: "trash-note" }, t("trash.note")),
|
|
3915
4245
|
archiveSection,
|
|
3916
4246
|
],
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import { dirname, join } from "node:path";
|
|
|
32
32
|
export const name = "ws-recency";
|
|
33
33
|
|
|
34
34
|
/** Version marker reported by the health route. */
|
|
35
|
-
export const HOST_VERSION = "0.
|
|
35
|
+
export const HOST_VERSION = "0.30.0";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Exact routes the client half calls. Registered on the bare web server, so they
|
|
@@ -394,7 +394,11 @@ export function aggregateSession(events) {
|
|
|
394
394
|
for (const event of events) {
|
|
395
395
|
if (event === null || typeof event !== "object") continue;
|
|
396
396
|
const data = event.data ?? {};
|
|
397
|
-
|
|
397
|
+
const eventType = typeof event.type === "string" ? event.type.toLowerCase() : "";
|
|
398
|
+
/* Only a finished compaction rewrites the window. The same family also emits
|
|
399
|
+
start/summary/prune events, and a prune does not reset the context, so
|
|
400
|
+
counting every "compaction*" type would cut the curve at the wrong places. */
|
|
401
|
+
if (eventType === "compaction/end") {
|
|
398
402
|
compactions.push(steps.length);
|
|
399
403
|
}
|
|
400
404
|
if (typeof event.time === "number") {
|
|
@@ -583,6 +587,9 @@ export function aggregateSession(events) {
|
|
|
583
587
|
share: bill > 0 ? attributed / bill : 0,
|
|
584
588
|
steps: totalSteps,
|
|
585
589
|
series,
|
|
590
|
+
/* Steps after which the window was rewritten. The curve restarts there, so the
|
|
591
|
+
client reads each segment on its own instead of comparing across a rewrite. */
|
|
592
|
+
compactions: [...compactions],
|
|
586
593
|
blocks: ranked,
|
|
587
594
|
byKind: [...byKind.values()]
|
|
588
595
|
.map((entry) => ({ ...entry, share: bill > 0 ? entry.amplified / bill : 0 }))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ws-recency",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "Sidebar session management for DeepSeek Harness: workspace groups sorted by latest activity, stale history folded, a global pinned section, follow-up marks, session delete into a recoverable trash, archived sessions managed from that same trash panel, per-session token statistics with an argument/result split and an option to count tool arguments as the agent's writing, moving a session to another workspace, and a literal content search that jumps to the turn a word was said in.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chyxhtc",
|