dsh-ws-recency 0.29.1 → 0.30.1
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 +16 -9
- package/client.js +354 -85
- package/index.js +31 -3
- 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
|
|
|
@@ -101,8 +102,14 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
101
102
|
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58%;
|
|
102
103
|
- **调用次数**:每条横条右侧带「N 次」;图表有一行列头(token / 占比 / 调用)对齐五列;
|
|
103
104
|
- **摘要卡片**:合计(高亮)+ 步数 + 输入(未缓存)+ 缓存命中 + 输出,合计排第一;
|
|
104
|
-
-
|
|
105
|
-
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3%
|
|
105
|
+
- **三个 tab(0.30.1)**:摘要卡片常驻顶部,下面按「分布统计 / 放大归因 / 放大排行」分页,打开时记住上次停留的 tab:分布统计看「钱花在哪些来源」,放大归因看「上下文什么时候涨起来」,放大排行看「是谁把它撑大的」;
|
|
106
|
+
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3% 账单),这样小数字才能读出结论。压缩之后旧内容不再重读,放大窗口会从压缩点截断。
|
|
107
|
+
- **上下文拐点(0.30.0)**:曲线上的圆点标出上下文涨得最陡的步,颜色表示段内排名(第 1 红、第 2 黄、第 3 蓝),悬停圆点或下方的数字,两边一起高亮。**按压缩分段**:压缩会重置上下文,跨压缩点比较涨幅没有意义,所以每段各自取涨幅最大的三步;压缩点用一条淡竖线标在曲线上。下面每行一个拐点,四列对齐(段 / 步号 / 涨幅 / 谁进来的),段号只在每组第一行出现。
|
|
108
|
+
|
|
109
|
+
- **一步 = 一次模型调用(0.30.1)**:所以「第 58 步」指这场会话第 58 次调用模型,不是第 58 行对话;
|
|
110
|
+
- **谁进来的(0.30.1)**:每根柱覆盖十几步,靠「进入步正好等于涨幅步」几乎永远对不上,所以由宿主算好——每根柱标出这一桶步数里**第一个出现、token 最多**的内容块(工具名 + 文件名),完整路径在悬停里;
|
|
111
|
+
- **放大排行(0.30.1)**:账单构成和按内容块排序的清单单独一个 tab。开头写明「内容大小 × 之后重读次数」这个乘法:分布统计的数字只算内容本身多大,两个 tab 的数不能直接比,能横向比的是占比。每行的说明也改成乘法在前(`8.9K token × 1019 次重读 · 第 3 步进入`);
|
|
112
|
+
- **精确值(0.30.1)**:所有金额(卡片、横条、排行)悬停显示完整 token 数,不用自己换算 K/M。
|
|
106
113
|
|
|
107
114
|
面板底部只有一条口径说明(原来两个 tab 各有一条相同的话)。
|
|
108
115
|
|
|
@@ -203,7 +210,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
203
210
|
或固定版本的预构建包:
|
|
204
211
|
|
|
205
212
|
```powershell
|
|
206
|
-
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.
|
|
213
|
+
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.30.1/dsh-ws-recency-0.30.1.tgz
|
|
207
214
|
```
|
|
208
215
|
|
|
209
216
|
装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
|
package/client.js
CHANGED
|
@@ -193,6 +193,33 @@
|
|
|
193
193
|
".wsr-page-head{display:flex;align-items:center;gap:8px}",
|
|
194
194
|
".wsr-page-heading{flex:1;font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary)}",
|
|
195
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}",
|
|
196
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))}",
|
|
197
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))}",
|
|
198
225
|
".wsr-card-head{display:flex;align-items:center;gap:10px;min-width:0}",
|
|
@@ -279,12 +306,29 @@
|
|
|
279
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))}",
|
|
280
307
|
".wsr-context-caption{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
281
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)}",
|
|
282
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}",
|
|
283
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}",
|
|
284
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)}",
|
|
285
318
|
".wsr-context-jump:hover .wsr-context-bar-inner{filter:brightness(1.15)}",
|
|
286
|
-
".wsr-context-jumps{display:flex;flex-direction:column;gap:2px}",
|
|
287
|
-
".wsr-context-jump-
|
|
319
|
+
".wsr-context-jumps{display:flex;flex-direction:column;gap:2px;margin-top:2px}",
|
|
320
|
+
".wsr-context-jump-group{display:flex;flex-direction:column;gap:2px}",
|
|
321
|
+
/* Fixed columns on every row is what aligns them: each row is its own
|
|
322
|
+
grid, so `auto` widths would drift with the numbers they hold. */
|
|
323
|
+
".wsr-context-jump-row{display:grid;grid-template-columns:40px 84px 62px minmax(0,1fr);align-items:center;gap:10px;font-size:11px;color:var(--dsw-alias-label-secondary);padding:1px 5px;border-radius:4px;transition:background .12s,color .12s}",
|
|
324
|
+
".wsr-context-jump-segment{color:var(--dsw-alias-label-tertiary);white-space:nowrap}",
|
|
325
|
+
".wsr-context-jump-rank-dot{flex:none;width:6px;height:6px;border-radius:50%;background:#d99a2b}",
|
|
326
|
+
".wsr-context-jump-row[data-wsr-rank=\"1\"] .wsr-context-jump-rank-dot{background:#f0553d}",
|
|
327
|
+
".wsr-context-jump-row[data-wsr-rank=\"2\"] .wsr-context-jump-rank-dot{background:#f5c542}",
|
|
328
|
+
".wsr-context-jump-row[data-wsr-rank=\"3\"] .wsr-context-jump-rank-dot{background:#4f9df7}",
|
|
329
|
+
".wsr-context-jump-step{display:flex;align-items:center;gap:6px;white-space:nowrap}",
|
|
330
|
+
".wsr-context-jump-rise{text-align:right;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary)}",
|
|
331
|
+
".wsr-context-jump-what{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary)}",
|
|
288
332
|
".wsr-context-jump-row-hot{background:rgba(217,154,43,.16);color:var(--dsw-alias-label-primary)}",
|
|
289
333
|
".wsr-kind-legend{display:flex;flex-wrap:wrap;gap:10px}",
|
|
290
334
|
".wsr-kind{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
@@ -298,6 +342,8 @@
|
|
|
298
342
|
".wsr-amplified-value{text-align:right;font-weight:600;font-variant-numeric:tabular-nums;font-size:12px}",
|
|
299
343
|
".wsr-amplified-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:11px;font-variant-numeric:tabular-nums}",
|
|
300
344
|
".wsr-amplified-empty{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
345
|
+
".wsr-amplified-subtitle{font-size:11px;font-weight:600;color:var(--dsw-alias-label-secondary);margin-top:4px}",
|
|
346
|
+
".wsr-amplified-lead{font-size:11px;line-height:1.6;color:var(--dsw-alias-label-tertiary)}",
|
|
301
347
|
".wsr-stats-footnote{padding-top:6px;border-top:.5px solid rgba(255,255,255,.06)}",
|
|
302
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}",
|
|
303
349
|
".wsr-toggle:hover{color:var(--dsw-alias-label-secondary)}",
|
|
@@ -368,7 +414,7 @@
|
|
|
368
414
|
"stats.col.source": "\u6765\u6e90",
|
|
369
415
|
"stats.col.calls": "\u8c03\u7528",
|
|
370
416
|
"stats.callsShort": "{n} 次",
|
|
371
|
-
"stats.col.tokensShort": "
|
|
417
|
+
"stats.col.tokensShort": "内容估算",
|
|
372
418
|
"stats.col.shareShort": "占比",
|
|
373
419
|
"stats.col.args": "\u53c2\u6570",
|
|
374
420
|
"stats.col.results": "\u7ed3\u679c",
|
|
@@ -489,12 +535,16 @@
|
|
|
489
535
|
"stats.barTooltip": "{name} 共 {total}:参数 {args}({argsShare}),结果 {results}({resultsShare})",
|
|
490
536
|
"stats.argModeNote": "当前把工具参数计入主 agent:每个工具只算返回结果,表格里「参数」列显示为淡色(那些 token 记在主 agent 那一行)。",
|
|
491
537
|
"stats.amplified.title": "放大成本(账单归因)",
|
|
538
|
+
"stats.amplified.kindTitle": "账单构成",
|
|
539
|
+
"stats.amplified.lead": "按「内容大小 × 之后重读次数」排序:一块内容读进来一次,之后每一步都会再发一遍,乘上重读次数才是它真正的开销。上面的分布统计只算内容本身多大,两个数不能直接比。",
|
|
492
540
|
"stats.amplified.summary": "账单 {bill} token;可归因内容经重读放大后占 {share}({attributed})",
|
|
493
|
-
"stats.amplified.contextCaption": "
|
|
541
|
+
"stats.amplified.contextCaption": "每步上下文(面积≈账单):一步=一次模型调用,越早进入的内容被重读越多",
|
|
494
542
|
"stats.amplified.point": "第 {step} 步 · {context}",
|
|
495
543
|
"stats.amplified.jump": "第 {step} 步上下文涨了 {rise}",
|
|
544
|
+
"stats.amplified.jumpStep": "第 {step} 步",
|
|
545
|
+
"stats.amplified.segment": "第 {segment} 段",
|
|
496
546
|
"stats.amplified.jumpFrom": "({name} 进来 {tokens})",
|
|
497
|
-
"stats.amplified.meta": "
|
|
547
|
+
"stats.amplified.meta": "{tokens} token × {remaining} 次重读 · 第 {entry} 步进入",
|
|
498
548
|
"stats.amplified.whatIf": "若压到 20%,可省 {save}({share})",
|
|
499
549
|
"stats.amplified.empty": "没有可归因的放大内容(压缩后或旧日志可能缺失)",
|
|
500
550
|
"stats.amplified.note": "放大成本按内容长度估算;账单总量来自真实 usage。思维链通常不回传,故未计入。",
|
|
@@ -505,6 +555,7 @@
|
|
|
505
555
|
"stats.amplified.system": "系统消息",
|
|
506
556
|
"stats.tab.distribution": "分布统计",
|
|
507
557
|
"stats.tab.amplified": "放大归因",
|
|
558
|
+
"stats.tab.ranking": "放大排行",
|
|
508
559
|
"stats.tab.details": "明细",
|
|
509
560
|
"trash.confirm": "\u5220\u9664\u8fd9\u4e2a\u4f1a\u8bdd\uff1f\n\n\u4f1a\u5148\u505c\u6b62\u5b83\u6b63\u5728\u8fdb\u884c\u7684\u5de5\u4f5c\uff0c\u518d\u628a\u65e5\u5fd7\u76ee\u5f55\u79fb\u5165\u56de\u6536\u7ad9\uff08\u4e0d\u662f\u7269\u7406\u5220\u9664\uff0c\u53ef\u4ee5\u624b\u52a8\u6062\u590d\uff09\u3002",
|
|
510
561
|
"trash.failed": "\u5220\u9664\u5931\u8d25\uff1a",
|
|
@@ -548,7 +599,7 @@
|
|
|
548
599
|
"stats.col.source": "source",
|
|
549
600
|
"stats.col.calls": "calls",
|
|
550
601
|
"stats.callsShort": "{n}x",
|
|
551
|
-
"stats.col.tokensShort": "
|
|
602
|
+
"stats.col.tokensShort": "content est.",
|
|
552
603
|
"stats.col.shareShort": "share",
|
|
553
604
|
"stats.col.args": "args",
|
|
554
605
|
"stats.col.results": "results",
|
|
@@ -668,12 +719,16 @@
|
|
|
668
719
|
"stats.barTooltip": "{name}: {total} total - arguments {args} ({argsShare}), results {results} ({resultsShare})",
|
|
669
720
|
"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.",
|
|
670
721
|
"stats.amplified.title": "Amplified cost (what the bill pays for)",
|
|
722
|
+
"stats.amplified.kindTitle": "What the bill is made of",
|
|
723
|
+
"stats.amplified.lead": "Ranked by content size × the later steps that re-read it: content is re-sent on every step after it enters, so the multiplier is what the bill actually pays. The distribution tab measures only the content itself, so the two numbers do not compare directly.",
|
|
671
724
|
"stats.amplified.summary": "Bill {bill} tokens; attributable content amplifies to {share} ({attributed})",
|
|
672
|
-
"stats.amplified.contextCaption": "Context per step (area ≈ bill): earlier content is re-read more",
|
|
725
|
+
"stats.amplified.contextCaption": "Context per step (area ≈ bill): one step is one model call; earlier content is re-read more",
|
|
673
726
|
"stats.amplified.point": "step {step} · {context}",
|
|
674
727
|
"stats.amplified.jump": "step {step} grew by {rise}",
|
|
728
|
+
"stats.amplified.jumpStep": "step {step}",
|
|
729
|
+
"stats.amplified.segment": "seg {segment}",
|
|
675
730
|
"stats.amplified.jumpFrom": "({name} brought {tokens})",
|
|
676
|
-
"stats.amplified.meta": "
|
|
731
|
+
"stats.amplified.meta": "{tokens} tokens × {remaining} re-reads · entered at step {entry}",
|
|
677
732
|
"stats.amplified.whatIf": "at 20%, saves {save} ({share})",
|
|
678
733
|
"stats.amplified.empty": "No amplifiable content (compacted or older logs may lack it)",
|
|
679
734
|
"stats.amplified.note": "Amplified cost is estimated from content length; the bill total comes from real usage. Reasoning is usually not resent, so it is excluded.",
|
|
@@ -684,6 +739,7 @@
|
|
|
684
739
|
"stats.amplified.system": "system messages",
|
|
685
740
|
"stats.tab.distribution": "Distribution",
|
|
686
741
|
"stats.tab.amplified": "Amplified",
|
|
742
|
+
"stats.tab.ranking": "Ranking",
|
|
687
743
|
"stats.tab.details": "Details",
|
|
688
744
|
"trash.confirm": "Delete this session?\n\nIt stops whatever the session is running, then moves the log directory into the trash folder (a move, not an erase: you can restore it by hand).",
|
|
689
745
|
"trash.failed": "Delete failed: ",
|
|
@@ -2021,9 +2077,10 @@
|
|
|
2021
2077
|
}
|
|
2022
2078
|
track.appendChild(group);
|
|
2023
2079
|
line.appendChild(track);
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2080
|
+
var valueCell = statsDiv("wsr-chart-value", formatTokens(entry.value));
|
|
2081
|
+
valueCell.setAttribute("title", String(Math.round(entry.value)) + " tokens");
|
|
2082
|
+
line.appendChild(valueCell);
|
|
2083
|
+
line.appendChild(statsDiv("wsr-chart-share", formatShare(entry.share))); /* The count the chart cannot draw: a bar says how heavy a source is,
|
|
2027
2084
|
the call count says how often it got there. The details table used to
|
|
2028
2085
|
be the only place for it. It always renders (empty for rows without
|
|
2029
2086
|
a count) so the five-column grid stays aligned. */
|
|
@@ -2152,45 +2209,131 @@
|
|
|
2152
2209
|
}
|
|
2153
2210
|
}
|
|
2154
2211
|
|
|
2155
|
-
/**
|
|
2212
|
+
/**
|
|
2213
|
+
* A short "what entered" label for a jump row.
|
|
2214
|
+
*
|
|
2215
|
+
* The detail is often a full path or a whole command; the row has one
|
|
2216
|
+
* narrow cell. Keep the tool name and the last path segment, and let the
|
|
2217
|
+
* tooltip carry the rest.
|
|
2218
|
+
*/
|
|
2219
|
+
function jumpWhatOf(name, detail) {
|
|
2220
|
+
if (typeof name !== "string" || name === "") return "";
|
|
2221
|
+
if (typeof detail !== "string" || detail === "") return name;
|
|
2222
|
+
var text = detail.trim();
|
|
2223
|
+
var cut = Math.max(text.lastIndexOf("/"), text.lastIndexOf("\\"));
|
|
2224
|
+
if (cut !== -1 && cut < text.length - 1) text = text.slice(cut + 1);
|
|
2225
|
+
if (text.length > 22) text = text.slice(0, 21) + "…";
|
|
2226
|
+
return name + " " + text;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
/**
|
|
2230
|
+
* The steepest rise in each compaction segment.
|
|
2231
|
+
*
|
|
2232
|
+
* A compaction rewrites the window, so a rise measured across that boundary
|
|
2233
|
+
* compares two different conversations: each segment has to be ranked on its
|
|
2234
|
+
* own. One marker per segment answers "where did this segment start growing",
|
|
2235
|
+
* and it keeps the chart readable when a session compacted several times.
|
|
2236
|
+
*/
|
|
2156
2237
|
function contextJumps(amplified) {
|
|
2157
2238
|
var series = Array.isArray(amplified.series) ? amplified.series : [];
|
|
2158
2239
|
var blocks = Array.isArray(amplified.blocks) ? amplified.blocks : [];
|
|
2159
|
-
var
|
|
2240
|
+
var compactions = Array.isArray(amplified.compactions)
|
|
2241
|
+
? amplified.compactions.map(Number).sort(function (a, b) { return a - b; })
|
|
2242
|
+
: [];
|
|
2243
|
+
var segmentOf = function (step) {
|
|
2244
|
+
var segment = 1;
|
|
2245
|
+
for (var c = 0; c < compactions.length; c += 1) if (step > compactions[c]) segment += 1;
|
|
2246
|
+
return segment;
|
|
2247
|
+
};
|
|
2248
|
+
/* Rises grouped per segment; the step that starts a new segment has no
|
|
2249
|
+
rise to compare against the step before the rewrite. */
|
|
2250
|
+
var bySegment = {};
|
|
2160
2251
|
for (var i = 1; i < series.length; i += 1) {
|
|
2252
|
+
var from = Number(series[i - 1].step);
|
|
2253
|
+
var to = Number(series[i].step);
|
|
2254
|
+
if (segmentOf(from) !== segmentOf(to)) continue;
|
|
2161
2255
|
var rise = Number(series[i].context) - Number(series[i - 1].context);
|
|
2162
|
-
if (rise
|
|
2256
|
+
if (rise <= 0) continue;
|
|
2257
|
+
var segment = segmentOf(to);
|
|
2258
|
+
if (bySegment[segment] === undefined) bySegment[segment] = [];
|
|
2259
|
+
/* `from` is the previous bar's step: on a downsampled curve one bar
|
|
2260
|
+
stands for several steps, and the content that entered during that
|
|
2261
|
+
span is what made it rise. The host labels each point with it. */
|
|
2262
|
+
bySegment[segment].push({ step: to, from: from, rise: rise, entered: series[i].entered || null });
|
|
2163
2263
|
}
|
|
2164
|
-
|
|
2264
|
+
var total = compactions.length + 1;
|
|
2165
2265
|
var picked = [];
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
var
|
|
2180
|
-
|
|
2181
|
-
|
|
2266
|
+
/* Three markers per segment, not three for the whole session: after a
|
|
2267
|
+
rewrite the earlier segment cannot crowd out the later ones. The
|
|
2268
|
+
spacing only matters when many steps share one bar; on a short curve
|
|
2269
|
+
each bar is wide enough for neighbouring marks. */
|
|
2270
|
+
var spacing = Math.max(1, Math.round(series.length / 10));
|
|
2271
|
+
for (var s = 1; s <= total; s += 1) {
|
|
2272
|
+
var rises = bySegment[s];
|
|
2273
|
+
if (rises === undefined || rises.length === 0) continue;
|
|
2274
|
+
rises.sort(function (a, b) { return b.rise - a.rise; });
|
|
2275
|
+
var chosen = [];
|
|
2276
|
+
for (var r = 0; r < rises.length && chosen.length < 3; r += 1) {
|
|
2277
|
+
/* Two markers side by side read as one wide jump. */
|
|
2278
|
+
var close = false;
|
|
2279
|
+
for (var p = 0; p < chosen.length; p += 1) {
|
|
2280
|
+
if (Math.abs(chosen[p].step - rises[r].step) < spacing) close = true;
|
|
2281
|
+
}
|
|
2282
|
+
if (close) continue;
|
|
2283
|
+
chosen.push(rises[r]);
|
|
2182
2284
|
}
|
|
2183
|
-
var
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2285
|
+
for (var k = 0; k < chosen.length; k += 1) {
|
|
2286
|
+
var best = chosen[k];
|
|
2287
|
+
/* The host labels each curve point with the biggest content block
|
|
2288
|
+
that first appeared inside it. That is the honest attribution: a
|
|
2289
|
+
bar spans several steps, so `entry === step` almost never holds,
|
|
2290
|
+
and guessing "the most recent entrant" pointed at the system
|
|
2291
|
+
prompt instead of the file that actually landed. */
|
|
2292
|
+
var block = null;
|
|
2293
|
+
var blockName = "";
|
|
2294
|
+
var blockDetail = "";
|
|
2295
|
+
var blockTokens = 0;
|
|
2296
|
+
if (best.entered !== null && best.entered !== undefined) {
|
|
2297
|
+
blockName = best.entered.kind === "tool" ? String(best.entered.name) : t("stats.agent");
|
|
2298
|
+
blockDetail = typeof best.entered.detail === "string" ? best.entered.detail : "";
|
|
2299
|
+
blockTokens = Number(best.entered.tokens) || 0;
|
|
2300
|
+
} else {
|
|
2301
|
+
/* An older host half sends no labels: fall back to the block that
|
|
2302
|
+
entered inside this span, and never to an unrelated older one. */
|
|
2303
|
+
for (var b = 0; b < blocks.length; b += 1) {
|
|
2304
|
+
var candidate = blocks[b];
|
|
2305
|
+
var entry = Number(candidate.entry);
|
|
2306
|
+
if (entry > best.step || entry <= best.from) continue;
|
|
2307
|
+
if (block === null || Number(candidate.tokens) > Number(block.tokens)) block = candidate;
|
|
2308
|
+
}
|
|
2309
|
+
if (block !== null) {
|
|
2310
|
+
blockName = block.kind === "tool" ? String(block.name) : t("stats.agent");
|
|
2311
|
+
if (typeof block.detail === "string" && block.detail !== "") blockDetail = block.detail;
|
|
2312
|
+
blockTokens = Number(block.tokens) || 0;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
var label = t("stats.amplified.jump", {
|
|
2316
|
+
step: String(best.step),
|
|
2317
|
+
rise: formatTokens(best.rise),
|
|
2318
|
+
});
|
|
2319
|
+
if (blockName !== "") {
|
|
2320
|
+
label += " " + t("stats.amplified.jumpFrom", {
|
|
2321
|
+
name: blockDetail === "" ? blockName : blockName + " " + blockDetail,
|
|
2322
|
+
tokens: formatTokens(blockTokens),
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
2325
|
+
picked.push({
|
|
2326
|
+
step: best.step,
|
|
2327
|
+
rise: best.rise,
|
|
2328
|
+
segment: s,
|
|
2329
|
+
/* Rank is within the segment; the row's segment number keeps two
|
|
2330
|
+
"first" markers apart when a session compacted more than once. */
|
|
2331
|
+
rank: k + 1,
|
|
2332
|
+
blockName: blockName,
|
|
2333
|
+
blockDetail: blockDetail,
|
|
2334
|
+
label: label,
|
|
2191
2335
|
});
|
|
2192
2336
|
}
|
|
2193
|
-
picked.push({ step: rise2.step, rise: rise2.rise, label: label });
|
|
2194
2337
|
}
|
|
2195
2338
|
return picked;
|
|
2196
2339
|
}
|
|
@@ -2216,19 +2359,35 @@
|
|
|
2216
2359
|
if (Number(series[i].context) > largest) largest = Number(series[i].context);
|
|
2217
2360
|
}
|
|
2218
2361
|
var chart = statsDiv("wsr-context-chart");
|
|
2219
|
-
/* Mark the
|
|
2220
|
-
large file shows up
|
|
2221
|
-
|
|
2222
|
-
instead of leaving the reader to compare 96 bars by eye. */
|
|
2362
|
+
/* Mark the steepest step of every compaction segment: a single read of a
|
|
2363
|
+
large file shows up as one tall rise, and after a rewrite the window
|
|
2364
|
+
starts over, so each segment is read on its own. */
|
|
2223
2365
|
var jumps = contextJumps(amplified);
|
|
2224
2366
|
var jumpByStep = {};
|
|
2225
2367
|
for (var jj = 0; jj < jumps.length; jj += 1) jumpByStep[jumps[jj].step] = jumps[jj];
|
|
2368
|
+
/* Where the window was rewritten: a faint divider makes the drop on the
|
|
2369
|
+
curve legible instead of looking like a glitch. */
|
|
2370
|
+
var breaks = {};
|
|
2371
|
+
var compactionAt = Array.isArray(amplified.compactions) ? amplified.compactions.map(Number) : [];
|
|
2372
|
+
for (var cb = 0; cb < compactionAt.length; cb += 1) breaks[compactionAt[cb]] = true;
|
|
2373
|
+
var openBreak = false;
|
|
2226
2374
|
for (var j = 0; j < series.length; j += 1) {
|
|
2227
2375
|
var bar = statsDiv("wsr-context-bar");
|
|
2228
2376
|
bar.style.height = Math.max(2, Math.round((Number(series[j].context) / largest) * 100)) + "%";
|
|
2229
|
-
|
|
2377
|
+
/* A compaction recorded at step N ends the segment at N: the first bar
|
|
2378
|
+
whose step is past it opens the next one. */
|
|
2379
|
+
var step = Number(series[j].step);
|
|
2380
|
+
var startsSegment = false;
|
|
2381
|
+
for (var cb2 = 0; cb2 < compactionAt.length; cb2 += 1) {
|
|
2382
|
+
if (step > compactionAt[cb2] && !openBreak) startsSegment = true;
|
|
2383
|
+
}
|
|
2384
|
+
if (startsSegment) {
|
|
2385
|
+
bar.className = "wsr-context-bar wsr-context-break";
|
|
2386
|
+
openBreak = true;
|
|
2387
|
+
}
|
|
2388
|
+
var jump = jumpByStep[step];
|
|
2230
2389
|
if (jump !== undefined) {
|
|
2231
|
-
bar.className = "wsr-context-bar wsr-context-jump";
|
|
2390
|
+
bar.className = "wsr-context-bar wsr-context-jump" + (startsSegment ? " wsr-context-break" : "");
|
|
2232
2391
|
bar.setAttribute("data-wsr-jump", String(jump.step));
|
|
2233
2392
|
bar.setAttribute("title", jump.label);
|
|
2234
2393
|
/* A hover target that is big enough to hit: a 5px dot on a 3px bar
|
|
@@ -2236,23 +2395,56 @@
|
|
|
2236
2395
|
below, so hovering the bar also lifts that row. */
|
|
2237
2396
|
var hit = statsDiv("wsr-context-jump-hit");
|
|
2238
2397
|
hit.setAttribute("data-wsr-jump-hit", String(jump.step));
|
|
2398
|
+
hit.setAttribute("data-wsr-rank", String(jump.rank));
|
|
2239
2399
|
hit.appendChild(statsDiv("wsr-context-jump-dot"));
|
|
2240
2400
|
hit.addEventListener("mouseenter", highlightJumpRow);
|
|
2241
2401
|
hit.addEventListener("mouseleave", clearJumpHighlight);
|
|
2242
2402
|
bar.appendChild(hit);
|
|
2243
2403
|
} else {
|
|
2244
|
-
bar.setAttribute("title", t("stats.amplified.point", { step: String(
|
|
2404
|
+
bar.setAttribute("title", t("stats.amplified.point", { step: String(step), context: formatTokens(series[j].context) }));
|
|
2245
2405
|
}
|
|
2246
2406
|
chart.appendChild(bar);
|
|
2247
2407
|
}
|
|
2248
2408
|
section.appendChild(chart);
|
|
2249
2409
|
section.appendChild(statsDiv("wsr-context-caption", t("stats.amplified.contextCaption")));
|
|
2250
2410
|
if (jumps.length > 0) {
|
|
2411
|
+
/* One row per rise, in fixed columns (segment / step / rise / what).
|
|
2412
|
+
Packing three rises onto one line truncated every label, and a row
|
|
2413
|
+
per rise with prose labels was too tall; four fixed columns give
|
|
2414
|
+
both: aligned numbers and room for the file name. */
|
|
2415
|
+
var segments = [];
|
|
2416
|
+
for (var js = 0; js < jumps.length; js += 1) {
|
|
2417
|
+
if (segments.indexOf(jumps[js].segment) === -1) segments.push(jumps[js].segment);
|
|
2418
|
+
}
|
|
2419
|
+
var multiSegment = segments.length > 1;
|
|
2251
2420
|
var jumpList = statsDiv("wsr-context-jumps");
|
|
2252
|
-
for (var
|
|
2253
|
-
var
|
|
2254
|
-
|
|
2255
|
-
|
|
2421
|
+
for (var sg = 0; sg < segments.length; sg += 1) {
|
|
2422
|
+
var group = statsDiv("wsr-context-jump-group");
|
|
2423
|
+
var firstOfSegment = true;
|
|
2424
|
+
for (var jl = 0; jl < jumps.length; jl += 1) {
|
|
2425
|
+
if (jumps[jl].segment !== segments[sg]) continue;
|
|
2426
|
+
var jumpRow = statsDiv("wsr-context-jump-row");
|
|
2427
|
+
jumpRow.setAttribute("data-wsr-jump-row", String(jumps[jl].step));
|
|
2428
|
+
jumpRow.setAttribute("data-wsr-rank", String(jumps[jl].rank));
|
|
2429
|
+
jumpRow.setAttribute("title", jumps[jl].label);
|
|
2430
|
+
/* The segment is named once per group, not on every row. */
|
|
2431
|
+
jumpRow.appendChild(statsDiv(
|
|
2432
|
+
"wsr-context-jump-segment",
|
|
2433
|
+
multiSegment && firstOfSegment ? t("stats.amplified.segment", { segment: String(segments[sg]) }) : "",
|
|
2434
|
+
));
|
|
2435
|
+
firstOfSegment = false;
|
|
2436
|
+
var stepCell = statsDiv("wsr-context-jump-step");
|
|
2437
|
+
stepCell.appendChild(statsDiv("wsr-context-jump-rank-dot"));
|
|
2438
|
+
stepCell.appendChild(statsDiv("wsr-context-jump-step-text", t("stats.amplified.jumpStep", { step: String(jumps[jl].step) })));
|
|
2439
|
+
jumpRow.appendChild(stepCell);
|
|
2440
|
+
jumpRow.appendChild(statsDiv("wsr-context-jump-rise", "+" + formatTokens(jumps[jl].rise)));
|
|
2441
|
+
/* What entered: the tool and a short form of what it touched, so
|
|
2442
|
+
the row answers "which file" instead of only "read". The full
|
|
2443
|
+
detail stays in the tooltip. */
|
|
2444
|
+
jumpRow.appendChild(statsDiv("wsr-context-jump-what", jumpWhatOf(jumps[jl].blockName, jumps[jl].blockDetail)));
|
|
2445
|
+
group.appendChild(jumpRow);
|
|
2446
|
+
}
|
|
2447
|
+
jumpList.appendChild(group);
|
|
2256
2448
|
}
|
|
2257
2449
|
section.appendChild(jumpList);
|
|
2258
2450
|
}
|
|
@@ -2260,8 +2452,13 @@
|
|
|
2260
2452
|
bar or its row lifts both, which is what "挪上去更明显" means here. */
|
|
2261
2453
|
jumpHoverHosts.push({ chart: chart, list: section });
|
|
2262
2454
|
|
|
2455
|
+
/* The ranking is a separate tab: the curve answers "when", the ranking
|
|
2456
|
+
answers "what", and stacking both in one scroll hid half of each. */
|
|
2457
|
+
var ranking = statsDiv("wsr-amplified wsr-amplified-ranking");
|
|
2458
|
+
ranking.appendChild(statsDiv("wsr-amplified-lead", t("stats.amplified.lead")));
|
|
2263
2459
|
var kinds = amplified.byKind || [];
|
|
2264
2460
|
if (kinds.length > 0) {
|
|
2461
|
+
ranking.appendChild(statsDiv("wsr-amplified-subtitle", t("stats.amplified.kindTitle")));
|
|
2265
2462
|
var legend = statsDiv("wsr-kind-legend");
|
|
2266
2463
|
for (var k = 0; k < kinds.length; k += 1) {
|
|
2267
2464
|
var kind = kinds[k];
|
|
@@ -2273,7 +2470,7 @@
|
|
|
2273
2470
|
item.appendChild(statsDiv("", t(known === undefined ? kind.kind : known[0]) + " " + formatShare(kind.share || 0)));
|
|
2274
2471
|
legend.appendChild(item);
|
|
2275
2472
|
}
|
|
2276
|
-
|
|
2473
|
+
ranking.appendChild(legend);
|
|
2277
2474
|
}
|
|
2278
2475
|
|
|
2279
2476
|
var list = statsDiv("wsr-amplified-list");
|
|
@@ -2292,12 +2489,16 @@
|
|
|
2292
2489
|
remaining: String(block.remaining),
|
|
2293
2490
|
})));
|
|
2294
2491
|
row.appendChild(main);
|
|
2295
|
-
|
|
2492
|
+
var valueCell = statsDiv("wsr-amplified-value", formatTokens(block.amplified));
|
|
2493
|
+
/* The exact count, so a number here can be matched against the same
|
|
2494
|
+
figure on the distribution tab without converting K/M by hand. */
|
|
2495
|
+
valueCell.setAttribute("title", String(Math.round(Number(block.amplified) || 0)) + " tokens");
|
|
2496
|
+
row.appendChild(valueCell);
|
|
2296
2497
|
row.appendChild(statsDiv("wsr-amplified-share", formatShare(block.share || 0)));
|
|
2297
2498
|
list.appendChild(row);
|
|
2298
2499
|
}
|
|
2299
|
-
|
|
2300
|
-
return section;
|
|
2500
|
+
ranking.appendChild(list);
|
|
2501
|
+
return { top: section, ranking: ranking };
|
|
2301
2502
|
}
|
|
2302
2503
|
|
|
2303
2504
|
function renderStats(body, stats) {
|
|
@@ -2314,15 +2515,19 @@
|
|
|
2314
2515
|
var grid = document.createElement("div");
|
|
2315
2516
|
grid.className = "wsr-stats-grid";
|
|
2316
2517
|
var cards = [
|
|
2317
|
-
[t("stats.total"), formatTokens(totals.totalTokens), true],
|
|
2318
|
-
[t("stats.steps"), formatTokens(stats.steps), false],
|
|
2319
|
-
[t("stats.input"), formatTokens(totals.inputTokens), false],
|
|
2320
|
-
[t("stats.cache"), formatTokens(totals.cacheReadTokens), false],
|
|
2321
|
-
[t("stats.output"), formatTokens(totals.outputTokens), false],
|
|
2518
|
+
[t("stats.total"), formatTokens(totals.totalTokens), true, Number(totals.totalTokens) || 0],
|
|
2519
|
+
[t("stats.steps"), formatTokens(stats.steps), false, Number(stats.steps) || 0],
|
|
2520
|
+
[t("stats.input"), formatTokens(totals.inputTokens), false, Number(totals.inputTokens) || 0],
|
|
2521
|
+
[t("stats.cache"), formatTokens(totals.cacheReadTokens), false, Number(totals.cacheReadTokens) || 0],
|
|
2522
|
+
[t("stats.output"), formatTokens(totals.outputTokens), false, Number(totals.outputTokens) || 0],
|
|
2322
2523
|
];
|
|
2323
2524
|
for (var i = 0; i < cards.length; i += 1) {
|
|
2324
2525
|
var card = statsDiv("wsr-stats-card" + (cards[i][2] === true ? " wsr-stats-card-primary" : ""));
|
|
2325
|
-
|
|
2526
|
+
var valueCell = statsDiv("wsr-stats-value", cards[i][1]);
|
|
2527
|
+
/* Numbers auto-scale to K/M/B; the exact count on hover is what makes
|
|
2528
|
+
two tabs comparable without converting units in your head. */
|
|
2529
|
+
valueCell.setAttribute("title", String(cards[i][3]));
|
|
2530
|
+
card.appendChild(valueCell);
|
|
2326
2531
|
card.appendChild(statsDiv("wsr-stats-label", cards[i][0]));
|
|
2327
2532
|
grid.appendChild(card);
|
|
2328
2533
|
}
|
|
@@ -2435,8 +2640,11 @@
|
|
|
2435
2640
|
var defs = [["distribution", "stats.tab.distribution", distributionPanel]];
|
|
2436
2641
|
if (amplifiedSection !== null) {
|
|
2437
2642
|
var amplifiedPanel = statsDiv("wsr-stats-panel");
|
|
2438
|
-
amplifiedPanel.appendChild(amplifiedSection);
|
|
2643
|
+
amplifiedPanel.appendChild(amplifiedSection.top);
|
|
2439
2644
|
defs.push(["amplified", "stats.tab.amplified", amplifiedPanel]);
|
|
2645
|
+
var rankingPanel = statsDiv("wsr-stats-panel");
|
|
2646
|
+
rankingPanel.appendChild(amplifiedSection.ranking);
|
|
2647
|
+
defs.push(["ranking", "stats.tab.ranking", rankingPanel]);
|
|
2440
2648
|
}
|
|
2441
2649
|
if (mode === "agent") defs[0][2].appendChild(statsDiv("wsr-stats-note", t("stats.argModeNote")));
|
|
2442
2650
|
var tabButtons = {};
|
|
@@ -3836,14 +4044,54 @@
|
|
|
3836
4044
|
* below. Both are "put away", so both are managed from here.
|
|
3837
4045
|
*/
|
|
3838
4046
|
/** One entry as a card: badge, title, the numbers that matter, and actions. */
|
|
4047
|
+
/**
|
|
4048
|
+
* An action as an icon button.
|
|
4049
|
+
*
|
|
4050
|
+
* Text buttons in the card header squeezed the title to an ellipsis; an
|
|
4051
|
+
* icon says the same thing in 24px, and the label moves into the title
|
|
4052
|
+
* attribute so it is still discoverable on hover.
|
|
4053
|
+
*/
|
|
4054
|
+
function iconButton(options) {
|
|
4055
|
+
var Icon = ui[options.icon];
|
|
4056
|
+
var label = options.label;
|
|
4057
|
+
var className = "wsr-icon-btn" + (options.danger === true ? " wsr-icon-btn-danger" : "");
|
|
4058
|
+
if (typeof Icon !== "function") {
|
|
4059
|
+
/* An older UI package without this glyph: keep the action usable. */
|
|
4060
|
+
return h("button", {
|
|
4061
|
+
type: "button",
|
|
4062
|
+
className: (options.danger === true ? "wsr-btn wsr-btn-danger" : "wsr-btn") + " wsr-icon-fallback",
|
|
4063
|
+
title: label,
|
|
4064
|
+
onClick: options.onClick,
|
|
4065
|
+
}, label);
|
|
4066
|
+
}
|
|
4067
|
+
/* One frame for every icon. The glyph artwork has its own intrinsic
|
|
4068
|
+
aspect (archive, trash and refresh outlines differ), so a raw `size`
|
|
4069
|
+
made neighbouring buttons look different sizes. */
|
|
4070
|
+
return h("button", {
|
|
4071
|
+
type: "button",
|
|
4072
|
+
className: className,
|
|
4073
|
+
title: label,
|
|
4074
|
+
"aria-label": label,
|
|
4075
|
+
onClick: options.onClick,
|
|
4076
|
+
}, h("span", { className: "wsr-icon-btn-glyph" }, h(Icon, { size: 14 })));
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4079
|
+
/**
|
|
4080
|
+
* One entry as a card.
|
|
4081
|
+
*
|
|
4082
|
+
* The section heading already says "deleted" or "archived", so no badge
|
|
4083
|
+
* repeats it. Every action lives in one row at the bottom of the card,
|
|
4084
|
+
* right-aligned: one row is one right edge, so nothing can drift, and the
|
|
4085
|
+
* title keeps the full width.
|
|
4086
|
+
*/
|
|
3839
4087
|
function entryCard(options) {
|
|
4088
|
+
var safeActions = options.actions === null || options.actions === undefined ? [] : options.actions;
|
|
4089
|
+
var actions = [];
|
|
4090
|
+
for (var i = 0; i < safeActions.length; i += 1) actions.push(safeActions[i]);
|
|
4091
|
+
if (options.danger !== null && options.danger !== undefined) actions.push(options.danger);
|
|
3840
4092
|
return h("div", { className: "wsr-card", key: options.key, title: options.titleAttr || "" },
|
|
3841
4093
|
h("div", { className: "wsr-card-head" },
|
|
3842
|
-
options.badge !== null && options.badge !== undefined
|
|
3843
|
-
? h("span", { className: "wsr-card-badge " + (options.badgeClass || "") }, options.badge)
|
|
3844
|
-
: null,
|
|
3845
4094
|
h("div", { className: options.titleClass || "wsr-card-title" }, options.title),
|
|
3846
|
-
h("div", { className: "wsr-card-actions" }, options.actions),
|
|
3847
4095
|
),
|
|
3848
4096
|
options.chips.length > 0
|
|
3849
4097
|
? h("div", { className: "wsr-chips" }, options.chips.map(function (text, index) {
|
|
@@ -3853,6 +4101,9 @@
|
|
|
3853
4101
|
typeof options.path === "string" && options.path !== ""
|
|
3854
4102
|
? h("div", { className: "wsr-card-path" }, options.path)
|
|
3855
4103
|
: null,
|
|
4104
|
+
actions.length > 0
|
|
4105
|
+
? h("div", { className: "wsr-card-actions wsr-card-actions-row" }, actions)
|
|
4106
|
+
: null,
|
|
3856
4107
|
);
|
|
3857
4108
|
}
|
|
3858
4109
|
|
|
@@ -3945,27 +4196,26 @@
|
|
|
3945
4196
|
if (when !== "") chips.push(when);
|
|
3946
4197
|
var actions = [];
|
|
3947
4198
|
if (entry.restorable === true) {
|
|
3948
|
-
actions.push(
|
|
3949
|
-
|
|
3950
|
-
|
|
4199
|
+
actions.push(iconButton({
|
|
4200
|
+
icon: "IconRefreshOutlineRegular",
|
|
4201
|
+
label: t("trash.restore"),
|
|
3951
4202
|
onClick: function () { act(entry, "restore"); },
|
|
3952
|
-
}
|
|
4203
|
+
}));
|
|
3953
4204
|
}
|
|
3954
|
-
actions.push(h("button", {
|
|
3955
|
-
type: "button",
|
|
3956
|
-
className: "wsr-btn wsr-btn-danger",
|
|
3957
|
-
onClick: function () { act(entry, "purge"); },
|
|
3958
|
-
}, t("trash.purge")));
|
|
3959
4205
|
var hasTitle = typeof entry.title === "string" && entry.title !== "";
|
|
3960
4206
|
rows.push(entryCard({
|
|
3961
4207
|
key: entry.name,
|
|
3962
|
-
badge: entry.reason === "move" ? t("trash.reason.move") : t("trash.reason.delete"),
|
|
3963
|
-
badgeClass: entry.reason === "move" ? "wsr-card-badge-muted" : "wsr-card-badge-danger",
|
|
3964
4208
|
titleClass: hasTitle ? "wsr-card-title" : "wsr-card-title wsr-card-title-id",
|
|
3965
4209
|
title: hasTitle ? entry.title : (entry.sessionId === null ? entry.name : entry.sessionId),
|
|
3966
4210
|
titleAttr: entry.sessionId === null ? entry.name : entry.sessionId,
|
|
3967
4211
|
chips: chips,
|
|
3968
4212
|
path: entry.cwd,
|
|
4213
|
+
danger: iconButton({
|
|
4214
|
+
icon: "IconCloseOutlineRegular",
|
|
4215
|
+
label: t("trash.purge"),
|
|
4216
|
+
danger: true,
|
|
4217
|
+
onClick: function () { act(entry, "purge"); },
|
|
4218
|
+
}),
|
|
3969
4219
|
actions: actions,
|
|
3970
4220
|
}));
|
|
3971
4221
|
})(view.entries[i]);
|
|
@@ -3989,19 +4239,38 @@
|
|
|
3989
4239
|
var missing = entry.missing === true;
|
|
3990
4240
|
archivedRows.push(entryCard({
|
|
3991
4241
|
key: entry.sessionId,
|
|
3992
|
-
badge: missing ? t("archive.badgeMissing") : t("archive.badge"),
|
|
3993
|
-
badgeClass: missing ? "wsr-card-badge-warning" : "wsr-card-badge-muted",
|
|
3994
4242
|
titleClass: hasTitle ? "wsr-card-title" : "wsr-card-title wsr-card-title-id",
|
|
3995
4243
|
title: hasTitle ? entry.title : entry.sessionId,
|
|
3996
4244
|
titleAttr: entry.sessionId,
|
|
3997
4245
|
chips: chips,
|
|
3998
4246
|
path: typeof entry.workspacePath === "string" && entry.workspacePath !== "" ? entry.workspacePath : entry.cwd,
|
|
4247
|
+
/* The destructive action stays alone on the title line; the safe
|
|
4248
|
+
ones sit in the corner with the rest of the card actions. */
|
|
4249
|
+
danger: missing
|
|
4250
|
+
? null
|
|
4251
|
+
: iconButton({
|
|
4252
|
+
icon: "IconCloseOutlineRegular",
|
|
4253
|
+
label: t("archive.forget"),
|
|
4254
|
+
danger: true,
|
|
4255
|
+
onClick: function () { actArchived(entry, "forget"); },
|
|
4256
|
+
}),
|
|
3999
4257
|
actions: missing
|
|
4000
|
-
? [
|
|
4258
|
+
? [iconButton({
|
|
4259
|
+
icon: "IconArchiveOffOutlineRegular",
|
|
4260
|
+
label: t("archive.detach"),
|
|
4261
|
+
onClick: function () { actArchived(entry, "detach"); },
|
|
4262
|
+
})]
|
|
4001
4263
|
: [
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4264
|
+
iconButton({
|
|
4265
|
+
icon: "IconRefreshOutlineRegular",
|
|
4266
|
+
label: t("archive.unarchive"),
|
|
4267
|
+
onClick: function () { actArchived(entry, "unarchive"); },
|
|
4268
|
+
}),
|
|
4269
|
+
iconButton({
|
|
4270
|
+
icon: "IconTrashOutlineRegular",
|
|
4271
|
+
label: t("archive.delete"),
|
|
4272
|
+
onClick: function () { actArchived(entry, "delete"); },
|
|
4273
|
+
}),
|
|
4005
4274
|
],
|
|
4006
4275
|
}));
|
|
4007
4276
|
})(archivedList[j]);
|
|
@@ -4014,7 +4283,7 @@
|
|
|
4014
4283
|
),
|
|
4015
4284
|
archivedList.length === 0
|
|
4016
4285
|
? h("div", { className: "wsr-page-note", key: "archive-empty" }, t("archive.empty"))
|
|
4017
|
-
: h("div", { className: "wsr-
|
|
4286
|
+
: h("div", { className: "wsr-card-grid", key: "archive-list" }, archivedRows),
|
|
4018
4287
|
h("div", { className: "wsr-page-note", key: "archive-note" }, t("archive.description")),
|
|
4019
4288
|
];
|
|
4020
4289
|
|
|
@@ -4042,7 +4311,7 @@
|
|
|
4042
4311
|
),
|
|
4043
4312
|
view.entries.length === 0
|
|
4044
4313
|
? h("div", { className: "wsr-page-note", key: "trash-empty" }, t("trash.empty"))
|
|
4045
|
-
: h("div", { className: "wsr-
|
|
4314
|
+
: h("div", { className: "wsr-card-grid", key: "trash-list" }, rows),
|
|
4046
4315
|
h("div", { className: "wsr-page-note", key: "trash-note" }, t("trash.note")),
|
|
4047
4316
|
archiveSection,
|
|
4048
4317
|
],
|
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.1";
|
|
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") {
|
|
@@ -574,7 +578,28 @@ export function aggregateSession(events) {
|
|
|
574
578
|
const end = Math.min(totalSteps, start + size);
|
|
575
579
|
let sum = 0;
|
|
576
580
|
for (let index = start; index < end; index += 1) sum += steps[index].input + steps[index].cacheRead;
|
|
577
|
-
|
|
581
|
+
/* What entered during this bucket: the biggest block that first appears
|
|
582
|
+
between these steps. The panel says "step 58 grew 33K" - this is the
|
|
583
|
+
content behind that number. The host is the only side that sees every
|
|
584
|
+
block (the payload carries the top 15), so the attribution is done here
|
|
585
|
+
and each curve point only carries one small label. */
|
|
586
|
+
let entered = null;
|
|
587
|
+
for (const block of blocks) {
|
|
588
|
+
if (block.entry < start || block.entry >= end) continue;
|
|
589
|
+
if (entered === null || block.tokens > entered.tokens) entered = block;
|
|
590
|
+
}
|
|
591
|
+
series.push({
|
|
592
|
+
step: start + 1,
|
|
593
|
+
context: Math.round(sum / (end - start)),
|
|
594
|
+
entered: entered === null
|
|
595
|
+
? null
|
|
596
|
+
: {
|
|
597
|
+
kind: entered.kind,
|
|
598
|
+
name: entered.name,
|
|
599
|
+
detail: typeof entered.detail === "string" ? entered.detail.slice(0, 80) : "",
|
|
600
|
+
tokens: entered.tokens,
|
|
601
|
+
},
|
|
602
|
+
});
|
|
578
603
|
}
|
|
579
604
|
}
|
|
580
605
|
summary.amplified = {
|
|
@@ -583,6 +608,9 @@ export function aggregateSession(events) {
|
|
|
583
608
|
share: bill > 0 ? attributed / bill : 0,
|
|
584
609
|
steps: totalSteps,
|
|
585
610
|
series,
|
|
611
|
+
/* Steps after which the window was rewritten. The curve restarts there, so the
|
|
612
|
+
client reads each segment on its own instead of comparing across a rewrite. */
|
|
613
|
+
compactions: [...compactions],
|
|
586
614
|
blocks: ranked,
|
|
587
615
|
byKind: [...byKind.values()]
|
|
588
616
|
.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.1",
|
|
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",
|