dsh-ws-recency 0.29.1 → 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 +10 -8
- package/client.js +264 -66
- 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
|
|
|
@@ -102,7 +103,8 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
102
103
|
- **调用次数**:每条横条右侧带「N 次」;图表有一行列头(token / 占比 / 调用)对齐五列;
|
|
103
104
|
- **摘要卡片**:合计(高亮)+ 步数 + 输入(未缓存)+ 缓存命中 + 输出,合计排第一;
|
|
104
105
|
- **两个 tab**:摘要卡片常驻顶部,下面按「分布统计 / 放大归因」分页,打开时记住上次停留的 tab;
|
|
105
|
-
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3%
|
|
106
|
+
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3% 账单),这样小数字才能读出结论。压缩之后旧内容不再重读,放大窗口会从压缩点截断。
|
|
107
|
+
- **上下文拐点(0.30.0)**:曲线上的圆点标出上下文涨得最陡的步,颜色表示段内排名(第 1 红、第 2 黄、第 3 蓝),悬停圆点或下方的数字,两边一起高亮。**按压缩分段**:压缩会重置上下文,跨压缩点比较涨幅没有意义,所以每段各自取涨幅最大的三步;压缩点用一条淡竖线标在曲线上。下面按「第 N 段」一行排开该段的三个拐点(步号 + 涨幅),各段共用同一套列宽,数字右对齐——一眼看出哪一段开始放大、放大了多少。
|
|
106
108
|
|
|
107
109
|
面板底部只有一条口径说明(原来两个 tab 各有一条相同的话)。
|
|
108
110
|
|
|
@@ -203,7 +205,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
203
205
|
或固定版本的预构建包:
|
|
204
206
|
|
|
205
207
|
```powershell
|
|
206
|
-
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
|
|
207
209
|
```
|
|
208
210
|
|
|
209
211
|
装完把 `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,31 @@
|
|
|
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:
|
|
287
|
-
".wsr-context-
|
|
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)}",
|
|
288
334
|
".wsr-context-jump-row-hot{background:rgba(217,154,43,.16);color:var(--dsw-alias-label-primary)}",
|
|
289
335
|
".wsr-kind-legend{display:flex;flex-wrap:wrap;gap:10px}",
|
|
290
336
|
".wsr-kind{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
@@ -493,6 +539,8 @@
|
|
|
493
539
|
"stats.amplified.contextCaption": "每步上下文(面积≈账单):越早进入的内容被重读越多",
|
|
494
540
|
"stats.amplified.point": "第 {step} 步 · {context}",
|
|
495
541
|
"stats.amplified.jump": "第 {step} 步上下文涨了 {rise}",
|
|
542
|
+
"stats.amplified.jumpStep": "第 {step} 步",
|
|
543
|
+
"stats.amplified.segment": "第 {segment} 段",
|
|
496
544
|
"stats.amplified.jumpFrom": "({name} 进来 {tokens})",
|
|
497
545
|
"stats.amplified.meta": "第 {entry} 步进入 · {tokens} token × {remaining} 次重读",
|
|
498
546
|
"stats.amplified.whatIf": "若压到 20%,可省 {save}({share})",
|
|
@@ -672,6 +720,8 @@
|
|
|
672
720
|
"stats.amplified.contextCaption": "Context per step (area ≈ bill): earlier content is re-read more",
|
|
673
721
|
"stats.amplified.point": "step {step} · {context}",
|
|
674
722
|
"stats.amplified.jump": "step {step} grew by {rise}",
|
|
723
|
+
"stats.amplified.jumpStep": "step {step}",
|
|
724
|
+
"stats.amplified.segment": "seg {segment}",
|
|
675
725
|
"stats.amplified.jumpFrom": "({name} brought {tokens})",
|
|
676
726
|
"stats.amplified.meta": "entered at step {entry} · {tokens} tokens × {remaining} re-reads",
|
|
677
727
|
"stats.amplified.whatIf": "at 20%, saves {save} ({share})",
|
|
@@ -2152,45 +2202,92 @@
|
|
|
2152
2202
|
}
|
|
2153
2203
|
}
|
|
2154
2204
|
|
|
2155
|
-
/**
|
|
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
|
+
*/
|
|
2156
2213
|
function contextJumps(amplified) {
|
|
2157
2214
|
var series = Array.isArray(amplified.series) ? amplified.series : [];
|
|
2158
2215
|
var blocks = Array.isArray(amplified.blocks) ? amplified.blocks : [];
|
|
2159
|
-
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 = {};
|
|
2160
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;
|
|
2161
2231
|
var rise = Number(series[i].context) - Number(series[i - 1].context);
|
|
2162
|
-
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 });
|
|
2163
2236
|
}
|
|
2164
|
-
|
|
2237
|
+
var total = compactions.length + 1;
|
|
2165
2238
|
var picked = [];
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
var
|
|
2180
|
-
|
|
2181
|
-
|
|
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]);
|
|
2182
2257
|
}
|
|
2183
|
-
var
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
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,
|
|
2191
2289
|
});
|
|
2192
2290
|
}
|
|
2193
|
-
picked.push({ step: rise2.step, rise: rise2.rise, label: label });
|
|
2194
2291
|
}
|
|
2195
2292
|
return picked;
|
|
2196
2293
|
}
|
|
@@ -2216,19 +2313,35 @@
|
|
|
2216
2313
|
if (Number(series[i].context) > largest) largest = Number(series[i].context);
|
|
2217
2314
|
}
|
|
2218
2315
|
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. */
|
|
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. */
|
|
2223
2319
|
var jumps = contextJumps(amplified);
|
|
2224
2320
|
var jumpByStep = {};
|
|
2225
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;
|
|
2226
2328
|
for (var j = 0; j < series.length; j += 1) {
|
|
2227
2329
|
var bar = statsDiv("wsr-context-bar");
|
|
2228
2330
|
bar.style.height = Math.max(2, Math.round((Number(series[j].context) / largest) * 100)) + "%";
|
|
2229
|
-
|
|
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];
|
|
2230
2343
|
if (jump !== undefined) {
|
|
2231
|
-
bar.className = "wsr-context-bar wsr-context-jump";
|
|
2344
|
+
bar.className = "wsr-context-bar wsr-context-jump" + (startsSegment ? " wsr-context-break" : "");
|
|
2232
2345
|
bar.setAttribute("data-wsr-jump", String(jump.step));
|
|
2233
2346
|
bar.setAttribute("title", jump.label);
|
|
2234
2347
|
/* A hover target that is big enough to hit: a 5px dot on a 3px bar
|
|
@@ -2236,23 +2349,47 @@
|
|
|
2236
2349
|
below, so hovering the bar also lifts that row. */
|
|
2237
2350
|
var hit = statsDiv("wsr-context-jump-hit");
|
|
2238
2351
|
hit.setAttribute("data-wsr-jump-hit", String(jump.step));
|
|
2352
|
+
hit.setAttribute("data-wsr-rank", String(jump.rank));
|
|
2239
2353
|
hit.appendChild(statsDiv("wsr-context-jump-dot"));
|
|
2240
2354
|
hit.addEventListener("mouseenter", highlightJumpRow);
|
|
2241
2355
|
hit.addEventListener("mouseleave", clearJumpHighlight);
|
|
2242
2356
|
bar.appendChild(hit);
|
|
2243
2357
|
} else {
|
|
2244
|
-
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) }));
|
|
2245
2359
|
}
|
|
2246
2360
|
chart.appendChild(bar);
|
|
2247
2361
|
}
|
|
2248
2362
|
section.appendChild(chart);
|
|
2249
2363
|
section.appendChild(statsDiv("wsr-context-caption", t("stats.amplified.contextCaption")));
|
|
2250
2364
|
if (jumps.length > 0) {
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
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);
|
|
2256
2393
|
}
|
|
2257
2394
|
section.appendChild(jumpList);
|
|
2258
2395
|
}
|
|
@@ -3836,14 +3973,54 @@
|
|
|
3836
3973
|
* below. Both are "put away", so both are managed from here.
|
|
3837
3974
|
*/
|
|
3838
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
|
+
*/
|
|
3839
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);
|
|
3840
4021
|
return h("div", { className: "wsr-card", key: options.key, title: options.titleAttr || "" },
|
|
3841
4022
|
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
4023
|
h("div", { className: options.titleClass || "wsr-card-title" }, options.title),
|
|
3846
|
-
h("div", { className: "wsr-card-actions" }, options.actions),
|
|
3847
4024
|
),
|
|
3848
4025
|
options.chips.length > 0
|
|
3849
4026
|
? h("div", { className: "wsr-chips" }, options.chips.map(function (text, index) {
|
|
@@ -3853,6 +4030,9 @@
|
|
|
3853
4030
|
typeof options.path === "string" && options.path !== ""
|
|
3854
4031
|
? h("div", { className: "wsr-card-path" }, options.path)
|
|
3855
4032
|
: null,
|
|
4033
|
+
actions.length > 0
|
|
4034
|
+
? h("div", { className: "wsr-card-actions wsr-card-actions-row" }, actions)
|
|
4035
|
+
: null,
|
|
3856
4036
|
);
|
|
3857
4037
|
}
|
|
3858
4038
|
|
|
@@ -3945,27 +4125,26 @@
|
|
|
3945
4125
|
if (when !== "") chips.push(when);
|
|
3946
4126
|
var actions = [];
|
|
3947
4127
|
if (entry.restorable === true) {
|
|
3948
|
-
actions.push(
|
|
3949
|
-
|
|
3950
|
-
|
|
4128
|
+
actions.push(iconButton({
|
|
4129
|
+
icon: "IconRefreshOutlineRegular",
|
|
4130
|
+
label: t("trash.restore"),
|
|
3951
4131
|
onClick: function () { act(entry, "restore"); },
|
|
3952
|
-
}
|
|
4132
|
+
}));
|
|
3953
4133
|
}
|
|
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
4134
|
var hasTitle = typeof entry.title === "string" && entry.title !== "";
|
|
3960
4135
|
rows.push(entryCard({
|
|
3961
4136
|
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
4137
|
titleClass: hasTitle ? "wsr-card-title" : "wsr-card-title wsr-card-title-id",
|
|
3965
4138
|
title: hasTitle ? entry.title : (entry.sessionId === null ? entry.name : entry.sessionId),
|
|
3966
4139
|
titleAttr: entry.sessionId === null ? entry.name : entry.sessionId,
|
|
3967
4140
|
chips: chips,
|
|
3968
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
|
+
}),
|
|
3969
4148
|
actions: actions,
|
|
3970
4149
|
}));
|
|
3971
4150
|
})(view.entries[i]);
|
|
@@ -3989,19 +4168,38 @@
|
|
|
3989
4168
|
var missing = entry.missing === true;
|
|
3990
4169
|
archivedRows.push(entryCard({
|
|
3991
4170
|
key: entry.sessionId,
|
|
3992
|
-
badge: missing ? t("archive.badgeMissing") : t("archive.badge"),
|
|
3993
|
-
badgeClass: missing ? "wsr-card-badge-warning" : "wsr-card-badge-muted",
|
|
3994
4171
|
titleClass: hasTitle ? "wsr-card-title" : "wsr-card-title wsr-card-title-id",
|
|
3995
4172
|
title: hasTitle ? entry.title : entry.sessionId,
|
|
3996
4173
|
titleAttr: entry.sessionId,
|
|
3997
4174
|
chips: chips,
|
|
3998
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
|
+
}),
|
|
3999
4186
|
actions: missing
|
|
4000
|
-
? [
|
|
4187
|
+
? [iconButton({
|
|
4188
|
+
icon: "IconArchiveOffOutlineRegular",
|
|
4189
|
+
label: t("archive.detach"),
|
|
4190
|
+
onClick: function () { actArchived(entry, "detach"); },
|
|
4191
|
+
})]
|
|
4001
4192
|
: [
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
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
|
+
}),
|
|
4005
4203
|
],
|
|
4006
4204
|
}));
|
|
4007
4205
|
})(archivedList[j]);
|
|
@@ -4014,7 +4212,7 @@
|
|
|
4014
4212
|
),
|
|
4015
4213
|
archivedList.length === 0
|
|
4016
4214
|
? h("div", { className: "wsr-page-note", key: "archive-empty" }, t("archive.empty"))
|
|
4017
|
-
: h("div", { className: "wsr-
|
|
4215
|
+
: h("div", { className: "wsr-card-grid", key: "archive-list" }, archivedRows),
|
|
4018
4216
|
h("div", { className: "wsr-page-note", key: "archive-note" }, t("archive.description")),
|
|
4019
4217
|
];
|
|
4020
4218
|
|
|
@@ -4042,7 +4240,7 @@
|
|
|
4042
4240
|
),
|
|
4043
4241
|
view.entries.length === 0
|
|
4044
4242
|
? h("div", { className: "wsr-page-note", key: "trash-empty" }, t("trash.empty"))
|
|
4045
|
-
: h("div", { className: "wsr-
|
|
4243
|
+
: h("div", { className: "wsr-card-grid", key: "trash-list" }, rows),
|
|
4046
4244
|
h("div", { className: "wsr-page-note", key: "trash-note" }, t("trash.note")),
|
|
4047
4245
|
archiveSection,
|
|
4048
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",
|