dsh-archived-chats 0.8.1 → 0.10.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 CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  [English](README.en.md) | [中文](README.md)
4
4
 
5
- > ⚡ **Deletion takes effect immediately — no restart.** Even sessions still resident in the background are torn down safely along the official lifecycle and wiped from disk the moment you click delete, instead of being "parked until the next restart".
5
+ > 🔎 **Archived no longer means lost.** Search conversation content, read complete messages and tool calls, then back up, restore, or delete safely.
6
6
 
7
- A settings page for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) that brings archived chats back into view.
7
+ > ⚡ **Deletion takes effect immediately — no restart.** Even sessions still resident in the background are torn down safely along the official lifecycle and wiped from disk when you click delete.
8
+
9
+ A local conversation archive center for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): recover, search, read, back up, restore, or delete archived sessions.
8
10
 
9
11
  Once a conversation is archived in DeepSeek Harness it disappears from the sidebar, and there is no built-in way to browse it again — only the workspace store (`~/.dsh/storages/workspace.json`) still remembers it. This plugin adds an **Archived Chats** page under Settings where every archived session is visible, searchable, and manageable.
10
12
 
@@ -24,14 +26,15 @@ dsh plugin --profile web update dsh-archived-chats
24
26
 
25
27
  ## Compatibility
26
28
 
27
- Version 0.8.1 uses DeepSeek Harness `0.1.0-rc.7` as its automated compatibility baseline. The plugin registers a top-level `settings.section`, so the rc.7 keyed-slot change for `settings.plugin.item` does not apply to it. A local real-host UI pass was also completed on Harness `0.1.0-rc.8` for the archive list, search, metadata editor, bulk actions, group actions, and import preview. Future Harness releases should still be checked with the smoke suite and a real-host UI pass before publishing a plugin update, because client slot and design-token contracts may evolve.
29
+ Version 0.10.0 uses DeepSeek Harness `0.1.0-rc.7` as its automated compatibility baseline. The plugin registers a top-level `settings.section`, so the rc.7 keyed-slot change for `settings.plugin.item` does not apply to it. The v0.9.0 archive list, metadata, bulk actions, and backup preview were checked in a real Harness `0.1.0-rc.8` host; v0.10.0 conversation search, native-style preview, and stored-image reads were checked in a real Harness `0.1.1-rc.2` host.
28
30
 
29
- ## Screenshots
31
+ ## Preview
30
32
 
31
- These screenshots represent the 0.8.1 documentation release's unchanged 0.8.x UI and were captured in a local DeepSeek Harness web profile.
33
+ Screenshots 1–7 were captured from 0.9.0 in a local DeepSeek Harness `0.1.0-rc.8` web profile; the archived conversation preview was captured from 0.10.0 in DeepSeek Harness `0.1.1-rc.2`.
32
34
 
33
35
  ![Archived Chats overview](assets/screenshots/1-archived-chats.png)
34
36
  ![Search and filters](assets/screenshots/2-search.png)
37
+ ![Read-only archived conversation preview](assets/screenshots/8-conversation-preview.png)
35
38
  ![Delete confirmation](assets/screenshots/3-delete-confirm.png)
36
39
  ![Group actions](assets/screenshots/4-group-menu.png)
37
40
  ![Metadata editor](assets/screenshots/5-metadata-editor.png)
@@ -42,19 +45,22 @@ These screenshots represent the 0.8.1 documentation release's unchanged 0.8.x UI
42
45
 
43
46
  1. Archive a conversation from the normal DSH session menu. Archiving removes it from the sidebar but keeps its session data in the workspace store.
44
47
  2. Open **Settings → Archived Chats**. The page groups archived conversations by workspace and remembers collapsed groups in this browser.
45
- 3. Search, filter, sort, or select conversations. Open a row's metadata editor to add tags and notes, or use the group menu for workspace-level actions.
46
- 4. Use **Export backup** for one conversation, the current selection, or all archived chats. To restore a backup, choose **Import backup**, review the preview, keep the non-conflicting sessions selected, and confirm.
47
- 5. Choose **Unarchive** to return a conversation to the sidebar. Choose **Delete** only when you want permanent removal; the confirmation dialog identifies the affected scope.
48
+ 3. Search titles, tags, notes, conversation text, or tool output. Open the row preview to read an archived conversation without unarchiving it. Click **Select multiple** only when you need bulk actions.
49
+ 4. Click **Import backup** to choose a ZIP produced by this plugin and confirm non-conflicting sessions after the preview. Click **Export backup** to export the current selection, or every archived chat when nothing is selected. Individual rows also have an export action.
50
+ 5. Choose **Unarchive** to return a conversation to the sidebar. Choose **Delete** only when you want permanent removal; the confirmation dialog identifies the affected scope. **Delete All** lives under the top **More** menu.
48
51
 
49
52
  ## Features
50
53
 
51
54
  - **Complete archived-session list**, grouped by workspace (project) with a per-group count. Every group can be collapsed or expanded, and the state is remembered per browser.
52
- - **Search and sort** by title, workspace title, tags, and note text; filter by type (all / regular / subagent), project, and tag; then order results by newest, oldest, or title.
55
+ - **Full-text conversation search**: one search field matches titles, workspaces, tags, notes, user messages, assistant answers, and tool results, with a readable hit excerpt on each matching row.
56
+ - **Native archived conversation preview and turn navigation**: follow the Harness conversation layout with user messages on the right and assistant messages on the left; present Markdown, reasoning, tool activity, JSON, code, and available stored images read-only, while retaining a responsive turn rail for quick jumps. If the host lacks attachment capability, only images degrade and the rest of the preview remains readable.
57
+ - **Filter and sort** by type (all / regular / subagent), project, and tag; then order results by newest, oldest, or title.
53
58
  - **Tags and notes**: open an editor from any row to attach up to 8 tags (24 Unicode characters each) and a note (2,000 Unicode characters). Tag chips render per row, overflowing past three into a `+N` indicator, and the tag filter narrows the list case-insensitively.
54
59
  - **Storage insights**: a summary strip reports the archived count, total measured size, and how many sessions could not be measured; each row shows its own size. Measurement never follows symbolic links and skips sessions whose directories are unreadable.
55
60
  - **JSON + Markdown backups**: export one row, the current selection, or every archived chat as a ZIP. Each package has a versioned manifest, a lossless machine-readable session record, and a human-readable transcript for every included session.
56
61
  - **Preview-first import and restore**: choose a ZIP backup, inspect every session before writing, preselect only non-conflicting IDs, and restore selected sessions as archived chats. Existing IDs are skipped and never overwritten.
57
- - **Flexible multi-select**: select individual chats, every visible result, or an entire project. The selection bar can export, unarchive, or permanently delete the chosen chats in one action, while selections hidden by another filter remain intact.
62
+ - **Compact top-level actions**: common **Import backup** / **Export backup** actions are direct, while the low-frequency destructive action lives under **More**. The page stays focused on DSH archive management without a persistent source selector or redundant menus.
63
+ - **On-demand multi-select**: checkboxes stay hidden by default and appear only after clicking **Select multiple**. Select individual chats, every visible result, or an entire project; the selection bar can export, unarchive, or permanently delete the chosen chats in one action, while selections hidden by another filter remain intact.
58
64
  - **Unarchive** a single chat or a whole project group from the group's `⋯` menu — restored chats reappear in the sidebar immediately.
59
65
  - **Delete** one chat, a project group, or everything (**Delete All**), each behind a confirmation dialog. Deletion is thorough: the session log is removed from disk, the session is detached from its workspace record, and the registry's in-memory header index is purged, so the sidebar drops the rows live.
60
66
  - Sessions still resident in the background are **deleted in place too**: the plugin disposes the session through the official lifecycle teardown order (cancel → quiesce → flush → fiber teardown → registry detach), the persistence layer releases the write path, and the physical delete completes within the same request — no restart. If the running DSH build does not expose the required internal seams, the plugin falls back to "park permanently + delete on the next start", with parked sessions staying hidden meanwhile.
@@ -124,10 +130,24 @@ User-facing storage, backup limits, deletion outcomes, and compatibility notes s
124
130
  npm test
125
131
  ```
126
132
 
127
- The suite (`test/*.test.mjs`) covers export records and real ZIP decoding, bounded import validation, restore transactions, the metadata store, the statistics service, and host-and-browser smoke tests. It uses an isolated temporary DSH home plus mocked host and browser runtimes; it never reads or changes real sessions.
133
+ The suite (`test/*.test.mjs`) covers export records and real ZIP decoding, bounded import validation, restore transactions, metadata and statistics, full-text search, conversation preview, and host-and-browser smoke tests. It uses an isolated temporary DSH home plus mocked host and browser runtimes; it never reads or changes real sessions.
128
134
 
129
135
  ## Version history
130
136
 
137
+ ### 0.10.0
138
+
139
+ - Added archived conversation preview that follows the Harness conversation layout, with user messages on the right, assistant messages on the left, paginated message loading, and a responsive turn rail.
140
+ - Markdown, reasoning, tool activity, JSON, code, and available stored images are presented read-only; a missing host attachment capability affects images only, not the rest of the conversation.
141
+ - Added full-text search over Unicode conversation text and tool output, merged with the existing title/tag/note filters and displayed as row excerpts.
142
+ - Hardened preview and search with guarded local POST routes, bounded bodies and results, four-way inspection concurrency, partial-failure degradation, and a bounded TTL/LRU memory cache.
143
+
144
+ ### 0.9.0
145
+
146
+ - Added an on-demand multi-select mode: list checkboxes stay hidden until requested, then disappear automatically after a completed bulk action.
147
+ - Made common ZIP backup actions direct **Import backup / Export backup** controls and moved the destructive action under **More** for a cleaner header.
148
+ - Removed the cross-tool JSONL migration surface that could not provide native resume, keeping the plugin focused on DSH archived-chat management.
149
+ - Verified the new controls, backup preview, and single-line page title in a real DeepSeek Harness `0.1.0-rc.8` host.
150
+
131
151
  ### 0.8.1
132
152
 
133
153
  - Made the Chinese README the default repository and npm entry point; the English guide is now `README.en.md`.
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  [English](README.en.md) | 中文
4
4
 
5
- > ⚡ **删除即生效,无需重启。** 即使会话仍驻留在后台,也会沿官方生命周期当场安全拆除并从磁盘彻底删除——点下删除的那一刻就删干净,而不是"停用后等下次重启"。
5
+ > 🔎 **归档不再等于消失。** 直接搜索聊天正文、阅读完整对话和工具调用,然后安全备份、恢复或删除。
6
6
 
7
- 为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 新增一个「已归档的聊天」设置页,把被归档的会话重新找回来。
7
+ > ⚡ **删除即生效,无需重启。** 即使会话仍驻留在后台,也会沿官方生命周期当场安全拆除并从磁盘彻底删除。
8
+
9
+ 为 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 新增一个本地会话归档中心:找回、搜索、阅读、备份、恢复或删除被归档的会话。
8
10
 
9
11
  在 DeepSeek Harness 里,聊天一旦归档就会从侧边栏消失,界面中没有任何入口可以再看到它,只有工作区存档(`~/.dsh/storages/workspace.json`)还记得它。这个插件在「设置」中补上一个「已归档的聊天」页面,让所有归档会话都可见、可搜索、可管理。
10
12
 
@@ -24,14 +26,15 @@ dsh plugin --profile web update dsh-archived-chats
24
26
 
25
27
  ## 兼容性
26
28
 
27
- 0.8.1 版本以 DeepSeek Harness `0.1.0-rc.7` 作为自动化兼容性基线。插件注册的是顶层 `settings.section`,因此 rc.7 针对 `settings.plugin.item` 的 keyed-slot 变更不影响本插件;同时已在 Harness `0.1.0-rc.8` 上完成真实宿主页面复核,覆盖归档列表、搜索、元数据编辑、批量操作、分组操作和导入预览。以后 Harness 发布新版本时,仍应在发布插件更新前重跑冒烟测试并检查真实宿主页面,因为客户端插槽和设计令牌契约仍可能演进。
29
+ 0.10.0 版本以 DeepSeek Harness `0.1.0-rc.7` 作为自动化兼容性基线。插件注册的是顶层 `settings.section`,因此 rc.7 针对 `settings.plugin.item` 的 keyed-slot 变更不影响本插件。v0.9.0 的归档列表、元数据、批量操作和备份预览已在 Harness `0.1.0-rc.8` 真实宿主中复核;v0.10.0 新增的正文搜索、原生风格对话预览和已存储图片读取已在 Harness `0.1.1-rc.2` 真实宿主中复核。
28
30
 
29
- ## 截图
31
+ ## 预览
30
32
 
31
- 以下截图来自当前 `0.8.1` 文档发布对应的 `0.8.x` UI,并在本地 DeepSeek Harness Web profile 中实际操作生成;本次 patch 不改变界面行为。
33
+ 截图 1–7 来自 `0.9.0` 在本地 DeepSeek Harness `0.1.0-rc.8` Web profile 中的实际操作;归档对话预览来自 `0.10.0` 在 DeepSeek Harness `0.1.1-rc.2` 中的实际操作。
32
34
 
33
35
  ![已归档的聊天总览](assets/screenshots/1-archived-chats.png)
34
36
  ![搜索与筛选](assets/screenshots/2-search.png)
37
+ ![归档对话只读预览](assets/screenshots/8-conversation-preview.png)
35
38
  ![删除确认](assets/screenshots/3-delete-confirm.png)
36
39
  ![分组操作](assets/screenshots/4-group-menu.png)
37
40
  ![标签与备注编辑](assets/screenshots/5-metadata-editor.png)
@@ -42,19 +45,22 @@ dsh plugin --profile web update dsh-archived-chats
42
45
 
43
46
  1. 在 DSH 正常聊天的会话菜单中点击归档。归档只会把会话从侧边栏隐藏,工作区存档仍会保留会话数据。
44
47
  2. 打开 **设置 → 已归档的聊天**。页面按工作区分组,并在当前浏览器中记住分组的折叠状态。
45
- 3. 搜索、筛选、排序或选择会话;打开某一行的元数据编辑器添加标签与备注,或使用分组菜单执行项目级操作。
46
- 4. 使用 **导出备份** 导出单条、当前选中项或全部归档会话。恢复备份时点击 **导入备份**,先查看预览,保留无冲突会话的勾选状态后确认恢复。
47
- 5. 点击 **取消归档** 将会话放回侧边栏;只有确实需要永久删除时才点击 **删除**,确认弹窗会明确显示受影响的范围。
48
+ 3. 搜索标题、标签、备注、聊天正文或工具结果;点击行内预览按钮可直接阅读归档对话,无需先取消归档。需要多选时点击 **批量选择** 显示复选框。
49
+ 4. 点击顶部 **导入备份** 选择本插件导出的 ZIP,预览后确认无冲突会话;点击 **导出备份** 导出当前选中项,未选择时导出全部归档会话。单条会话也可以从行内操作导出。
50
+ 5. 点击 **取消归档** 将会话放回侧边栏;只有确实需要永久删除时才点击 **删除**,确认弹窗会明确显示受影响的范围。**全部删除** 收纳在顶部 **更多** 菜单中。
48
51
 
49
52
  ## 功能
50
53
 
51
54
  - **完整归档列表**:按工作区(项目)分组并显示每组数量;每个分组都可折叠/展开,状态按浏览器记忆。
52
- - **搜索与排序**:按标题、项目名、标签和备注内容搜索,用类型(全部 / 普通会话 / 子代理会话)、项目和标签筛选,并按最新、最早或标题排序。
55
+ - **聊天正文全文搜索**:同一个搜索框同时匹配标题、项目、标签、备注、用户消息、助手回答与工具结果,并在结果行显示命中摘要。
56
+ - **原生归档对话预览与轮次导航**:沿用 Harness 会话布局,用户消息靠右、助手消息靠左;以只读方式展示 Markdown、思考过程、工具活动、JSON、代码和可用的已存储图片,并保留可快速跳转的响应式轮次轨道。宿主缺少附件能力时只影响图片,其他预览内容仍可阅读。
57
+ - **筛选与排序**:用类型(全部 / 普通会话 / 子代理会话)、项目和标签筛选,并按最新、最早或标题排序。
53
58
  - **标签与备注**:任意行打开编辑器即可添加最多 8 个标签(每个最多 24 个 Unicode 字符)和一条备注(最多 2,000 个 Unicode 字符)。每行渲染标签小徽章,超过 3 个折叠为 `+N`,标签筛选不区分大小写。
54
59
  - **存储统计**:概览条显示归档数量、已统计总大小与无法统计的会话数;每行显示各自占用。统计不会跟随符号链接,无法读取的会话目录显示为「无法统计」而非让请求失败。
55
60
  - **JSON + Markdown 备份**:可导出单条、当前选中项或全部归档会话。每个 ZIP 都包含带版本的清单、用于机器恢复的完整会话 JSON,以及方便阅读的 Markdown 对话稿。
56
61
  - **预览后导入与恢复**:选择 ZIP 备份后先检查全部会话,默认选中无冲突 ID 的项目,确认后作为已归档聊天恢复。已有 ID 会跳过,绝不会覆盖。
57
- - **灵活多选**:逐条选择、选择当前筛选结果或选择整个项目;选中后可一次导出、取消归档或永久删除,隐藏在其他筛选结果中的选择不会丢失。
62
+ - **紧凑顶部操作**:常用的 **导入备份** / **导出备份** 直接可用,低频危险操作收纳在 **更多**;页面专注于 DSH 归档管理,不常驻来源选择器或冗余菜单。
63
+ - **按需多选**:复选框默认隐藏,点击 **批量选择** 后才显示;可逐条选择、选择当前筛选结果或整个项目。选中后可一次导出、取消归档或永久删除,隐藏在其他筛选结果中的选择不会丢失。
58
64
  - **取消归档**单个聊天,或从分组的 `⋯` 菜单整组取消——恢复的聊天会立刻回到侧边栏。
59
65
  - **删除**单个聊天、某个项目分组或全部(**全部删除**),均有确认弹窗。删除是彻底的:会话日志从磁盘移除、从工作区记录中摘除、注册表内存索引同步清理,主侧边栏的条目也会立即消失。
60
66
  - 仍驻留后台的会话也**当场删除**:插件按官方生命周期的拆除顺序原地停用并注销会话(取消 → 静默 → 落盘 → 拆纤程 → 摘出注册表),持久层随之释放写入通道,同一次请求内即完成物理删除——无需重启。若当前 DSH 版本不提供所需内部接口,则自动回退为「永久停用 + 下次启动完成删除」,停用期间会话保持隐藏。
@@ -114,7 +120,7 @@ JSON 会保留附件引用,但**本版不复制附件二进制,也不包含
114
120
 
115
121
  ## 实现概览
116
122
 
117
- 插件由两部分组成:Host 服务层负责读取和修改本地归档数据,浏览器设置页负责搜索、筛选、备份和恢复操作。所有修改都通过受保护的本地路由完成;导入会先预览,删除会优先尝试安全的生命周期拆除,能力不足时回退到下次启动处理。
123
+ 插件由两部分组成:Host 服务层负责读取和修改本地归档数据,浏览器设置页负责搜索、筛选、备份和恢复。所有修改都通过受保护的本地路由完成;导入会先预览,删除会优先尝试安全的生命周期拆除,能力不足时回退到下次启动处理。
118
124
 
119
125
  普通用户需要了解的数据保存、备份限制、删除结果和兼容性说明已列在本 README 中。路由清单、数据流、恢复事务、实时删除生命周期和失败回退等维护者细节请参阅 [架构文档](docs/ARCHITECTURE.md)。
120
126
 
@@ -124,10 +130,24 @@ JSON 会保留附件引用,但**本版不复制附件二进制,也不包含
124
130
  npm test
125
131
  ```
126
132
 
127
- 测试套件(`test/*.test.mjs`)覆盖导出记录与真实 ZIP 解包、有界导入校验、恢复事务、元数据存储、统计服务以及宿主+浏览器冒烟测试,使用隔离的临时 DSH 主目录和模拟运行时,不会读取或修改真实会话。
133
+ 测试套件(`test/*.test.mjs`)覆盖导出记录与真实 ZIP 解包、有界导入校验、恢复事务、元数据存储、统计服务、全文搜索、对话预览,以及宿主+浏览器冒烟测试。测试使用隔离的临时 DSH 主目录和模拟运行时,不会读取或修改真实会话。
128
134
 
129
135
  ## 版本更新记录
130
136
 
137
+ ### 0.10.0
138
+
139
+ - 新增遵循 Harness 会话布局的归档对话预览:用户消息靠右,助手消息靠左,并支持分页与响应式轮次导航。
140
+ - Markdown、思考过程、工具活动、JSON、代码和可用的已存储图片均以只读方式呈现;宿主缺少附件能力时只影响图片,不影响其余对话内容。
141
+ - 新增归档聊天正文全文搜索:匹配 Unicode 文本和工具结果,在原有标题/标签/备注筛选上合并命中结果。
142
+ - 搜索与预览使用受保护的本地 POST 路由、有界请求、并发 4 的读取、部分失败降级和有上限的 TTL/LRU 内存缓存。
143
+
144
+ ### 0.9.0
145
+
146
+ - 新增按需显示的批量选择模式:列表默认不展示复选框,点击入口后才显示,完成批量操作后自动退出。
147
+ - 将常用 ZIP 备份操作改为直接的 **导入备份 / 导出备份**,危险操作收纳到 **更多**,精简页头布局。
148
+ - 移除未提供原生继续能力的跨工具 JSONL 迁移入口,让插件专注于 DSH 已归档聊天管理。
149
+ - 在 DeepSeek Harness `0.1.0-rc.8` 真实宿主中复核新控件、备份预览和标题单行布局。
150
+
131
151
  ### 0.8.1
132
152
 
133
153
  - 将中文 README 设为仓库和 npm 包的默认入口,英文文档改为 `README.en.md`。
Binary file
Binary file
@@ -0,0 +1,154 @@
1
+ # Architecture and Maintainer Notes
2
+
3
+ [English](ARCHITECTURE.en.md) | [中文](ARCHITECTURE.md)
4
+
5
+ This document is for maintainers and developers who need to understand data behavior. End users should start with the repository README.md, whose installation, usage, privacy, and limitation notes take precedence.
6
+
7
+ ## Architecture boundaries
8
+
9
+ The plugin has a Host service half and a browser client half:
10
+
11
+ - The Host service in lib/index.js runs inside the DSH Web host, reads the workspace registry and session persistence, and exposes local HTTP routes.
12
+ - The browser client in lib/client.js registers the Archived Chats settings.section and renders state and actions.
13
+ - Pure domain logic lives in lib/export.js, lib/import.js, lib/restore.js, lib/metadata.js, lib/search.js, and lib/stats.js so it can be tested independently.
14
+
15
+ The browser never reads session files directly. All reads and writes go through Host routes.
16
+
17
+ ## Host routes
18
+
19
+ Current routes:
20
+
21
+ ~~~text
22
+ GET /plugins/dsh-archived-chats/state
23
+ GET /plugins/dsh-archived-chats/stats
24
+ POST /plugins/dsh-archived-chats/preview
25
+ POST /plugins/dsh-archived-chats/preview/image
26
+ POST /plugins/dsh-archived-chats/search
27
+ POST /plugins/dsh-archived-chats/export
28
+ POST /plugins/dsh-archived-chats/import/inspect
29
+ POST /plugins/dsh-archived-chats/import/restore
30
+ POST /plugins/dsh-archived-chats/metadata
31
+ POST /plugins/dsh-archived-chats/unarchive
32
+ POST /plugins/dsh-archived-chats/unarchive-all
33
+ POST /plugins/dsh-archived-chats/delete
34
+ POST /plugins/dsh-archived-chats/delete-all
35
+ ~~~
36
+
37
+ Every mutating route, plus the preview, preview/image, and search routes that return conversation content, requires the `x-dsh-archived-chats: 1` header. preview/image and export are read-only and do not modify plugin or Harness state. Unarchive writes through the workspace registry state path and broadcasts archived-sessions-changed to connected clients.
38
+
39
+ ## State and local data
40
+
41
+ The state route joins archived sessions, workspace, tags, notes, and metadataUpdatedAt for the browser list. Tags and notes are stored only at:
42
+
43
+ ~~~text
44
+ $DSH_HOME/plugin-data/archived-chats/metadata.json
45
+ ~~~
46
+
47
+ The metadata file is versioned. Writes are serialized and replace the file through a temporary-file rename. Unreadable or unsupported versions are never overwritten.
48
+
49
+ The stats route measures session directories with concurrency four, skips symbolic links, and caches results for 30 seconds. A measurement failure marks only that row unavailable; list and mutation actions continue. Delete invalidates the affected cache row.
50
+
51
+ ## Preview and full-text search
52
+
53
+ Preview and search accept only currently visible archived IDs; pending-deletion and unarchived sessions cannot be read. lib/search.js uses Harness append-origin message projection, so replacement copies are never indexed twice. User, assistant, reasoning, tool-call, and tool-result text is searchable, while preview returns bounded pages of structured segments and sanitized image descriptors.
54
+
55
+ The preview/image authorization sequence is fixed: first require POST and `x-dsh-archived-chats: 1`, then bounded-parse `sessionId` and `attachmentId`; next confirm that the session is still in the currently visible archive set, find an exact image-descriptor match in that session's canonical projection, and only then read bytes through the optional `attachments.readImage` service. Both preview and preview/image recheck visible archive state after asynchronous reads and immediately before sending a response, preventing an overlapping unarchive or delete from exposing stale content. Image bytes use `no-store` and `nosniff`; cross-session, non-archived, and unprojected references are rejected, and error responses never echo filesystem paths. A host without attachment-read capability returns `preview-image-unsupported`; this degrades images only and does not block text, Markdown, reasoning, tool, JSON, or code preview.
56
+
57
+ Cross-session persistence inspection is limited to four concurrent reads. A broken session is reported in `skipped` while other hits still succeed. Canonical projections use a 30-second TTL, a 64-session LRU, and a per-session cached-code-point cap; oversized sessions remain searchable but do not stay resident. Unarchive, delete, and restore invalidate affected cache entries.
58
+
59
+ ## Export flow
60
+
61
+ The export route accepts a bounded native form request and export.js writes a versioned ZIP:
62
+
63
+ ~~~text
64
+ manifest.json
65
+ sessions/001-safe-title-id/session.json
66
+ sessions/001-safe-title-id/transcript.md
67
+ ~~~
68
+
69
+ session.json preserves the complete metadata and event values returned by persistence, plus archive title, workspace, timestamps, origin, tags, notes, and storage facts. transcript.md is produced with Harness's canonical message projection.
70
+
71
+ ZIP paths are sanitized and collision-safe. Batch export inspects and writes sessions sequentially, retaining at most one inspected payload. Attachment references can remain in JSON, but attachment bytes and descendant sessions are outside the version-one format.
72
+
73
+ ## Import and restore flow
74
+
75
+ import/inspect accepts only version-one ZIPs produced by this plugin. Host validation is bounded and checks the manifest, paths, versions, session records, and cross-file consistency before returning a preview:
76
+
77
+ 1. The browser uploads the ZIP and receives session summaries, versions, size, and warnings.
78
+ 2. Existing session IDs are marked as conflicts and deselected by default.
79
+ 3. Unresolved workspaces and attachment references are warnings, never invented data.
80
+ 4. After confirmation, the browser submits a single-use token and selected non-conflicting IDs.
81
+ 5. restore.js uses a feature-detected adapter to write sessions, metadata, and archive state.
82
+ 6. Any failure rolls back staged data and never overwrites an existing session.
83
+
84
+ The confirmation token expires quickly and can be used once. Hosts without the supported writer capability return restore-unsupported without writing.
85
+
86
+ ## Deletion lifecycle
87
+
88
+ A cold delete confirms the physical location, removes the session log, workspace record, and registry indexes, then cleans metadata and stats caches.
89
+
90
+ For a live session, the plugin first attempts the official lifecycle order:
91
+
92
+ ~~~text
93
+ cancel(disposed)
94
+ -> whenIdle
95
+ -> flush
96
+ -> agent.scope.dispose()
97
+ -> detach agents and sessions
98
+ -> retire persistence writer
99
+ -> remove session files
100
+ ~~~
101
+
102
+ These are internal host surfaces and every call is feature-detected. If a required surface is missing, the plugin does not guess at internal objects. It records the ID in:
103
+
104
+ ~~~text
105
+ $DSH_HOME/plugin-data/archived-chats/pending-deletions.json
106
+ ~~~
107
+
108
+ The parked session remains archived and hidden, and the next boot sweeps the queue. In-place deletes use the same queue as a crash bracket: record before disposal, clear after files are confirmed gone.
109
+
110
+ ## Browser client
111
+
112
+ client.js registers an order-30 settings.section and uses the DSH rc.7 overlay, state, and design tokens. The page state includes:
113
+
114
+ - Archived sessions and workspace groups.
115
+ - Search, type/project/tag filters, and sorting.
116
+ - Tag and note editor.
117
+ - Selected-item export, unarchive, and delete.
118
+ - Import preview, disabled conflicts, and restore results.
119
+ - Responsive settings-page markers and sidebar refresh injection.
120
+
121
+ The preview prefers Harness's publicly exported `MarkdownText`, `DisclosureRow`, and `JsonBlock`. When a public primitive is unavailable, only that content falls back to escaped plain text, native `details`/`summary`, or `pre`; the plugin never reaches into a private chat renderer. A tool result folds into an earlier call only when its `toolCallId` exactly matches the call's `callId`, consuming matches in chronological order. Unmatched results remain standalone, and errors use the semantic error token. Images are read from the protected route into Blob URLs, may load lazily before entering the viewport, and abort their read and call `URL.revokeObjectURL` when the preview closes or the image node unmounts.
122
+
123
+ The turn rail remains part of the preview: on desktop it stays to the left of the feed, jumps and follows feed scrolling, and exposes the active turn through `aria-current`; at 640px or narrower it moves above the feed and scrolls horizontally while user bubbles retain useful width. It is not replaced by a private host navigation component.
124
+
125
+ The browser never mutates files directly. After an operation, the Host response becomes the new list baseline. Closing a preview or switching to another session aborts the pending request, and a request sequence ignores late responses so a closed dialog cannot reopen and an older session cannot replace the newest preview.
126
+
127
+ ## Security and failure policy
128
+
129
+ - All state-changing routes require POST and the guard header.
130
+ - Import limits ZIP size, entries, paths, versions, and JSON structure, rejecting traversal, duplicates, and prototype-pollution keys.
131
+ - Delete reports success only when the physical location is confirmed; otherwise the session and authoritative metadata remain.
132
+ - Metadata or stats outages do not disable listing, unarchive, or delete.
133
+ - Unknown host capabilities must degrade or return a clear error; they must not be inferred.
134
+
135
+ ## Compatibility and testing
136
+
137
+ The automated compatibility baseline is DeepSeek Harness 0.1.0-rc.7; the v0.9.0 surfaces received a real-host page pass on rc.8. The v0.10.0 conversation search, native-style preview, and stored-image reads received a real-host pass on 0.1.1-rc.2. When host slots, design tokens, or session internals change, run the smoke suite first and then repeat a real-host check.
138
+
139
+ Coverage includes:
140
+
141
+ - export.js records, transcripts, and ZIP streaming.
142
+ - import.js bounded validation and unsafe-path rejection.
143
+ - restore.js transactional commit, rollback, and unsupported capabilities.
144
+ - metadata.js versioning, concurrency, and atomic writes.
145
+ - stats.js symlink handling, caching, and concurrency limits.
146
+ - search.js message projection, Unicode search, pagination, partial failures, and TTL/LRU caching.
147
+ - Host routes and browser settings smoke/responsive behavior.
148
+
149
+ Run:
150
+
151
+ ~~~sh
152
+ npm test
153
+ npm pack --dry-run --json
154
+ ~~~
@@ -0,0 +1,154 @@
1
+ # 架构与维护者说明
2
+
3
+ [English](ARCHITECTURE.en.md) | 中文
4
+
5
+ 本文面向维护者和需要理解数据行为的开发者。普通用户请先阅读仓库根目录的 README.md;其中的安装、使用、隐私和限制说明优先于本文。
6
+
7
+ ## 架构边界
8
+
9
+ 插件由 Host 服务层和浏览器客户端两部分组成:
10
+
11
+ - Host 服务层位于 lib/index.js,运行在 DSH Web 宿主中,读取工作区注册表和会话持久层,并提供本地 HTTP 路由。
12
+ - 浏览器客户端位于 lib/client.js,通过 settings.section 注册「已归档的聊天」设置页,负责展示状态和发起操作。
13
+ - 纯领域逻辑拆分在 lib/export.js、lib/import.js、lib/restore.js、lib/metadata.js、lib/search.js 和 lib/stats.js 中,便于独立测试。
14
+
15
+ 浏览器不直接访问会话文件。所有读取和写入都经 Host 路由完成。
16
+
17
+ ## Host 路由
18
+
19
+ 当前注册的路由:
20
+
21
+ ~~~text
22
+ GET /plugins/dsh-archived-chats/state
23
+ GET /plugins/dsh-archived-chats/stats
24
+ POST /plugins/dsh-archived-chats/preview
25
+ POST /plugins/dsh-archived-chats/preview/image
26
+ POST /plugins/dsh-archived-chats/search
27
+ POST /plugins/dsh-archived-chats/export
28
+ POST /plugins/dsh-archived-chats/import/inspect
29
+ POST /plugins/dsh-archived-chats/import/restore
30
+ POST /plugins/dsh-archived-chats/metadata
31
+ POST /plugins/dsh-archived-chats/unarchive
32
+ POST /plugins/dsh-archived-chats/unarchive-all
33
+ POST /plugins/dsh-archived-chats/delete
34
+ POST /plugins/dsh-archived-chats/delete-all
35
+ ~~~
36
+
37
+ 所有修改路由以及会返回对话内容的 preview、preview/image、search 路由都要求 `x-dsh-archived-chats: 1` 请求头。preview/image 和 export 都是只读操作,不修改插件或 Harness 状态。取消归档通过 workspace registry 自身的状态写入路径完成,并向已连接客户端发送 archived-sessions-changed 更新。
38
+
39
+ ## 状态和本地数据
40
+
41
+ state 路由把归档会话、工作区、标签、备注和 metadataUpdatedAt 组合成浏览器列表。标签和备注只写入:
42
+
43
+ ~~~text
44
+ $DSH_HOME/plugin-data/archived-chats/metadata.json
45
+ ~~~
46
+
47
+ 元数据文件带版本号,写入通过队列串行化,并用临时文件重命名替换。无法解析或不支持的版本不会被覆盖。
48
+
49
+ stats 路由以并发 4 测量会话目录,跳过符号链接,结果缓存 30 秒。测量失败只标记当前行不可用,不阻塞列表和其他操作;删除会使对应缓存失效。
50
+
51
+ ## 预览和全文搜索
52
+
53
+ preview 和 search 只接受当前可见归档 ID,等待删除或已取消归档的会话不可读。lib/search.js 使用 Harness 的 append-origin 消息投影,不会将 replacement 副本重复索引。用户、助手、思考、工具调用与工具结果均可搜索,预览窗口以分页方式返回有界段落和净化后的图片描述符。
54
+
55
+ preview/image 的授权顺序固定为:先验证 POST 和 `x-dsh-archived-chats: 1`,再有界解析 `sessionId` 与 `attachmentId`;随后确认会话仍在当前可见归档集合中,从该会话的规范投影中查找完全匹配的图片描述符,最后才通过可选的 `attachments.readImage` 服务读取。preview 和 preview/image 都会在异步读取完成后、响应发送前再次检查可见归档状态,避免并发取消归档或删除泄露旧内容。图片字节以 `no-store`、`nosniff` 返回;跨会话、非归档或不在投影中的引用均会被拒绝,错误响应不回显文件路径。宿主没有附件读取能力时返回 `preview-image-unsupported`;这只降级图片,不阻塞文本、Markdown、思考、工具、JSON 或代码预览。
56
+
57
+ 跨会话搜索的持久层读取并发上限为 4;单个会话失败会记入 skipped,其他命中仍正常返回。规范投影使用 30 秒 TTL、64 会话 LRU 和单会话最大缓存字符数保护内存;超大会话仍可搜索,但不会常驻缓存。取消归档、删除和恢复会使相关缓存失效。
58
+
59
+ ## 导出流程
60
+
61
+ export 路由接收有界的原生表单请求,由 export.js 生成版本化 ZIP:
62
+
63
+ ~~~text
64
+ manifest.json
65
+ sessions/001-safe-title-id/session.json
66
+ sessions/001-safe-title-id/transcript.md
67
+ ~~~
68
+
69
+ session.json 保留持久层返回的完整元数据和事件,并附加归档标题、工作区、时间、来源、标签、备注和存储信息。transcript.md 使用 Harness 的规范消息投影生成。
70
+
71
+ ZIP 路径会清理遍历字符并处理重名。批量导出按会话顺序逐个检查和写入,最多保留一个已检查的会话载荷。附件引用可保留在 JSON 中,但附件二进制和子会话不属于版本一格式。
72
+
73
+ ## 导入和恢复流程
74
+
75
+ import/inspect 只接受本插件版本一导出的 ZIP。Host 会有界读取和校验 manifest、路径、版本、会话记录及跨文件一致性,然后生成预览:
76
+
77
+ 1. 浏览器上传 ZIP,Host 返回会话摘要、版本、大小和警告。
78
+ 2. 已存在的会话 ID 标记为冲突并默认取消选择。
79
+ 3. 未解析的工作区和附件引用只显示警告,不伪造数据。
80
+ 4. 用户确认后,浏览器提交一次性令牌和选中的非冲突 ID。
81
+ 5. restore.js 通过能力探测的适配器写入会话、元数据和归档状态。
82
+ 6. 任一步骤失败都回滚暂存数据,不覆盖已有会话。
83
+
84
+ 确认令牌短期有效且只能使用一次。宿主不支持写入能力时返回 restore-unsupported,不执行任何写入。
85
+
86
+ ## 删除生命周期
87
+
88
+ 删除普通冷会话时,插件确认物理位置后移除会话日志、工作区记录和注册表索引,并清理元数据和统计缓存。
89
+
90
+ 删除仍在后台运行的会话时,优先尝试官方生命周期顺序:
91
+
92
+ ~~~text
93
+ cancel(disposed)
94
+ -> whenIdle
95
+ -> flush
96
+ -> agent.scope.dispose()
97
+ -> detach agents and sessions
98
+ -> retire persistence writer
99
+ -> remove session files
100
+ ~~~
101
+
102
+ 这些是内部宿主接口,全部通过能力探测调用。宿主缺少任一必要接口时,插件不会强行操作内部对象,而是把 ID 写入:
103
+
104
+ ~~~text
105
+ $DSH_HOME/plugin-data/archived-chats/pending-deletions.json
106
+ ~~~
107
+
108
+ 待删会话保持归档并从列表隐藏,下次启动清扫队列。原地删除同样使用队列作为崩溃保护:删除前登记,文件确认移除后清除。
109
+
110
+ ## 浏览器客户端
111
+
112
+ client.js 注册 order 30 的 settings.section,并使用 DSH rc.7 的浮层、状态和设计令牌。页面状态包括:
113
+
114
+ - 归档列表和工作区分组。
115
+ - 搜索、类型/项目/标签筛选和排序。
116
+ - 标签备注编辑器。
117
+ - 选中项批量导出、取消归档和删除。
118
+ - 导入预览、冲突禁用和恢复结果。
119
+ - 响应式设置页标记和侧边栏刷新注入面。
120
+
121
+ 预览优先使用 Harness 公开导出的 `MarkdownText`、`DisclosureRow` 和 `JsonBlock`;某个公开原语不可用时,只把对应内容降级为转义的纯文本、原生 `details`/`summary` 或 `pre`,不调用私有聊天渲染器。工具结果仅在其 `toolCallId` 与更早工具调用的 `callId` 精确匹配时折叠进该调用,匹配按时间顺序消费;未匹配结果保留为独立条目,错误状态使用语义错误令牌。图片由受保护路由读取为 Blob URL,离开视口前可按需加载,预览关闭或图片节点卸载时会中止读取并调用 `URL.revokeObjectURL`。
122
+
123
+ 轮次轨道保留在预览内:桌面位于消息流左侧,跳转后随消息流滚动并用 `aria-current` 标出当前轮次;宽度不超过 640px 时轨道移到消息流上方并水平滚动,用户气泡仍保留可用宽度。轨道不会被替换为宿主私有导航组件。
124
+
125
+ 浏览器操作不会直接改变本地文件;操作完成后以 Host 返回的状态作为新的列表基线。关闭预览或切换到另一条会话会取消未完成的预览请求;客户端同时使用请求序号忽略迟到响应,避免已关闭的弹窗重新出现或旧会话覆盖新会话。
126
+
127
+ ## 安全和失败策略
128
+
129
+ - 所有状态变更路由都要求 POST 和 guard header。
130
+ - 导入限制 ZIP 大小、条目数量、路径格式、版本和 JSON 结构,拒绝遍历、重复和原型污染字段。
131
+ - 删除只在物理位置可确认时报告成功;无法确认时保留会话和权威元数据。
132
+ - 元数据或统计服务不可用时,列表、取消归档和删除仍保持可用。
133
+ - 未知宿主能力必须降级或返回明确错误,不得猜测内部对象结构。
134
+
135
+ ## 兼容性和测试
136
+
137
+ 自动化兼容性基线是 DeepSeek Harness 0.1.0-rc.7;v0.9.0 界面已在 rc.8 宿主上复核。v0.10.0 的正文搜索、原生风格对话预览与已存储图片读取已在 0.1.1-rc.2 真实宿主上复核。宿主插槽、设计令牌或会话内部接口变化时,应先运行冒烟测试,再做真实宿主检查。
138
+
139
+ 测试覆盖:
140
+
141
+ - export.js 的记录、转录和 ZIP 流。
142
+ - import.js 的有界校验和拒绝路径。
143
+ - restore.js 的事务提交、回滚和能力缺失。
144
+ - metadata.js 的版本、并发和原子写入。
145
+ - stats.js 的符号链接、缓存和并发限制。
146
+ - search.js 的消息投影、Unicode 搜索、分页、部分失败与 TTL/LRU 缓存。
147
+ - Host 路由和浏览器设置页的冒烟及响应式行为。
148
+
149
+ 运行:
150
+
151
+ ~~~sh
152
+ npm test
153
+ npm pack --dry-run --json
154
+ ~~~