dsh-sessions-manager 3.6.2 → 3.7.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.en.md +21 -10
- package/README.md +23 -12
- package/lib/client.js +990 -32
- package/lib/client.js.map +2 -2
- package/lib/index.js +921 -151
- package/lib/index.js.map +4 -4
- package/package.json +1 -1
- package/src/client/index.jsx +816 -33
- package/src/client/logic.js +285 -0
- package/src/empty-scan-index.js +118 -0
- package/src/index.js +340 -79
- package/src/lineage.js +18 -14
- package/src/move-notices.js +129 -0
- package/src/saved-filters.js +208 -0
- package/src/tag-index.js +308 -0
package/README.en.md
CHANGED
|
@@ -20,12 +20,13 @@ A persistent DSH plugin (host + browser halves) covering both the **settings pan
|
|
|
20
20
|
|
|
21
21
|
- **Unified panel**: three always-visible top-level views — **All / Active / Archived** — while the low-frequency ones (**Starred / Empty / Recycle bin**) are tucked behind an arrow button at the end of the filter row and slide out horizontally on click (they stay expanded automatically while a low-frequency view is selected). Search across title, session ID, and workspace, plus workspace filters and creation-time/title sorting. The result line is a single sentence such as "Showing 5 sessions, 4 more subagents folded under their parents". A maintenance row below the filters holds the **Storage usage** and **Auto-archive** tools, which expand on demand instead of taking up a view.
|
|
22
22
|
- **Starred sessions**: an always-visible star button on each session row toggles starring optimistically with rollback on failure; the Starred view is orthogonal to DSH's active/archived states and they stack. The star index is plugin-owned (schema v3) and never touches DSH logs; stars are cleaned up automatically when a session is permanently purged.
|
|
23
|
-
- **
|
|
23
|
+
- **Tags & saved filters**: label sessions with custom tags (up to 200 global, 10 per session; rename, merge, delete — **deleting a tag never touches the sessions**), filter the list by tag, and save the current "view + workspace + sort + tag" combination as a preset (up to 20) for one-click reuse. Tags and presets live in plugin-owned indexes (same discipline as the star index) inside this machine's DSH data directory — they do not follow your account; cross-machine migration belongs to the 3.10.0 backup scope.
|
|
24
|
+
- **Cold-title synchronization**: the sidebar is corrected from the latest log-backed `session/title`, so renamed cold sessions no longer need to be opened before showing their current name. On cold starts of large stores a title that is not ready yet simply renders blank while it fills in the background — and once it arrives, **rows already on screen and the “⑂ branch” chip's tooltip update automatically**, no page rebuild needed.
|
|
24
25
|
- **Sidebar workspace drag-and-drop**: drag a session onto a workspace heading to move it, with a highlighted drop target, same-workspace protection, failure feedback, and the More → Move session menu retained for keyboard access.
|
|
25
26
|
- **Archive / Restore**: archive hides a session from the sidebar; restore unarchives it and puts it back into its original workspace group.
|
|
26
|
-
- **Move to a workspace**: pick an **existing workspace**, or enter a **new directory path** (auto-created); the new-path mode also lets you open the **native OS directory picker** with a **「浏览…」** button. The session's working directory and log are migrated together. On the legacy runtime (`0.1.2-rc.1`) even an open session can be moved; on
|
|
27
|
+
- **Move to a workspace**: pick an **existing workspace**, or enter a **new directory path** (auto-created); the new-path mode also lets you open the **native OS directory picker** with a **「浏览…」** button. The session's working directory and log are migrated together. On the legacy runtime (`0.1.2-rc.1`) even an open session can be moved immediately; on newer runtimes session logs are **single-writer** (DSH claims write ownership when it opens a session and releases it only at process exit), so such a move is **queued automatically** instead of failing and completes on its own once the session is released — see "Moving an active session (queued moves)" below.
|
|
27
28
|
- **Session details**: expand any session to see **disk usage**, **turns / steps / user·assistant messages / tool calls / image attachments** stats, **tool-usage breakdown**, **search·fetch records**, the **write/edit file list** (already filtered for paths that no longer exist on disk), and **lineage** (parent session / child sessions / subagents).
|
|
28
|
-
- **Lineage disclosure**: the panel's **Grouping** select offers **Lineage (
|
|
29
|
+
- **Lineage disclosure**: the panel's **Grouping** select offers **Lineage (folded groups, default)** and **Flat (all inline)** views. Under lineage grouping, subagent sessions fold under their parents ("▸ N 子代理"), and sessions forked from the same source are **gathered into branch groups** ("▸ N 分支", oldest first by creation time; the source row stays in place, and if the parent is filtered out / archived / deleted the group degrades to a "来源:<短 ID>" header — no row is ever lost, so branches of an archived parent do hang under a "source" header in the Active view by design). Grouping lives in the panel; the sidebar only badges rows (React-owned DOM, never reordered). Fork sessions also carry the green **"⑂ 分支"** badge (hover shows the source parent; the title is late-arriving data and refreshes itself), and empty sessions carry a gray badge with a dedicated **Empty** view for reviewing and cleaning them up. Empty sessions are identified by an **event-type method**: since `0.1.3` the log header grew and every creation writes a lifecycle-metadata frame, so the old size threshold no longer holds — the plugin decodes candidate sessions through the official API and marks one empty only when no content event exists beyond the header (decode failures fall back to non-empty). Since 3.7.0 the checks run entirely off the request path: sidebar data answers immediately with empties marked "unknown" (unknown is never hidden and never counted as empty), a small background queue resolves candidates session by session, verdicts persist across restarts, and later polls converge automatically — zero-decode lineage such as the "⑂ branch" chip is no longer gated behind any refinement work.
|
|
29
30
|
- **Export**: the detail panel offers two actions — "**Download raw log (ZIP)**" goes straight to DSH's official `session.export` endpoint (subsessions + attachments included, hidden automatically when the persistence backend lacks raw-artifact support); "**Export Markdown**" renders the session into a human-readable transcript (front matter + per-turn sections + user / assistant / tool-call summaries, with no streaming-delta duplication).
|
|
30
31
|
- **Storage analysis**: a **Storage usage** button in the maintenance row expands on demand to aggregate per-workspace disk usage of session logs (share bars + session counts) and list the Top 10 largest sessions. Read-only statistics that never modify any data; collapsed by default, so nothing is scanned until you open it.
|
|
31
32
|
- **Auto-archive**: optionally move sessions that have been **inactive for 30 / 60 / 90 days** into **Archived**, **off by default**. The session you are currently using and any starred session (that guard can be turned off) are never auto-archived; it only sets an archived flag and never deletes data, so recovery is always one click away. The check is lazily triggered when you open the panel, at most once per day, and can also be run manually with "Check now".
|
|
@@ -78,7 +79,8 @@ So held-open sessions get **deferred (queued) moves**:
|
|
|
78
79
|
- The request does not fail; the move is recorded in a pending queue (`~/.dsh/sessions-manager/pending-moves.json`) and the plugin reports **"queued" honestly** — it never claims "moved" for a move that did not happen.
|
|
79
80
|
- The queue runs automatically **immediately after plugin startup and retries densely** (0 / 1 / 3 / 6 / 12 / 30 s — it must win the race against the browser opening sessions), then on a light 2-minute fallback, and whenever the host releases a session.
|
|
80
81
|
- Up to 50 entries are kept; an entry that fails 5 times for **non-lock** reasons is dropped and logged (failures within the first 30 s after startup do not count, so a startup race cannot silently drop your queue).
|
|
81
|
-
- Inspect / cancel: `POST /archived-sessions/pending-moves`, `POST /archived-sessions/pending-moves/cancel { sessionIds }
|
|
82
|
+
- Inspect / cancel: `POST /archived-sessions/pending-moves`, `POST /archived-sessions/pending-moves/cancel { sessionIds }`; while the queue is non-empty the panel also shows a **Pending moves queue** section with per-entry cancel.
|
|
83
|
+
- **Results are no longer silent**: a background completion or a final give-up (5 consecutive non-lock failures) becomes a persisted notice, surfaced as a toast the next time a DSH page is open (give-ups include the reason). Notices stay on the server until acknowledged (up to 20, at most 7 days) — closing the page before the toast never loses one.
|
|
82
84
|
- **To actually move an active session**: request the move (it queues), then **restart DSH and don't open that session first** — it completes a few seconds after startup. Pending entries survive restarts.
|
|
83
85
|
|
|
84
86
|
### Session format v3 (DSH 0.1.5+)
|
|
@@ -149,6 +151,7 @@ src/client/index.jsx client source (React, settings.section + sidebar DOM augme
|
|
|
149
151
|
src/auto-archive.js auto-archive settings (schema v4) + candidate-selection pure functions
|
|
150
152
|
src/storage-stats.js storage-usage aggregation (pure functions, by workspace / Top N)
|
|
151
153
|
src/lineage.js lineage classification and empty-session detection (pure functions, event-type method)
|
|
154
|
+
src/empty-scan-index.js persisted empty-verdict cache (cross-restart reuse, fingerprint + TTL gates)
|
|
152
155
|
build.mjs esbuild build script (regenerates lib/)
|
|
153
156
|
lib/index.js pre-built host (ESM)
|
|
154
157
|
lib/client.js pre-built client (ModuleLoader CJS handshake)
|
|
@@ -179,10 +182,18 @@ lib/client.js pre-built client (ModuleLoader CJS handshake)
|
|
|
179
182
|
| POST | `/archived-sessions/move-many` | Batch cross-workspace move `{ sessionIds, targetPath }` — one failure never blocks the rest, failures are reported per session, held-open sessions land in `queued`, and the grouping index is rebuilt once at the end |
|
|
180
183
|
| POST | `/archived-sessions/pending-moves` | Inspect the pending-move queue (sessions queued while held open; completed automatically once released) |
|
|
181
184
|
| POST | `/archived-sessions/pending-moves/cancel` | Cancel queued moves `{ sessionIds }` |
|
|
185
|
+
| POST | `/archived-sessions/pending-moves/notices/ack` | Acknowledge queued-move outcome notices (cleared once shown; unacknowledged ones live at most 7 days) |
|
|
182
186
|
| POST | `/archived-sessions/details` | Session details (disk / stats / tools / fetch / files / lineage) `{ sessionId }` |
|
|
183
|
-
| POST | `/archived-sessions/sidebar-state` | Authoritative sidebar titles, recycle-bin IDs, permanent-deletion tombstones, **lineage disclosure** (subagent / branch / empty badges),
|
|
187
|
+
| POST | `/archived-sessions/sidebar-state` | Authoritative sidebar titles, recycle-bin IDs, permanent-deletion tombstones, **lineage disclosure** (subagent / branch / empty badges), , `warmPending` / `refinePending` (whether the title-warming and empty-refinement background queues still have work in flight) and `moveNotices` (queued-move outcome notices; omitted when empty) |
|
|
184
188
|
| POST | `/archived-sessions/lineage-tree` | Recursive subagent tree (feeds the panel's Lineage grouping and the sidebar folding), filtered for recycle-bin and tombstoned sessions |
|
|
185
189
|
| POST | `/archived-sessions/star/set` | Star / unstar sessions `{ sessionId or sessionIds, starred }` |
|
|
190
|
+
| POST | `/archived-sessions/tags/list` | Tag definitions + session→tag map `{ tags, assignments }` |
|
|
191
|
+
| POST | `/archived-sessions/tags/create` | Create a tag `{ name }` (duplicate/over-cap rejected with stable codes) |
|
|
192
|
+
| POST | `/archived-sessions/tags/rename` | Rename `{ id, name }` (id is stable) |
|
|
193
|
+
| POST | `/archived-sessions/tags/merge` | Merge `{ fromId, toId }` (deduped; source tag disappears) |
|
|
194
|
+
| POST | `/archived-sessions/tags/delete` | Delete a tag `{ id }` (definitions + assignments only, never sessions) |
|
|
195
|
+
| POST | `/archived-sessions/tags/set` | Replace one session's tags wholesale `{ sessionId, tagIds }` |
|
|
196
|
+
| POST | `/archived-sessions/filters/list` / `save` / `delete` | Filter presets `{ name, filters }` (≤20; filters is an opaque payload) |
|
|
186
197
|
| GET | `/archived-sessions/export-md?sessionId=` | Single-session Markdown export (human-readable transcript) |
|
|
187
198
|
| POST | `/archived-sessions/storage` | Storage-usage aggregation (per-workspace ranking + largest sessions) `{ topN }` |
|
|
188
199
|
| POST | `/archived-sessions/auto-archive/settings` | Read or update the auto-archive policy `{ inactiveDays, skipStarred }`; reading lazily triggers the daily check |
|
|
@@ -197,20 +208,20 @@ lib/client.js pre-built client (ModuleLoader CJS handshake)
|
|
|
197
208
|
- Works in both DSH Desktop and DSH web (same host + client halves).
|
|
198
209
|
- Peer dependencies are listed in `package.json`; `react` and `@deepseek-ai/*` are provided by the DSH runtime.
|
|
199
210
|
- `0.1.2-rc.1`: the existing read, archive, recycle-bin, permanent-purge, and cross-workspace move paths remain available.
|
|
200
|
-
- `0.1.3-alpha.1`: snapshot lists and chunked `SessionHandle` read flows are supported. Permanent purge and cross-workspace move are
|
|
201
|
-
- `0.1.5-rc.1` (current
|
|
211
|
+
- `0.1.3-alpha.1`: snapshot lists and chunked `SessionHandle` read flows are supported. Permanent purge and cross-workspace move are available through guarded path derivation + write-ownership probes (see the behavior notes below), and disable themselves whenever a safe path cannot be verified; other management capabilities are unaffected. The panel shows the effective capabilities.
|
|
212
|
+
- `0.1.5-rc.1` / `0.1.5-rc.2` (current runtimes; the two are byte-identical across every API this plugin uses, both verified): the session log format is upgraded to **v3** and this plugin is adapted — it reads the **highest generation** (matching the runtime), tolerates v0/v2/v3 generations side by side, follows the new `SessionHandle.read()` shape (`{ eventState, events }`), moves sessions as **whole-directory moves** (reclaiming superseded-generation copies automatically), and queues moves for sessions DSH holds open (see "Moving an active session" above).
|
|
202
213
|
- Unverified future runtimes expose only capabilities the plugin can safely identify; method presence alone is not presented as behavioral compatibility.
|
|
203
214
|
|
|
204
|
-
### Behavior differences and degradations
|
|
215
|
+
### Behavior differences and degradations on the SessionHandle era (`0.1.3+`)
|
|
205
216
|
|
|
206
217
|
- **Recycle-bin restore is verified**: before restoring, the plugin confirms the underlying stored session still exists (live / `stat` / listing, in that order). It returns accurate errors when the session is gone (`DSM_SESSION_MISSING`), was permanently purged (`DSM_SESSION_PURGED`), or the index still lists it but the log file has vanished (`DSM_SESSION_LOG_MISSING`); when the log location cannot be verified the entry is honestly reported as `unverified` instead of silently passing. Restoring a session whose workspace was deleted succeeds and notes that it now lives under "未分组" (ungrouped).
|
|
207
218
|
- **Permanent purge / empty recycle bin / automatic physical cleanup**: the official public contract offers no delete API, so the plugin keeps the legacy-era semi-official approach — a **three-layer guarded path derivation** starting from the backend instance's storage-root field (root → session directory structure → session-id ownership check), followed by a whole-directory removal verified with the official `stat`. Sessions with an active writer are refused (409). When the derivation fails (e.g. the storage root is unavailable), the actions degrade to disabled with an explicit reason instead of deleting blindly.
|
|
208
219
|
- **Cross-workspace move**: the primary path replays events through the official `create` + `append` (writer-ownership probe refuses sessions whose write ownership is held by DSH, before/after `revision` checks guard against concurrent writes, backup + rollback guarantees no half-moved state on failure); when the backend holds a ghost record for the same id it falls back to relocating the log with a frame0 cwd rewrite (frame count and content verified byte-for-byte). Paths come from the same guarded derivation; the workspace grouping index is rebuilt automatically after the move — no restart needed. Since runtime `0.1.5` a session may keep **several log generations side by side** (the runtime publishes a newer generation but keeps the older ones: `session.jsonl.zstd` + `session.v2.jsonl.zstd` + `session.v3.jsonl.zstd`), while the runtime insists that one id lives in exactly one project directory — so a move is a **whole-directory move**: the source session directory is renamed out of sight first, the target is materialized and verified, then the source directory is deleted. Superseded older-generation copies left in other project directories by earlier versions are **reclaimed automatically**, so a session can never get stuck as a cross-directory duplicate.
|
|
209
220
|
- **Purge tombstones never suppress new sessions**: if a session with the same id is recreated later, the tombstone yields automatically and the new session appears normally in lists and the sidebar.
|
|
210
|
-
- **Metadata
|
|
221
|
+
- **Metadata cache**: whether a session log changed is judged by the official snapshot's `revision` on newer runtimes (comparable only within one process, and never written to any cross-restart cache file), or by the file's `(mtime, size)` fingerprint on legacy runtimes. A list's folder and creation time come straight from the snapshot header without reading logs; titles are never decoded during page loads either — a session whose title is not cached yet simply renders blank, and the list refreshes itself once the background pass fills it in. **A failed read is kept apart from a session that genuinely has no title**: failures are never cached and are retried later (immediately once that session's log changes), so one transient failure can't leave a session stuck at "(untitled)".
|
|
211
222
|
- **Auto-archive**: the new runtime exposes no reliable "last activity" timestamp; the sweep skips (`no-activity-data`) when idleness cannot be proven, and never archives on a guess.
|
|
212
223
|
- **Sidebar injection**: DOM / React fiber recognition is centralized in a versioned adapter; when the upstream sidebar shape is no longer recognized, all injections degrade safely and the official sidebar is left untouched. While recognition works, updates are driven incrementally by a MutationObserver with only a low-frequency fallback check.
|
|
213
|
-
- **Lineage disclosure**: subagent sessions are recognized via the official header fields (`origin: 'subagent'`, `parentSession`, `delegationDepth`); since the upstream sidebar renders neither subagent nor empty sessions, the plugin injects subagent rows under their parent and hides empty rows. Empty detection uses the **event-type method** — `0.1.3` always writes one lifecycle-metadata frame at creation (`permission/preset` / `sandbox/mode` / `approval/policy`), which breaks the old size threshold; candidates up to 8KB (compressed) are decoded once through the official API and marked empty only when no content event exists beyond the header, decode failures fall back to non-empty
|
|
224
|
+
- **Lineage disclosure**: subagent sessions are recognized via the official header fields (`origin: 'subagent'`, `parentSession`, `delegationDepth`); since the upstream sidebar renders neither subagent nor empty sessions, the plugin injects subagent rows under their parent and hides empty rows. Empty detection uses the **event-type method** — `0.1.3` always writes one lifecycle-metadata frame at creation (`permission/preset` / `sandbox/mode` / `approval/policy`), which breaks the old size threshold; candidates up to 8KB (compressed) are decoded once through the official API and marked empty only when no content event exists beyond the header, decode failures fall back to non-empty. Verdicts are cached per session under a cross-restart size fingerprint and persisted to disk (only genuinely decoded verdicts are; failures never are), the queue yields the event loop between batches, and sidebar responses stay decode-free end to end.
|
|
214
225
|
|
|
215
226
|
## License
|
|
216
227
|
|
package/README.md
CHANGED
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
|
|
21
21
|
- **统一面板**:顶部提供「全部 / 活动 / 已归档」三个常驻视图,低频的「已收藏 / 空白 / 回收站」收进行尾的箭头按钮,点按横向滑出展开(低频视图处于选中态时自动保持展开);支持按标题、会话 ID、工作区搜索,按工作区筛选,并按创建时间或标题排序。结果行合并为一句说明,如「显示 5 个会话,另有 4 个子代理折叠在父会话下」。筛选栏下方的维护栏收纳「存储占用」与「自动归档」两个按需展开的工具,不占用视图位置。
|
|
22
22
|
- **收藏(星标)**:会话行左侧常驻星标按钮,单击即收藏 / 取消(乐观更新、失败回滚);「已收藏」视图与 DSH 的活动 / 归档状态正交、可叠加;收藏索引为插件自有 schema v3,不触碰 DSH 日志,会话被彻底删除时自动清理。
|
|
23
|
-
-
|
|
23
|
+
- **标签与保存筛选**:给会话贴自定义标签(全局 ≤200、单会话 ≤10;支持重命名、合并、删除——**删除标签只删标签,绝不触碰会话**),并按标签筛选列表;「视图 + 工作区 + 排序 + 标签」的组合可保存为筛选预设(≤20 条)一键应用。标签与预设存在插件自有索引里(同星标索引纪律),跟随这台机器的 DSH 数据目录、不跟账号走——换机迁移属 3.10.0 备份范围。
|
|
24
|
+
- **冷态标题同步**:侧栏使用日志中最新的 `session/title` 修正冷启动缓存,改名后的会话无需先打开即可显示新名称;冷启动大库里标题先留空、后台分批补齐,补齐后**已经在屏幕上的侧栏行和「⑂ 分支」标记的悬停说明会跟着自动更新**,不必等页面重建。
|
|
24
25
|
- **侧栏跨工作区拖拽**:直接把会话拖到目标工作区标题即可切换工作区;目标高亮、同工作区拦截、失败反馈,并保留“更多 → 移动会话”作为键盘操作入口。
|
|
25
26
|
- **归档 / 恢复**:归档把会话从侧栏隐藏;恢复取消归档并放回原工作区分组。
|
|
26
|
-
- **移动到工作区**:任选**已有工作区**或**新建目录路径**(自动创建),新建目录支持点击 **「浏览…」** 调用系统目录选择窗口。会话的工作目录与日志一起迁移。旧版 Runtime(`0.1.2-rc.1
|
|
27
|
-
- **会话详情**:展开单条会话查看**磁盘占用**、**轮次 / 步骤 / 用户·助手消息 / 工具调用 / 图片附件**统计、**工具使用分布**、**搜索·抓取记录**、**write/edit
|
|
28
|
-
-
|
|
27
|
+
- **移动到工作区**:任选**已有工作区**或**新建目录路径**(自动创建),新建目录支持点击 **「浏览…」** 调用系统目录选择窗口。会话的工作目录与日志一起迁移。旧版 Runtime(`0.1.2-rc.1`)下已打开的会话也可立即移动;新版 Runtime 为会话日志引入**单写者所有权**(DSH 打开会话即持有、只在进程退出时释放),此时移动会**自动排队**而不是失败——释放后由插件自动完成,详见下文「移动活跃会话(排队移动)」。
|
|
28
|
+
- **会话详情**:展开单条会话查看**磁盘占用**、**轮次 / 步骤 / 用户·助手消息 / 工具调用 / 图片附件**统计、**工具使用分布**、**搜索·抓取记录**、**write/edit 写过的文件列表**(已过滤磁盘上已不存在的路径),以及**血缘**(父会话 / 子会话 / 子代理)。
|
|
29
|
+
- **血缘分层披露**:面板的「分组」下拉提供**血缘(折叠分组,默认)**与**平铺(全部并列)**两种视图。血缘视图下:子代理会话折叠在其父会话下(「▸ N 子代理」);由同一来源会话派生的**分支(fork)自动聚拢成组**(「▸ N 分支」,组内按创建时间升序,来源父行原位保留;父会话被筛掉/归档/删除时降级为「来源:<短 ID>」组头,一行不丢——因此**「活动」视图里已归档父会话的分支会挂在「来源」组头下,这是设计不是 bug**)。注意:聚拢在设置面板的血缘视图;侧栏受官方 React 托管行 DOM 限制只打标记不重排。分支会话带绿色「⑂ 分支」标记(悬停显示来源父会话;父标题为后到数据,到达后自动刷新),空白会话带灰色标记并可进入「空白」视图统一查看与清理。空白会话识别采用**事件类型法**:`0.1.3` 起日志头部扩容且创建时恒写一帧生命周期元数据,旧体积阈值失效——插件对候选会话做官方解码精判,头部之外没有任何内容事件才判空白(解码失败按非空兜底)。3.7.0 起精判完全移出数据返回路径:侧栏数据**首拍即回**,空白与否先按「未知」处理(未知一律不隐藏、不计入空白分类),后台小队列逐条判定、结论落盘跨重启复用,后续拍自动收敛——「⑂ 分支」等零解码信息不再被任何精判解码挡住。
|
|
29
30
|
- **导出**:详情面板底部提供两个入口——「**下载原始日志 (ZIP)**」直接走 DSH 官方 `session.export` 端点(含子会话与附件,持久化后端不支持时自动隐藏);「**导出 Markdown**」由本插件把会话渲染为人类可读对话记录(front matter + 按轮分节 + 用户 / 助手 / 工具调用摘要,流式增量不重复)。
|
|
30
31
|
- **存储占用分析**:维护栏的「存储占用」按钮按需展开,按工作区聚合会话日志的磁盘占用(占比条 + 会话数),并列出占用最大的会话 Top 10。纯只读统计,不修改任何数据;默认收起、展开时才统计,因此不会拖慢会话列表的加载。
|
|
31
32
|
- **自动归档**:可设为把 **30 / 60 / 90 天未活跃**的会话自动收进「已归档」,**默认关闭**。当前正在使用的会话与已收藏的会话(该保护可关闭)永不自动归档;只做归档标记,不删除任何数据,随时可恢复。检查在打开面板时惰性触发,每天最多一次,也可点「立即检查」手动执行。
|
|
@@ -78,7 +79,8 @@ DSH(0.1.5 起)给每个会话日志加了**单写者锁**:会话一旦被
|
|
|
78
79
|
- 命中占用时**不会失败**,而是登记进待移动队列(`~/.dsh/sessions-manager/pending-moves.json`),并**如实提示「已排队」**——绝不会在没有真正搬运的情况下报「已移动」。
|
|
79
80
|
- 队列的自动执行时机:**插件启动后立即并密集重试**(0 / 1 / 3 / 6 / 12 / 30 秒,必须抢在浏览器打开会话之前)、之后每 2 分钟轻量兜底、以及宿主释放会话时。
|
|
80
81
|
- 队列最多保留 50 条;同一条连续 5 次因**非占用原因**失败会被放弃并记录日志(启动 30 秒内的失败不计入,避免启动竞态丢队列)。
|
|
81
|
-
- 查看与取消:`POST /archived-sessions/pending-moves`、`POST /archived-sessions/pending-moves/cancel { sessionIds }
|
|
82
|
+
- 查看与取消:`POST /archived-sessions/pending-moves`、`POST /archived-sessions/pending-moves/cancel { sessionIds }`;队列非空时面板显示「待移动队列」小节(逐条取消)。
|
|
83
|
+
- **结果不再静默**:后台完成或最终放弃(连续 5 次非占用失败)会落成通知,下次打开 DSH 页面时以提示弹出(放弃类附原因)。通知在服务端保留到确认展示(最多 20 条、最长 7 天),没弹就不会丢。
|
|
82
84
|
- **要真正搬走一个活跃会话**:先发起移动(进队列),再**重启 DSH 并先别打开那个会话**——启动后几秒内会自动完成。未完成的项跨重启保留,不会丢。
|
|
83
85
|
|
|
84
86
|
### 关于会话格式 v3(DSH 0.1.5+)
|
|
@@ -149,6 +151,7 @@ src/client/index.jsx client 源码(React,settings.section + 侧栏 DOM 增
|
|
|
149
151
|
src/auto-archive.js 自动归档设置(schema v4)+ 候选判定纯函数
|
|
150
152
|
src/storage-stats.js 存储占用聚合(纯函数,按工作区 / Top N)
|
|
151
153
|
src/lineage.js 血缘分类与空白会话判定(纯函数,事件类型法)
|
|
154
|
+
src/empty-scan-index.js 空白精判结论的磁盘缓存(跨重启复用,指纹 + TTL 双闸门)
|
|
152
155
|
build.mjs esbuild 构建脚本(本地开发时生成 lib/)
|
|
153
156
|
lib/index.js 预构建 host(ESM)
|
|
154
157
|
lib/client.js 预构建 client(ModuleLoader CJS handshake)
|
|
@@ -179,10 +182,18 @@ lib/client.js 预构建 client(ModuleLoader CJS handshake)
|
|
|
179
182
|
| POST | `/archived-sessions/move-many` | 批量跨工作区移动 `{ sessionIds, targetPath }`——单条失败不阻断,失败明细逐条回报,被占用的会话进 `queued` 列表,末尾统一重建索引 |
|
|
180
183
|
| POST | `/archived-sessions/pending-moves` | 查看待移动队列(会话被占用时排队,释放后自动完成) |
|
|
181
184
|
| POST | `/archived-sessions/pending-moves/cancel` | 取消排队 `{ sessionIds }` |
|
|
182
|
-
| POST | `/archived-sessions/
|
|
183
|
-
| POST | `/archived-sessions/
|
|
185
|
+
| POST | `/archived-sessions/pending-moves/notices/ack` | 确认排队移动终局通知(展示后清理;未确认项最长保留 7 天) |
|
|
186
|
+
| POST | `/archived-sessions/details` | 会话详情(磁盘/统计/工具/fetch/文件/血缘)`{ sessionId }` |
|
|
187
|
+
| POST | `/archived-sessions/sidebar-state` | 返回侧栏权威标题、回收站 ID、永久删除墓碑、**血缘分层**(子代理 / 分支 / 空白标记)、`warmPending` / `refinePending`(标题预热、空白精判两条后台队列是否仍在途)与 `moveNotices`(排队移动终局通知,空则省略字段) |
|
|
184
188
|
| POST | `/archived-sessions/lineage-tree` | 递归子代理树(面板血缘分组与侧栏折叠的数据源),已过滤回收站与墓碑 |
|
|
185
189
|
| POST | `/archived-sessions/star/set` | 收藏 / 取消收藏 `{ sessionId 或 sessionIds, starred }` |
|
|
190
|
+
| POST | `/archived-sessions/tags/list` | 标签定义 + 会话→标签映射 `{ tags, assignments }` |
|
|
191
|
+
| POST | `/archived-sessions/tags/create` | 新建标签 `{ name }`(重名/超 200 拒绝,错误带 code) |
|
|
192
|
+
| POST | `/archived-sessions/tags/rename` | 重命名 `{ id, name }`(id 不变) |
|
|
193
|
+
| POST | `/archived-sessions/tags/merge` | 并入 `{ fromId, toId }`(去重合并后源标签消失) |
|
|
194
|
+
| POST | `/archived-sessions/tags/delete` | 删除标签 `{ id }`(只删定义与映射,不碰会话) |
|
|
195
|
+
| POST | `/archived-sessions/tags/set` | 全量设置某会话的标签 `{ sessionId, tagIds }` |
|
|
196
|
+
| POST | `/archived-sessions/filters/list` / `save` / `delete` | 筛选预设 `{ name, filters }`(≤20;filters 为不透明载荷) |
|
|
186
197
|
| GET | `/archived-sessions/export-md?sessionId=` | 单会话 Markdown 导出(人类可读对话记录) |
|
|
187
198
|
| POST | `/archived-sessions/storage` | 存储占用聚合(按工作区排行 + 最大的会话)`{ topN }` |
|
|
188
199
|
| POST | `/archived-sessions/auto-archive/settings` | 读取或更新自动归档策略 `{ inactiveDays, skipStarred }`;读取时惰性触发每日检查 |
|
|
@@ -197,21 +208,21 @@ lib/client.js 预构建 client(ModuleLoader CJS handshake)
|
|
|
197
208
|
- DSH Desktop / web 均可(同一套 host + client)。
|
|
198
209
|
- peerDependencies 见 `package.json`;`react`、`@deepseek-ai/*` 由 DSH 运行时提供。
|
|
199
210
|
- `0.1.2-rc.1`:现有读取、归档、回收站、永久删除和跨工作区移动能力保持可用。
|
|
200
|
-
- `0.1.3-alpha.1`:支持 snapshot 列表和 `SessionHandle`
|
|
201
|
-
- `0.1.5-rc.1`(当前 runtime
|
|
211
|
+
- `0.1.3-alpha.1`:支持 snapshot 列表和 `SessionHandle` 只读流程;永久删除与跨工作区移动经由守卫式路径推导 + 写所有权探测开放(见下文),无法安全验证时自动禁用,其余管理能力不受影响。能力以面板实际提示为准。
|
|
212
|
+
- `0.1.5-rc.1` / `0.1.5-rc.2`(当前 runtime,两版对本插件的接口逐字节一致,已分别实测):会话日志格式升级到 **v3**,本插件已适配——按**最高代**读取(与官方一致)、v0/v2/v3 多代共存、跟随 `SessionHandle.read()` 的新返回结构
|
|
202
213
|
(`{ eventState, events }`)、跨工作区移动按**整目录搬运**并自动回收被取代的旧代副本;被 DSH 打开着的会话改为**排队延迟移动**(见上文「移动活跃会话」)。
|
|
203
214
|
- 未经验证的未来 Runtime 默认只开放能够识别的安全能力;插件不会用方法存在与否冒充行为兼容。
|
|
204
215
|
|
|
205
|
-
###
|
|
216
|
+
### 新版 Runtime(SessionHandle 世代,`0.1.3+`)的行为差异与降级说明
|
|
206
217
|
|
|
207
218
|
- **回收站恢复需要校验**:恢复前会确认底层会话仍存在(live / `stat` / 列表三级判定)。底层会话已不存在(`DSM_SESSION_MISSING`)、已被彻底删除(`DSM_SESSION_PURGED`)或索引仍在但日志文件消失(`DSM_SESSION_LOG_MISSING`)时返回准确错误;无法核验日志位置时如实标注 `unverified`,不会假装校验通过。恢复到「工作区已删除」的会话会成功并提示其暂归「未分组」。
|
|
208
219
|
- **彻底删除 / 清空回收站 / 自动物理清理**:官方公共契约未提供删除 API,插件沿用 legacy 时代的半官方路线——从后端实例的存储根目录字段出发做**三层守卫式路径推导**(根目录 → 会话目录结构 → 会话 ID 归属校验),通过后整目录删除并以官方 `stat` 复核;存在活跃写入的会话会被拒绝(409)。推导失败(如无法确认存储根目录)时自动禁用并说明原因,绝不盲删。
|
|
209
220
|
- **跨工作区移动**:主路径为官方 `create` + `append` 事件重放(写所有权探测会拒绝**被 DSH 占用写权限**的会话、revision 前后校验防并发写入、备份回滚保证失败不留半移动状态);后端存在同 ID 幽灵记录时回退到 frame0 cwd 改写搬运(帧数与内容逐位校验)。路径同样来自守卫式推导;移动后自动重建工作区分组索引,无需重启。Runtime `0.1.5` 起会话日志会**多代共存**(官方发布新代时保留旧代,如 `session.jsonl.zstd` + `session.v2.jsonl.zstd` + `session.v3.jsonl.zstd`),而官方按「同一 ID 只能落在一个项目目录」校验——因此移动是**整目录搬运**:先把源会话目录整体移开(对官方扫描彻底不可见),目标侧重放校验成功后再删除源目录;顺带**自动回收**其它项目目录里被取代的旧代副本(历史移动残留),避免同一会话永久卡在「跨目录重复」而无法移动或删除。
|
|
210
221
|
- **彻底删除墓碑不压制新会话**:若同 ID 会话被重新创建,墓碑自动让位,新会话正常出现在列表与侧栏。
|
|
211
|
-
-
|
|
222
|
+
- **元数据缓存**:判断会话日志有没有变化,新 Runtime 用官方快照的 `revision`(仅同一进程内可比,绝不写进跨重启的缓存文件),旧 Runtime 用文件 `(mtime, size)` 指纹。列表的目录 / 创建时间直接来自快照会话头,不需要读日志;标题也不在页面加载时现读——缓存里没有就先留空显示,后台分批补齐后自动刷出。**读取失败与「会话确实没有标题」严格区分**:失败不写入任何缓存,稍后自动重试(该会话日志一变就立刻再试),偶发一次失败不会让会话永久显示「(无标题)」。
|
|
212
223
|
- **自动归档**:新 Runtime 不提供可靠的「最后活跃时间」,无法证明会话闲置时检查会跳过(`no-activity-data`),绝不基于猜测归档。
|
|
213
224
|
- **侧栏注入**:DOM / React fiber 识别收敛为可版本化的 adapter;上游侧栏结构不被识别时整体安全停用,不影响官方侧栏本身。识别正常时以 MutationObserver 增量驱动为主,仅保留低频兜底检查。
|
|
214
|
-
- **血缘分层**:子代理会话以官方头部字段识别(`origin: 'subagent'`、`parentSession`、`delegationDepth`);上游侧栏不渲染子代理行与空白会话,插件据此把子代理行就地注入父会话下、把空白行隐藏。空白判定用**事件类型法**——`0.1.3` 创建会话时恒写一帧生命周期元数据(`permission/preset` / `sandbox/mode` / `approval/policy`),体积阈值法失效;插件对压缩体积 ≤8KB
|
|
225
|
+
- **血缘分层**:子代理会话以官方头部字段识别(`origin: 'subagent'`、`parentSession`、`delegationDepth`);上游侧栏不渲染子代理行与空白会话,插件据此把子代理行就地注入父会话下、把空白行隐藏。空白判定用**事件类型法**——`0.1.3` 创建会话时恒写一帧生命周期元数据(`permission/preset` / `sandbox/mode` / `approval/policy`),体积阈值法失效;插件对压缩体积 ≤8KB 的候选走官方解码精判,头部之外无内容事件才判空白,解码失败按非空兜底。结果按会话 + 跨重启稳定的体积指纹缓存并落盘(只有真解码成功的结论才持久化),日志没变就不重复读;精判在独立的后台小队列进行(批间让出事件循环),侧栏数据的返回始终零解码。
|
|
215
226
|
|
|
216
227
|
## License
|
|
217
228
|
|