dsh-ws-recency 0.27.0 → 0.27.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.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/index.js +94 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -85,6 +85,8 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
85
85
  - 每条记录是一张**卡片**:标题、来源(已删除 / 移动前的旧副本 / 已归档)、轮次、步骤、token 总量、日志大小、时间、原目录(归档的统计按日志大小缓存,第一次读完后不再重算);
86
86
  已删除会话的标题与统计在删除时就写进 `.wsr-trash.json`,旧条目则在第一次打开面板时从日志里补算并缓存;
87
87
  - 恢复/扫描/移动之后宿主会广播 `api-session/added`;面板与「扫描并刷新」都能重载页面(不重启应用)让侧栏立刻看到改动;
88
+ - 广播里带**列表投影**(标题、最后提问时间来自投影缓存,缓存没记录时读日志第一页):侧栏是靠这些投影把会话分进工作区分组的,只有摘要没有投影时,会话会“进了列表但不进分组”,看起来像没恢复——0.27.1 修;
89
+ - 恢复 = 恢复日志 + 重新挂到工作区 + 广播;先归档再删除的会话,恢复后重新出现在原工作区分组里,不需要重启;
88
90
  - 移动操作留下的旧副本会标成「移动时的旧副本」,只允许彻底删除;
89
91
  - 所有确认(删除、恢复、彻底删除、移动、取消归档)都是**页面内弹层**,不调用系统 `confirm`/`alert`:系统对话框在 Windows 上关掉后会让渲染进程丢掉键盘焦点,表现为输入框点不进去、切换会话也没用,只能切走再切回来(0.24.2 修)。
90
92
 
@@ -197,7 +199,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
197
199
  或固定版本的预构建包:
198
200
 
199
201
  ```powershell
200
- dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.27.0/dsh-ws-recency-0.27.0.tgz
202
+ dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.27.1/dsh-ws-recency-0.27.1.tgz
201
203
  ```
202
204
 
203
205
  装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
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.27.0";
35
+ export const HOST_VERSION = "0.27.1";
36
36
 
37
37
  /**
38
38
  * Exact routes the client half calls. Registered on the bare web server, so they
@@ -1168,6 +1168,60 @@ export async function announceSession(ctx, sessionId) {
1168
1168
  const stat = await ctx.sessionPersistence.stat(sessionId);
1169
1169
  const header = stat !== undefined && stat !== null ? stat.header : undefined;
1170
1170
  if (header !== undefined && header !== null) {
1171
+ /* The sidebar groups by workspace through list-surface projections; a
1172
+ summary without them lands in the list but never in a workspace group.
1173
+ Read them from the projection cache (cheap) and fall back to the first
1174
+ prompt of the log (one page) when the cache has no record. */
1175
+ let values = null;
1176
+ const checkpoint = cachedCheckpoint(ctx, sessionId);
1177
+ if (checkpoint !== undefined) {
1178
+ const projections = {};
1179
+ const title = checkpointValue(checkpoint, "title");
1180
+ if (typeof title === "string" && title.trim() !== "") projections.title = title.trim();
1181
+ const listMeta = checkpointValue(checkpoint, "sessionListMetadata");
1182
+ if (listMeta !== null && typeof listMeta === "object") {
1183
+ if (typeof listMeta.lastPromptAt === "number") projections.lastPromptAt = listMeta.lastPromptAt;
1184
+ if (listMeta.blank === true) projections.blank = true;
1185
+ }
1186
+ if (Object.keys(projections).length > 0) values = projections;
1187
+ }
1188
+ if (values !== null) {
1189
+ ctx.emit("api-session/added", {
1190
+ sessionId: header.id,
1191
+ updatedAt: typeof header.updatedAt === "number" ? header.updatedAt : Date.now(),
1192
+ agentAvailable: false,
1193
+ formatStatus: "current",
1194
+ running: false,
1195
+ blank: values.blank === true,
1196
+ title: values.title ?? header.title,
1197
+ cwd: header.cwd,
1198
+ createdAt: header.createdAt,
1199
+ projections: { kind: "cached", values },
1200
+ });
1201
+ return true;
1202
+ }
1203
+ const first = await firstPromptOf(ctx, sessionId);
1204
+ if (first.title !== "" || first.lastPromptAt > 0) {
1205
+ ctx.emit("api-session/added", {
1206
+ sessionId: header.id,
1207
+ updatedAt: typeof header.updatedAt === "number" ? header.updatedAt : Date.now(),
1208
+ agentAvailable: false,
1209
+ formatStatus: "current",
1210
+ running: false,
1211
+ blank: first.title === "" && first.lastPromptAt === 0,
1212
+ title: first.title !== "" ? first.title : header.title,
1213
+ cwd: header.cwd,
1214
+ createdAt: header.createdAt,
1215
+ projections: {
1216
+ kind: "cached",
1217
+ values: {
1218
+ ...(first.title !== "" ? { title: first.title } : {}),
1219
+ ...(first.lastPromptAt > 0 ? { lastPromptAt: first.lastPromptAt } : {}),
1220
+ },
1221
+ },
1222
+ });
1223
+ return true;
1224
+ }
1171
1225
  ctx.emit("api-session/added", {
1172
1226
  sessionId: header.id,
1173
1227
  updatedAt: typeof header.updatedAt === "number" ? header.updatedAt : Date.now(),
@@ -1187,6 +1241,45 @@ export async function announceSession(ctx, sessionId) {
1187
1241
  return false;
1188
1242
  }
1189
1243
 
1244
+ /** Title and first prompt time from the log's first page; empty when unreadable. */
1245
+ async function firstPromptOf(ctx, sessionId) {
1246
+ let handle;
1247
+ try {
1248
+ handle = await ctx.sessionPersistence.open(sessionId, "read");
1249
+ } catch {
1250
+ return { title: "", lastPromptAt: 0 };
1251
+ }
1252
+ try {
1253
+ const page = await handle.read(0, 500);
1254
+ const events = page !== null && page !== undefined && Array.isArray(page.events) ? page.events : [];
1255
+ let title = "";
1256
+ let lastPromptAt = 0;
1257
+ for (const event of events) {
1258
+ if (event === null || typeof event !== "object") continue;
1259
+ if (event.type === "session/title") {
1260
+ const value = event.data?.title ?? event.data;
1261
+ if (typeof value === "string" && value.trim() !== "") title = value.trim();
1262
+ } else if (event.type === "user/message" && lastPromptAt === 0 && typeof event.time === "number") {
1263
+ lastPromptAt = event.time;
1264
+ if (title === "") {
1265
+ const text = conversationText(event.data?.message?.content ?? event.data?.content);
1266
+ const line = text.trim().split("\n")[0];
1267
+ if (line !== "") title = line.slice(0, 120);
1268
+ }
1269
+ }
1270
+ }
1271
+ return { title, lastPromptAt };
1272
+ } catch {
1273
+ return { title: "", lastPromptAt: 0 };
1274
+ } finally {
1275
+ try {
1276
+ if (typeof handle.close === "function") await handle.close();
1277
+ } catch {
1278
+ /* closing is best effort */
1279
+ }
1280
+ }
1281
+ }
1282
+
1190
1283
  /** The session root's project-directory key: separators collapse to `-`. */
1191
1284
  export function projectKey(cwd) {
1192
1285
  if (typeof cwd !== "string" || cwd === "") return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ws-recency",
3
- "version": "0.27.0",
3
+ "version": "0.27.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",