@leiyi-works/dsh-feature-tweaks 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +7 -5
  2. package/client.js +69 -36
  3. package/index.js +30 -2
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  - **在右侧边栏打开(0.6.0)**:点左侧「功能微调」会先回到当前会话,再在右侧原生边栏打开面板,会话保持可见;再次点入口会聚焦该标签页。右侧边栏不可用(例如某些精简宿主)时自动退回原来的全页面板。
17
17
  - **功能微调首次有设置页**:六项功能各带一个开关,保存后立即生效,写入本机 profile 的 `cordis.patch.yml`,换机随云端同步带走。
18
18
  - **文件夹数据沿用**:仍保存在 `<DSH_HOME>/data/menu-folders.json`,旧配置无需迁移。
19
- - **隐私名单沿用**:仍保存在 `<DSH_HOME>/session-log-privacy.json`,已排除的会话无需重新设置。
19
+ - **隐私名单沿用**:仍保存在 `<DSH_HOME>/session-log-privacy.json`,已排除的会话无需重新设置。合并后的 0.7.1 会自动把旧文件夹里残留的 `session-log-privacy` 成员项清掉(旧入口 id 只在文件夹里留了记录,插件已经不存在)。
20
20
  - **不再覆盖官方 `agent-team` 行**:新会话默认开团队协作改由本包自己实现,所以能随时开关。
21
21
 
22
22
  ## 功能微调(标签页 1)
@@ -50,29 +50,31 @@
50
50
  - 旧包 `dsh-menu-folders` 的状态文件(`menu-folders.json`)与更早的 `sidebar-folders.json` 都会被自动沿用。
51
51
  - 0.6.1 排版:每个入口行左侧留出缩进(文件夹内成员与未收纳菜单项都缩进),名称/标题在左,上移/下移/重命名/删除等按钮和「收纳到…」下拉固定在同一行右侧;「新建文件夹」按钮在左、文件夹名称输入框在它右侧。
52
52
  - 0.6.2 排版:文件夹标题行也有整行 hover 灰底(和成员行一致);未收纳菜单项的缩进与文件夹内成员对齐;「新建文件夹」输入框在左、按钮在右。
53
+ - 0.7.2 显示规则:文件夹(下拉、管理页、会话标题栏)只列出**当前真实存在**的入口;插件被停用/卸载后残留的收纳记录不再显示成英文 id,而是折叠成一行「另有 N 个入口当前不可用……插件恢复后会自动回来」,记录本身不删。
53
54
 
54
55
  ## 隐私模式(标签页 3)
55
56
 
56
57
  - 作用:**单独禁止指定会话**随官方 DeepSeek API 请求上传 session log(`dsh_session_log` 附加会话日志字段);其他会话照常上传,开关对下一个模型请求生效。
57
58
  - 用法:在当前会话对应的行上打开开关即排除;「已排除的会话」列表可取消排除(取消前二次确认,因为排除期间记录的内容会在下一次请求补传)。
59
+ - 刷新规则:和「临时目录」面板一致——打开即读取,页签可见时每 5 秒静默刷新一次,切回页签立即刷新;没有刷新按钮,页面也不显示更新时间和名单文件路径。
58
60
  - 名单保存在 `<DSH_HOME>/session-log-privacy.json`;已删除的会话会在读取名单时自动清理。旧隐私模式插件的名单文件直接被沿用。
59
61
  - **边界**:这里只阻止「额外会话日志字段」上传,模型请求本身的对话上下文(messages)仍会发给官方 API——这是推理必需。若文件完全不能出本机,请改用本地模型或非官方 provider。
60
62
 
61
63
  ## 安装
62
64
 
63
65
  ```powershell
64
- dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.7.0
66
+ dsh plugin --profile <profile> add @leiyi-works/dsh-feature-tweaks@0.7.2
65
67
  ```
66
68
 
67
69
  装完后确认 profile 的 `dsh.profile.bundles` 含 `@leiyi-works/dsh-feature-tweaks`,并且**不再**含 `@leiyi-works/dsh-menu-folders`、`@leiyi-works/dsh-session-log-privacy`(后两个已合并进本包)。**重启 DSH** 生效。
68
70
 
69
- 从 0.6.x 升级:本包升到 0.7.0,从 profile 依赖与 bundles 里移除 `@leiyi-works/dsh-session-log-privacy`,重启即可;隐私名单、文件夹、开关配置都不需要迁移。
71
+ 从 0.6.x 升级:本包升到 0.7.2,从 profile 依赖与 bundles 里移除 `@leiyi-works/dsh-session-log-privacy`,重启即可;隐私名单、文件夹、开关配置都不需要迁移。
70
72
 
71
- 从 0.5.0 升级:本包升到 0.7.0、重启即可,开关和文件夹配置都不用迁移(左侧入口点开后改为右侧边栏面板)。
73
+ 从 0.5.0 升级:本包升到 0.7.2、重启即可,开关和文件夹配置都不用迁移(左侧入口点开后改为右侧边栏面板)。
72
74
 
73
75
  从 0.4.x + 旧插件升级:
74
76
 
75
- 1. 本包升到 0.7.0;
77
+ 1. 本包升到 0.7.2;
76
78
  2. 从 profile 依赖与 `dsh.profile.bundles` 里移除 `@leiyi-works/dsh-menu-folders` 和 `@leiyi-works/dsh-session-log-privacy`;
77
79
  3. 重启;文件夹、隐私名单、开关默认值都保持原状,不需要迁移配置。
78
80
 
package/client.js CHANGED
@@ -48,7 +48,7 @@ window.__ModuleLoader__.load({
48
48
  try { ReactDOM = require('react-dom') } catch { ReactDOM = null }
49
49
 
50
50
  /** Bundle version reported in diagnostics (kept in step with package.json). */
51
- const VERSION = '0.7.0'
51
+ const VERSION = '0.7.2'
52
52
  /** Locale namespace of the feature half. */
53
53
  const NS = 'featureTweaks'
54
54
  /** Locale namespace of the folder half. */
@@ -300,6 +300,7 @@ window.__ModuleLoader__.load({
300
300
  'folders.down': '下移',
301
301
  'folders.delete': '删除',
302
302
  'folders.noMembers': '这个文件夹还没有收纳任何入口。',
303
+ 'folders.hiddenMembers': '另有 {n} 个入口当前不可用(插件被停用或卸载),暂不显示;插件恢复后会自动回来。',
303
304
  'entries.section': '未收纳的菜单项',
304
305
  'entries.empty': '所有菜单项都已收纳进文件夹。',
305
306
  'entries.moveTo': '收纳到…',
@@ -324,6 +325,7 @@ window.__ModuleLoader__.load({
324
325
  'folders.down': 'Down',
325
326
  'folders.delete': 'Delete',
326
327
  'folders.noMembers': 'This folder holds no entries yet.',
328
+ 'folders.hiddenMembers': '{n} collected entries are currently unavailable (their plugin is disabled or uninstalled) and stay hidden; they come back when the plugin returns.',
327
329
  'entries.section': 'Uncollected entries',
328
330
  'entries.empty': 'Every menu entry is already collected.',
329
331
  'entries.moveTo': 'Collect into…',
@@ -361,9 +363,6 @@ window.__ModuleLoader__.load({
361
363
  loadFailed: '读取失败:{message}',
362
364
  saveFailed: '保存失败:{message}',
363
365
  retry: '重试',
364
- refresh: '刷新',
365
- fileLabel: '名单文件',
366
- updatedAt: '更新于 {time}',
367
366
  excludedAt: '排除于 {time}',
368
367
  currentBadge: '当前',
369
368
  hint: '排除名单保存在本机文件,改完即时生效;已删除的会话会自动从名单移除。',
@@ -394,9 +393,6 @@ window.__ModuleLoader__.load({
394
393
  loadFailed: 'Load failed: {message}',
395
394
  saveFailed: 'Save failed: {message}',
396
395
  retry: 'Retry',
397
- refresh: 'Refresh',
398
- fileLabel: 'List file',
399
- updatedAt: 'Updated {time}',
400
396
  excludedAt: 'Excluded {time}',
401
397
  currentBadge: 'Current',
402
398
  hint: 'The exclusion list is a local file and changes apply immediately; deleted sessions drop out of the list automatically.',
@@ -1109,6 +1105,9 @@ window.__ModuleLoader__.load({
1109
1105
  // 隐私模式标签页(合并自 dsh-session-log-privacy)
1110
1106
  // ------------------------------------------------------------------
1111
1107
 
1108
+ /** Refresh interval of the privacy tab (same policy as the 临时目录 panel). */
1109
+ const PRIVACY_REFRESH_MS = 5000
1110
+
1112
1111
  /** Presentation shared by the embedded privacy pane. */
1113
1112
  const PRIVACY = {
1114
1113
  warn: {
@@ -1291,6 +1290,26 @@ window.__ModuleLoader__.load({
1291
1290
  }))
1292
1291
  }
1293
1292
 
1293
+ /**
1294
+ * Folder members whose panel is currently registered.
1295
+ *
1296
+ * Stored ids of disabled or uninstalled plugins stay in the folder data so
1297
+ * they come back when the plugin returns, but they must never render as a
1298
+ * raw English id: every folder view lists only live panels.
1299
+ * @param folder - folder row (or undefined).
1300
+ * @param panelById - live panellist index.
1301
+ * @returns live member panels in stored order.
1302
+ */
1303
+ function liveFolderMembers(folder, panelById) {
1304
+ if (folder === undefined) return []
1305
+ const members = []
1306
+ for (const id of folder.panelIds) {
1307
+ const panel = panelById.get(id)
1308
+ if (panel !== undefined) members.push(panel)
1309
+ }
1310
+ return members
1311
+ }
1312
+
1294
1313
  /** A plain session title with the untitled fallback. */
1295
1314
  function privacyTitleOf(session, tp) {
1296
1315
  const title = session !== null && typeof session === 'object' && typeof session.title === 'string' ? session.title.trim() : ''
@@ -1319,29 +1338,43 @@ window.__ModuleLoader__.load({
1319
1338
  const [error, setError] = React.useState(null)
1320
1339
  const [busyId, setBusyId] = React.useState(undefined)
1321
1340
  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
-
1341
+ // Read the current translator from a ref so the polling effect keeps its
1342
+ // identity while locale changes still reach error messages.
1343
+ const tpRef = React.useRef(tp)
1344
+ tpRef.current = tp
1345
+
1346
+ // Same refresh policy as the 临时目录 panel: initial load, a silent 5 s
1347
+ // poll while the page is visible, and an immediate refresh when the tab
1348
+ // becomes visible again. No manual refresh button.
1328
1349
  React.useEffect(() => {
1329
1350
  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
- })
1351
+ const load = async (quiet) => {
1352
+ try {
1353
+ const next = await fetchPrivacyState()
1354
+ if (cancelled) return
1355
+ setState(next)
1356
+ setError(null)
1357
+ } catch (reason) {
1358
+ if (cancelled || quiet) return
1359
+ setState(null)
1360
+ setError(tpRef.current('loadFailed', { message: String(reason instanceof Error ? reason.message : reason) }))
1361
+ }
1362
+ }
1363
+ void load(false)
1364
+ const timer = window.setInterval(() => {
1365
+ if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return
1366
+ void load(true)
1367
+ }, PRIVACY_REFRESH_MS)
1368
+ const onVisible = () => {
1369
+ if (typeof document === 'undefined' || document.visibilityState !== 'hidden') void load(true)
1370
+ }
1371
+ if (typeof document !== 'undefined') document.addEventListener('visibilitychange', onVisible)
1341
1372
  return () => {
1342
1373
  cancelled = true
1374
+ window.clearInterval(timer)
1375
+ if (typeof document !== 'undefined') document.removeEventListener('visibilitychange', onVisible)
1343
1376
  }
1344
- }, [reloadToken, sessionSignature])
1377
+ }, [sessionSignature])
1345
1378
 
1346
1379
  const rows = list !== undefined && list !== null && list.byId !== undefined && list.byId !== null ? Object.values(list.byId) : []
1347
1380
  // The side tab knows its own Session through the scoped slot props; the
@@ -1455,11 +1488,7 @@ window.__ModuleLoader__.load({
1455
1488
  })
1456
1489
 
1457
1490
  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}`),
1491
+ state === null ? null : h('div', null, tp('excludedCount', { n: excluded.length })),
1463
1492
  h('div', null, tp('hint')))
1464
1493
 
1465
1494
  return h('div', { className: 'twhPane' },
@@ -1577,7 +1606,7 @@ window.__ModuleLoader__.load({
1577
1606
  const open = ui.expandedFolderId === folderId
1578
1607
  const panels = snapshot.panels.filter((panel) => panel.id !== 'plugins' && !panel.id.startsWith(FOLDER_PANEL_PREFIX))
1579
1608
  const panelById = new Map(panels.map((panel) => [panel.id, panel]))
1580
- const members = folder === undefined ? [] : folder.panelIds.map((id) => panelById.get(id) || { id, label: id })
1609
+ const members = liveFolderMembers(folder, panelById)
1581
1610
  return h('span', {
1582
1611
  className: 'sfbRowGlyph',
1583
1612
  'data-sfb-row': folderId,
@@ -1723,7 +1752,7 @@ window.__ModuleLoader__.load({
1723
1752
  }, [ui.headerFolderId, folders, anchor])
1724
1753
  if (folders.length === 0) return null
1725
1754
  const openFolder = menu === null ? undefined : folders.find((folder) => folder.id === menu.folderId)
1726
- const members = openFolder === undefined ? [] : openFolder.panelIds.map((id) => panelById.get(id) || { id, label: id })
1755
+ const members = liveFolderMembers(openFolder, panelById)
1727
1756
  const chips = folders.map((folder) => h('button', {
1728
1757
  key: 'chip:' + folder.id,
1729
1758
  ref: (node) => {
@@ -1782,7 +1811,7 @@ window.__ModuleLoader__.load({
1782
1811
  */
1783
1812
  function FoldersPage(props) {
1784
1813
  const runtime = props.runtime
1785
- const locale = (key) => (typeof props.t === 'function' ? props.t(key) : key)
1814
+ const locale = (key, vars) => (typeof props.t === 'function' ? props.t(key, vars) : key)
1786
1815
  const snapshot = React.useSyncExternalStore(runtime.subscribe, runtime.getSnapshot, runtime.getSnapshot)
1787
1816
  const [newDraft, setNewDraft] = React.useState('')
1788
1817
  const [editingId, setEditingId] = React.useState(null)
@@ -1812,7 +1841,8 @@ window.__ModuleLoader__.load({
1812
1841
  }
1813
1842
 
1814
1843
  const folderCard = (folder) => {
1815
- const members = folder.panelIds.map((id) => panelById.get(id) || { id, label: id })
1844
+ const members = liveFolderMembers(folder, panelById)
1845
+ const hiddenCount = folder.panelIds.length - members.length
1816
1846
  const renaming = editingId === folder.id
1817
1847
  const memberRow = (panel, index) => h('div', {
1818
1848
  key: 'member:' + panel.id,
@@ -1854,7 +1884,10 @@ window.__ModuleLoader__.load({
1854
1884
  h('div', { className: 'sfbFolderBody' },
1855
1885
  members.length === 0
1856
1886
  ? h('div', { className: 'sfbMuted' }, locale('folders.noMembers'))
1857
- : members.map((panel, index) => memberRow(panel, index))))
1887
+ : members.map((panel, index) => memberRow(panel, index)),
1888
+ hiddenCount > 0
1889
+ ? h('div', { className: 'sfbMuted' }, locale('folders.hiddenMembers', { n: hiddenCount }))
1890
+ : null))
1858
1891
  }
1859
1892
 
1860
1893
  const entryRow = (panel) => h('div', { key: 'entry:' + panel.id, className: 'sfbEntryRow' },
@@ -1917,7 +1950,7 @@ window.__ModuleLoader__.load({
1917
1950
  const folder = snapshot.folders.find((item) => item.id === folderId)
1918
1951
  const panels = snapshot.panels.filter((panel) => panel.id !== 'plugins' && !panel.id.startsWith(FOLDER_PANEL_PREFIX))
1919
1952
  const panelById = new Map(panels.map((panel) => [panel.id, panel]))
1920
- const members = folder === undefined ? [] : folder.panelIds.map((id) => panelById.get(id) || { id, label: id })
1953
+ const members = liveFolderMembers(folder, panelById)
1921
1954
  return h('div', { className: 'sfbRoot' },
1922
1955
  h('div', { className: 'sfbInner' },
1923
1956
  h('div', { className: 'sfbHeader' },
package/index.js CHANGED
@@ -39,7 +39,7 @@ import z from '@deepseek-ai/schemastery'
39
39
  export const name = 'feature-tweaks'
40
40
 
41
41
  /** Reported by /status; keep in sync with package.json. */
42
- const VERSION = '0.7.0'
42
+ const VERSION = '0.7.2'
43
43
  /** Package name; used to locate this row's profile entry id for settings writes. */
44
44
  const PACKAGE_NAME = '@leiyi-works/dsh-feature-tweaks'
45
45
  const LOG_TAG = 'dsh-feature-tweaks'
@@ -221,6 +221,14 @@ function legacyStateFile() {
221
221
  return path.join(home, 'data', 'sidebar-folders.json')
222
222
  }
223
223
 
224
+ /**
225
+ * Panel ids of plugins that were merged into this bundle and no longer register
226
+ * a panel of their own. Their ids may still sit in a folder's member list from
227
+ * the merged package (0.7.0 merges session-log-privacy), where they would only
228
+ * render as a raw English id; folder reads drop them and rewrite the file.
229
+ */
230
+ const RETIRED_PANEL_IDS = new Set(['session-log-privacy'])
231
+
224
232
  /** Normalize one untrusted folder row, returning null when unusable. */
225
233
  function sanitizeFolder(raw) {
226
234
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return null
@@ -231,6 +239,7 @@ function sanitizeFolder(raw) {
231
239
  if (Array.isArray(raw.panelIds)) {
232
240
  for (const value of raw.panelIds) {
233
241
  if (typeof value !== 'string' || value === '' || value.length > MAX_PANEL_ID) continue
242
+ if (RETIRED_PANEL_IDS.has(value)) continue
234
243
  if (panelIds.includes(value)) continue
235
244
  panelIds.push(value)
236
245
  if (panelIds.length >= MAX_PANELS_PER_FOLDER) break
@@ -285,7 +294,19 @@ async function readLegacyState() {
285
294
  async function readState() {
286
295
  try {
287
296
  const text = await fsp.readFile(stateFile(), 'utf8')
288
- return sanitizeState(JSON.parse(text))
297
+ const raw = JSON.parse(text)
298
+ const state = sanitizeState(raw)
299
+ // A retired panel id is removed from the file once, so the menu no longer
300
+ // shows it as a raw id after a plugin was merged into this bundle.
301
+ const before = JSON.stringify(raw !== null && typeof raw === 'object' && Array.isArray(raw.folders) ? raw.folders : [])
302
+ if (before !== JSON.stringify(state.folders)) {
303
+ try {
304
+ await writeState(state)
305
+ } catch (error) {
306
+ void appendDiag('folder-migrate-persist-failed: ' + String(error?.message ?? error))
307
+ }
308
+ }
309
+ return state
289
310
  } catch {
290
311
  const migrated = await readLegacyState()
291
312
  return migrated === null ? { version: STATE_VERSION, folders: [] } : migrated
@@ -725,6 +746,13 @@ export function apply(ctx, config) {
725
746
  installPrivacyExclusion(ctx, privacy)
726
747
  void appendDiag(`privacy-store-ready: ${privacy.file}`)
727
748
 
749
+ // One-time folder-data migration at boot: drop member ids of plugins that were
750
+ // merged into this bundle (their panels no longer register, and the leftover id
751
+ // would only render as a raw English id inside the folder dropdown).
752
+ void readState().catch((error) => {
753
+ void appendDiag('folder-migrate-failed: ' + String(error?.message ?? error))
754
+ })
755
+
728
756
  // ── 刷新前的安全探针需要知道哪些 Client bundle 重建过 ─────────────────────
729
757
  const rebuiltClientIds = new Set()
730
758
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leiyi-works/dsh-feature-tweaks",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "title": "功能微调",
6
6
  "description": "功能微调:DSH 跨版本的功能/默认值与界面微调合集,一个包管两类最小侵入调整,不改任何核心包。0.5.0 起并入「菜单文件夹」、0.7.0 起并入「隐私模式」:左侧菜单只留一个入口,页面内分「功能微调 / 菜单文件夹 / 隐私模式」三个标签页;功能微调提供六项开关(隐藏右栏展开按钮、隐藏「⋯」导出菜单、会话列表默认展开、刷新页面快捷键、桌面端退出忽略定时任务确认、新会话默认开启团队协作),设置即时生效并保存在本机 profile。0.6.0 起入口点开后在右侧原生边栏打开、不遮挡会话,右侧边栏不可用时退回全页面板。0.6.2 菜单文件夹排版:入口行缩进、按钮/下拉在标题右侧。隐私模式标签页按会话禁止 session-log 上传(名单沿用 <DSH_HOME>/session-log-privacy.json)。",