dsh-session-superagent 0.9.286 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,41 @@
2
2
 
3
3
  格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
4
 
5
+ ## [0.10.0] - 2026-11-06 —— 功能稳定版
6
+
7
+ 这是严格审查后收口的功能稳定版。上一轮 11 项必须修、18 项值得改全部处理,终审新增 N1/N2/N3 也已修复。
8
+
9
+ ### 状态与数据正确性
10
+
11
+ - 主面板 `/state` 携带 sessionId,goal/title/usage 正确;空会话不串值。
12
+ - 首次 loading/失败不再渲染零统计和 Onboarding;Orbit 区分读取中、读取失败与真实空。
13
+ - 保存使用草稿版本 + 保存序号;pending 后的新输入不被旧响应覆盖,回读成功才提示成功。
14
+ - `/state` ETag 按作用域分开,圆环全局请求与会话面板不互相污染。
15
+ - trace 使用请求代际,慢旧响应不覆盖新编号;200→500→304 清旧错误。
16
+
17
+ ### 表单、Orbit 与草稿
18
+
19
+ - 校验失败调用 reportValidity 并聚焦无效控件,不发 POST。
20
+ - 折叠/切换 dirty 表单先确认;取消、Escape、遮罩保留草稿,确认才丢弃。
21
+ - Orbit 立刻/暂停/恢复/删除按 watcher+action 加锁;连点不重复 POST,删除失败在当前 Modal 可见且可重试。
22
+ - 删除失败不会残留到下一次删除确认框;保存回读被刷新顶掉不再假报失败。
23
+
24
+ ### UI 与可访问性
25
+
26
+ - CollapsibleList、Pill、Tag、StateDot 等继续使用 DSH 官方组件;无导出时完整回退。
27
+ - 高级区补 aria-controls/body id;busy Disclosure 退出 Tab 顺序并忽略长按。
28
+ - Section 标题改 h2;持久异步错误有 alert/live;SaveBar 关闭后合理回焦。
29
+ - fallback Tooltip 支持 Escape 与 aria 关联;Modal 独占 Escape;Toast 用 id 重启。
30
+ - 事件记录全局按时间倒序取最近 20,reopened 纳入问题计数;过滤空态给出真实恢复动作。
31
+
32
+ ### 验证
33
+
34
+ - 全量 **675/675**。
35
+ - UI 体检 **11/11=100**。
36
+ - 真实 Chromium **47/47**(每次独立任务空间)。
37
+ - 0.10.0 终审报告记录 11+18 项复核、N1/N2/N3 修复与未验边界。
38
+ - 未验真实 DSH WebView、物理读屏、触摸/IME、真实 GitHub/Gitee 写操作。
39
+
5
40
  ## [0.9.286] - 2026-11-06 —— 切换中的 dirty 草稿保护
6
41
 
7
42
  ### 折叠/切换不再静默丢草稿
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="assets/icon-180.png" width="88" height="88" alt="">
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Version](https://img.shields.io/badge/version-0.9.286-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.10.0-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
7
7
  [![npm](https://img.shields.io/npm/v/dsh-session-superagent.svg)](https://www.npmjs.com/package/dsh-session-superagent)
8
8
  [![dsh](https://img.shields.io/badge/DeepSeek%20Harness-plugin-orange.svg)](https://github.com/topics/dsh-plugin)
9
9
  [![awesome](https://img.shields.io/badge/awesome-dsh--plugin-%E2%9C%93-success.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
@@ -148,7 +148,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
148
148
  ## 开发
149
149
 
150
150
  ```sh
151
- npm test # 648 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
151
+ npm test # 675 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
152
152
  ```
153
153
 
154
154
  ### 工具输出:文本给人和 agent,JSON 给程序
@@ -208,7 +208,7 @@ dsh plugin --profile <profile> add dsh-session-superagent@latest
208
208
 
209
209
 
210
210
  ```bash
211
- npm test # 648 项单测(带离线开关,约 1.6 秒)
211
+ npm test # 675 项单测(带离线开关,约 1.6 秒)
212
212
  node scripts/ui-audit.mjs # 11 项 UI 指标(写死颜色 / 自造 token / 官方结构采用 …)
213
213
  node scripts/preflight.mjs # 41 项门禁(含上面两条,外加 profile 一致性、路由面、包内容)
214
214
  node scripts/render-preview.mjs preview.html # 双主题静态预览,直接浏览器打开
package/client.js CHANGED
@@ -418,7 +418,7 @@ window.__ModuleLoader__.load({
418
418
  }
419
419
 
420
420
  // 客户端版本探针:每次模块加载写一次,用来确认浏览器里跑的是哪一版
421
- const CLIENT_VERSION = '0.9.286'
421
+ const CLIENT_VERSION = '0.10.0'
422
422
  // SEMVER_COMPARATOR_SOURCE_START
423
423
  // This block is duplicated verbatim in client.js because the browser UMD cannot import ESM.
424
424
  // test/update-semver.test.mjs audits both copies and exercises their behavior.
@@ -515,8 +515,19 @@ window.__ModuleLoader__.load({
515
515
 
516
516
  const POLL_MS = 5000
517
517
 
518
- // 上一次 /state 的 ETag:带上它,没变化时服务端回 304,省掉整份 JSON
519
- let stateEtag = null
518
+ // 上一次 /state 的 ETag:带上它,没变化时服务端回 304,省掉整份 JSON。
519
+ // 必须按作用域分开存(终审 N3):状态栏圆环拉的是全局 /state,主面板拉的是 /state?sessionId=…;
520
+ // 服务端 etag 对整份 body 求值,两个作用域 body 不同 —— 共用一个 etag 会让面板的条件请求永远打不中 304。
521
+ // 不带 sessionId 时仍然只有一个键,与旧行为一致。
522
+ const stateEtags = new Map()
523
+ const readStateEtag = (path) => (typeof path === 'string' && path.startsWith('/state')
524
+ ? (stateEtags.get(path) || null)
525
+ : null)
526
+ const writeStateEtag = (path, etag) => {
527
+ if (typeof path !== 'string' || !path.startsWith('/state')) return
528
+ if (etag) stateEtags.set(path, etag)
529
+ else stateEtags.delete(path)
530
+ }
520
531
 
521
532
  async function call(path, options, retried) {
522
533
  const init = {
@@ -551,11 +562,11 @@ window.__ModuleLoader__.load({
551
562
  // 304:内容没变(服务端带 ETag)。不是错误,也没有正文。
552
563
  if (res.status === 304) {
553
564
  const etag = res.headers && res.headers.get ? res.headers.get('etag') : null
554
- if (etag) stateEtag = etag
565
+ if (etag) writeStateEtag(path, etag)
555
566
  return { notModified: true }
556
567
  }
557
568
  const freshEtag = res.headers && res.headers.get ? res.headers.get('etag') : null
558
- if (freshEtag && path.startsWith('/state')) stateEtag = freshEtag
569
+ if (freshEtag && path.startsWith('/state')) writeStateEtag(path, freshEtag)
559
570
  const text = await res.text()
560
571
  let body = null
561
572
  try { body = text ? JSON.parse(text) : null } catch { body = { raw: text } }
@@ -851,7 +862,7 @@ window.__ModuleLoader__.load({
851
862
  function Section({ title, count, subtitle, hint, action, children }) {
852
863
  return h('section', { className: 'dt-section' },
853
864
  title
854
- ? h('div', { className: 'dt-section-title' },
865
+ ? h('h2', { className: 'dt-section-title' },
855
866
  h('span', { className: 'dt-section-name' }, title),
856
867
  count !== undefined && count !== null ? h('span', { className: 'dt-count' }, String(count)) : null,
857
868
  subtitle ? h('span', { className: 'dt-section-sub' }, subtitle) : null,
@@ -890,25 +901,30 @@ window.__ModuleLoader__.load({
890
901
  /** 官方 DisclosureRow 承载过滤清单;缺导出时完整保留本地键盘与焦点行为。 */
891
902
  function CollapsibleList({ title, items }) {
892
903
  const [open, setOpen] = useState(false)
904
+ // 字符串仍是兼容调用面;结构化记录带独立摘要、正文和稳定 key,避免先压平而丢失来源。
905
+ const summaryOf = (item) => item && typeof item === 'object' && 'summary' in item ? item.summary : item
906
+ const contentOf = (item) => item && typeof item === 'object' && 'content' in item ? item.content : item
893
907
  const rowProps = {
894
908
  title: title + '(' + items.length + ')',
895
909
  open, onToggle: () => setOpen((current) => !current),
896
910
  icon: h(Icon, { name: 'question', size: 14 }),
897
- collapsedContent: h('span', { className: 'dt-hint' }, items[0] ? String(items[0]).slice(0, 40) : ''),
911
+ collapsedContent: h('span', { className: 'dt-hint' }, items[0] ? String(summaryOf(items[0])).slice(0, 40) : ''),
898
912
  }
899
913
  return h(hostCollapsibleRow || DisclosureRow,
900
914
  hostCollapsibleRow ? { ...rowProps, expandable: true, expandOnRowClick: true } : rowProps,
901
915
  h('ul', { className: 'dt-plain-list' },
902
- items.map((text, index) => h('li', { key: index }, text))))
916
+ items.map((item, index) => h('li', {
917
+ key: item && typeof item === 'object' && item.key !== undefined ? item.key : index,
918
+ }, contentOf(item)))))
903
919
  }
904
920
 
905
- /** DSH Pill:有 onClick 时是可切换按钮,否则是静态只读胶囊。 */
906
- function Pill({ active = false, className, onClick, children, ...rest }) {
921
+ /** DSH Pill:active 有定义时才是 toggle;无 active 的 onClick 只是动作,静态则无 onClick。 */
922
+ function Pill({ active, className, onClick, children, ...rest }) {
907
923
  if (hostPill) {
908
- // 官方没有 aria-pressed;只在交互形态最小补齐,不把只读 badge 变成按钮。
924
+ // 官方没有 aria-pressed;只给真正的 toggle 补齐,清除等普通动作不得误报 pressed=false。
909
925
  return h(hostPill, {
910
926
  ...rest, active, className, onClick,
911
- 'aria-pressed': onClick ? !!active : undefined,
927
+ 'aria-pressed': onClick && active !== undefined ? !!active : undefined,
912
928
  }, children)
913
929
  }
914
930
  if (!onClick) {
@@ -916,7 +932,7 @@ window.__ModuleLoader__.load({
916
932
  }
917
933
  return h('button', {
918
934
  type: 'button', ...rest, className: cx('dt-pill', active && 'dt-pill-active', className),
919
- 'aria-pressed': !!active, onClick,
935
+ 'aria-pressed': active !== undefined ? !!active : undefined, onClick,
920
936
  }, children)
921
937
  }
922
938
 
@@ -932,15 +948,23 @@ window.__ModuleLoader__.load({
932
948
  }
933
949
 
934
950
  /** 官方 DisclosureRow:折叠行的标准写法(Enter / 空格可切换,带 aria-expanded)。 */
935
- function DisclosureRow({ icon, title, open, onToggle, collapsedContent, bodyId, children }) {
951
+ function DisclosureRow({ icon, title, open, onToggle, collapsedContent, bodyId, busy = false, disabled = false, children }) {
936
952
  const content = Array.isArray(children) && children.length === 1 ? children[0] : children
953
+ const unavailable = Boolean(busy || disabled)
937
954
  return h('div', { className: 'dt-disclosure', 'data-open': open ? 'true' : undefined },
938
955
  h('div', {
939
- className: 'dt-disclosure-row', role: 'button', tabIndex: 0, 'aria-expanded': !!open,
956
+ className: 'dt-disclosure-row', role: 'button', tabIndex: unavailable ? -1 : 0, 'aria-expanded': !!open,
940
957
  'aria-controls': bodyId,
941
- onClick: onToggle,
958
+ 'aria-disabled': unavailable,
959
+ 'aria-busy': busy ? 'true' : undefined,
960
+ 'aria-label': busy && typeof title === 'string' ? title + '(保存中,暂不可开合)' : undefined,
961
+ onClick: () => { if (!unavailable) onToggle() },
942
962
  onKeyDown: (event) => {
943
- if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); onToggle() }
963
+ if (event.key !== 'Enter' && event.key !== ' ') return
964
+ event.preventDefault()
965
+ // 长按只认第一次;busy/disabled 也必须在本层拦截,不能依赖调用方静默吞掉。
966
+ if (unavailable || event.repeat) return
967
+ onToggle()
944
968
  },
945
969
  },
946
970
  h('span', { className: 'dt-disclosure-lead' },
@@ -957,16 +981,36 @@ window.__ModuleLoader__.load({
957
981
  : null)
958
982
  }
959
983
 
960
- /** 无 DSH Tooltip 时完整保留原实现:原 trigger、点击/失焦与本地气泡都不改写。 */
984
+ // 本地气泡的 id 序号:同一 trigger 反复开合复用同一个 id,trigger 才能稳定用 aria-describedby 指向它。
985
+ // 用 ref 而不是新增 state,避免打乱父组件按位置取值的 hook 队列。
986
+ let fallbackTipSerial = 0
987
+ /** 无 DSH Tooltip 时完整保留原实现;补上 Escape 关闭与 trigger↔tooltip 关联(W15)。 */
961
988
  function FallbackInfoTip({ text, icon = 'question', warn }) {
962
989
  const [open, setOpen] = useState(false)
990
+ const tipIdRef = useRef(null)
991
+ if (!tipIdRef.current) {
992
+ fallbackTipSerial += 1
993
+ tipIdRef.current = 'dt-info-tip-' + fallbackTipSerial
994
+ }
995
+ const tipId = tipIdRef.current
963
996
  return h('span', { style: { position: 'relative', display: 'inline-flex' } },
964
997
  h('button', {
965
998
  type: 'button', className: cx('dt-info', warn && 'dt-info-warn'),
966
999
  'aria-label': text, 'aria-expanded': open,
1000
+ // 只有气泡真的在 DOM 里才关联;关闭时同步清掉,读屏不会指向已消失的节点。
1001
+ 'aria-describedby': open ? tipId : undefined,
967
1002
  onClick: () => setOpen(!open), onBlur: () => setOpen(false),
1003
+ onKeyDown: (event) => {
1004
+ if (event.key !== 'Escape' || !open) return
1005
+ // 键盘约定:Escape 只关气泡,焦点留在 trigger 上(不能 blur 掉)。
1006
+ event.preventDefault()
1007
+ setOpen(false)
1008
+ },
968
1009
  }, h(Icon, { name: icon, size: 14 })),
969
- open ? h('span', { className: 'dt-tooltip', role: 'tooltip', style: { position: 'absolute', bottom: '130%', left: 0, visibility: 'visible' } }, text) : null)
1010
+ open ? h('span', {
1011
+ id: tipId, className: 'dt-tooltip', role: 'tooltip',
1012
+ style: { position: 'absolute', bottom: '130%', left: 0, visibility: 'visible' },
1013
+ }, text) : null)
970
1014
  }
971
1015
 
972
1016
  // 保持 InfoTip({text,icon,warn}) 调用面;静态分支不会在组件生命周期内改变 hooks 顺序。
@@ -1082,6 +1126,31 @@ window.__ModuleLoader__.load({
1082
1126
  h(Btn, { size: 'sm', variant: 'primary', type: 'submit', disabled: !dirty || !!busy || !!disabled, onClick: onSave }, busy ? '保存中…' : saveLabel))
1083
1127
  }
1084
1128
 
1129
+ /**
1130
+ * SaveBar 消失后只在焦点仍属于这张表单时归还;用户已移到其它存活控件就不抢。
1131
+ * 编辑保存会卸载整个 form,所以 opener 在提交前捕获;新增/放弃则回首个可编辑控件。
1132
+ */
1133
+ function restoreSaveBarFocus({ form, saveBar, opener, wasFocused = false, shouldRestore }) {
1134
+ if (typeof document === 'undefined') return
1135
+ const active = document.activeElement
1136
+ const inSaveBar = (node) => Boolean(node && saveBar && typeof saveBar.contains === 'function' && saveBar.contains(node))
1137
+ const lost = (node) => !node || node === document.body || node.isConnected === false
1138
+ if (!inSaveBar(active) && !wasFocused) return
1139
+ setTimeout(() => {
1140
+ const current = document.activeElement
1141
+ if (!inSaveBar(current) && !lost(current)) return
1142
+ if (typeof shouldRestore === 'function' && !shouldRestore()) return
1143
+ // busy=true 时 input 仍 disabled;必须等 finally 与 React commit 后再找可编辑控件。
1144
+ const target = opener && opener.isConnected !== false
1145
+ ? opener
1146
+ : form && form.isConnected !== false && typeof form.querySelector === 'function'
1147
+ ? form.querySelector('input:not(:disabled), textarea:not(:disabled), select:not(:disabled)')
1148
+ : null
1149
+ if (!target || target.isConnected === false || typeof target.focus !== 'function') return
1150
+ try { target.focus({ preventScroll: true }) } catch { try { target.focus() } catch {} }
1151
+ }, 0)
1152
+ }
1153
+
1085
1154
  /** derived HoursField:两个原生时间控件,Field 的 label 只关联起始控件。 */
1086
1155
  function HoursField({ value, onChange, id, disabled }) {
1087
1156
  const match = String(value || '').match(/^(\d{1,2}):(\d{2})\s*-\s*(\d{1,2}):(\d{2})$/)
@@ -1139,10 +1208,24 @@ window.__ModuleLoader__.load({
1139
1208
  const [busy, setBusy] = useState(false)
1140
1209
  const [error, setError] = useState(null)
1141
1210
  const busyRef = useRef(false)
1211
+ const formRef = useRef(null)
1212
+ const formFocusedRef = useRef(false)
1142
1213
  const values = value || {}
1143
1214
  const opening = snapshot || values
1144
1215
  const dirty = watcherDirty(values, opening)
1145
1216
  const change = (key, next) => { setError(null); onChange(key, next) }
1217
+ const captureFocus = () => {
1218
+ const form = formRef.current
1219
+ const active = typeof document === 'undefined' ? null : document.activeElement
1220
+ const ticket = mode === 'edit' && form && typeof form.closest === 'function' ? form.closest('.dt-ticket') : null
1221
+ return {
1222
+ form,
1223
+ saveBar: form && typeof form.querySelector === 'function' ? form.querySelector('.dt-savebar') : null,
1224
+ opener: ticket && typeof ticket.querySelector === 'function' ? ticket.querySelector('.dt-open') : null,
1225
+ wasFocused: formFocusedRef.current || Boolean(form && active && typeof form.contains === 'function' && form.contains(active)),
1226
+ shouldRestore: () => formFocusedRef.current,
1227
+ }
1228
+ }
1146
1229
  const submit = async (event) => {
1147
1230
  if (event && typeof event.preventDefault === 'function') event.preventDefault()
1148
1231
  // 原生点击保存时仍执行 constraints;测试桩没有 form,直接走同一提交函数。
@@ -1155,12 +1238,14 @@ window.__ModuleLoader__.load({
1155
1238
  }
1156
1239
  if (busyRef.current || disabled || (mode === 'edit' && !dirty)) return false
1157
1240
  if (mode === 'create' && (!sessionId || !String(values.repo || '').trim())) return false
1241
+ const focus = captureFocus()
1158
1242
  busyRef.current = true
1159
1243
  setBusy(true)
1160
1244
  setError(null)
1161
1245
  try {
1162
1246
  const result = await onSave(values)
1163
1247
  if (result === false) throw new Error('保存失败,请重试')
1248
+ restoreSaveBarFocus(focus)
1164
1249
  return result
1165
1250
  } catch (failure) {
1166
1251
  setError(String((failure && failure.message) || failure || '保存失败,请重试'))
@@ -1172,8 +1257,10 @@ window.__ModuleLoader__.load({
1172
1257
  }
1173
1258
  const discard = () => {
1174
1259
  if (busyRef.current) return
1260
+ const focus = captureFocus()
1175
1261
  setError(null)
1176
1262
  onDiscard(opening)
1263
+ restoreSaveBarFocus({ ...focus, opener: null })
1177
1264
  }
1178
1265
  const renderField = (spec) => {
1179
1266
  if (spec.modes && !spec.modes.includes(mode)) return null
@@ -1215,12 +1302,21 @@ window.__ModuleLoader__.load({
1215
1302
  return h('span', { key: spec.key, className: 'dt-hint', placeholder }, spec.label + ' ' + placeholder)
1216
1303
  }))
1217
1304
  const submitFromClick = (event) => submit(event)
1218
- return h('form', { id: idPrefix, className: 'dt-form dt-card', 'data-mode': mode, onSubmit: submit },
1305
+ return h('form', {
1306
+ id: idPrefix, ref: formRef, className: 'dt-form dt-card', 'data-mode': mode, onSubmit: submit,
1307
+ onFocusCapture: () => { formFocusedRef.current = true },
1308
+ onBlurCapture: (event) => {
1309
+ const next = event.relatedTarget
1310
+ // disabled 让当前控件失焦时 relatedTarget 可能为空;保存 pending 不应因此丢掉回焦资格。
1311
+ if ((!next || !event.currentTarget.contains(next)) && !(busyRef.current && !next)) formFocusedRef.current = false
1312
+ },
1313
+ },
1219
1314
  h(Fields, { disabled: busy || disabled },
1220
1315
  basic,
1221
1316
  h(DisclosureRow, {
1222
1317
  icon: h(Icon, { name: 'settings' }), title: '高级设置', open: advancedOpen,
1223
- onToggle: () => { if (!busy && !disabled) setAdvancedOpen(!advancedOpen) },
1318
+ busy, disabled,
1319
+ onToggle: () => { if (!busyRef.current && !busy && !disabled) setAdvancedOpen((current) => !current) },
1224
1320
  collapsedContent: collapsedAdvanced, bodyId: idPrefix + '-advanced-body',
1225
1321
  }, h('div', { className: 'dt-disclosure-body' }, advanced))),
1226
1322
  h(SaveBar, { dirty, busy, error, disabled, onDiscard: discard, onSave: submitFromClick, saveLabel: submitLabel }),
@@ -1243,6 +1339,9 @@ window.__ModuleLoader__.load({
1243
1339
 
1244
1340
  // 官方 Modal 的键盘行为:Escape 关闭 + Tab 焦点陷阱 + 关闭后焦点回到触发元素。
1245
1341
  // 移植时只搬了样式,行为是后补的(2026-11-02 对官方 controls.tsx 逐行比对时发现)。
1342
+ // 本地 Modal 打开层数:Modal 存在时 Escape 属于最上层对话框,底层 Orbit 的 capture 必须让位(W16)。
1343
+ // 用模块级计数而不是给 StatusOrbit 加 hook,保持它按位置取值的 hook 契约不变。
1344
+ let localDialogDepth = 0
1246
1345
  const FOCUSABLE = 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])'
1247
1346
  function trapTab(event, dialog) {
1248
1347
  const items = [...dialog.querySelectorAll('*')].filter((element) => element.matches(FOCUSABLE))
@@ -1264,6 +1363,7 @@ window.__ModuleLoader__.load({
1264
1363
  close.current = onClose
1265
1364
  useEffect(() => {
1266
1365
  if (!open || typeof document === 'undefined') return undefined
1366
+ localDialogDepth += 1
1267
1367
  restoreTo.current = document.activeElement
1268
1368
  // 打开后把焦点挪进对话框,否则键盘用户还停在背后的页面上
1269
1369
  const timer = setTimeout(() => {
@@ -1273,11 +1373,16 @@ window.__ModuleLoader__.load({
1273
1373
  ;(first || node).focus()
1274
1374
  }, 0)
1275
1375
  const onKey = (event) => {
1276
- if (event.key === 'Escape') { event.preventDefault(); close.current(); return }
1376
+ if (event.key === 'Escape') {
1377
+ // 已被更上层控件(如 fallback Tooltip)消费的 Escape 不再关 Modal。
1378
+ if (event.defaultPrevented) return
1379
+ event.preventDefault(); close.current(); return
1380
+ }
1277
1381
  if (event.key === 'Tab' && dialog.current) trapTab(event, dialog.current)
1278
1382
  }
1279
1383
  document.addEventListener('keydown', onKey)
1280
1384
  return () => {
1385
+ localDialogDepth = Math.max(0, localDialogDepth - 1)
1281
1386
  clearTimeout(timer)
1282
1387
  document.removeEventListener('keydown', onKey)
1283
1388
  const back = restoreTo.current
@@ -1355,7 +1460,7 @@ window.__ModuleLoader__.load({
1355
1460
  }
1356
1461
 
1357
1462
  /** 官方 ConfirmButton 动线:触发按钮只开 Modal,取消不执行,确认期间 busy 防重复。 */
1358
- function ConfirmButton({ label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, variant = 'ghost', icon, size, modalContext = 'panel', ButtonComponent = Btn, danger = true, preventDismissOnBusy = false, error = null, busyLabel = confirmLabel, busyHint }) {
1463
+ function ConfirmButton({ label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, variant = 'ghost', icon, size, modalContext = 'panel', ButtonComponent = Btn, danger = true, preventDismissOnBusy = false, error = null, busyLabel = confirmLabel, busyHint, onOpen }) {
1359
1464
  const [open, setOpen] = useState(false)
1360
1465
  const close = useCallback(() => setOpen(false), [])
1361
1466
  return h(React.Fragment, null,
@@ -1365,7 +1470,11 @@ window.__ModuleLoader__.load({
1365
1470
  icon,
1366
1471
  'aria-label': label,
1367
1472
  'aria-haspopup': 'dialog',
1368
- onClick: () => setOpen(true),
1473
+ onClick: () => {
1474
+ // 打开前先跑调用方的清理(例如清掉上一次「删除失败」);打开行为本身不变。
1475
+ if (typeof onOpen === 'function') onOpen()
1476
+ setOpen(true)
1477
+ },
1369
1478
  }, label),
1370
1479
  h(ConfirmDialog, { open, label, confirmLabel, title, message, onConfirm, onClose: close, modalContext, ButtonComponent, danger, preventDismissOnBusy, error, busyLabel, busyHint }))
1371
1480
  }
@@ -1584,7 +1693,8 @@ window.__ModuleLoader__.load({
1584
1693
  orbitRef: btnRef,
1585
1694
  onCloseOrbit: () => setOpen(false),
1586
1695
  // DSH 路径复用旧 anchor 槽保存待删 watcher;fallback 仍只保存手算坐标,状态槽位不变。
1587
- onRequestConfirm: ({ watcher }) => setAnchor(watcher),
1696
+ // 打开时先清掉上一次的「删除失败:…」,否则新确认框一打开就带着别人的错误。
1697
+ onRequestConfirm: ({ watcher }) => openDeleteConfirm(watcher),
1588
1698
  })
1589
1699
 
1590
1700
  const isReadError = (value) => typeof value === 'string'
@@ -1623,16 +1733,33 @@ window.__ModuleLoader__.load({
1623
1733
  // 而弹层是"一开就要好看"的东西,不能等到下次渲染才发现没样式
1624
1734
  useEffect(() => { if (open) ensurePortedCss(true) }, [open])
1625
1735
 
1736
+ // 终审 N2:删除失败只属于「那一次确认框」。打开新的删除确认时必须先清掉它,
1737
+ // 否则 A 的失败会跟着 B 的确认框一起出现(B 还没发任何请求)。读取错误属于列表状态,不能一起清。
1738
+ const clearDeleteError = () => setOrbitError((current) =>
1739
+ typeof current === 'string' && current.startsWith('删除失败:') ? null : current)
1740
+ const openDeleteConfirm = (watcher) => {
1741
+ // 先选中待删 watcher(保持原有 state 调用顺序),再清旧错误;两者同批渲染。
1742
+ setAnchor(watcher)
1743
+ clearDeleteError()
1744
+ }
1745
+
1626
1746
  useEffect(() => {
1627
1747
  // 仅旧路径保留 capture mousedown / 手算焦点;DSH 由 OrbitPopover 与宿主 dismiss hook 接管。
1628
1748
  if (!open || hostOrbit) return undefined
1629
1749
  const onDown = (event) => {
1750
+ // 本地确认 Modal 在最上层时,点背板/取消不能穿透到 Orbit(W16)。
1751
+ if (localDialogDepth > 0) return
1630
1752
  const target = event.target
1631
1753
  if (panelRef.current && panelRef.current.contains(target)) return
1632
1754
  if (btnRef.current && btnRef.current.contains(target)) return
1633
1755
  setOpen(false)
1634
1756
  }
1635
- const onKey = (event) => { if (event.key === 'Escape') setOpen(false) }
1757
+ const onKey = (event) => {
1758
+ if (event.key !== 'Escape' || event.repeat) return
1759
+ // 第一次 Escape 只关 Modal;Modal 的 keydown 在 bubble 阶段处理并归还焦点(W16)。
1760
+ if (localDialogDepth > 0) return
1761
+ setOpen(false)
1762
+ }
1636
1763
  document.addEventListener('mousedown', onDown, true)
1637
1764
  document.addEventListener('keydown', onKey, true)
1638
1765
  // 键盘可达:打开后把焦点送进弹层(Tab 才能顺序走进去),关掉时还给圆环按钮。
@@ -1707,7 +1834,7 @@ window.__ModuleLoader__.load({
1707
1834
  // 新数组只触发一次渲染,watcher 内容不变;可见 pending 直接读取同步锁集合。
1708
1835
  setWatchers((current) => Array.isArray(current) ? [...current] : current)
1709
1836
  if (action === 'delete') {
1710
- setOrbitError((current) => typeof current === 'string' && current.startsWith('删除失败:') ? null : current)
1837
+ clearDeleteError()
1711
1838
  }
1712
1839
  try {
1713
1840
  // 删除只走 ConfirmButton + Modal;不要再叠一层原生确认框(同一动作问两次)。
@@ -1732,6 +1859,8 @@ window.__ModuleLoader__.load({
1732
1859
  // fallback 完全保留原提前返回;DSH 即使 orbit 已关,也要继续渲染由本组件持有的确认 Modal。
1733
1860
  if (!open && !hostOrbit) return button
1734
1861
  const closeConfirm = () => {
1862
+ // 关掉确认框等于放弃这一次删除:错误跟着走,不要留在弹层里冒充「刚发生的失败」。
1863
+ clearDeleteError()
1735
1864
  setAnchor(null)
1736
1865
  orbitConfirm.onConfirmClose()
1737
1866
  }
@@ -1803,6 +1932,8 @@ window.__ModuleLoader__.load({
1803
1932
  : h(ConfirmButton, {
1804
1933
  label: '删除', confirmLabel: '确认删除', variant: 'ghost', size: 'sm', modalContext: 'orbit',
1805
1934
  icon: h(Icon, { name: 'trash' }),
1935
+ // 打开确认框时清掉上一次的删除失败(读取错误不动);本次失败由 act() 重新写入。
1936
+ onOpen: clearDeleteError,
1806
1937
  onConfirm: () => act(w, 'delete'), error: deleteError,
1807
1938
  preventDismissOnBusy: true, busyLabel: '删除中…', busyHint: '删除进行中,完成后才能关闭',
1808
1939
  }))
@@ -1938,7 +2069,9 @@ window.__ModuleLoader__.load({
1938
2069
  }, [intervalMs])
1939
2070
  }
1940
2071
 
1941
- /** 轻量 Toast:DSH 可用时由宿主计时;fallback 保留原有 4 秒自动消失。 */
2072
+ /** 轻量 Toast:DSH 可用时由宿主计时;fallback 保留 4 秒自动消失。 */
2073
+ const TOAST_HOLD_MS = 3000
2074
+ const TOAST_FADE_MS = 1000
1942
2075
  function useToast() {
1943
2076
  if (hostUi) {
1944
2077
  const { item, notify, dismiss } = hostUi.createToastState()
@@ -1954,16 +2087,19 @@ window.__ModuleLoader__.load({
1954
2087
  const notify = useCallback((text, tone = 'info') => {
1955
2088
  if (timer.current) clearTimeout(timer.current)
1956
2089
  setItem({ id: Math.random().toString(36).slice(2), text, tone })
1957
- timer.current = setTimeout(() => setItem(null), 4000)
2090
+ // timer 覆盖 hold + fade 全段;比只等 hold 长 1 秒,淡出不会被提前卸载打断。
2091
+ timer.current = setTimeout(() => setItem(null), TOAST_HOLD_MS + TOAST_FADE_MS)
1958
2092
  }, [])
1959
2093
  const view = item === null ? null : h('div', {
2094
+ // key 用 item.id:连续通知换 id 时 React 会重建节点,dt-toast-in 动画才会从头播(W17)。
2095
+ key: item.id,
1960
2096
  className: cx('dt-toast', item.tone === 'error' && 'dt-danger'),
1961
2097
  role: 'status',
1962
2098
  'aria-live': 'polite',
1963
2099
  // 官方 toast 是深底白字;错误态不要改成浅红底(白字会看不清),改用左侧红条标记
1964
2100
  style: item.tone === 'error'
1965
- ? { '--dt-toast-hold': '3600ms', borderLeft: '3px solid var(--dsw-alias-state-error-primary)' }
1966
- : { '--dt-toast-hold': '3600ms' },
2101
+ ? { '--dt-toast-hold': TOAST_HOLD_MS + 'ms', borderLeft: '3px solid var(--dsw-alias-state-error-primary)' }
2102
+ : { '--dt-toast-hold': TOAST_HOLD_MS + 'ms' },
1967
2103
  }, item.text)
1968
2104
  return [view, notify]
1969
2105
  }
@@ -1971,7 +2107,7 @@ window.__ModuleLoader__.load({
1971
2107
  /** 判定页内联追溯时间线:结构化 traces 优先,旧服务端只有 text 时降级。 */
1972
2108
  function TraceTimeline({ payload }) {
1973
2109
  if (payload.loading) return h('p', { className: 'dt-hint' }, '正在追溯 #' + payload.number + '…')
1974
- if (payload.error) return h('p', { className: 'dt-error' }, '追溯失败:' + payload.error)
2110
+ if (payload.error) return h('p', { className: 'dt-error', role: 'alert', 'aria-atomic': 'true' }, '追溯失败:' + payload.error)
1975
2111
  const traces = Array.isArray(payload.traces) ? payload.traces : []
1976
2112
  if (traces.length === 0) return h('p', { className: 'dt-hint' }, payload.text || '没有结果')
1977
2113
  return h('ol', { className: 'dt-timeline' }, traces.map((trace) => {
@@ -2074,6 +2210,8 @@ window.__ModuleLoader__.load({
2074
2210
  const [giteeToken, setGiteeToken] = useState('')
2075
2211
  // 判定页内联追溯结果(官方 Thread 详情最小吸收):不再只塞进一条 Toast。
2076
2212
  const [traceResult, setTraceResult] = useState(null)
2213
+ // 每次追溯独占一个代际:新编号一开始,旧请求的结果/错误就全部作废。
2214
+ const traceSeqRef = useRef(0)
2077
2215
  // 安装回执与版本检查分开:POST 失败不能冲掉当前版本和命令回退。
2078
2216
  const [updateResult, setUpdateResult] = useState(null)
2079
2217
  // POST 后 GET 仍以 runningVersion 比较 latest;已装到 latest 且等待重载时,回执优先于 hasUpdate。
@@ -2087,8 +2225,8 @@ window.__ModuleLoader__.load({
2087
2225
  // 建议规则弹层:给"叫醒了没回音"一个下一步动作(只提供可复制的规则,不替客户写仓库文件)
2088
2226
 
2089
2227
  // 「我现在手上有没有能渲染的数据」。判断依据必须是**当前 snap**,不是"以前拿到过一次" ——
2090
- // 状态栏圆环每 5 秒全量拉一次 /state 并刷新模块级 stateEtag;面板首次挂载时正好带着这个
2091
- // etag 去问,首帧必然 304。旧代码在 304 分支直接 return、从不 setSnap,于是面板永远停在
2228
+ // 会话作用域的 etag 只属于本会话;面板挂载时如果带着一份自己以前留下的 etag(快照已丢),
2229
+ // 首帧会 304。旧代码在 304 分支直接 return、从不 setSnap,于是面板永远停在
2092
2230
  // {loading:true, body:null}:统计条全 0、列表空态、底下还挂着「正在读取…」(真机现象:2 条显示 0 条)。
2093
2231
  const hasBodyRef = useRef(false)
2094
2232
  hasBodyRef.current = Boolean(snap.body)
@@ -2096,28 +2234,49 @@ window.__ModuleLoader__.load({
2096
2234
  // 审核 M1:四条路径(轮询 / 工具栏刷新 / 错误卡重试 / run() 成功后)都能并发,
2097
2235
  // 没有序号时「后到的旧响应」会覆盖新数据。序号只认最新的那次。
2098
2236
  const loadSeqRef = useRef(0)
2099
- const load = useCallback(async () => {
2237
+ // 终审 N1:被更新的一次 load 顶掉时,旧的那次不能把「成功」当失败 ——
2238
+ // run() 的 requireReload 会因此假报「回读失败,请重试」(数据其实已经取到了)。
2239
+ // 记下最新一次的 promise:被顶掉就等它,用最新快照回话;它真失败时仍然按失败返回。
2240
+ const latestLoadRef = useRef(null)
2241
+ const load = useCallback(() => {
2100
2242
  const seq = ++loadSeqRef.current
2101
- const statePath = sessionId ? '/state?sessionId=' + encodeURIComponent(String(sessionId)) : '/state'
2102
- try {
2103
- const payload = await call(statePath, stateEtag ? { headers: { 'if-none-match': stateEtag } } : undefined)
2104
- if (seq !== loadSeqRef.current) return null // 已经有更新的一次请求在飞:这次结果作废
2105
- // 304:内容没变,别白白重渲染 —— 前提是本地已经有一份能渲染的 body
2106
- if (payload && payload.notModified) {
2107
- // 有本地快照时,304 也是一次成功回读;保存后的成功反馈可以依赖它。
2108
- if (hasBodyRef.current) return payload
2109
- // 本地没有数据:这次 304 是被状态栏的 etag 带出来的,清掉 etag 重取一次全量
2110
- stateEtag = null
2111
- return load()
2243
+ const job = (async () => {
2244
+ const statePath = sessionId ? '/state?sessionId=' + encodeURIComponent(String(sessionId)) : '/state'
2245
+ const etag = readStateEtag(statePath)
2246
+ try {
2247
+ const payload = await call(statePath, etag ? { headers: { 'if-none-match': etag } } : undefined)
2248
+ // 已经有更新的一次请求在飞:等它的结果,别把自己的成功报成失败
2249
+ if (seq !== loadSeqRef.current) return await (latestLoadRef.current || null)
2250
+ // 304:内容没变,前提是本地已经有一份能渲染的 body
2251
+ if (payload && payload.notModified) {
2252
+ // 有本地快照时,304 也是一次成功回读;清掉此前的 500/网络错误。
2253
+ // 正常且无旧错时返回原 state,避免每次条件轮询都重渲染。
2254
+ if (hasBodyRef.current) {
2255
+ setSnap((prev) => prev.error || prev.loading
2256
+ ? { loading: false, error: null, body: prev.body }
2257
+ : prev)
2258
+ return payload
2259
+ }
2260
+ // 本地没有数据:这次 304 是被同一作用域旧 etag 带出来的,清掉它重取一次全量
2261
+ writeStateEtag(statePath, null)
2262
+ return load()
2263
+ }
2264
+ const body = payload
2265
+ setSnap({ loading: false, error: null, body })
2266
+ return body
2267
+ } catch (error) {
2268
+ // 旧请求的失败同样不盖新数据:等最新那次的结果(它失败就一并按失败返回)
2269
+ if (seq !== loadSeqRef.current) return await (latestLoadRef.current || null)
2270
+ const message = String((error && error.message) || error)
2271
+ // 同文轮询失败复用同一 snap/alert DOM;显式重试成功仍会清错,错误文本变化仍会通知。
2272
+ setSnap((prev) => prev.error === message && !prev.loading
2273
+ ? prev
2274
+ : { loading: false, error: message, body: prev.body })
2275
+ return null
2112
2276
  }
2113
- const body = payload
2114
- setSnap({ loading: false, error: null, body })
2115
- return body
2116
- } catch (error) {
2117
- if (seq !== loadSeqRef.current) return null // 旧请求的失败也别盖掉新数据
2118
- setSnap((prev) => ({ loading: false, error: String((error && error.message) || error), body: prev.body }))
2119
- return null
2120
- }
2277
+ })()
2278
+ latestLoadRef.current = job
2279
+ return job
2121
2280
  }, [sessionId])
2122
2281
 
2123
2282
  useEffect(() => { ensurePortedCss() }, [])
@@ -2369,7 +2528,10 @@ window.__ModuleLoader__.load({
2369
2528
  return warnings
2370
2529
  }, null, { rethrow: true })
2371
2530
 
2531
+ const credentialsDirty = Boolean(token.trim() || giteeToken.trim() || ghDir.trim())
2372
2532
  const saveCredentials = () => {
2533
+ // 空草稿没有可保存的改动;即使绕过 disabled 直接调用,也不能发 {} 后假报成功。
2534
+ if (!credentialsDirty) return Promise.resolve(false)
2373
2535
  const draftVersion = credentialsDraftVersionRef.current
2374
2536
  let saveSeq = 0
2375
2537
  return run(async () => {
@@ -2401,6 +2563,8 @@ window.__ModuleLoader__.load({
2401
2563
  }, '已解绑 gh 账号目录(评论改回宿主账号)')
2402
2564
 
2403
2565
  const saveGoal = () => {
2566
+ // 与按钮/文本域的 disabled 同一道防线:没有会话归属时不能提交或假报成功。
2567
+ if (!sessionId) return Promise.resolve(false)
2404
2568
  const draftVersion = goalDraftVersionRef.current
2405
2569
  let saveSeq = 0
2406
2570
  return run(async () => {
@@ -2635,7 +2799,7 @@ window.__ModuleLoader__.load({
2635
2799
  // 两处并排会让同一句话在同一屏出现两次;而且「时段外 / 已停用」是配置出来的状态、不是待处理的问题。
2636
2800
  }
2637
2801
  if (body.gh && body.gh.ok === false && credentials.token === 'none') {
2638
- problems.push({ key: 'gh', rank: 0, kind: 'gh', text: 'gh CLI 不可用,且没有配置 token —— 现在所有轮询都会失败。先跑 gh auth login,或在「设置 → 来源」填一个 token。' })
2802
+ problems.push({ key: 'gh', rank: 0, kind: 'gh', text: 'gh CLI 不可用,且没有配置 token —— 现在所有轮询都会失败。先跑 gh auth login,或在「设置 → 凭证」填一个 token。' })
2639
2803
  }
2640
2804
  if (watchers.length > 0 && credentials.token === 'none') {
2641
2805
  problems.push({ key: 'cred', rank: 7, kind: 'cred', text: '未配置 token,正在复用已登录的 gh CLI(可用 panel 填 token 换成独立凭据)' })
@@ -2649,6 +2813,7 @@ window.__ModuleLoader__.load({
2649
2813
  const matchesBadge = (watcher) => !badgeFilter
2650
2814
  || repoBadges(watcher.repoAccess).some((badge) => badge.text === badgeFilter)
2651
2815
  const hasProblem = (watcher) => Boolean(watcher.lastError)
2816
+ || Boolean(watcher.lastReopened)
2652
2817
  || Number(watcher.silentWakes) >= 2
2653
2818
  || Boolean(repoStructureNote(watcher.repoAccess))
2654
2819
  || repoBadges(watcher.repoAccess).some((badge) => badge.tone === 'warning' || badge.tone === 'danger')
@@ -2663,6 +2828,10 @@ window.__ModuleLoader__.load({
2663
2828
  const visible = watchers.filter((watcher) => matches(watcher) && matchesBadge(watcher) && stateMatches(watcher)
2664
2829
  && (!problemsOnly || hasProblem(watcher))
2665
2830
  && (!deferFilter || watcher.deferReason === deferFilter))
2831
+ const hasActiveFilters = Boolean(needle || badgeFilter || stateFilter || problemsOnly || deferFilter)
2832
+ const clearAllFilters = () => {
2833
+ setBadgeFilter(null); setStateFilter(null); setSearch(''); setProblemsOnly(false); setReasonFilter(null)
2834
+ }
2666
2835
 
2667
2836
  // T24 W1:「全部暂停/全部恢复」对**这一屏**生效,可用性也按这一屏算(同口径)。
2668
2837
  const pausable = countPausable(visible)
@@ -2688,11 +2857,7 @@ window.__ModuleLoader__.load({
2688
2857
  })(),
2689
2858
  ...chips.map((chip) => h(Pill, { key: chip.label, onClick: chip.clear }, chip.label + ' ✕')),
2690
2859
  chips.length > 1
2691
- ? h(Pill, {
2692
- key: '__all', onClick: () => {
2693
- setBadgeFilter(null); setStateFilter(null); setSearch(''); setProblemsOnly(false); setReasonFilter(null)
2694
- },
2695
- }, '全部清除')
2860
+ ? h(Pill, { key: '__all', onClick: clearAllFilters }, '全部清除')
2696
2861
  : null)
2697
2862
  })()
2698
2863
 
@@ -2707,6 +2872,11 @@ window.__ModuleLoader__.load({
2707
2872
  return acc
2708
2873
  }, { woken: 0, acked: 0 })
2709
2874
 
2875
+ // 服务端已限制每守带回的记录数;面板在全局合并后排序,不能按守各切两条再拼接。
2876
+ const filteredEntries = watchers
2877
+ .flatMap((watcher) => (watcher.filteredLog || []).map((entry, sourceIndex) => ({ watcher, entry, sourceIndex })))
2878
+ .sort((a, b) => String(b.entry.at || '').localeCompare(String(a.entry.at || '')))
2879
+
2710
2880
  const overview = [
2711
2881
  filterSummary,
2712
2882
  h('div', { className: 'dt-stats', key: 'stats' },
@@ -2735,12 +2905,22 @@ window.__ModuleLoader__.load({
2735
2905
  key: 'dormant', value: dormant, unit: '时段外',
2736
2906
  active: stateFilter === 'dormant', onClick: () => setStateFilter(stateFilter === 'dormant' ? null : 'dormant'),
2737
2907
  }) : null),
2738
- watchers.some((w) => (w.filteredLog || []).length > 0)
2908
+ filteredEntries.length > 0
2739
2909
  ? h(Section, { key: 'filtered', title: '最近被过滤' },
2740
2910
  h(CollapsibleList, {
2741
2911
  title: '看被过滤的条目',
2742
- items: watchers.flatMap((w) => (w.filteredLog || []).slice(-2).map((entry) =>
2743
- '#' + entry.number + ' ' + (entry.title || '') + ' — ' + entry.reason)),
2912
+ items: filteredEntries.map(({ watcher, entry, sourceIndex }) => {
2913
+ const head = watcher.repo + ' · 会话 ' + sessionTag(watcher.sessionId)
2914
+ + ' · #' + String(entry.number ?? '—') + ' ' + (entry.title || '') + ' — ' + entry.reason
2915
+ const at = String(entry.at || '')
2916
+ return {
2917
+ key: ['filtered', watcher.sessionId, watcher.repo, entry.number, entry.at, entry.reason, sourceIndex]
2918
+ .map((part) => String(part ?? '')).join('|'),
2919
+ summary: head + ' · ' + (at || '时间未知'),
2920
+ content: h(React.Fragment, null, head, ' · ',
2921
+ h('time', { dateTime: at || undefined, title: at || undefined }, at || '时间未知')),
2922
+ }
2923
+ }),
2744
2924
  }))
2745
2925
  : null,
2746
2926
  // 排序:会丢消息的(失败/没回音)排前面;静态提示(仓库归档、只读)排后面
@@ -2782,7 +2962,16 @@ window.__ModuleLoader__.load({
2782
2962
  watchers.length === 0
2783
2963
  ? h(Onboarding, { onStart: () => setTab('trigger') })
2784
2964
  : visible.length === 0
2785
- ? h(Hint, null, '没有匹配「' + search + '」的主理鱼。')
2965
+ ? h('div', { className: 'dt-empty' },
2966
+ h(Hint, null, needle
2967
+ ? '没有匹配「' + search.trim() + '」的主理鱼。'
2968
+ : hasActiveFilters
2969
+ ? '没有符合当前筛选条件的主理鱼。'
2970
+ : '当前没有可显示的主理鱼。'),
2971
+ hasActiveFilters
2972
+ ? h('div', { className: 'dt-actions' },
2973
+ h(Btn, { size: 'sm', variant: 'outline', onClick: clearAllFilters }, '清除全部筛选'))
2974
+ : null)
2786
2975
  : h('ul', { className: 'dt-list' }, visible.map(row))),
2787
2976
  ]
2788
2977
 
@@ -2815,12 +3004,15 @@ window.__ModuleLoader__.load({
2815
3004
  className: 'dt-textlink',
2816
3005
  type: 'button',
2817
3006
  onClick: async () => {
3007
+ const seq = ++traceSeqRef.current
2818
3008
  setTraceResult({ loading: true, number: asNumber })
2819
3009
  try {
2820
3010
  const query = '/trace?number=' + encodeURIComponent(asNumber) + (onlyRepo ? '&repo=' + encodeURIComponent(onlyRepo) : '')
2821
3011
  const payload = await call(query)
3012
+ if (seq !== traceSeqRef.current) return
2822
3013
  setTraceResult(payload || { text: '没有结果', traces: [] })
2823
3014
  } catch (error) {
3015
+ if (seq !== traceSeqRef.current) return
2824
3016
  setTraceResult({ error: String((error && error.message) || error), number: asNumber })
2825
3017
  }
2826
3018
  },
@@ -2930,7 +3122,13 @@ window.__ModuleLoader__.load({
2930
3122
  h('time', { className: 'dt-event-time', dateTime: entry.at, title: entry.at }, ageText(entry.at)))))
2931
3123
  }
2932
3124
 
2933
- // 迷你时间线:回答"为什么这一轮没叫醒我"
3125
+ // 迷你时间线:回答"为什么这一轮没叫醒我"。先全局合并排序,再兑现标题的最近 20 条。
3126
+ const runtimeEvents = watchers
3127
+ .flatMap((watcher) => (watcher.events || []).map((event, sourceIndex) => ({ watcher, event, sourceIndex })))
3128
+ .sort((a, b) => String(b.event.at || '').localeCompare(String(a.event.at || ''))
3129
+ // 同守同时间戳仍保持原先 slice().reverse() 的后进先出;跨守同刻交给稳定排序。
3130
+ || (a.watcher === b.watcher ? b.sourceIndex - a.sourceIndex : 0))
3131
+ .slice(0, 20)
2934
3132
  const timeline = h(Section, {
2935
3133
  key: 'timeline',
2936
3134
  title: '运行时事件(最近 20 条)',
@@ -2939,19 +3137,24 @@ window.__ModuleLoader__.load({
2939
3137
  },
2940
3138
  watchers.length === 0
2941
3139
  ? h(Hint, null, '还没有守。添加一条之后,这里会记录每次唤醒、攒着、限流、回收。')
2942
- : h('ol', { className: 'dt-timeline' }, watchers.flatMap((watcher) => (watcher.events || []).slice().reverse().map((event, index) => h('li', {
2943
- key: watcher.repo + '-ev' + index,
2944
- className: 'dt-event',
2945
- },
2946
- h('div', { className: 'dt-event-head' },
2947
- h(Tag, { tone: event.kind === 'wake' ? 'success' : event.kind === 'wake-failed' ? 'danger' : 'outline' },
2948
- event.kind + (Number(event.count) > 1 ? ' ×' + event.count : '')),
2949
- (Number(event.count) > 1 && event.since)
2950
- ? h('span', { className: 'dt-row-meta' }, '持续 ' + durationText(event.since, event.at))
2951
- : null,
2952
- h('span', { className: 'dt-row-meta' }, ageText(event.at))),
2953
- h('div', { className: 'dt-event-text' }, watcher.repo + ' · ' + event.text),
2954
- h('div', { className: 'dt-event-foot' }, event.at))))))
3140
+ : runtimeEvents.length === 0
3141
+ ? h(Hint, null, '还没有运行时事件;完成一次轮询后,这里会记录唤醒、攒着、限流、回收。')
3142
+ : h('ol', { className: 'dt-timeline' }, runtimeEvents.map(({ watcher, event, sourceIndex }) => h('li', {
3143
+ key: ['event', watcher.sessionId, watcher.repo,
3144
+ event.number ?? (Array.isArray(event.numbers) ? event.numbers.join(',') : ''),
3145
+ event.kind, event.at, sourceIndex].map((part) => String(part ?? '')).join('|'),
3146
+ className: 'dt-event',
3147
+ },
3148
+ h('div', { className: 'dt-event-head' },
3149
+ h(Tag, { tone: event.kind === 'wake' ? 'success' : event.kind === 'wake-failed' ? 'danger' : 'outline' },
3150
+ event.kind + (Number(event.count) > 1 ? ' ×' + event.count : '')),
3151
+ (Number(event.count) > 1 && event.since)
3152
+ ? h('span', { className: 'dt-row-meta' }, '持续 ' + durationText(event.since, event.at))
3153
+ : null,
3154
+ h('span', { className: 'dt-row-meta' }, '会话 ' + sessionTag(watcher.sessionId)),
3155
+ h('span', { className: 'dt-row-meta' }, ageText(event.at))),
3156
+ h('div', { className: 'dt-event-text' }, watcher.repo + ' · ' + event.text),
3157
+ h('div', { className: 'dt-event-foot' }, event.at)))))
2955
3158
 
2956
3159
  // 按仓库汇总:守多个仓库时先看哪个健康,再看明细(渐进披露)
2957
3160
  const problemCount = watchers.filter(hasProblem).length
@@ -2985,7 +3188,9 @@ window.__ModuleLoader__.load({
2985
3188
  ]
2986
3189
  })())
2987
3190
  : null,
2988
- visible.length === 0 ? h(Hint, null, '没有符合条件的主理鱼。点上面「全部」看所有守。') : null,
3191
+ visible.length === 0 && watchers.length > 0
3192
+ ? h(Hint, null, '按仓库汇总也为空;请用上方「清除全部筛选」恢复。')
3193
+ : null,
2989
3194
  h('div', { className: 'dt-rows' }, ...summarizeByRepo(visible).map((group) => h('div', { key: 'repo-' + group.repo, className: 'dt-row' },
2990
3195
  h('div', { className: 'dt-row-main' },
2991
3196
  h('div', { className: 'dt-row-title' },
@@ -3036,7 +3241,7 @@ window.__ModuleLoader__.load({
3036
3241
  ? '不需要(没有 GitHub 主理鱼)' + (body.gh.skipped ? ' · ' + String(body.gh.skipped) : '')
3037
3242
  : body.gh.ok
3038
3243
  ? '可用 · ' + (body.gh.version || '')
3039
- : '不可用 —— 先跑 gh auth login(或装 gh CLI);也可以直接在下面填 token · ' + String(body.gh.error || '').slice(0, 80)],
3244
+ : '不可用 —— 先跑 gh auth login(或装 gh CLI);也可以去「凭证」填 token · ' + String(body.gh.error || '').slice(0, 80)],
3040
3245
  // 标签要能和左栏「凭证」分区区分开;值要写出「面板 token / gh 登录态」二选一。
3041
3246
  ['GitHub 凭证', credentials.token === 'none' ? '回退到已登录的 gh CLI' : '用面板 token(不再需要 gh login)'],
3042
3247
  ['权限范围', (() => {
@@ -3068,12 +3273,14 @@ window.__ModuleLoader__.load({
3068
3273
  credentials.ghConfigDir === 'configured'
3069
3274
  ? h('div', { className: 'dt-actions' }, h(Btn, { variant: 'ghost', size: 'sm', onClick: clearGhDir }, '解绑 gh 账号目录'))
3070
3275
  : null,
3071
- h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveCredentials }, '保存凭证')),
3276
+ h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveCredentials, disabled: !credentialsDirty }, '保存凭证')),
3072
3277
  h(Hint, null, '不填也能用:插件直接复用已登录的 gh CLI。填了 gh 账号目录,插件就用那个目录里的账号发言(git push 仍用会话自己的身份,唤醒消息里会提醒会话)。')),
3073
3278
  h(Section, { key: 'update', title: '版本与更新' },
3074
3279
  h(KeyValues, { rows: [
3075
3280
  ['当前版本', (update && update.current) || CLIENT_VERSION],
3076
- ['npm 最新', !update ? '检测中…' : update.error ? '检测失败 · ' + update.error : (update.latest || '未知')],
3281
+ ['npm 最新', !update ? '检测中…' : update.error
3282
+ ? h('span', { className: 'dt-error', role: 'alert', 'aria-atomic': 'true' }, '检测失败 · ' + update.error)
3283
+ : (update.latest || '未知')],
3077
3284
  ['状态', updateResult && updateResult.resultUnknown
3078
3285
  ? UPDATE_UNKNOWN_HINT
3079
3286
  : updateAwaitingReload
@@ -3143,9 +3350,11 @@ window.__ModuleLoader__.load({
3143
3350
  h(Section, { key: 'goal', title: '会话 goal' },
3144
3351
  h('textarea', {
3145
3352
  className: 'dt-textarea', rows: 3, value: goalDraft,
3353
+ 'aria-label': '会话 goal', disabled: !sessionId,
3146
3354
  placeholder: '这个会话要达成什么(会写进 /goal)',
3147
3355
  onChange: (e) => { goalDraftVersionRef.current += 1; setGoalTouched(true); setGoalDraft(e.target.value) },
3148
3356
  }),
3357
+ !sessionId ? h(Hint, null, '没有会话上下文,无法编辑或保存 goal;请先在会话里打开本面板。') : null,
3149
3358
  h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveGoal, disabled: !sessionId }, '保存 goal'))),
3150
3359
  ]
3151
3360
 
@@ -3397,7 +3606,7 @@ window.__ModuleLoader__.load({
3397
3606
  ],
3398
3607
  value: tab, onChange: setTab, label: '主理鱼分区',
3399
3608
  }),
3400
- notice ? h('div', { className: 'dt-banner dt-danger' }, notice.text) : null,
3609
+ notice ? h('div', { className: 'dt-banner dt-danger', role: 'alert', 'aria-atomic': 'true' }, notice.text) : null,
3401
3610
  // 有新版本时在顶部提示一次;已装到 latest 且等待重载时完全隐藏,避免重复安装入口。
3402
3611
  update && update.hasUpdate && !updateAwaitingReload
3403
3612
  ? h('div', { className: 'dt-banner dt-banner-actions' },
@@ -3408,7 +3617,7 @@ window.__ModuleLoader__.load({
3408
3617
  snap.error
3409
3618
  ? h('div', { className: 'dt-card dt-error-card', key: 'read-error' },
3410
3619
  h('div', { className: 'dt-card-head' }, h('span', { className: 'dt-card-title' }, '读不到面板数据')),
3411
- h('p', { className: 'dt-error' }, humanizeError(snap.error)),
3620
+ h('p', { className: 'dt-error', role: 'alert', 'aria-atomic': 'true' }, humanizeError(snap.error)),
3412
3621
  h('div', { className: 'dt-actions' }, h(Btn, { size: 'sm', variant: 'primary', onClick: () => load() }, '重试')))
3413
3622
  : null,
3414
3623
  snap.loading && !snap.body ? h(Hint, null, '正在读取…') : null,
package/lib/index.js CHANGED
@@ -49,7 +49,7 @@ import {
49
49
 
50
50
  export const name = 'dsh-session-superagent'
51
51
  /** 服务端版本:随 package.json 同步(meta 测试守着)。客户端据此挑「最新的那个实例」。 */
52
- export const SERVER_VERSION = '0.9.286'
52
+ export const SERVER_VERSION = '0.10.0'
53
53
  export const inject = ['tools', 'agents', 'webServer']
54
54
  /** 一条会话每小时最多被唤醒几次(跨所有守累计)。单守上限挡不住多守叠加。 */
55
55
  // 本进程启动时刻:用来区分「刚重启还没轮到」与「定时器真的丢了」
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-session-superagent",
3
- "version": "0.9.286",
3
+ "version": "0.10.0",
4
4
  "description": "Session-level superagent for DeepSeek Harness: watch a GitHub repository and wake a session when something needs doing. Credentials never reach the model.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",