dsh-config-sync-plugin 0.3.82 → 0.3.84

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/client.js CHANGED
@@ -504,7 +504,11 @@ window.__ModuleLoader__.load({
504
504
 
505
505
  /** 工作区显示状态:三态(显示 / 隐藏会话 / 归档工作区)+ 会话级独立隐藏。 */
506
506
  async function callWorkspaceView(payload, opts) {
507
- const query = opts && opts.includeAgents ? '?agents=1' : ''
507
+ // 两类默认折叠的会话各有一个开关:agents=1 放回智能体,blank=1 放回空会话。
508
+ const q = []
509
+ if (opts && opts.includeAgents) q.push('agents=1')
510
+ if (opts && opts.includeBlank) q.push('blank=1')
511
+ const query = q.length > 0 ? '?' + q.join('&') : ''
508
512
  const res = await fetch('/config-sync/workspace-view' + query, payload
509
513
  ? {
510
514
  method: 'POST',
@@ -1604,41 +1608,45 @@ window.__ModuleLoader__.load({
1604
1608
  const [busy, setBusy] = react.useState(false)
1605
1609
  const [msg, setMsg] = react.useState('')
1606
1610
  const [expanded, setExpanded] = react.useState({})
1607
- const [editing, setEditing] = react.useState({})
1611
+ // 整张卡片只有一个「修改」按钮:进入编辑态后所有工作区与会话一起可改,
1612
+ // 不再每行各带一个按钮(那样按钮多、和会话对不上)。
1613
+ const [editing, setEditing] = react.useState(false)
1608
1614
  // 默认折叠智能体(subagent)会话:一屏全是子会话时根本找不到自己的会话。
1609
1615
  const [showAgents, setShowAgents] = react.useState(false)
1616
+ // 默认折叠空会话:建了没聊过、或者只是 Mnemon 空闲审查的父容器,列出只会干扰。
1617
+ const [showBlank, setShowBlank] = react.useState(false)
1610
1618
 
1611
1619
  const load = react.useCallback(async () => {
1612
1620
  setBusy(true); setErr('')
1613
- try { setData(await callWorkspaceView(null, { includeAgents: showAgents })) }
1621
+ try { setData(await callWorkspaceView(null, { includeAgents: showAgents, includeBlank: showBlank })) }
1614
1622
  catch (e) { setErr(String((e && e.message) || e)) }
1615
1623
  finally { setBusy(false) }
1616
- }, [showAgents])
1624
+ }, [showAgents, showBlank])
1617
1625
  react.useEffect(() => { load() }, [load])
1618
1626
 
1619
1627
  const changeWorkspace = react.useCallback(async (wsId, state) => {
1620
1628
  setBusy(true); setErr(''); setMsg('')
1621
1629
  try {
1622
- const d = await callWorkspaceView({ action: 'workspace', workspaceId: wsId, state, includeAgents: showAgents }, { includeAgents: showAgents })
1630
+ const d = await callWorkspaceView({ action: 'workspace', workspaceId: wsId, state, includeAgents: showAgents, includeBlank: showBlank }, { includeAgents: showAgents, includeBlank: showBlank })
1623
1631
  setData(d)
1624
1632
  setMsg(d.live === true
1625
1633
  ? M('已更新,会话列表已同步', 'Updated — the session list is in sync')
1626
1634
  : M('已更新;宿主服务暂不可用,已直接写入状态文件', 'Updated; host service unavailable, wrote the state file directly'))
1627
1635
  } catch (e) { setErr(String((e && e.message) || e)) }
1628
1636
  finally { setBusy(false) }
1629
- }, [showAgents])
1637
+ }, [showAgents, showBlank])
1630
1638
 
1631
1639
  const changeSession = react.useCallback(async (sid, hidden) => {
1632
1640
  setBusy(true); setErr(''); setMsg('')
1633
1641
  try {
1634
- const d = await callWorkspaceView({ action: 'session', sessionId: sid, hidden, includeAgents: showAgents }, { includeAgents: showAgents })
1642
+ const d = await callWorkspaceView({ action: 'session', sessionId: sid, hidden, includeAgents: showAgents, includeBlank: showBlank }, { includeAgents: showAgents, includeBlank: showBlank })
1635
1643
  setData(d)
1636
1644
  setMsg(d.live === true
1637
1645
  ? M('已更新,会话列表已同步', 'Updated — the session list is in sync')
1638
1646
  : M('已更新;宿主服务暂不可用,已直接写入状态文件', 'Updated; host service unavailable, wrote the state file directly'))
1639
1647
  } catch (e) { setErr(String((e && e.message) || e)) }
1640
1648
  finally { setBusy(false) }
1641
- }, [showAgents])
1649
+ }, [showAgents, showBlank])
1642
1650
 
1643
1651
  const stateLabel = (st) => st === 'archive' ? M('归档', 'Archived')
1644
1652
  : st === 'hide-sessions' ? M('隐藏会话', 'Sessions hidden')
@@ -1661,11 +1669,46 @@ window.__ModuleLoader__.load({
1661
1669
  const wss = data.workspaces || []
1662
1670
  const archived = wss.filter(w => w.state === 'archive').length
1663
1671
  const agentHidden = Number(data.agentHidden || 0)
1672
+ const blankHidden = Number(data.blankHidden || 0)
1673
+ // 编辑态用一条明显的强调色说明条,让「现在可改」这件事一眼可见。
1674
+ const editBanner = editing
1675
+ ? h('div', {
1676
+ style: {
1677
+ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap',
1678
+ padding: '7px 10px', borderRadius: '8px',
1679
+ background: 'var(--dsw-alias-state-warn-secondary, transparent)',
1680
+ color: 'var(--dsw-alias-label-primary)',
1681
+ fontSize: '12px', lineHeight: '18px',
1682
+ },
1683
+ },
1684
+ h('span', { style: { fontWeight: 600 } }, M('编辑中', 'Editing')),
1685
+ h('span', { style: { flex: 1, minWidth: '160px' } },
1686
+ M('现在可以改工作区三态和每条会话的显示/隐藏;点「完成」退出编辑。', 'You can change workspace states and toggle each session now; click Done to finish.')),
1687
+ h('button', {
1688
+ type: 'button', style: { ...S.btn, fontWeight: 600 }, disabled: busy,
1689
+ onClick: () => setEditing(false),
1690
+ }, M('完成', 'Done')),
1691
+ )
1692
+ : null
1664
1693
  return h('div', { style: S.card },
1665
1694
  h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' } },
1666
1695
  h('div', { style: S.cardTitle }, M('工作区显示状态', 'Workspace visibility')),
1667
1696
  h('div', { style: { ...S.hint, flex: 1, minWidth: '160px' } },
1668
- M('点工作区展开会话;点「修改」后才可切换状态。改动即时生效,会话列表会跟着变。', 'Click a workspace to expand sessions; click Edit to change states. Changes apply immediately and the session list follows.')),
1697
+ editing
1698
+ ? M('点工作区展开会话;每条会话右侧的按钮就是它自己的显示/隐藏。改动即时生效。', 'Click a workspace to expand sessions; the button on each row toggles that session. Changes apply immediately.')
1699
+ : M('点工作区展开会话;要改状态先点右侧「修改」。改动即时生效,会话列表会跟着变。', 'Click a workspace to expand sessions; click Edit on the right to change states. Changes apply immediately and the session list follows.')),
1700
+ h('label', {
1701
+ style: { display: 'inline-flex', alignItems: 'center', gap: '4px', fontSize: '12px', color: 'var(--dsw-alias-label-secondary)', cursor: 'pointer' },
1702
+ title: M('默认隐藏空会话(没跑过对话的历史条目)与 Mnemon 空闲审查的父容器,勾选后一并列出', 'Blank sessions (never used) and Mnemon idle-review parents are hidden by default; tick to list them too'),
1703
+ },
1704
+ h('input', {
1705
+ type: 'checkbox',
1706
+ checked: showBlank,
1707
+ disabled: busy,
1708
+ onChange: (e) => setShowBlank(e.target.checked === true),
1709
+ }),
1710
+ h('span', null, M('显示空会话', 'Show blank')),
1711
+ ),
1669
1712
  h('label', {
1670
1713
  style: { display: 'inline-flex', alignItems: 'center', gap: '4px', fontSize: '12px', color: 'var(--dsw-alias-label-secondary)', cursor: 'pointer' },
1671
1714
  title: M('默认隐藏智能体(subagent)会话,勾选后一并列出', 'Agent (subagent) sessions are hidden by default; tick to list them too'),
@@ -1678,20 +1721,36 @@ window.__ModuleLoader__.load({
1678
1721
  }),
1679
1722
  h('span', null, M('显示智能体', 'Show agents')),
1680
1723
  ),
1724
+ // 全卡片唯一的主操作按钮:编辑 / 完成切换(编辑态下高亮,位置不变)
1725
+ h('button', {
1726
+ type: 'button',
1727
+ style: editing ? { ...S.btnPrimary } : { ...S.btn },
1728
+ disabled: busy,
1729
+ onClick: () => setEditing(v => !v),
1730
+ title: editing ? M('退出编辑态', 'Leave edit mode') : M('进入编辑态,才能改状态', 'Enter edit mode to change states'),
1731
+ }, editing ? M('完成', 'Done') : M('修改', 'Edit')),
1681
1732
  h('button', { type: 'button', style: S.btn, disabled: busy, onClick: load }, busy ? M('刷新中…', 'Refreshing…') : M('刷新', 'Refresh')),
1682
1733
  ),
1734
+ editBanner,
1683
1735
  msg ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-success-primary, #1a7f37)' } }, msg) : null,
1684
1736
  err ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-error-primary)' } }, err) : null,
1685
1737
  h('div', { style: S.footnote },
1686
1738
  M('共 ' + wss.length + ' 个工作区,' + archived + ' 个已归档;归档的工作区会从列表消失,会话仍保留。', wss.length + ' workspaces, ' + archived + ' archived; archived ones disappear from the list, sessions are kept.')
1687
- + (agentHidden > 0 && !showAgents ? M('已隐藏 ' + agentHidden + ' 条智能体会话。', ' ' + agentHidden + ' agent sessions hidden.') : '')),
1739
+ + (agentHidden > 0 && !showAgents ? M('已隐藏 ' + agentHidden + ' 条智能体会话。', ' ' + agentHidden + ' agent sessions hidden.') : '')
1740
+ + (blankHidden > 0 && !showBlank ? M('已隐藏 ' + blankHidden + ' 条空会话(含空闲审查父容器)。', ' ' + blankHidden + ' blank sessions hidden (incl. idle-review parents).') : '')),
1688
1741
  wss.length === 0
1689
1742
  ? h('div', { style: S.footnote }, M('没有工作区。', 'No workspaces.'))
1690
1743
  : h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px', marginTop: '2px' } },
1691
1744
  wss.map(w => {
1692
1745
  const open = !!expanded[w.workspaceId]
1693
- const edit = !!editing[w.workspaceId]
1694
- return h('div', { key: w.workspaceId, style: { border: '1px solid var(--dsw-alias-border-l1)', borderRadius: '8px', padding: '8px 10px' } },
1746
+ const wsTone = w.state === 'archive' ? 'warn' : w.state === 'normal' ? 'ok' : 'pull'
1747
+ return h('div', {
1748
+ key: w.workspaceId,
1749
+ style: {
1750
+ border: '1px solid ' + (editing ? 'var(--dsw-alias-border-l2)' : 'var(--dsw-alias-border-l1)'),
1751
+ borderRadius: '8px', padding: '8px 10px',
1752
+ },
1753
+ },
1695
1754
  // 整行可点展开 / 收起(需求3)
1696
1755
  h('div', {
1697
1756
  style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', cursor: 'pointer' },
@@ -1700,44 +1759,57 @@ window.__ModuleLoader__.load({
1700
1759
  },
1701
1760
  h('span', { style: { fontSize: '12px', color: 'var(--dsw-alias-label-tertiary)', width: '12px' } }, open ? '▾' : '▸'),
1702
1761
  h('span', { style: { fontSize: '12px', fontWeight: 600, minWidth: '90px' } }, w.title || w.workspaceId.slice(0, 8)),
1703
- h('span', { style: chipStyle(w.state === 'archive' ? 'warn' : w.state === 'normal' ? 'ok' : 'pull') }, stateLabel(w.state)),
1704
- h('span', { style: { ...S.footnote, flex: 1 } }, M(w.sessionCount + ' 会话 · ' + w.hiddenCount + ' 隐藏', w.sessionCount + ' sessions · ' + w.hiddenCount + ' hidden')),
1705
- h('button', {
1706
- type: 'button', style: S.btn, disabled: busy,
1707
- onClick: (e) => { stop(e); setEditing(v => ({ ...v, [w.workspaceId]: !edit })) },
1708
- }, edit ? M('完成', 'Done') : M('修改', 'Edit')),
1709
- ),
1710
- // 编辑态才出现三态选择(需求2)
1711
- edit
1712
- ? h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', marginTop: '6px', flexWrap: 'wrap' }, onClick: stop },
1713
- h('span', { style: S.footnote }, M('工作区状态', 'Workspace state')),
1714
- h('select', {
1762
+ // 非编辑态:状态只作为徽标展示(只读);
1763
+ // 编辑态:徽标右侧直接给出三态下拉,改的是这个工作区本身 —— 不再需要行内「修改」按钮。
1764
+ editing
1765
+ ? h('select', {
1715
1766
  value: w.state === 'partial' ? 'partial' : w.state,
1716
1767
  disabled: busy,
1768
+ onClick: stop,
1717
1769
  onChange: (e) => { if (e.target.value !== 'partial') changeWorkspace(w.workspaceId, e.target.value) },
1718
- style: { fontSize: '12px', padding: '3px 6px', borderRadius: '6px', border: '1px solid var(--dsw-alias-border-l1)', background: 'var(--dsw-alias-bg-base)', color: 'var(--dsw-alias-label-primary)' },
1770
+ title: M('这个工作区的三态', 'State of this workspace'),
1771
+ style: { fontSize: '12px', padding: '3px 6px', borderRadius: '6px', border: '1px solid var(--dsw-alias-border-l2)', background: 'var(--dsw-alias-bg-base)', color: 'var(--dsw-alias-label-primary)' },
1719
1772
  },
1720
1773
  w.state === 'partial' ? h('option', { value: 'partial' }, stateLabel('partial')) : null,
1721
1774
  opts.map(([v, label]) => h('option', { key: v, value: v }, label)),
1722
- ),
1723
- )
1724
- : null,
1725
- // 展开的会话列表:显示会话名(需求1),编辑态才出隐藏/显示按钮(需求2)
1775
+ )
1776
+ : h('span', { style: chipStyle(wsTone) }, stateLabel(w.state)),
1777
+ h('span', { style: { ...S.footnote, flex: 1 } }, M(w.sessionCount + ' 会话 · ' + w.hiddenCount + ' 隐藏', w.sessionCount + ' sessions · ' + w.hiddenCount + ' hidden')),
1778
+ ),
1779
+ // 展开的会话列表:每行是「会话名 + 它自己的开关」,按钮与会话同一行、紧跟其名,
1780
+ // 编辑态下用带词义的按钮文案(隐藏/显示,颜色区分),不再是一个孤零零的按钮。
1726
1781
  open
1727
1782
  ? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px', marginTop: '6px', paddingLeft: '18px' } },
1728
1783
  (w.sessions || []).length === 0
1729
1784
  ? h('div', { style: S.footnote }, M('这个工作区还没有会话。', 'No sessions in this workspace.'))
1730
- : w.sessions.map(s => h('div', { key: s.id, style: { display: 'flex', alignItems: 'center', gap: '8px', fontSize: '12px', lineHeight: '18px' } },
1785
+ : w.sessions.map(s => h('div', {
1786
+ key: s.id,
1787
+ style: {
1788
+ display: 'flex', alignItems: 'center', gap: '8px', fontSize: '12px', lineHeight: '18px',
1789
+ borderTop: '1px solid var(--dsw-alias-border-l1)',
1790
+ // 编辑态给整行加底色,视线一眼能把「这一行会话」和「这一行的按钮」框在一起
1791
+ padding: editing ? '3px 6px' : '3px 0',
1792
+ borderRadius: editing ? '6px' : 0,
1793
+ background: editing ? 'var(--dsw-alias-fill-l1, var(--dsw-alias-border-l1))' : 'transparent',
1794
+ },
1795
+ },
1731
1796
  h('span', {
1732
- style: { flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', color: s.hidden ? 'var(--dsw-alias-label-tertiary)' : 'var(--dsw-alias-label-secondary)' },
1797
+ style: {
1798
+ flex: '1 1 auto', minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
1799
+ color: s.hidden ? 'var(--dsw-alias-label-tertiary)' : 'var(--dsw-alias-label-secondary)',
1800
+ textDecoration: s.hidden ? 'line-through' : 'none',
1801
+ },
1733
1802
  title: (s.title || s.id) + '\n' + s.id,
1734
1803
  }, s.title || s.id),
1735
- s.hidden
1736
- ? h('span', { style: { ...S.footnote, color: 'var(--dsw-alias-label-tertiary)' } }, M('已隐藏', 'Hidden'))
1737
- : null,
1738
- edit
1804
+ // 按钮与会话同行、等宽右对齐:换行也不会跑到别的会话旁边
1805
+ editing
1739
1806
  ? h('button', {
1740
- type: 'button', style: S.btn, disabled: busy,
1807
+ type: 'button',
1808
+ style: s.hidden
1809
+ ? { ...S.btn, minWidth: '56px', color: 'var(--dsw-alias-state-success-primary, #1a7f37)' }
1810
+ : { ...S.btn, minWidth: '56px', color: 'var(--dsw-alias-state-error-primary)' },
1811
+ disabled: busy,
1812
+ title: (s.hidden ? M('让这条会话重新显示在列表里', 'Make this session visible again') : M('把这条会话从列表隐藏', 'Hide this session from the list')) + '\n' + (s.title || s.id),
1741
1813
  onClick: () => changeSession(s.id, !s.hidden),
1742
1814
  }, s.hidden ? M('显示', 'Show') : M('隐藏', 'Hide'))
1743
1815
  : null,
package/index.js CHANGED
@@ -4234,12 +4234,16 @@ async function handleCacheGuard(req, res, config) {
4234
4234
  // 0.3.76:工作区显示状态。自包含读写,不依赖 session-manager API(那个要 owner 凭证)。
4235
4235
  // 0.3.82:改成优先走 workspaceRegistry(宿主服务)→ 落盘同时触发 session-list feed,
4236
4236
  // 面板上切隐藏/显示即时生效;拿不到 registry 时函数内部退回纯文件写法(live:false)。
4237
+ // 0.3.83:视图默认多折叠一类「空会话」(创建后没发过消息、也没跑过 turn),
4238
+ // 以及 Mnemon 空闲审查的父容器(它只有 subagent/catalog,按空会话判定),
4239
+ // 面板不会再列出一堆空白条目。`?agents=1` / `?blank=1` 分别把两类放回来。
4237
4240
  async function handleWorkspaceView(req, res, config) {
4238
4241
  const dshHome = dshHomeOf(config)
4239
4242
  const registry = workspaceRegistryOf()
4240
4243
  const includeAgents = Boolean(req.url && /[?&]agents=1\b/.test(req.url))
4244
+ const includeBlank = Boolean(req.url && /[?&]blank=1\b/.test(req.url))
4241
4245
  if (req.method === 'GET') {
4242
- try { sendJson(res, 200, { ok: true, ...readView(dshHome, { includeAgents }) }) }
4246
+ try { sendJson(res, 200, { ok: true, ...readView(dshHome, { includeAgents, includeBlank }) }) }
4243
4247
  catch (error) { sendJson(res, 400, { ok: false, error: String((error && error.message) || error) }) }
4244
4248
  return
4245
4249
  }
@@ -4250,13 +4254,14 @@ async function handleWorkspaceView(req, res, config) {
4250
4254
  const body = raw.trim() ? JSON.parse(raw) : {}
4251
4255
  const action = String(body.action || '')
4252
4256
  const withAgents = body.includeAgents === true
4257
+ const withBlank = body.includeBlank === true
4253
4258
  if (action === 'workspace') {
4254
- const view = await setWorkspaceStateLive(dshHome, String(body.workspaceId || ''), String(body.state || ''), { registry, includeAgents: withAgents })
4259
+ const view = await setWorkspaceStateLive(dshHome, String(body.workspaceId || ''), String(body.state || ''), { registry, includeAgents: withAgents, includeBlank: withBlank })
4255
4260
  sendJson(res, 200, { ok: true, ...view })
4256
4261
  return
4257
4262
  }
4258
4263
  if (action === 'session') {
4259
- const view = await setSessionStateLive(dshHome, String(body.sessionId || ''), body.hidden === true, { registry, includeAgents: withAgents })
4264
+ const view = await setSessionStateLive(dshHome, String(body.sessionId || ''), body.hidden === true, { registry, includeAgents: withAgents, includeBlank: withBlank })
4260
4265
  sendJson(res, 200, { ok: true, ...view })
4261
4266
  return
4262
4267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-sync-plugin",
3
- "version": "0.3.82",
3
+ "version": "0.3.84",
4
4
  "type": "module",
5
5
  "description": "在 DSH 设置里查看 dsh-config 仓库与本机的同步状态,并生成退出后执行的 push/pull 脚本。同步动作本身不在应用内执行。面板与文案跟随客户端语言(中文/English)。",
6
6
  "main": "./index.js",
@@ -117,17 +117,18 @@ function cleanTitle(text) {
117
117
  }
118
118
 
119
119
  /**
120
- * 从单个会话日志文件提取标题与来源。返回 {title, origin} 并写入缓存。
121
- * origin 取自日志首个 `session` 头事件:`subagent` 表示智能体(子)会话,
122
- * 面板「工作区显示」卡片默认把它们折叠掉,只留用户自己的会话。
120
+ * 从单个会话日志文件提取标题、来源与空会话标记。返回 {title, origin, blank} 并写入缓存。
121
+ * origin 取自日志首个 `session` 头事件:`subagent` 表示智能体(子)会话;
122
+ * blank 表示从没跑过对话(没有 turn/start、没有首条用户消息)。
123
+ * 面板「工作区显示」卡片默认把这两类都折叠掉,只留用户自己真正聊过的会话。
123
124
  */
124
125
  function titleFromFile(file) {
125
126
  let mtime = 0
126
- try { mtime = fs.statSync(file).mtimeMs } catch { return { title: '', origin: '' } }
127
+ try { mtime = fs.statSync(file).mtimeMs } catch { return { title: '', origin: '', blank: false } }
127
128
  const key = `${file}:${mtime}`
128
129
  const hit = TITLE_CACHE.get(key)
129
130
  if (hit) return hit
130
- let result = { title: '', origin: '' }
131
+ let result = { title: '', origin: '', blank: false }
131
132
  try {
132
133
  const buf = fs.readFileSync(file)
133
134
  let text = ''
@@ -145,6 +146,7 @@ function titleFromFile(file) {
145
146
  let anyTitle = '' // 无 source 信息的兜底标题(取最后一条)
146
147
  let firstUserText = ''
147
148
  let origin = '' // 会话来源:subagent = 智能体子会话
149
+ let sawTurn = false // 出现过 turn/start:真正跑过对话
148
150
  for (const line of text.split('\n')) {
149
151
  if (!line) continue
150
152
  let ev
@@ -153,6 +155,7 @@ function titleFromFile(file) {
153
155
  if (typeof ev.origin === 'string') origin = ev.origin
154
156
  else if (ev.data && typeof ev.data.origin === 'string') origin = ev.data.origin
155
157
  }
158
+ if (ev.type === 'turn/start') sawTurn = true
156
159
  if (ev.type === 'session/title' && ev.data && typeof ev.data.title === 'string') {
157
160
  const kind = ev.data.source && ev.data.source.kind
158
161
  if (kind === 'provider') providerTitle = ev.data.title
@@ -172,9 +175,12 @@ function titleFromFile(file) {
172
175
  result = {
173
176
  title: cleanTitle(providerTitle) || cleanTitle(fallbackTitle) || cleanTitle(anyTitle) || cleanTitle(firstUserText),
174
177
  origin,
178
+ // 空会话:从没跑过对话(没有 turn/start,也没有首条用户消息)。DSH 自己也算 blank,
179
+ // 这里独立算一遍,因为面板要据此把「新建了没发消息」的会话藏起来。
180
+ blank: !sawTurn && !firstUserText,
175
181
  }
176
182
  } catch {
177
- result = { title: '', origin: '' }
183
+ result = { title: '', origin: '', blank: false }
178
184
  }
179
185
  if (TITLE_CACHE.size > 400) TITLE_CACHE.clear()
180
186
  TITLE_CACHE.set(key, result)
@@ -206,21 +212,31 @@ function buildSessionLogIndex(dshHome) {
206
212
 
207
213
  /**
208
214
  * 读视图:列出所有工作区 + 每个工作区下会话的隐藏状态 + 三态归一化 + 会话名称。
209
- * options.includeAgents=true 时才把智能体(origin === 'subagent')会话算进来;
210
- * 默认折叠,三态与计数都只按用户自己的会话计算(否则一屏全是智能体会话)。
215
+ * 默认只留用户自己真正聊过的会话,折叠两类会话:
216
+ * ① 智能体会话(origin === 'subagent');
217
+ * ② 空会话(blank:从没跑过对话)。
218
+ * options.includeAgents=true 时把智能体也算进来;options.includeBlank=true 时把空会话也算进来。
219
+ * 三态与计数都只按保留下来的会话计算。
220
+ *
221
+ * 「Mnemon 空闲审查」的父容器(mnemon-review-owner-v1-*)被一并折叠:
222
+ * 它自己的 header 没有 origin(不是 subagent),但日志里只有一个 subagent/catalog
223
+ * 事件、没有 turn/start,因此按空会话判定隐藏;真正的审查内容在它指向的
224
+ * mnemon-review-v1-* 子会话里,那个带 origin=subagent,属于第 ① 类。
211
225
  */
212
226
  export function readView(dshHome, options = {}) {
213
227
  const includeAgents = options.includeAgents === true
228
+ const includeBlank = options.includeBlank === true
214
229
  const ws = readJson(workspacePath(dshHome))
215
230
  const arch = readJson(archivePath(dshHome))
216
231
  if (!ws || !ws.tables || !ws.tables.workspaces) {
217
- return { ok: true, available: false, workspaces: [], includeAgents, agentHidden: 0 }
232
+ return { ok: true, available: false, workspaces: [], includeAgents, includeBlank, agentHidden: 0, blankHidden: 0 }
218
233
  }
219
234
  const globalArchived = new Set(Array.isArray(ws.global?.archivedSessionIds) ? ws.global.archivedSessionIds : [])
220
235
  const archMap = (arch && arch.workspaces && typeof arch.workspaces === 'object') ? arch.workspaces : {}
221
236
  const logIndex = buildSessionLogIndex(dshHome)
222
237
  const workspaces = []
223
238
  let totalAgents = 0
239
+ let totalBlank = 0
224
240
  for (const [wsId, rec] of Object.entries(ws.tables.workspaces)) {
225
241
  if (!rec || typeof rec !== 'object') continue
226
242
  const sessionIds = Array.isArray(rec.sessionIds) ? rec.sessionIds.slice() : []
@@ -228,12 +244,22 @@ export function readView(dshHome, options = {}) {
228
244
  const workspaceArchived = Boolean(archRec && archRec.archived === true)
229
245
  const all = sessionIds.map((sid) => {
230
246
  const log = logIndex.get(sid)
231
- const meta = log ? titleFromFile(log) : { title: '', origin: '' }
232
- return { id: sid, title: meta.title, hidden: globalArchived.has(sid), agent: meta.origin === 'subagent' }
247
+ const meta = log ? titleFromFile(log) : { title: '', origin: '', blank: false }
248
+ return {
249
+ id: sid,
250
+ title: meta.title,
251
+ hidden: globalArchived.has(sid),
252
+ agent: meta.origin === 'subagent',
253
+ blank: meta.blank === true,
254
+ }
233
255
  })
234
256
  const agentCount = all.filter((s) => s.agent).length
257
+ const blankCount = all.filter((s) => !s.agent && s.blank).length
235
258
  totalAgents += agentCount
236
- const sessions = includeAgents ? all : all.filter((s) => !s.agent)
259
+ totalBlank += blankCount
260
+ // 两道过滤独立生效:智能体一类、空会话一类。
261
+ let sessions = includeAgents ? all : all.filter((s) => !s.agent)
262
+ if (!includeBlank) sessions = sessions.filter((s) => !s.blank)
237
263
  const hiddenCount = sessions.filter((s) => s.hidden).length
238
264
  let state = 'normal'
239
265
  if (workspaceArchived) state = 'archive'
@@ -246,13 +272,14 @@ export function readView(dshHome, options = {}) {
246
272
  sessionCount: sessions.length,
247
273
  hiddenCount,
248
274
  agentCount,
275
+ blankCount,
249
276
  state,
250
277
  archived: workspaceArchived,
251
278
  archivedAt: workspaceArchived && typeof archRec.archivedAt === 'number' ? archRec.archivedAt : 0,
252
279
  sessions,
253
280
  })
254
281
  }
255
- return { ok: true, available: true, workspaces, includeAgents, agentHidden: totalAgents }
282
+ return { ok: true, available: true, workspaces, includeAgents, includeBlank, agentHidden: totalAgents, blankHidden: totalBlank }
256
283
  }
257
284
 
258
285
  /** 切换一个工作区的三态。state ∈ normal | hide-sessions | archive。 */
@@ -373,7 +400,7 @@ function withRegistryHidden(view, registry) {
373
400
  * options.registry 传宿主 workspaceRegistry;传 null/undefined 时退回文件写法。
374
401
  */
375
402
  export async function setWorkspaceStateLive(dshHome, workspaceId, state, options = {}) {
376
- const { registry = null, includeAgents = false } = options
403
+ const { registry = null, includeAgents = false, includeBlank = false } = options
377
404
  if (!['normal', 'hide-sessions', 'archive'].includes(state)) {
378
405
  throw new Error(`不支持的工作区状态:${state}`)
379
406
  }
@@ -426,16 +453,16 @@ export async function setWorkspaceStateLive(dshHome, workspaceId, state, options
426
453
  return { ...fallback, live: false, fallbackFrom: 'registry', stopped, errors }
427
454
  }
428
455
  void results
429
- return { ...withRegistryHidden(readView(dshHome, { includeAgents }), registry), live: true, stopped }
456
+ return { ...withRegistryHidden(readView(dshHome, { includeAgents, includeBlank }), registry), live: true, stopped }
430
457
  }
431
458
 
432
459
  /** 实时隐藏/显示单个会话。 */
433
460
  export async function setSessionStateLive(dshHome, sessionId, hidden, options = {}) {
434
- const { registry = null, includeAgents = false } = options
461
+ const { registry = null, includeAgents = false, includeBlank = false } = options
435
462
  const live = Boolean(registry && typeof registry.archiveSession === 'function')
436
463
  if (!live) {
437
464
  return { ...setSessionState(dshHome, sessionId, hidden), live: false }
438
465
  }
439
466
  const r = await applySessionState(registry, sessionId, hidden)
440
- return { ...withRegistryHidden(readView(dshHome, { includeAgents }), registry), live: true, stopped: r.stopped ? 1 : 0 }
467
+ return { ...withRegistryHidden(readView(dshHome, { includeAgents, includeBlank }), registry), live: true, stopped: r.stopped ? 1 : 0 }
441
468
  }
@@ -1626,18 +1626,18 @@ console.log('== 0.3.82:工作区显示卡片折叠智能体 + 隐藏/显示即
1626
1626
 
1627
1627
  // 1) 智能体折叠:标题提取同时给出 origin,readView 支持 includeAgents 过滤
1628
1628
  check('智能体折叠:titleFromFile 同时返回 origin',
1629
- wvSrc.includes("let result = { title: '', origin: '' }")
1629
+ wvSrc.includes("let result = { title: '', origin: '', blank: false }")
1630
1630
  && wvSrc.includes('if (!origin && ev.type === \'session\')')
1631
1631
  && wvSrc.includes('origin,'), 'workspace-view.mjs 的头事件解析')
1632
1632
  check('智能体折叠:readView 默认过滤 origin=subagent 并回报 agentHidden',
1633
1633
  wvSrc.includes('const includeAgents = options.includeAgents === true')
1634
1634
  && wvSrc.includes("agent: meta.origin === 'subagent'")
1635
- && wvSrc.includes('const sessions = includeAgents ? all : all.filter((s) => !s.agent)')
1635
+ && wvSrc.includes('let sessions = includeAgents ? all : all.filter((s) => !s.agent)')
1636
1636
  && wvSrc.includes('agentHidden: totalAgents'), 'workspace-view.mjs 的 readView')
1637
1637
  check('智能体折叠:卡片默认不显示、可勾选「显示智能体」',
1638
1638
  cliSrc.includes('const [showAgents, setShowAgents] = react.useState(false)')
1639
1639
  && cliSrc.includes("M('显示智能体', 'Show agents')")
1640
- && cliSrc.includes('opts.includeAgents ? \'?agents=1\' : \'\''), 'client.js 的勾选框')
1640
+ && cliSrc.includes("q.push('agents=1')"), 'client.js 的勾选框')
1641
1641
 
1642
1642
  // 2) 即时生效:走 workspaceRegistry 而不是直接改文件
1643
1643
  check('即时生效:workspace-view 导出实时通道两函数',
@@ -1653,7 +1653,7 @@ console.log('== 0.3.82:工作区显示卡片折叠智能体 + 隐藏/显示即
1653
1653
  check('即时生效:路由改用 Live 版本并透传 registry',
1654
1654
  idxSrc.includes("import { setWorkspaceStateLive, setSessionStateLive } from './runtime/tools/workspace-view.mjs'")
1655
1655
  && idxSrc.includes('await setWorkspaceStateLive(') && idxSrc.includes('await setSessionStateLive(')
1656
- && idxSrc.includes('{ registry, includeAgents: withAgents }'), 'index.js 的 handleWorkspaceView')
1656
+ && idxSrc.includes('{ registry, includeAgents: withAgents, includeBlank: withBlank }'), 'index.js 的 handleWorkspaceView')
1657
1657
  check('即时生效:registry 拿不到时退回文件写法并标记 live:false',
1658
1658
  wvSrc.includes('return { ...setWorkspaceState(dshHome, workspaceId, state), live: false }')
1659
1659
  && wvSrc.includes("live: false, fallbackFrom: 'registry'"), 'workspace-view.mjs 的降级')
@@ -1671,20 +1671,25 @@ console.log('== 配置同步页面 5 点调整 ==')
1671
1671
  check('会话名称:工具从 session 日志提取 title 并随 readView 返回',
1672
1672
  wvSrc.includes('zstdDecompressSync') && wvSrc.includes('buildSessionLogIndex')
1673
1673
  && wvSrc.includes("'session/title'") && wvSrc.includes('title: rec.title || wsId')
1674
- && wvSrc.includes("const meta = log ? titleFromFile(log) : { title: '', origin: '' }"), 'workspace-view.mjs 的标题提取')
1674
+ && wvSrc.includes("const meta = log ? titleFromFile(log) : { title: '', origin: '', blank: false }"), 'workspace-view.mjs 的标题提取')
1675
1675
  check('会话名称:与 DSH 面板一致——优先 provider 正式标题,不再取第一条 fallback',
1676
1676
  wvSrc.includes('providerTitle') && wvSrc.includes("kind === 'provider'")
1677
1677
  && wvSrc.includes('cleanTitle(providerTitle) || cleanTitle(fallbackTitle)')
1678
1678
  && !wvSrc.includes('if (lastTitle) break'), '标题演进:provider > fallback > 无来源 > 首条消息')
1679
1679
  check('会话名称:卡片显示 s.title || s.id', cliSrc.includes('s.title || s.id'), 'client.js 卡片')
1680
- // 2) 修改按钮:点「修改」才出现三态 select 与会话隐藏按钮
1681
- check('修改按钮:编辑态才显示三态 select 与会话隐藏按钮',
1682
- cliSrc.includes('const [editing, setEditing]')
1680
+ // 2) 修改按钮:全卡片只有一个「修改」,进入编辑态后三态 select 与每行的隐藏/显示按钮一起出现
1681
+ check('修改按钮:整卡一个「修改」,编辑态才显示三态 select 与会话隐藏按钮',
1682
+ cliSrc.includes('// 整张卡片只有一个「修改」按钮')
1683
1683
  && cliSrc.includes("M('修改', 'Edit')") && cliSrc.includes("M('完成', 'Done')")
1684
- && cliSrc.includes('const edit = !!editing[w.workspaceId]')
1685
- && cliSrc.includes('setEditing(v => ({ ...v, [w.workspaceId]: !edit }))')
1684
+ // 工作区行不再各带一个编辑按钮
1685
+ && !cliSrc.includes('const edit = !!editing[w.workspaceId]')
1686
+ && !cliSrc.includes('setEditing(v => ({ ...v, [w.workspaceId]: !edit }))')
1687
+ // 编辑态由整卡开关控制,且行内下拉与行内按钮都存在
1688
+ && cliSrc.includes('onClick: () => setEditing(v => !v)')
1686
1689
  && cliSrc.includes('changeWorkspace(w.workspaceId, e.target.value)')
1687
- && cliSrc.includes('changeSession(s.id, !s.hidden)'), 'client.js 编辑态')
1690
+ && cliSrc.includes('changeSession(s.id, !s.hidden)')
1691
+ // 编辑态有明显的说明条与退出按钮
1692
+ && cliSrc.includes("M('编辑中', 'Editing')"), 'client.js 编辑态')
1688
1693
  // 3) 点工作区整行即展开,不再单独展开按钮
1689
1694
  check('点工作区即展开(整行 onClick,无独立展开按钮)',
1690
1695
  cliSrc.includes("onClick: () => setExpanded(e => ({ ...e, [w.workspaceId]: !open }))")