@leiyi-works/dsh-feature-tweaks 0.6.2 → 0.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.md CHANGED
@@ -1,20 +1,22 @@
1
1
  # @leiyi-works/dsh-feature-tweaks · 功能微调
2
2
 
3
- > DeepSeek Harness(DSH)插件:**功能微调**与**菜单文件夹**合并后的单包。左侧菜单只留一个「功能微调」入口,点开后在**右侧原生边栏**打开(不遮挡会话,和 AI视频 / 临时目录 / 自动重启一致),面板内分「功能微调 / 菜单文件夹」两个标签页,各自是独立的设置页;功能微调的各项功能从此都能在页面里开关。右侧边栏不可用时退回全页面板。不改任何核心包。
3
+ > DeepSeek Harness(DSH)插件:**功能微调**、**菜单文件夹**与**隐私模式**合并后的单包。左侧菜单只留一个「功能微调」入口,点开后在**右侧原生边栏**打开(不遮挡会话,和 AI视频 / 临时目录 / 自动重启一致),面板内分「功能微调 / 菜单文件夹 / 隐私模式」三个标签页,各自是独立的设置页;功能微调的各项功能从此都能在页面里开关。右侧边栏不可用时退回全页面板。不改任何核心包。
4
4
 
5
- ## 这个版本管什么(0.6.x)
5
+ ## 这个版本管什么(0.7.x)
6
6
 
7
- 0.5.0 把原来的两个插件合并成一个;0.6.0 把入口的打开方式改成右侧边栏面板:
7
+ 0.5.0 把「菜单文件夹」合并进来;0.6.0 把入口改成右侧边栏面板;0.7.0 再把「隐私模式」合并为第三个标签页:
8
8
 
9
9
  | 原来 | 现在 |
10
10
  |---|---|
11
11
  | `@leiyi-works/dsh-feature-tweaks` 0.4.x(功能微调) | 本包的「功能微调」标签页 |
12
12
  | `@leiyi-works/dsh-menu-folders` 0.16.0(菜单文件夹) | 本包的「菜单文件夹」标签页 |
13
+ | `@leiyi-works/dsh-session-log-privacy` 0.1.1(隐私模式) | 本包的「隐私模式」标签页 |
13
14
 
14
- - **入口只放在左侧菜单**:原来的「设置 → 菜单文件夹」设置页不再注册,统一从这个入口进入。
15
+ - **入口只放在左侧菜单**:原来的「设置 → 菜单文件夹」、隐私模式插件自己的左侧入口都不再注册,统一从这个入口进入。
15
16
  - **在右侧边栏打开(0.6.0)**:点左侧「功能微调」会先回到当前会话,再在右侧原生边栏打开面板,会话保持可见;再次点入口会聚焦该标签页。右侧边栏不可用(例如某些精简宿主)时自动退回原来的全页面板。
16
17
  - **功能微调首次有设置页**:六项功能各带一个开关,保存后立即生效,写入本机 profile 的 `cordis.patch.yml`,换机随云端同步带走。
17
18
  - **文件夹数据沿用**:仍保存在 `<DSH_HOME>/data/menu-folders.json`,旧配置无需迁移。
19
+ - **隐私名单沿用**:仍保存在 `<DSH_HOME>/session-log-privacy.json`,已排除的会话无需重新设置。
18
20
  - **不再覆盖官方 `agent-team` 行**:新会话默认开团队协作改由本包自己实现,所以能随时开关。
19
21
 
20
22
  ## 功能微调(标签页 1)
@@ -49,21 +51,30 @@
49
51
  - 0.6.1 排版:每个入口行左侧留出缩进(文件夹内成员与未收纳菜单项都缩进),名称/标题在左,上移/下移/重命名/删除等按钮和「收纳到…」下拉固定在同一行右侧;「新建文件夹」按钮在左、文件夹名称输入框在它右侧。
50
52
  - 0.6.2 排版:文件夹标题行也有整行 hover 灰底(和成员行一致);未收纳菜单项的缩进与文件夹内成员对齐;「新建文件夹」输入框在左、按钮在右。
51
53
 
54
+ ## 隐私模式(标签页 3)
55
+
56
+ - 作用:**单独禁止指定会话**随官方 DeepSeek API 请求上传 session log(`dsh_session_log` 附加会话日志字段);其他会话照常上传,开关对下一个模型请求生效。
57
+ - 用法:在当前会话对应的行上打开开关即排除;「已排除的会话」列表可取消排除(取消前二次确认,因为排除期间记录的内容会在下一次请求补传)。
58
+ - 名单保存在 `<DSH_HOME>/session-log-privacy.json`;已删除的会话会在读取名单时自动清理。旧隐私模式插件的名单文件直接被沿用。
59
+ - **边界**:这里只阻止「额外会话日志字段」上传,模型请求本身的对话上下文(messages)仍会发给官方 API——这是推理必需。若文件完全不能出本机,请改用本地模型或非官方 provider。
60
+
52
61
  ## 安装
53
62
 
54
63
  ```powershell
55
- dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.6.2
64
+ dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.7.0
56
65
  ```
57
66
 
58
- 装完后确认 profile 的 `dsh.profile.bundles` 含 `@leiyi-works/dsh-feature-tweaks`,并且**不再**含 `@leiyi-works/dsh-menu-folders`(合并后旧的菜单文件夹包应卸载)。**重启 DSH** 生效。
67
+ 装完后确认 profile 的 `dsh.profile.bundles` 含 `@leiyi-works/dsh-feature-tweaks`,并且**不再**含 `@leiyi-works/dsh-menu-folders`、`@leiyi-works/dsh-session-log-privacy`(后两个已合并进本包)。**重启 DSH** 生效。
68
+
69
+ 从 0.6.x 升级:本包升到 0.7.0,从 profile 依赖与 bundles 里移除 `@leiyi-works/dsh-session-log-privacy`,重启即可;隐私名单、文件夹、开关配置都不需要迁移。
59
70
 
60
- 从 0.5.0 升级:本包升到 0.6.2、重启即可,开关和文件夹配置都不用迁移(左侧入口点开后改为右侧边栏面板)。
71
+ 从 0.5.0 升级:本包升到 0.7.0、重启即可,开关和文件夹配置都不用迁移(左侧入口点开后改为右侧边栏面板)。
61
72
 
62
- 从 0.4.x + dsh-menu-folders 升级:
73
+ 从 0.4.x + 旧插件升级:
63
74
 
64
- 1. 本包升到 0.6.2;
65
- 2. 从 profile 依赖与 `dsh.profile.bundles` 里移除 `@leiyi-works/dsh-menu-folders`;
66
- 3. 重启;文件夹、开关默认值都保持原状,不需要迁移配置。
75
+ 1. 本包升到 0.7.0;
76
+ 2. 从 profile 依赖与 `dsh.profile.bundles` 里移除 `@leiyi-works/dsh-menu-folders` 和 `@leiyi-works/dsh-session-log-privacy`;
77
+ 3. 重启;文件夹、隐私名单、开关默认值都保持原状,不需要迁移配置。
67
78
 
68
79
  ## 接口(本机回环)
69
80
 
@@ -77,12 +88,14 @@ dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.6.2
77
88
  | `POST /__dsh-feature-tweaks/diag` | Client 半边写一行诊断日志,返回 `{ ok: true }` |
78
89
  | `GET/POST /__dsh-feature-tweaks/state` | 菜单文件夹配置 `{ version, folders }` |
79
90
  | `GET/POST /__dsh-feature-tweaks/ghosts` | 幽灵会话(磁盘已删、Host 仍在内存)的探测与归档 |
91
+ | `GET /__dsh-feature-tweaks/privacy/state` | 隐私排除名单 `{ ok, file, updatedAt, excluded }`(读取时顺带清理已删除会话) |
92
+ | `POST /__dsh-feature-tweaks/privacy/set` | `{ sessionId, excluded, title?, cwd? }`:增删排除名单,返回最新状态 |
80
93
 
81
94
  ## 实现机制
82
95
 
83
96
  - `cordis.patch.yml` —— bundle patch:只插入本包 Host 行(不再覆盖 `agent-team` 行)。
84
- - `index.js` —— Host 行 `feature-tweaks`:功能开关读写(settings 服务)+ SSE/配置/诊断路由 + 刷新安全探针 + 退出确认包装 + 新会话默认团队 + 菜单文件夹状态与幽灵会话路由。
85
- - `client.js` —— Web 侧半边:左侧「功能微调」入口(点开在右侧原生边栏打开,带全页面板兜底)、双标签页、功能开关页、菜单文件夹全部界面、界面类隐藏规则、会话列表自动展开、刷新快捷键、SSE 订阅 + 兜底轮询。
97
+ - `index.js` —— Host 行 `feature-tweaks`:功能开关读写(settings 服务)+ SSE/配置/诊断路由 + 刷新安全探针 + 退出确认包装 + 新会话默认团队 + 菜单文件夹状态与幽灵会话路由 + 隐私排除名单与 session-log 上传排除。
98
+ - `client.js` —— Web 侧半边:左侧「功能微调」入口(点开在右侧原生边栏打开,带全页面板兜底)、三标签页、功能开关页、菜单文件夹全部界面、隐私模式界面、界面类隐藏规则、会话列表自动展开、刷新快捷键、SSE 订阅 + 兜底轮询。
86
99
  - `locale/{zh,en}.json` —— 插件页显示名与介绍。
87
100
 
88
101
  ## 撤回
@@ -90,7 +103,8 @@ dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.6.2
90
103
  - **整体**:从 profile 的 `dsh.profile.bundles` 移除本包,回到官方默认;
91
104
  - **单项**:在设置页把对应开关关掉即可(写回 profile patch);
92
105
  - **菜单文件夹**:把文件夹删掉、把收纳项移出,即回到原生左侧菜单;
93
- - **旧包**:`@leiyi-works/dsh-menu-folders` 已并入本包,不需要也不再更新。
106
+ - **隐私模式**:把「已排除的会话」逐个取消排除即可;
107
+ - **旧包**:`@leiyi-works/dsh-menu-folders`、`@leiyi-works/dsh-session-log-privacy` 都已并入本包,不需要也不再更新。
94
108
 
95
109
  ## 已知限制
96
110
 
@@ -102,6 +116,7 @@ dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.6.2
102
116
  - 新会话默认团队只作用于 `startup` 来源的根会话;`resume`/`clear`/`compact` 与子智能体会话不套用。
103
117
  - 右侧边栏面板依赖宿主提供 `sidebarRightTabs` / `sidebarRight` 两个客户端服务;没有它们的精简宿主会自动退回全页面板(功能不变,只是占满主区域)。
104
118
  - 面板变窄时(右侧边栏)文件夹管理页的操作按钮会换行,属窄栏适配,不是布局错误。
119
+ - 隐私模式只作用于本机名单里的会话;模型请求本身的对话内容仍会发给官方 API(推理必需),隐私模式不改变这一点。
105
120
 
106
121
  ## License
107
122
 
package/client.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Client half of @leiyi-works/dsh-feature-tweaks (0.5.0, merged with Menu Folders).
2
+ * Client half of @leiyi-works/dsh-feature-tweaks (0.7.0, merged with Menu Folders
3
+ * and Session Log Privacy).
3
4
  *
4
- * One bundle now owns both halves:
5
+ * One bundle now owns three parts:
5
6
  *
6
7
  * 一、功能微调(原 dsh-feature-tweaks + dsh-ui-tweaks)
7
8
  * 1) 隐藏会话头部右上角的右侧栏展开按钮。选择器只用 ui-sidebar-right 写在
@@ -21,9 +22,15 @@
21
22
  * · 会话标题栏右上角的文件夹入口与「更多」按钮同一行对齐。
22
23
  * · 管理页从「设置 → 菜单文件夹」搬进本插件左侧入口的「菜单文件夹」标签页。
23
24
  *
24
- * 入口(左侧菜单只有一个「功能微调」图标):`sidebar.panellist` 行 + `main` 页面,
25
- * 页面内分「功能微调 / 菜单文件夹」两个标签页,各自是独立设置页。功能微调的开关
26
- * 写 Host 的 settings 服务(profile 的 cordis.patch.yml),保存后立即生效。
25
+ * 三、隐私模式(原 dsh-session-log-privacy 0.1.1)
26
+ * · 按会话禁止随官方 DeepSeek API 请求上传 session log;名单走 Host 路由
27
+ * `/__dsh-feature-tweaks/privacy/*`,文件仍是 <DSH_HOME>/session-log-privacy.json。
28
+ * · 在标签页里对当前会话开关,并列出/取消已排除会话(取消前二次确认)。
29
+ *
30
+ * 入口(左侧菜单只有一个「功能微调」图标):`sidebar.panellist` 行 + 右侧原生边栏
31
+ * 标签页(`main` 页面仅作为右侧边栏不可用时的兜底),页面内分「功能微调 / 菜单
32
+ * 文件夹 / 隐私模式」三个标签页,各自是独立设置页。功能微调的开关写 Host 的
33
+ * settings 服务(profile 的 cordis.patch.yml),保存后立即生效。
27
34
  *
28
35
  * 配置通过 SSE(`/__dsh-feature-tweaks/events`)热更新,SSE 不可用时退回慢轮询
29
36
  * (`/__dsh-feature-tweaks/config`)。上游若改了属性名,按钮会保持可见并在控制台
@@ -41,11 +48,13 @@ window.__ModuleLoader__.load({
41
48
  try { ReactDOM = require('react-dom') } catch { ReactDOM = null }
42
49
 
43
50
  /** Bundle version reported in diagnostics (kept in step with package.json). */
44
- const VERSION = '0.6.2'
51
+ const VERSION = '0.7.0'
45
52
  /** Locale namespace of the feature half. */
46
53
  const NS = 'featureTweaks'
47
54
  /** Locale namespace of the folder half. */
48
55
  const NS_MENU = 'menuFolders'
56
+ /** Locale namespace of the privacy half. */
57
+ const NS_PRIVACY = 'sessionLogPrivacy'
49
58
  /** Host route prefix owned by the Host half. */
50
59
  const API_PREFIX = '__dsh-feature-tweaks/'
51
60
  /** Id of the single left-menu entry and the main page it opens. */
@@ -226,6 +235,7 @@ window.__ModuleLoader__.load({
226
235
  'page.hint': 'DSH 跨版本的功能与界面微调。下面的开关保存后立即生效,写入本机 profile 并随云端同步;右侧「菜单文件夹」标签页管理左侧菜单文件夹。',
227
236
  'tab.features': '功能微调',
228
237
  'tab.folders': '菜单文件夹',
238
+ 'tab.privacy': '隐私模式',
229
239
  'group.interface': '界面',
230
240
  'group.behavior': '操作与退出',
231
241
  'group.team': '智能体协作',
@@ -254,6 +264,7 @@ window.__ModuleLoader__.load({
254
264
  'page.hint': 'Cross-version behaviour and UI tweaks for DSH. Each switch applies at once, is stored in this machine profile, and travels with cloud sync. The Menu folders tab manages the folders in the left menu.',
255
265
  'tab.features': 'Feature tweaks',
256
266
  'tab.folders': 'Menu folders',
267
+ 'tab.privacy': 'Privacy mode',
257
268
  'group.interface': 'Interface',
258
269
  'group.behavior': 'Shortcuts and quitting',
259
270
  'group.team': 'Agent teams',
@@ -324,6 +335,72 @@ window.__ModuleLoader__.load({
324
335
  'more.note': 'Collected entries are not listed in this menu; open them from their folder. Manage them in Feature tweaks → Menu folders.',
325
336
  'save.failed': 'Folder settings did not sync; changes stay on this page for now.',
326
337
  }
338
+ /** Simplified Chinese dictionary of the privacy half (merged dsh-session-log-privacy). */
339
+ const zhPrivacy = {
340
+ panel: '隐私模式',
341
+ title: '隐私模式',
342
+ subtitle:
343
+ '单独禁止指定会话随官方 DeepSeek API 请求上传 session log(完整会话日志字段);其他会话不受影响,开关对下一个模型请求生效。',
344
+ warningTitle: '边界说明',
345
+ warningText:
346
+ '这里只阻止“额外会话日志字段”的上传:模型请求本身的对话上下文(messages)仍会发给官方 API,这是推理必需。若公司文件完全不能出本机,需要改用本地模型或非官方 provider。',
347
+ currentSection: '当前会话',
348
+ excludedSection: '已排除的会话',
349
+ noSession: '当前没有打开的会话。先在左侧打开要处理的会话,再回到这里开关。',
350
+ untitled: '未命名会话',
351
+ blockCurrent: '禁止本会话上传 session log',
352
+ currentBlocked: '已生效:本会话不会再上传 session log',
353
+ currentAllowed: '本会话正常上传 session log',
354
+ remove: '取消排除',
355
+ removeConfirm: '取消后,排除期间记录的内容会在下一次请求中补传。确认取消?',
356
+ confirmRemove: '仍要取消',
357
+ cancel: '取消',
358
+ excludedEmpty: '还没有排除任何会话。',
359
+ excludedCount: '已排除 {n} 个会话',
360
+ loading: '正在读取名单…',
361
+ loadFailed: '读取失败:{message}',
362
+ saveFailed: '保存失败:{message}',
363
+ retry: '重试',
364
+ refresh: '刷新',
365
+ fileLabel: '名单文件',
366
+ updatedAt: '更新于 {time}',
367
+ excludedAt: '排除于 {time}',
368
+ currentBadge: '当前',
369
+ hint: '排除名单保存在本机文件,改完即时生效;已删除的会话会自动从名单移除。',
370
+ }
371
+ /** English dictionary, complete against the zhPrivacy key set. */
372
+ const enPrivacy = {
373
+ panel: 'Privacy Mode',
374
+ title: 'Privacy Mode',
375
+ subtitle:
376
+ 'Block the extra session-log upload for chosen sessions on official DeepSeek API requests, while every other session stays unaffected. A change applies to the next model request.',
377
+ warningTitle: 'Scope',
378
+ warningText:
379
+ 'Only the extra session-log field is blocked. The model request itself still sends the conversation context (messages) to the official API — that is required for inference. If company files must never leave this machine, use a local model or a non-official provider.',
380
+ currentSection: 'Current session',
381
+ excludedSection: 'Excluded sessions',
382
+ noSession: 'No session is open. Open the session you want to protect in the sidebar, then come back here.',
383
+ untitled: 'Untitled session',
384
+ blockCurrent: 'Block session-log upload for this session',
385
+ currentBlocked: 'Active: this session no longer uploads its session log',
386
+ currentAllowed: 'This session uploads its session log',
387
+ remove: 'Remove exclusion',
388
+ removeConfirm: 'Removing lets the next request upload everything recorded while it was excluded. Remove anyway?',
389
+ confirmRemove: 'Remove anyway',
390
+ cancel: 'Cancel',
391
+ excludedEmpty: 'No session is excluded yet.',
392
+ excludedCount: '{n} excluded session(s)',
393
+ loading: 'Reading the list…',
394
+ loadFailed: 'Load failed: {message}',
395
+ saveFailed: 'Save failed: {message}',
396
+ retry: 'Retry',
397
+ refresh: 'Refresh',
398
+ fileLabel: 'List file',
399
+ updatedAt: 'Updated {time}',
400
+ excludedAt: 'Excluded {time}',
401
+ currentBadge: 'Current',
402
+ hint: 'The exclusion list is a local file and changes apply immediately; deleted sessions drop out of the list automatically.',
403
+ }
327
404
 
328
405
  /** Fallback translator used until the locale service hands over its bound one. */
329
406
  function fallbackTranslator(dictionary, ns) {
@@ -338,6 +415,8 @@ window.__ModuleLoader__.load({
338
415
  let t = fallbackTranslator(zh)
339
416
  /** Live folder translator. */
340
417
  let tMenu = fallbackTranslator(zhMenu)
418
+ /** Live privacy translator. */
419
+ let tPrivacy = fallbackTranslator(zhPrivacy)
341
420
 
342
421
  // ------------------------------------------------------------------
343
422
  // Shared helpers
@@ -1026,8 +1105,378 @@ window.__ModuleLoader__.load({
1026
1105
  h('p', { className: 'twhFootnote' }, props.t('footnote.saved')))
1027
1106
  }
1028
1107
 
1108
+ // ------------------------------------------------------------------
1109
+ // 隐私模式标签页(合并自 dsh-session-log-privacy)
1110
+ // ------------------------------------------------------------------
1111
+
1112
+ /** Presentation shared by the embedded privacy pane. */
1113
+ const PRIVACY = {
1114
+ warn: {
1115
+ display: 'flex',
1116
+ flexDirection: 'column',
1117
+ gap: 4,
1118
+ borderLeft: '3px solid var(--dsw-alias-state-warn-primary)',
1119
+ background: 'var(--dsw-alias-bg-layer-2)',
1120
+ borderRadius: '0 8px 8px 0',
1121
+ padding: '10px 14px',
1122
+ },
1123
+ warnTitle: { fontSize: 12, fontWeight: 600, color: 'var(--dsw-alias-label-primary)' },
1124
+ warnText: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },
1125
+ card: {
1126
+ border: '1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.22))',
1127
+ borderRadius: 10,
1128
+ background: 'var(--dsw-alias-bg-layer-1, transparent)',
1129
+ overflow: 'hidden',
1130
+ },
1131
+ cardHead: {
1132
+ display: 'flex',
1133
+ alignItems: 'center',
1134
+ justifyContent: 'space-between',
1135
+ gap: 12,
1136
+ padding: '10px 16px',
1137
+ borderBottom: '1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.22))',
1138
+ },
1139
+ cardTitle: { fontSize: 13, fontWeight: 600 },
1140
+ row: {
1141
+ display: 'flex',
1142
+ alignItems: 'center',
1143
+ justifyContent: 'space-between',
1144
+ gap: 16,
1145
+ padding: '12px 16px',
1146
+ borderTop: '1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.22))',
1147
+ flexWrap: 'wrap',
1148
+ },
1149
+ rowMain: { minWidth: 0, display: 'flex', flexDirection: 'column', gap: 2, flex: '1 1 200px' },
1150
+ rowTitle: { fontSize: 14, lineHeight: '20px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
1151
+ rowMeta: {
1152
+ fontSize: 12,
1153
+ lineHeight: '16px',
1154
+ color: 'var(--dsw-alias-label-secondary)',
1155
+ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
1156
+ overflow: 'hidden',
1157
+ textOverflow: 'ellipsis',
1158
+ whiteSpace: 'nowrap',
1159
+ },
1160
+ status: { fontSize: 12, lineHeight: '18px' },
1161
+ button: {
1162
+ fontSize: 12,
1163
+ lineHeight: '18px',
1164
+ padding: '3px 10px',
1165
+ borderRadius: 6,
1166
+ border: '1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.35))',
1167
+ background: 'transparent',
1168
+ color: 'var(--dsw-alias-label-primary)',
1169
+ cursor: 'pointer',
1170
+ flex: '0 0 auto',
1171
+ },
1172
+ buttonPrimary: {
1173
+ fontSize: 12,
1174
+ lineHeight: '18px',
1175
+ padding: '3px 10px',
1176
+ borderRadius: 6,
1177
+ border: '1px solid var(--dsw-alias-state-error-primary, #d14a4a)',
1178
+ background: 'transparent',
1179
+ color: 'var(--dsw-alias-state-error-primary, #d14a4a)',
1180
+ cursor: 'pointer',
1181
+ flex: '0 0 auto',
1182
+ },
1183
+ confirm: {
1184
+ display: 'flex',
1185
+ alignItems: 'center',
1186
+ gap: 8,
1187
+ flexWrap: 'wrap',
1188
+ justifyContent: 'flex-end',
1189
+ maxWidth: 420,
1190
+ },
1191
+ confirmText: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-warn-primary)', flex: '1 1 200px', textAlign: 'right' },
1192
+ empty: { fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-secondary)', padding: '14px 16px' },
1193
+ foot: { display: 'flex', flexDirection: 'column', gap: 4, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },
1194
+ mono: { fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace', wordBreak: 'break-all' },
1195
+ error: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary, #d14a4a)', whiteSpace: 'pre-wrap' },
1196
+ badge: {
1197
+ fontSize: 11,
1198
+ lineHeight: '16px',
1199
+ padding: '0 6px',
1200
+ borderRadius: 999,
1201
+ color: 'var(--dsw-alias-brand-primary)',
1202
+ border: '1px solid var(--dsw-alias-brand-primary)',
1203
+ },
1204
+ }
1205
+
1206
+ /** Format a millisecond timestamp as local `YYYY-MM-DD HH:mm`. */
1207
+ function privacyFormatTime(value) {
1208
+ const date = new Date(Number(value))
1209
+ if (Number.isNaN(date.getTime())) return '—'
1210
+ const pad = (part) => String(part).padStart(2, '0')
1211
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`
1212
+ }
1213
+
1214
+ /** Short display form of one Session id. */
1215
+ function privacyShortId(sessionId) {
1216
+ const value = String(sessionId)
1217
+ const body = value.startsWith('session-') ? value.slice('session-'.length) : value
1218
+ return body.length > 12 ? `${body.slice(0, 8)}…${body.slice(-4)}` : body
1219
+ }
1220
+
1221
+ /** Read the Host privacy exclusion state. */
1222
+ async function fetchPrivacyState() {
1223
+ const response = await fetch(apiUrl('privacy/state'), { headers: { accept: 'application/json' } })
1224
+ if (!response.ok) throw new Error(`HTTP ${response.status}`)
1225
+ const data = await response.json()
1226
+ if (data === null || typeof data !== 'object' || data.ok !== true) throw new Error('unexpected response')
1227
+ return data
1228
+ }
1229
+
1230
+ /** Ask the Host to add or remove one privacy exclusion. */
1231
+ async function postPrivacyExclusion(body) {
1232
+ const response = await fetch(apiUrl('privacy/set'), {
1233
+ method: 'POST',
1234
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
1235
+ body: JSON.stringify(body),
1236
+ })
1237
+ let data
1238
+ try {
1239
+ data = JSON.parse(await response.text())
1240
+ } catch {
1241
+ data = undefined
1242
+ }
1243
+ if (!response.ok || data === null || typeof data !== 'object' || data.ok !== true) {
1244
+ const detail = data !== undefined && typeof data.error === 'string' ? data.error : `HTTP ${response.status}`
1245
+ throw new Error(detail)
1246
+ }
1247
+ return data
1248
+ }
1249
+
1250
+ /** One accessible switch of the privacy pane. */
1251
+ function PrivacySwitch(props) {
1252
+ const checked = props.checked === true
1253
+ const disabled = props.disabled === true
1254
+ return h('button', {
1255
+ type: 'button',
1256
+ role: 'switch',
1257
+ 'aria-checked': checked,
1258
+ 'aria-label': props.label,
1259
+ title: props.label,
1260
+ disabled,
1261
+ onClick: () => {
1262
+ if (!disabled) props.onChange(!checked)
1263
+ },
1264
+ style: {
1265
+ width: 36,
1266
+ height: 20,
1267
+ flex: '0 0 auto',
1268
+ position: 'relative',
1269
+ borderRadius: 999,
1270
+ border: 'none',
1271
+ padding: 0,
1272
+ background: checked ? 'var(--dsw-alias-brand-primary, #4f7cff)' : 'var(--dsw-alias-border-l2, rgba(127,127,127,.35))',
1273
+ opacity: disabled ? 0.45 : 1,
1274
+ cursor: disabled ? 'default' : 'pointer',
1275
+ transition: 'background 120ms ease',
1276
+ },
1277
+ },
1278
+ h('span', {
1279
+ 'aria-hidden': true,
1280
+ style: {
1281
+ position: 'absolute',
1282
+ top: 2,
1283
+ left: checked ? 18 : 2,
1284
+ width: 16,
1285
+ height: 16,
1286
+ borderRadius: 999,
1287
+ background: '#ffffff',
1288
+ boxShadow: '0 1px 2px rgba(0, 0, 0, 0.25)',
1289
+ transition: 'left 120ms ease',
1290
+ },
1291
+ }))
1292
+ }
1293
+
1294
+ /** A plain session title with the untitled fallback. */
1295
+ function privacyTitleOf(session, tp) {
1296
+ const title = session !== null && typeof session === 'object' && typeof session.title === 'string' ? session.title.trim() : ''
1297
+ return title === '' ? tp('untitled') : title
1298
+ }
1299
+
1300
+ /**
1301
+ * 隐私模式标签页:当前会话开关 + 已排除会话列表。
1302
+ * Rendered inside the hub tab shell; receives the slot's session hooks.
1303
+ * @param props - slot props (`useSessions`, `sessionId`), `t`, `variant`.
1304
+ */
1305
+ function PrivacyPane(props) {
1306
+ const tp = typeof props.t === 'function' ? props.t : tPrivacy
1307
+ const pane = props.variant === 'pane'
1308
+ const rowStyle = pane ? { ...PRIVACY.row, flexWrap: 'wrap', padding: '10px 12px' } : PRIVACY.row
1309
+ const cardHeadStyle = pane ? { ...PRIVACY.cardHead, padding: '9px 12px' } : PRIVACY.cardHead
1310
+ const useSessions = typeof props.useSessions === 'function' ? props.useSessions : undefined
1311
+ const list = useSessions === undefined ? undefined : useSessions((value) => value)
1312
+ // Any membership change in the client's Session list re-reads the Host
1313
+ // state, so a deletion converges without the user pressing Refresh.
1314
+ const sessionSignature = React.useMemo(() => {
1315
+ const byId = list !== undefined && list !== null && list.byId !== undefined && list.byId !== null ? list.byId : undefined
1316
+ return byId === undefined ? '' : Object.keys(byId).sort().join('|')
1317
+ }, [list])
1318
+ const [state, setState] = React.useState(null)
1319
+ const [error, setError] = React.useState(null)
1320
+ const [busyId, setBusyId] = React.useState(undefined)
1321
+ const [pendingRemove, setPendingRemove] = React.useState(undefined)
1322
+ const [reloadToken, setReloadToken] = React.useState(0)
1323
+
1324
+ const refresh = React.useCallback(() => {
1325
+ setReloadToken((value) => value + 1)
1326
+ }, [])
1327
+
1328
+ React.useEffect(() => {
1329
+ let cancelled = false
1330
+ setError(null)
1331
+ fetchPrivacyState()
1332
+ .then((next) => {
1333
+ if (!cancelled) setState(next)
1334
+ })
1335
+ .catch((reason) => {
1336
+ if (!cancelled) {
1337
+ setState(null)
1338
+ setError(tp('loadFailed', { message: String(reason instanceof Error ? reason.message : reason) }))
1339
+ }
1340
+ })
1341
+ return () => {
1342
+ cancelled = true
1343
+ }
1344
+ }, [reloadToken, sessionSignature])
1345
+
1346
+ const rows = list !== undefined && list !== null && list.byId !== undefined && list.byId !== null ? Object.values(list.byId) : []
1347
+ // The side tab knows its own Session through the scoped slot props; the
1348
+ // full-page fallback falls back to the Session the main view retains.
1349
+ const paneSessionId = typeof props.sessionId === 'string' && props.sessionId !== '' ? props.sessionId : undefined
1350
+ const currentRow = paneSessionId !== undefined
1351
+ ? (list !== undefined && list !== null && list.byId !== undefined && list.byId !== null ? list.byId[paneSessionId] : undefined)
1352
+ : rows.find((row) => row !== null && typeof row === 'object' && ((row.retainedBy?.mainView ?? 0) > 0))
1353
+ const currentId = paneSessionId !== undefined
1354
+ ? paneSessionId
1355
+ : currentRow !== undefined && currentRow.blank !== true
1356
+ ? currentRow.id
1357
+ : undefined
1358
+ const currentSession = currentId === undefined ? undefined : (currentRow ?? { id: currentId })
1359
+ const excluded = React.useMemo(() => {
1360
+ const records = state !== null && Array.isArray(state.excluded) ? state.excluded : []
1361
+ return records.slice().sort((left, right) => (Number(right.excludedAt) || 0) - (Number(left.excludedAt) || 0))
1362
+ }, [state])
1363
+ const excludedIds = React.useMemo(() => new Set(excluded.map((record) => record.sessionId)), [excluded])
1364
+
1365
+ const mutate = async (sessionId, shouldExclude, meta) => {
1366
+ setBusyId(sessionId)
1367
+ setError(null)
1368
+ try {
1369
+ const next = await postPrivacyExclusion({ sessionId, excluded: shouldExclude, ...(meta ?? {}) })
1370
+ setState(next)
1371
+ setPendingRemove(undefined)
1372
+ } catch (reason) {
1373
+ setError(tp('saveFailed', { message: String(reason instanceof Error ? reason.message : reason) }))
1374
+ } finally {
1375
+ setBusyId(undefined)
1376
+ }
1377
+ }
1378
+
1379
+ const warning = h('div', { style: PRIVACY.warn },
1380
+ h('div', { style: PRIVACY.warnTitle }, tp('warningTitle')),
1381
+ h('div', { style: PRIVACY.warnText }, tp('warningText')))
1382
+
1383
+ const currentRowNode = (() => {
1384
+ if (currentSession === undefined) return h('div', { style: PRIVACY.empty }, tp('noSession'))
1385
+ const isExcluded = excludedIds.has(currentId)
1386
+ const busy = busyId === currentId
1387
+ const confirming = pendingRemove === currentId
1388
+ return h('div', { style: { ...rowStyle, borderTop: 'none' } },
1389
+ h('div', { style: PRIVACY.rowMain },
1390
+ h('div', { style: PRIVACY.rowTitle }, privacyTitleOf(currentSession, tp)),
1391
+ h('div', { style: PRIVACY.rowMeta }, String(currentSession.cwd ?? currentId)),
1392
+ h('div', {
1393
+ style: { ...PRIVACY.status, color: isExcluded ? 'var(--dsw-alias-state-success-primary)' : 'var(--dsw-alias-label-secondary)' },
1394
+ }, isExcluded ? tp('currentBlocked') : tp('currentAllowed'))),
1395
+ confirming
1396
+ ? h('div', { style: PRIVACY.confirm },
1397
+ h('span', { style: PRIVACY.confirmText }, tp('removeConfirm')),
1398
+ h('button', {
1399
+ type: 'button',
1400
+ style: PRIVACY.buttonPrimary,
1401
+ disabled: busy,
1402
+ onClick: () => mutate(currentId, false),
1403
+ }, tp('confirmRemove')),
1404
+ h('button', {
1405
+ type: 'button',
1406
+ style: PRIVACY.button,
1407
+ disabled: busy,
1408
+ onClick: () => setPendingRemove(undefined),
1409
+ }, tp('cancel')))
1410
+ : h(PrivacySwitch, {
1411
+ checked: isExcluded,
1412
+ disabled: busy || state === null,
1413
+ label: tp('blockCurrent'),
1414
+ onChange: (next) => {
1415
+ if (next) mutate(currentId, true, { title: privacyTitleOf(currentSession, tp), cwd: typeof currentSession.cwd === 'string' ? currentSession.cwd : undefined })
1416
+ else setPendingRemove(currentId)
1417
+ },
1418
+ }))
1419
+ })()
1420
+
1421
+ const excludedRows = excluded.length === 0
1422
+ ? [h('div', { key: 'empty', style: PRIVACY.empty }, tp('excludedEmpty'))]
1423
+ : excluded.map((record) => {
1424
+ const isCurrent = record.sessionId === currentId
1425
+ const busy = busyId === record.sessionId
1426
+ const confirming = pendingRemove === record.sessionId
1427
+ return h('div', { key: record.sessionId, style: rowStyle },
1428
+ h('div', { style: PRIVACY.rowMain },
1429
+ h('div', { style: { ...PRIVACY.rowTitle, display: 'flex', alignItems: 'center', gap: 8 } },
1430
+ h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } },
1431
+ typeof record.title === 'string' && record.title.trim() !== '' ? record.title : tp('untitled')),
1432
+ isCurrent ? h('span', { style: PRIVACY.badge }, tp('currentBadge')) : null),
1433
+ h('div', { style: PRIVACY.rowMeta }, `${privacyShortId(record.sessionId)} · ${tp('excludedAt', { time: privacyFormatTime(record.excludedAt) })}`)),
1434
+ confirming
1435
+ ? h('div', { style: PRIVACY.confirm },
1436
+ h('span', { style: PRIVACY.confirmText }, tp('removeConfirm')),
1437
+ h('button', {
1438
+ type: 'button',
1439
+ style: PRIVACY.buttonPrimary,
1440
+ disabled: busy,
1441
+ onClick: () => mutate(record.sessionId, false),
1442
+ }, tp('confirmRemove')),
1443
+ h('button', {
1444
+ type: 'button',
1445
+ style: PRIVACY.button,
1446
+ disabled: busy,
1447
+ onClick: () => setPendingRemove(undefined),
1448
+ }, tp('cancel')))
1449
+ : h('button', {
1450
+ type: 'button',
1451
+ style: PRIVACY.button,
1452
+ disabled: busy,
1453
+ onClick: () => setPendingRemove(record.sessionId),
1454
+ }, tp('remove')))
1455
+ })
1456
+
1457
+ const footer = h('div', { style: PRIVACY.foot },
1458
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, flexWrap: 'wrap' } },
1459
+ h('button', { type: 'button', style: PRIVACY.button, onClick: refresh }, tp('refresh')),
1460
+ state === null ? null : h('span', null, tp('updatedAt', { time: privacyFormatTime(state.updatedAt) })),
1461
+ state === null ? null : h('span', null, tp('excludedCount', { n: excluded.length }))),
1462
+ state === null ? null : h('div', { style: PRIVACY.mono }, `${tp('fileLabel')}: ${state.file}`),
1463
+ h('div', null, tp('hint')))
1464
+
1465
+ return h('div', { className: 'twhPane' },
1466
+ warning,
1467
+ error === null ? null : h('div', { style: PRIVACY.error }, error),
1468
+ state === null && error === null ? h('div', { style: PRIVACY.empty }, tp('loading')) : null,
1469
+ h('div', { style: PRIVACY.card },
1470
+ h('div', { style: cardHeadStyle }, h('span', { style: PRIVACY.cardTitle }, tp('currentSection'))),
1471
+ currentRowNode),
1472
+ h('div', { style: PRIVACY.card },
1473
+ h('div', { style: cardHeadStyle }, h('span', { style: PRIVACY.cardTitle }, tp('excludedSection'))),
1474
+ ...excludedRows),
1475
+ footer)
1476
+ }
1477
+
1029
1478
  /**
1030
- * The hub page: one left-menu entry, two tabs.
1479
+ * The hub page: one left-menu entry, three tabs.
1031
1480
  * Rendered either as the fallback full page (`variant: 'page'`) or as the
1032
1481
  * native right-sidebar tab body (`variant: 'pane'`).
1033
1482
  * @param props - owner props, injected `runtime`/`menuT`, locale `t`, `variant`.
@@ -1039,7 +1488,7 @@ window.__ModuleLoader__.load({
1039
1488
  const [tab, setTab] = React.useState(() => {
1040
1489
  try {
1041
1490
  const stored = localStorage.getItem(TAB_KEY)
1042
- return stored === 'folders' ? 'folders' : 'features'
1491
+ return stored === 'folders' || stored === 'privacy' ? stored : 'features'
1043
1492
  } catch {
1044
1493
  return 'features'
1045
1494
  }
@@ -1082,6 +1531,7 @@ window.__ModuleLoader__.load({
1082
1531
  const tabs = [
1083
1532
  { id: 'features', label: props.t('tab.features') },
1084
1533
  { id: 'folders', label: props.t('tab.folders') },
1534
+ { id: 'privacy', label: props.t('tab.privacy') },
1085
1535
  ]
1086
1536
  return h('div', { className: cx(pane ? 'twhPaneRoot' : 'sfbRoot') },
1087
1537
  h('div', { className: cx('twhInner', pane ? 'twhNarrow' : '') },
@@ -1106,7 +1556,9 @@ window.__ModuleLoader__.load({
1106
1556
  props.t('save.failed', { message: saveError })),
1107
1557
  tab === 'features'
1108
1558
  ? h(FeaturePane, { feature, savingKey, onToggle: toggle, t: props.t })
1109
- : h(FoldersPage, { runtime, t: menuT })))
1559
+ : tab === 'privacy'
1560
+ ? h(PrivacyPane, { ...props, variant: pane ? 'pane' : 'page', t: tPrivacy })
1561
+ : h(FoldersPage, { runtime, t: menuT })))
1110
1562
  }
1111
1563
 
1112
1564
  /**
@@ -2475,7 +2927,7 @@ window.__ModuleLoader__.load({
2475
2927
  name: 'sidebar.right.pane.tab',
2476
2928
  key: TAB_ID,
2477
2929
  locale: NS,
2478
- }, (props) => h(HubPage, { runtime, menuT, t: props.t, variant: 'pane' })))
2930
+ }, (props) => h(HubPage, { ...props, runtime, menuT, t: props.t, variant: 'pane' })))
2479
2931
  if (typeof disposeBody === 'function') disposers.push(disposeBody)
2480
2932
  if (sidebarRight !== undefined && typeof sidebarRight.openTab === 'function') {
2481
2933
  nativeOpen = () => sidebarRight.openTab(TAB_ID)
@@ -2560,12 +3012,14 @@ window.__ModuleLoader__.load({
2560
3012
  try {
2561
3013
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'feature-tweaks: dictionaries')
2562
3014
  ctx.effect(() => ctx.locale.register(NS_MENU, { zh: zhMenu, en: enMenu }), 'feature-tweaks: folder dictionaries')
3015
+ ctx.effect(() => ctx.locale.register(NS_PRIVACY, { zh: zhPrivacy, en: enPrivacy }), 'feature-tweaks: privacy dictionaries')
2563
3016
  } catch (error) {
2564
3017
  reportDiag('locale-register-failed: ' + errorText(error))
2565
3018
  }
2566
3019
  try {
2567
3020
  t = ctx.locale.bind(NS)
2568
3021
  tMenu = ctx.locale.bind(NS_MENU)
3022
+ tPrivacy = ctx.locale.bind(NS_PRIVACY)
2569
3023
  } catch (error) {
2570
3024
  reportDiag('locale-bind-failed: ' + errorText(error))
2571
3025
  }
package/cordis.patch.yml CHANGED
@@ -9,6 +9,9 @@
9
9
  # 文件夹的设置页不再出现在「设置」里。文件夹数据仍保存在
10
10
  # <DSH_HOME>/data/menu-folders.json(沿用旧文件名,旧文件夹自动沿用,无需迁移)。
11
11
  #
12
+ # 0.7.0:再并入原「隐私模式」(@leiyi-works/dsh-session-log-privacy 0.1.1),成为
13
+ # 第三个标签页。排除名单仍保存在 <DSH_HOME>/session-log-privacy.json(沿用旧文件)。
14
+ #
12
15
  # 本版本有两点与 0.4.x 不同:
13
16
  # · 不再覆盖 agent-team 行:新会话默认开团队协作改由 index.js 自己处理,因此
14
17
  # 可以在设置页里随时开关,不需要改官方行配置;
package/index.js CHANGED
@@ -21,8 +21,15 @@
21
21
  * GET/POST /__dsh-feature-tweaks/ghosts → 幽灵会话(磁盘已删、Host 仍活着)的探测与归档
22
22
  * POST /__dsh-feature-tweaks/diag → 同上(共用一条诊断日志)
23
23
  *
24
+ * 隐私模式(原 dsh-session-log-privacy):
25
+ * GET /__dsh-feature-tweaks/privacy/state → { ok, file, updatedAt, excluded: [...] }
26
+ * POST /__dsh-feature-tweaks/privacy/set → { sessionId, excluded, title?, cwd? } 增删排除名单
27
+ * · 通过 @deepseek-ai/dsh-session-log-deepseek 的 registerExclusion() 按会话排除
28
+ * dsh_session_log 上传;名单保存在 <DSH_HOME>/session-log-privacy.json(沿用旧文件)。
29
+ *
24
30
  * Diagnostics: <DSH_HOME>/data/feature-tweaks-diag.log
25
31
  */
32
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
26
33
  import fsp from 'node:fs/promises'
27
34
  import os from 'node:os'
28
35
  import path from 'node:path'
@@ -32,7 +39,7 @@ import z from '@deepseek-ai/schemastery'
32
39
  export const name = 'feature-tweaks'
33
40
 
34
41
  /** Reported by /status; keep in sync with package.json. */
35
- const VERSION = '0.6.2'
42
+ const VERSION = '0.7.0'
36
43
  /** Package name; used to locate this row's profile entry id for settings writes. */
37
44
  const PACKAGE_NAME = '@leiyi-works/dsh-feature-tweaks'
38
45
  const LOG_TAG = 'dsh-feature-tweaks'
@@ -356,6 +363,231 @@ async function archiveGhosts(ctx, sessionIds) {
356
363
  return { ok: true, archived, failed }
357
364
  }
358
365
 
366
+ // ---------------------------------------------------------------------------
367
+ // 隐私模式:按会话排除 session-log 上传(原 dsh-session-log-privacy)
368
+ // ---------------------------------------------------------------------------
369
+
370
+ /** On-disk format version of the exclusion list. */
371
+ const PRIVACY_STATE_VERSION = 1
372
+
373
+ /** Absolute path of the session-log exclusion list (kept from the merged plugin). */
374
+ function privacyStateFile() {
375
+ const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
376
+ return path.join(home, 'session-log-privacy.json')
377
+ }
378
+
379
+ /** An empty exclusion list. */
380
+ function emptyPrivacyState() {
381
+ return { version: PRIVACY_STATE_VERSION, updatedAt: Date.now(), excluded: [] }
382
+ }
383
+
384
+ /** Validate one stored/browser-provided exclusion record. */
385
+ function normalizePrivacyRecord(raw) {
386
+ if (raw === null || typeof raw !== 'object') return undefined
387
+ const sessionId = typeof raw.sessionId === 'string' ? raw.sessionId.trim() : ''
388
+ if (sessionId === '' || sessionId.length > 200) return undefined
389
+ const excludedAt = Number.isFinite(raw.excludedAt) ? Math.trunc(raw.excludedAt) : Date.now()
390
+ const record = { sessionId, excludedAt }
391
+ if (typeof raw.title === 'string' && raw.title.trim() !== '') record.title = raw.title.trim().slice(0, 300)
392
+ if (typeof raw.cwd === 'string' && raw.cwd.trim() !== '') record.cwd = raw.cwd.trim().slice(0, 1000)
393
+ return record
394
+ }
395
+
396
+ /** Sort records for display: most recently excluded first. */
397
+ function sortPrivacyRecords(records) {
398
+ return records.slice().sort((left, right) => right.excludedAt - left.excludedAt || left.sessionId.localeCompare(right.sessionId))
399
+ }
400
+
401
+ /** Read the exclusion list from disk. */
402
+ function readPrivacyState(file) {
403
+ let text
404
+ try {
405
+ text = readFileSync(file, 'utf8')
406
+ } catch (error) {
407
+ if (error !== null && typeof error === 'object' && error.code === 'ENOENT') {
408
+ return { state: emptyPrivacyState(), missing: true }
409
+ }
410
+ return { state: emptyPrivacyState(), error: String(error?.message ?? error) }
411
+ }
412
+ try {
413
+ const parsed = JSON.parse(text.replace(/^\uFEFF/, ''))
414
+ const rows = parsed !== null && typeof parsed === 'object' && Array.isArray(parsed.excluded) ? parsed.excluded : []
415
+ const records = []
416
+ for (const row of rows) {
417
+ const record = normalizePrivacyRecord(row)
418
+ if (record !== undefined) records.push(record)
419
+ }
420
+ const updatedAt = parsed !== null && typeof parsed === 'object' && Number.isFinite(parsed.updatedAt) ? parsed.updatedAt : Date.now()
421
+ return { state: { version: PRIVACY_STATE_VERSION, updatedAt, excluded: records } }
422
+ } catch (error) {
423
+ return { state: emptyPrivacyState(), error: String(error?.message ?? error) }
424
+ }
425
+ }
426
+
427
+ /** Atomically write the exclusion list. */
428
+ function writePrivacyState(file, records) {
429
+ const state = { version: PRIVACY_STATE_VERSION, updatedAt: Date.now(), excluded: sortPrivacyRecords(records) }
430
+ mkdirSync(path.dirname(file), { recursive: true })
431
+ const temporary = `${file}.tmp`
432
+ writeFileSync(temporary, `${JSON.stringify(state, null, 2)}\n`, 'utf8')
433
+ renameSync(temporary, file)
434
+ return state
435
+ }
436
+
437
+ /**
438
+ * In-memory exclusion list + its upload predicate + deletion pruning.
439
+ *
440
+ * A Session that is excluded keeps its local canonical log untouched; only the
441
+ * remote upload of the additional `dsh_session_log` field stops. Removing an
442
+ * exclusion lets the next request upload the still-unaccepted suffix.
443
+ */
444
+ function createPrivacyStore(ctx) {
445
+ const file = privacyStateFile()
446
+ /** Live exclusion list: session id → stored record. */
447
+ const excluded = new Map()
448
+ /** Latest written/read list metadata. */
449
+ let updatedAt = Date.now()
450
+
451
+ /** Reload the in-memory list from disk (creates an empty file when missing). */
452
+ const load = () => {
453
+ const result = readPrivacyState(file)
454
+ excluded.clear()
455
+ for (const record of result.state.excluded) excluded.set(record.sessionId, record)
456
+ updatedAt = result.state.updatedAt
457
+ if (result.error !== undefined) {
458
+ void appendDiag(`privacy-list-read-failed: ${result.error}`)
459
+ return
460
+ }
461
+ if (result.missing === true) {
462
+ try {
463
+ const created = writePrivacyState(file, [])
464
+ updatedAt = created.updatedAt
465
+ void appendDiag(`privacy-list-created: ${file}`)
466
+ } catch (error) {
467
+ void appendDiag(`privacy-list-create-failed: ${String(error?.message ?? error)}`)
468
+ }
469
+ }
470
+ }
471
+
472
+ /** The browser-visible state. */
473
+ const snapshot = () => ({ ok: true, file, updatedAt, excluded: sortPrivacyRecords([...excluded.values()]) })
474
+
475
+ /** Add or remove one Session and persist the list. */
476
+ const change = (sessionId, shouldExclude, meta) => {
477
+ const previous = excluded.get(sessionId)
478
+ if (shouldExclude) {
479
+ const record = normalizePrivacyRecord({
480
+ sessionId,
481
+ title: typeof meta?.title === 'string' ? meta.title : previous?.title,
482
+ cwd: typeof meta?.cwd === 'string' ? meta.cwd : previous?.cwd,
483
+ excludedAt: previous?.excludedAt ?? Date.now(),
484
+ })
485
+ if (record === undefined) throw new Error('invalid Session id')
486
+ excluded.set(sessionId, record)
487
+ } else {
488
+ excluded.delete(sessionId)
489
+ }
490
+ const state = writePrivacyState(file, [...excluded.values()])
491
+ updatedAt = state.updatedAt
492
+ return snapshot()
493
+ }
494
+
495
+ const has = (sessionId) => excluded.has(sessionId)
496
+
497
+ /** Drop records whose Session can no longer issue a model request. */
498
+ const pruneMissing = async () => {
499
+ if (excluded.size === 0) return false
500
+ const query = ctx.get('sessionQuery')
501
+ if (query === undefined || query === null || typeof query.filterSessions !== 'function') return false
502
+ let records
503
+ try {
504
+ records = await query.filterSessions([{ kind: 'id', values: [...excluded.keys()] }])
505
+ } catch (error) {
506
+ void appendDiag(`privacy-verify-failed: ${String(error?.message ?? error)}`)
507
+ return false
508
+ }
509
+ const alive = new Set()
510
+ const liveOnly = []
511
+ for (const record of Array.isArray(records) ? records : []) {
512
+ const header = record !== null && typeof record === 'object' ? record.header : undefined
513
+ const id = header !== undefined && header !== null ? header.id : undefined
514
+ if (id === undefined) continue
515
+ const sessionId = String(id)
516
+ if (record.persisted === true) alive.add(sessionId)
517
+ else if (record.live === true) liveOnly.push(sessionId)
518
+ }
519
+ // A live-only record cannot issue another request once its log is gone;
520
+ // keep it when the backend cannot answer, so an unreadable backend never
521
+ // drops a real exclusion.
522
+ const persistence = liveOnly.length === 0 ? undefined : ctx.get('sessionPersistence')
523
+ for (const sessionId of liveOnly) {
524
+ if (persistence === undefined || typeof persistence.stat !== 'function') {
525
+ alive.add(sessionId)
526
+ continue
527
+ }
528
+ try {
529
+ if (await persistence.stat(sessionId) !== undefined) alive.add(sessionId)
530
+ } catch {
531
+ alive.add(sessionId)
532
+ }
533
+ }
534
+ let changed = false
535
+ for (const sessionId of [...excluded.keys()]) {
536
+ if (alive.has(sessionId)) continue
537
+ excluded.delete(sessionId)
538
+ changed = true
539
+ void appendDiag(`privacy-dropped-deleted-session: ${sessionId}`)
540
+ }
541
+ if (!changed) return false
542
+ try {
543
+ const state = writePrivacyState(file, [...excluded.values()])
544
+ updatedAt = state.updatedAt
545
+ } catch (error) {
546
+ void appendDiag(`privacy-prune-persist-failed: ${String(error?.message ?? error)}`)
547
+ }
548
+ return true
549
+ }
550
+
551
+ load()
552
+ return { file, snapshot, change, has, pruneMissing }
553
+ }
554
+
555
+ /**
556
+ * Register the session-log upload exclusion of the privacy tab.
557
+ *
558
+ * `sessionLogDeepSeek.registerExclusion(predicate)` runs before the request
559
+ * field is prepared: a matching Session never sends `dsh_session_log` and never
560
+ * records an acceptance watermark for the skipped range.
561
+ */
562
+ function installPrivacyExclusion(ctx, privacy) {
563
+ try {
564
+ ctx.inject(['sessionLogDeepSeek'], (logCtx) => {
565
+ /** Session ids already reported once, so a busy Session logs one line only. */
566
+ const reported = new Set()
567
+ logCtx.effect(
568
+ () =>
569
+ logCtx.sessionLogDeepSeek.registerExclusion((request) => {
570
+ let sessionId
571
+ try {
572
+ sessionId = String(request.sessionId)
573
+ } catch {
574
+ return false
575
+ }
576
+ if (!privacy.has(sessionId)) return false
577
+ if (!reported.has(sessionId)) {
578
+ reported.add(sessionId)
579
+ void appendDiag(`privacy-session-excluded: ${sessionId}`)
580
+ }
581
+ return true
582
+ }),
583
+ 'feature-tweaks: privacy upload exclusion',
584
+ )
585
+ })
586
+ } catch (error) {
587
+ void appendDiag('privacy-exclusion-inject-failed: ' + String(error?.message ?? error))
588
+ }
589
+ }
590
+
359
591
  // ---------------------------------------------------------------------------
360
592
  // 功能微调:退出确认与默认团队
361
593
  // ---------------------------------------------------------------------------
@@ -445,9 +677,9 @@ function installDefaultTeamTweak(ctx, source) {
445
677
 
446
678
  /**
447
679
  * Plugin activation. Registers the merged Web routes (feature switches + folder
448
- * state + ghosts + diagnostics), wires the quit-inspection and default-team
449
- * tweaks, tracks rebuilt Client bundles for the reload probe, and broadcasts
450
- * feature settings over SSE.
680
+ * state + ghosts + privacy exclusions + diagnostics), wires the quit-inspection,
681
+ * default-team and privacy upload tweaks, tracks rebuilt Client bundles for the
682
+ * reload probe, and broadcasts feature settings over SSE.
451
683
  * @param {import('@deepseek-ai/cordis').Context} ctx - plugin context.
452
684
  * @param {object} config - validated Config value (fields may be volatile refs).
453
685
  */
@@ -488,6 +720,11 @@ export function apply(ctx, config) {
488
720
  }
489
721
  installDefaultTeamTweak(ctx, source)
490
722
 
723
+ // ── 隐私模式:排除名单 + session-log 上传排除 ─────────────────────────────
724
+ const privacy = createPrivacyStore(ctx)
725
+ installPrivacyExclusion(ctx, privacy)
726
+ void appendDiag(`privacy-store-ready: ${privacy.file}`)
727
+
491
728
  // ── 刷新前的安全探针需要知道哪些 Client bundle 重建过 ─────────────────────
492
729
  const rebuiltClientIds = new Set()
493
730
  try {
@@ -656,6 +893,55 @@ export function apply(ctx, config) {
656
893
  sendJson(response, 200, { ok: true, config: next })
657
894
  return
658
895
  }
896
+ if (route === '/privacy/state') {
897
+ if (request.method !== 'GET') {
898
+ sendJson(response, 405, { ok: false, error: 'method not allowed' })
899
+ return
900
+ }
901
+ try {
902
+ await privacy.pruneMissing()
903
+ } catch (error) {
904
+ void appendDiag('privacy-prune-failed: ' + String(error?.message ?? error))
905
+ }
906
+ sendJson(response, 200, privacy.snapshot())
907
+ return
908
+ }
909
+ if (route === '/privacy/set') {
910
+ if (request.method !== 'POST') {
911
+ sendJson(response, 405, { ok: false, error: 'method not allowed' })
912
+ return
913
+ }
914
+ let parsed
915
+ try {
916
+ parsed = JSON.parse(await readBody(request))
917
+ } catch (error) {
918
+ sendJson(response, 400, { ok: false, error: 'invalid JSON body' })
919
+ return
920
+ }
921
+ if (parsed === null || typeof parsed !== 'object') {
922
+ sendJson(response, 400, { ok: false, error: 'body must be a JSON object' })
923
+ return
924
+ }
925
+ const sessionId = typeof parsed.sessionId === 'string' ? parsed.sessionId.trim() : ''
926
+ if (sessionId === '') {
927
+ sendJson(response, 400, { ok: false, error: 'sessionId is required' })
928
+ return
929
+ }
930
+ if (typeof parsed.excluded !== 'boolean') {
931
+ sendJson(response, 400, { ok: false, error: 'excluded must be a boolean' })
932
+ return
933
+ }
934
+ try {
935
+ const next = privacy.change(sessionId, parsed.excluded === true, { title: parsed.title, cwd: parsed.cwd })
936
+ void appendDiag(`privacy-change ${parsed.excluded === true ? 'exclude' : 'include'} ${sessionId}`)
937
+ sendJson(response, 200, next)
938
+ } catch (error) {
939
+ const message = String(error?.message ?? error)
940
+ void appendDiag('privacy-change-failed: ' + message)
941
+ sendJson(response, 500, { ok: false, error: message })
942
+ }
943
+ return
944
+ }
659
945
  if (route === '/state') {
660
946
  if (request.method === 'GET') {
661
947
  sendJson(response, 200, await readState())
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Feature tweaks",
4
- "description": "Cross-version fixes for DSH behaviour, defaults and UI in one bundle, without touching any core package. Since 0.5.0 it also contains Menu Folders: the left menu has a single Feature tweaks entry whose page has two tabs, Feature tweaks and Menu folders, each with its own settings page. Since 0.6.0 that entry opens as a native right-sidebar tab beside the conversation, falling back to a full page when the right sidebar is unavailable. The Feature tweaks tab adds switches for six tweaks: hide the conversation header's right-sidebar expand button, hide the header's more-actions export menu, expand every workspace's session list by default, the Reload page shortcut (F5 on desktop, Ctrl+Shift+R on the web), quitting the desktop app without a confirmation caused only by armed scheduled tasks, and starting new root sessions with Agent Teams enabled. Changes apply immediately, persist in this machine's profile, and travel with cloud sync. The Menu folders tab manages the folders in the left menu, whose collected entries leave the More menu."
4
+ "description": "Cross-version fixes for DSH behaviour, defaults and UI in one bundle, without touching any core package. Since 0.5.0 it also contains Menu Folders and since 0.7.0 Privacy Mode: the left menu has a single Feature tweaks entry that opens as a native right-sidebar tab beside the conversation (falling back to a full page when the right sidebar is unavailable), with three tabs — Feature tweaks, Menu folders and Privacy mode — each with its own settings page. The Feature tweaks tab adds switches for six tweaks: hide the conversation header's right-sidebar expand button, hide the header's more-actions export menu, expand every workspace's session list by default, the Reload page shortcut (F5 on desktop, Ctrl+Shift+R on the web), quitting the desktop app without a confirmation caused only by armed scheduled tasks, and starting new root sessions with Agent Teams enabled. The Menu folders tab manages the folders in the left menu. The Privacy mode tab stops the extra session-log upload for chosen sessions and keeps its exclusion list on this machine. Everything applies immediately and travels with cloud sync."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "功能微调",
4
- "description": "DSH 跨版本的功能/默认值与界面微调合集,一个包管两类最小侵入调整,不改任何核心包。0.5.0 起并入「菜单文件夹」:左侧菜单只保留一个「功能微调」入口,页面内分「功能微调 / 菜单文件夹」两个标签页,各自是独立的设置页。0.6.0 起入口点开后在右侧原生边栏打开,不遮挡会话(右侧边栏不可用时退回全页面板)。功能微调标签页提供六项开关:隐藏会话右上角的右侧栏展开按钮、隐藏会话标题栏「⋯」导出菜单、左侧会话列表默认展开全部会话、刷新页面快捷键(桌面端 F5 / 网页端 Ctrl+Shift+R)、桌面端退出不再因定时任务弹确认、新会话默认开启「智能体团队协作」。开关保存后立即生效并写入本机 profile,随云端同步换机。菜单文件夹标签页管理左侧菜单文件夹与收纳项,已收纳入口从「更多」菜单移走,文件夹显示在「更多」上方。"
4
+ "description": "DSH 跨版本的功能/默认值与界面微调合集,不改任何核心包。0.5.0 起并入「菜单文件夹」、0.7.0 起并入「隐私模式」:左侧菜单只保留一个「功能微调」入口,点开后在右侧原生边栏打开(不遮挡会话,右侧边栏不可用时退回全页面板),面板内分「功能微调 / 菜单文件夹 / 隐私模式」三个标签页,各自是独立的设置页。功能微调提供六项开关:隐藏会话右上角的右侧栏展开按钮、隐藏会话标题栏「⋯」导出菜单、左侧会话列表默认展开全部会话、刷新页面快捷键(桌面端 F5 / 网页端 Ctrl+Shift+R)、桌面端退出不再因定时任务弹确认、新会话默认开启「智能体团队协作」。菜单文件夹管理左侧菜单文件夹与收纳项。隐私模式按会话禁止随官方 API 上传 session log,排除名单保存在本机。所有开关即时生效并随云端同步换机。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@leiyi-works/dsh-feature-tweaks",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "title": "功能微调",
6
- "description": "功能微调:DSH 跨版本的功能/默认值与界面微调合集,一个包管两类最小侵入调整,不改任何核心包。0.5.0 起并入「菜单文件夹」:左侧菜单只留一个入口,页面内分「功能微调 / 菜单文件夹」两个标签页;功能微调首次提供设置页,六项功能各带开关(隐藏右栏展开按钮、隐藏「⋯」导出菜单、会话列表默认展开、刷新页面快捷键、桌面端退出忽略定时任务确认、新会话默认开启团队协作),设置即时生效并保存在本机 profile。0.6.0 起入口点开后在右侧原生边栏打开、不遮挡会话,右侧边栏不可用时退回全页面板。0.6.1 菜单文件夹列表排版:入口行左侧缩进,按钮/「收纳到」下拉固定在同一行右侧。0.6.2 文件夹标题行也带整行 hover 灰底,未收纳菜单项缩进与文件夹内成员对齐,新建文件夹输入框在按钮左侧。",
6
+ "description": "功能微调:DSH 跨版本的功能/默认值与界面微调合集,一个包管两类最小侵入调整,不改任何核心包。0.5.0 起并入「菜单文件夹」、0.7.0 起并入「隐私模式」:左侧菜单只留一个入口,页面内分「功能微调 / 菜单文件夹 / 隐私模式」三个标签页;功能微调提供六项开关(隐藏右栏展开按钮、隐藏「⋯」导出菜单、会话列表默认展开、刷新页面快捷键、桌面端退出忽略定时任务确认、新会话默认开启团队协作),设置即时生效并保存在本机 profile。0.6.0 起入口点开后在右侧原生边栏打开、不遮挡会话,右侧边栏不可用时退回全页面板。0.6.2 菜单文件夹排版:入口行缩进、按钮/下拉在标题右侧。隐私模式标签页按会话禁止 session-log 上传(名单沿用 <DSH_HOME>/session-log-privacy.json)。",
7
7
  "exports": {
8
8
  ".": "./index.js",
9
9
  "./client": "./client.js",