dsh-session-superagent 0.9.285 → 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 +54 -0
- package/README.md +3 -3
- package/client.js +371 -117
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,60 @@
|
|
|
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
|
+
|
|
40
|
+
## [0.9.286] - 2026-11-06 —— 切换中的 dirty 草稿保护
|
|
41
|
+
|
|
42
|
+
### 折叠/切换不再静默丢草稿
|
|
43
|
+
|
|
44
|
+
- dirty 折叠或切换复用 `ConfirmDialog → PanelModal → DSH Modal`。
|
|
45
|
+
- 取消、Escape、遮罩与关闭都保留当前 draft 和 touched;确认放弃才重置。
|
|
46
|
+
- 切换确认后载入目标 watcher 的干净快照,无 dirty 时保持原直达行为。
|
|
47
|
+
- 确认期间原表单仍挂载,连点受 busy 锁保护,不产生意外 POST。
|
|
48
|
+
- Modal 获焦,关闭后返回触发按钮。
|
|
49
|
+
|
|
50
|
+
### 验证
|
|
51
|
+
|
|
52
|
+
- 新增用例先红 1 绿 2 红,修后定向 4/4。
|
|
53
|
+
- 全量 **648/648**,UI 体检 **11/11=100**。
|
|
54
|
+
- 真实 Chromium **54/54**,新增 7 项覆盖取消/Escape/确认/焦点/clean 切回。
|
|
55
|
+
- 功能走查 mutation=0,防写探针 403。
|
|
56
|
+
|
|
57
|
+
未验真实 DSH Web GUI 与真实 watcher 写操作。按 Git 工作流保留本地候选。
|
|
58
|
+
|
|
5
59
|
## [0.9.285] - 2026-11-06 —— /state 会话上下文修复
|
|
6
60
|
|
|
7
61
|
### 主面板带 sessionId
|
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)
|
|
6
|
-
[](https://github.com/MYCF711/dsh-session-superagent/releases)
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-session-superagent)
|
|
8
8
|
[](https://github.com/topics/dsh-plugin)
|
|
9
9
|
[](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
|
|
@@ -148,7 +148,7 @@ Gitee 私有仓库要在「设置 → 凭证」填私人令牌;公开仓库不
|
|
|
148
148
|
## 开发
|
|
149
149
|
|
|
150
150
|
```sh
|
|
151
|
-
npm test #
|
|
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 #
|
|
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.
|
|
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
|
-
|
|
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)
|
|
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'))
|
|
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('
|
|
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((
|
|
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
|
|
906
|
-
function Pill({ active
|
|
921
|
+
/** DSH Pill:active 有定义时才是 toggle;无 active 的 onClick 只是动作,静态则无 onClick。 */
|
|
922
|
+
function Pill({ active, className, onClick, children, ...rest }) {
|
|
907
923
|
if (hostPill) {
|
|
908
|
-
// 官方没有 aria-pressed
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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', {
|
|
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', {
|
|
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
|
-
|
|
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') {
|
|
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: () =>
|
|
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
|
-
|
|
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) => {
|
|
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
|
-
|
|
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
|
|
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
|
|
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': '
|
|
1966
|
-
: { '--dt-toast-hold': '
|
|
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) => {
|
|
@@ -2033,6 +2169,7 @@ window.__ModuleLoader__.load({
|
|
|
2033
2169
|
const createTouchedRef = useRef(new Set())
|
|
2034
2170
|
const createSnapshotRef = useRef({ ...CREATE_WATCHER_VALUES })
|
|
2035
2171
|
const editSnapshotRef = useRef(null)
|
|
2172
|
+
const watcherDraftConfirmedRef = useRef(false)
|
|
2036
2173
|
// 保存期间仍可输入:旧响应只能清理它提交的那份草稿,不能覆盖 pending 后的新输入。
|
|
2037
2174
|
const credentialsDraftVersionRef = useRef(0)
|
|
2038
2175
|
const credentialsSaveSeqRef = useRef(0)
|
|
@@ -2052,6 +2189,7 @@ window.__ModuleLoader__.load({
|
|
|
2052
2189
|
setForm({ ...form, [key]: value })
|
|
2053
2190
|
}
|
|
2054
2191
|
const [search, setSearch] = useState('')
|
|
2192
|
+
// 面板弹层共用既有状态槽:术语/规则使用 boolean/string,dirty 编辑确认使用对象。
|
|
2055
2193
|
const [glossary, setGlossary] = useState(false)
|
|
2056
2194
|
// 版本检查结果(只读):面板里直接告诉客户「有没有新版本、该跑什么命令」
|
|
2057
2195
|
const [update, setUpdate] = useState(null)
|
|
@@ -2072,6 +2210,8 @@ window.__ModuleLoader__.load({
|
|
|
2072
2210
|
const [giteeToken, setGiteeToken] = useState('')
|
|
2073
2211
|
// 判定页内联追溯结果(官方 Thread 详情最小吸收):不再只塞进一条 Toast。
|
|
2074
2212
|
const [traceResult, setTraceResult] = useState(null)
|
|
2213
|
+
// 每次追溯独占一个代际:新编号一开始,旧请求的结果/错误就全部作废。
|
|
2214
|
+
const traceSeqRef = useRef(0)
|
|
2075
2215
|
// 安装回执与版本检查分开:POST 失败不能冲掉当前版本和命令回退。
|
|
2076
2216
|
const [updateResult, setUpdateResult] = useState(null)
|
|
2077
2217
|
// POST 后 GET 仍以 runningVersion 比较 latest;已装到 latest 且等待重载时,回执优先于 hasUpdate。
|
|
@@ -2085,8 +2225,8 @@ window.__ModuleLoader__.load({
|
|
|
2085
2225
|
// 建议规则弹层:给"叫醒了没回音"一个下一步动作(只提供可复制的规则,不替客户写仓库文件)
|
|
2086
2226
|
|
|
2087
2227
|
// 「我现在手上有没有能渲染的数据」。判断依据必须是**当前 snap**,不是"以前拿到过一次" ——
|
|
2088
|
-
//
|
|
2089
|
-
//
|
|
2228
|
+
// 会话作用域的 etag 只属于本会话;面板挂载时如果带着一份自己以前留下的 etag(快照已丢),
|
|
2229
|
+
// 首帧会 304。旧代码在 304 分支直接 return、从不 setSnap,于是面板永远停在
|
|
2090
2230
|
// {loading:true, body:null}:统计条全 0、列表空态、底下还挂着「正在读取…」(真机现象:2 条显示 0 条)。
|
|
2091
2231
|
const hasBodyRef = useRef(false)
|
|
2092
2232
|
hasBodyRef.current = Boolean(snap.body)
|
|
@@ -2094,28 +2234,49 @@ window.__ModuleLoader__.load({
|
|
|
2094
2234
|
// 审核 M1:四条路径(轮询 / 工具栏刷新 / 错误卡重试 / run() 成功后)都能并发,
|
|
2095
2235
|
// 没有序号时「后到的旧响应」会覆盖新数据。序号只认最新的那次。
|
|
2096
2236
|
const loadSeqRef = useRef(0)
|
|
2097
|
-
|
|
2237
|
+
// 终审 N1:被更新的一次 load 顶掉时,旧的那次不能把「成功」当失败 ——
|
|
2238
|
+
// run() 的 requireReload 会因此假报「回读失败,请重试」(数据其实已经取到了)。
|
|
2239
|
+
// 记下最新一次的 promise:被顶掉就等它,用最新快照回话;它真失败时仍然按失败返回。
|
|
2240
|
+
const latestLoadRef = useRef(null)
|
|
2241
|
+
const load = useCallback(() => {
|
|
2098
2242
|
const seq = ++loadSeqRef.current
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
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
|
|
2110
2276
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
} catch (error) {
|
|
2115
|
-
if (seq !== loadSeqRef.current) return null // 旧请求的失败也别盖掉新数据
|
|
2116
|
-
setSnap((prev) => ({ loading: false, error: String((error && error.message) || error), body: prev.body }))
|
|
2117
|
-
return null
|
|
2118
|
-
}
|
|
2277
|
+
})()
|
|
2278
|
+
latestLoadRef.current = job
|
|
2279
|
+
return job
|
|
2119
2280
|
}, [sessionId])
|
|
2120
2281
|
|
|
2121
2282
|
useEffect(() => { ensurePortedCss() }, [])
|
|
@@ -2125,6 +2286,65 @@ window.__ModuleLoader__.load({
|
|
|
2125
2286
|
// 默认值提示从后端读:写死 12/3/6 会在常量变化后变成谎话(JSON Schema 的 default 也是这个用法)
|
|
2126
2287
|
const DEFAULTS = body.defaults || {}
|
|
2127
2288
|
const watchers = body.watchers || []
|
|
2289
|
+
// 行内编辑只有这一条入口:clean 维持原直达行为;dirty 先确认,取消绝不重置 draft/touched。
|
|
2290
|
+
const applyWatcherEditor = (watcher, nextKey) => {
|
|
2291
|
+
const values = watcherValuesFrom(watcher)
|
|
2292
|
+
setEditing(nextKey)
|
|
2293
|
+
touchedRef.current = new Set()
|
|
2294
|
+
editSnapshotRef.current = nextKey ? { key: nextKey, values } : null
|
|
2295
|
+
setDraft({
|
|
2296
|
+
intervalSec: watcherNumberText(watcher.intervalSec ?? 60),
|
|
2297
|
+
labels: (watcher.filters && watcher.filters.labels ? watcher.filters.labels : []).join(','),
|
|
2298
|
+
ignoreLabels: (watcher.filters && watcher.filters.ignoreLabels ? watcher.filters.ignoreLabels : []).join(','),
|
|
2299
|
+
assignee: (watcher.filters && watcher.filters.assignee) || '',
|
|
2300
|
+
activeHours: watcher.activeHours || '',
|
|
2301
|
+
// `watcher.goal` 可能是 goalView 对象;输入框只能接收已展开的字符串。
|
|
2302
|
+
goal: watcher.note || (typeof watcher.goal === 'string' ? watcher.goal : (watcher.goal && watcher.goal.objective) || ''),
|
|
2303
|
+
ackLabel: watcher.ackLabel || (watcher.provider === 'gitee' ? '主理鱼-已处理' : '主理鱼:已处理'),
|
|
2304
|
+
onlyAssigned: !!(watcher.filters && watcher.filters.onlyAssigned),
|
|
2305
|
+
allowAuthors: (watcher.filters && watcher.filters.allowAuthors ? watcher.filters.allowAuthors : []).join(', '),
|
|
2306
|
+
observe: !!watcher.observe,
|
|
2307
|
+
isolated: !!watcher.isolated,
|
|
2308
|
+
workdir: watcher.workdir || '',
|
|
2309
|
+
batchLimit: watcherNumberText(watcher.batchLimit),
|
|
2310
|
+
maxWakesPerHour: watcherNumberText(watcher.maxWakesPerHour),
|
|
2311
|
+
sessionMaxWakes: watcherNumberText(watcher.sessionMaxWakes),
|
|
2312
|
+
isolateKeepDays: watcherNumberText(watcher.isolateKeepDays),
|
|
2313
|
+
maxIsolated: watcherNumberText(watcher.maxIsolated),
|
|
2314
|
+
priorityReopened: (watcher.priority && watcher.priority.reopened) !== false,
|
|
2315
|
+
priorityComments: (watcher.priority && watcher.priority.comments) !== false,
|
|
2316
|
+
priorityLabels: (watcher.priority && watcher.priority.labels) !== false,
|
|
2317
|
+
priorityUnassigned: Boolean(watcher.priority && watcher.priority.unassigned) === true,
|
|
2318
|
+
priorityStale: Boolean(watcher.priority && watcher.priority.stale) === true,
|
|
2319
|
+
})
|
|
2320
|
+
}
|
|
2321
|
+
const editingWatcher = watchers.find((watcher) => watcher.repo + '#' + watcher.sessionId === editing)
|
|
2322
|
+
const editingOpening = editSnapshotRef.current && editSnapshotRef.current.key === editing
|
|
2323
|
+
? editSnapshotRef.current.values
|
|
2324
|
+
: editingWatcher ? watcherValuesFrom(editingWatcher) : null
|
|
2325
|
+
const editingDirty = Boolean(editing && editingOpening && (
|
|
2326
|
+
touchedRef.current.size > 0 || watcherDirty({ ...editingOpening, ...draft }, editingOpening)))
|
|
2327
|
+
const pendingCollapseKey = glossary && glossary.type === 'watcher-draft' && !glossary.nextKey
|
|
2328
|
+
? glossary.fromKey : null
|
|
2329
|
+
// dirty 折叠在确认期间挂起 editing id,但原表单仍挂载;取消/确认之前绝不清它的 draft。
|
|
2330
|
+
const displayedEditing = editing || pendingCollapseKey
|
|
2331
|
+
const toggleWatcherEditor = (watcher) => {
|
|
2332
|
+
const key = watcher.repo + '#' + watcher.sessionId
|
|
2333
|
+
const nextKey = editing === key ? null : key
|
|
2334
|
+
if (editing && editingDirty) {
|
|
2335
|
+
watcherDraftConfirmedRef.current = false
|
|
2336
|
+
setGlossary({ type: 'watcher-draft', watcher, nextKey, fromKey: editing })
|
|
2337
|
+
if (!nextKey) setEditing(null)
|
|
2338
|
+
return
|
|
2339
|
+
}
|
|
2340
|
+
applyWatcherEditor(watcher, nextKey)
|
|
2341
|
+
}
|
|
2342
|
+
const dismissWatcherDraft = () => {
|
|
2343
|
+
if (glossary && glossary.type === 'watcher-draft' && !glossary.nextKey
|
|
2344
|
+
&& !watcherDraftConfirmedRef.current) setEditing(glossary.fromKey)
|
|
2345
|
+
watcherDraftConfirmedRef.current = false
|
|
2346
|
+
setGlossary(false)
|
|
2347
|
+
}
|
|
2128
2348
|
const sessionGoal = body.sessionGoal || null
|
|
2129
2349
|
const credentials = body.credentials || { token: 'none', sshKeyPath: 'none' }
|
|
2130
2350
|
|
|
@@ -2308,7 +2528,10 @@ window.__ModuleLoader__.load({
|
|
|
2308
2528
|
return warnings
|
|
2309
2529
|
}, null, { rethrow: true })
|
|
2310
2530
|
|
|
2531
|
+
const credentialsDirty = Boolean(token.trim() || giteeToken.trim() || ghDir.trim())
|
|
2311
2532
|
const saveCredentials = () => {
|
|
2533
|
+
// 空草稿没有可保存的改动;即使绕过 disabled 直接调用,也不能发 {} 后假报成功。
|
|
2534
|
+
if (!credentialsDirty) return Promise.resolve(false)
|
|
2312
2535
|
const draftVersion = credentialsDraftVersionRef.current
|
|
2313
2536
|
let saveSeq = 0
|
|
2314
2537
|
return run(async () => {
|
|
@@ -2340,6 +2563,8 @@ window.__ModuleLoader__.load({
|
|
|
2340
2563
|
}, '已解绑 gh 账号目录(评论改回宿主账号)')
|
|
2341
2564
|
|
|
2342
2565
|
const saveGoal = () => {
|
|
2566
|
+
// 与按钮/文本域的 disabled 同一道防线:没有会话归属时不能提交或假报成功。
|
|
2567
|
+
if (!sessionId) return Promise.resolve(false)
|
|
2343
2568
|
const draftVersion = goalDraftVersionRef.current
|
|
2344
2569
|
let saveSeq = 0
|
|
2345
2570
|
return run(async () => {
|
|
@@ -2400,38 +2625,7 @@ window.__ModuleLoader__.load({
|
|
|
2400
2625
|
h('div', { className: 'dt-row-title' },
|
|
2401
2626
|
h('button', {
|
|
2402
2627
|
type: 'button', className: 'dt-open', title: '展开或收起这条主理鱼的设置',
|
|
2403
|
-
'aria-expanded':
|
|
2404
|
-
setEditing(editing === key ? null : key)
|
|
2405
|
-
touchedRef.current = new Set()
|
|
2406
|
-
editSnapshotRef.current = editing === key ? null : { key, values: watcherValuesFrom(watcher) }
|
|
2407
|
-
setDraft({
|
|
2408
|
-
intervalSec: watcherNumberText(watcher.intervalSec ?? 60),
|
|
2409
|
-
labels: (watcher.filters && watcher.filters.labels ? watcher.filters.labels : []).join(','),
|
|
2410
|
-
ignoreLabels: (watcher.filters && watcher.filters.ignoreLabels ? watcher.filters.ignoreLabels : []).join(','),
|
|
2411
|
-
assignee: (watcher.filters && watcher.filters.assignee) || '',
|
|
2412
|
-
activeHours: watcher.activeHours || '',
|
|
2413
|
-
// 审核 T26 M2:`watcher.goal` 是**对象**(goalView),当字符串塞进输入框会显示
|
|
2414
|
-
// [object Object];保存时后端只收 string,于是静默无效而 Toast 说「已保存」。
|
|
2415
|
-
goal: watcher.note || (typeof watcher.goal === 'string' ? watcher.goal : (watcher.goal && watcher.goal.objective) || ''),
|
|
2416
|
-
ackLabel: watcher.ackLabel || (watcher.provider === 'gitee' ? '主理鱼-已处理' : '主理鱼:已处理'),
|
|
2417
|
-
onlyAssigned: !!(watcher.filters && watcher.filters.onlyAssigned),
|
|
2418
|
-
allowAuthors: (watcher.filters && watcher.filters.allowAuthors ? watcher.filters.allowAuthors : []).join(', '),
|
|
2419
|
-
// 下面这些以前没填 —— 打开一条隔离执行的守再直接保存,会把 isolated 写回 false
|
|
2420
|
-
observe: !!watcher.observe,
|
|
2421
|
-
isolated: !!watcher.isolated,
|
|
2422
|
-
workdir: watcher.workdir || '',
|
|
2423
|
-
batchLimit: watcherNumberText(watcher.batchLimit),
|
|
2424
|
-
maxWakesPerHour: watcherNumberText(watcher.maxWakesPerHour),
|
|
2425
|
-
sessionMaxWakes: watcherNumberText(watcher.sessionMaxWakes),
|
|
2426
|
-
isolateKeepDays: watcherNumberText(watcher.isolateKeepDays),
|
|
2427
|
-
maxIsolated: watcherNumberText(watcher.maxIsolated),
|
|
2428
|
-
priorityReopened: (watcher.priority && watcher.priority.reopened) !== false,
|
|
2429
|
-
priorityComments: (watcher.priority && watcher.priority.comments) !== false,
|
|
2430
|
-
priorityLabels: (watcher.priority && watcher.priority.labels) !== false,
|
|
2431
|
-
priorityUnassigned: Boolean(watcher.priority && watcher.priority.unassigned) === true,
|
|
2432
|
-
priorityStale: Boolean(watcher.priority && watcher.priority.stale) === true,
|
|
2433
|
-
})
|
|
2434
|
-
},
|
|
2628
|
+
'aria-expanded': displayedEditing === key, onClick: () => toggleWatcherEditor(watcher),
|
|
2435
2629
|
}, watcher.repo)),
|
|
2436
2630
|
pauseNote(watcher),
|
|
2437
2631
|
h('div', { className: 'dt-row-meta dt-ticket-meta' },
|
|
@@ -2522,7 +2716,7 @@ window.__ModuleLoader__.load({
|
|
|
2522
2716
|
? editSnapshotRef.current.values
|
|
2523
2717
|
: watcherValuesFrom(watcher)
|
|
2524
2718
|
const editorValue = { ...opening, ...draft }
|
|
2525
|
-
const editor =
|
|
2719
|
+
const editor = displayedEditing === key
|
|
2526
2720
|
? h(WatcherForm, {
|
|
2527
2721
|
mode: 'edit', idPrefix: 'watcher-edit-' + encodeURIComponent(key),
|
|
2528
2722
|
value: editorValue, snapshot: opening, defaults: DEFAULTS, sessionId,
|
|
@@ -2605,7 +2799,7 @@ window.__ModuleLoader__.load({
|
|
|
2605
2799
|
// 两处并排会让同一句话在同一屏出现两次;而且「时段外 / 已停用」是配置出来的状态、不是待处理的问题。
|
|
2606
2800
|
}
|
|
2607
2801
|
if (body.gh && body.gh.ok === false && credentials.token === 'none') {
|
|
2608
|
-
problems.push({ key: 'gh', rank: 0, kind: 'gh', text: 'gh CLI 不可用,且没有配置 token —— 现在所有轮询都会失败。先跑 gh auth login,或在「设置 →
|
|
2802
|
+
problems.push({ key: 'gh', rank: 0, kind: 'gh', text: 'gh CLI 不可用,且没有配置 token —— 现在所有轮询都会失败。先跑 gh auth login,或在「设置 → 凭证」填一个 token。' })
|
|
2609
2803
|
}
|
|
2610
2804
|
if (watchers.length > 0 && credentials.token === 'none') {
|
|
2611
2805
|
problems.push({ key: 'cred', rank: 7, kind: 'cred', text: '未配置 token,正在复用已登录的 gh CLI(可用 panel 填 token 换成独立凭据)' })
|
|
@@ -2619,6 +2813,7 @@ window.__ModuleLoader__.load({
|
|
|
2619
2813
|
const matchesBadge = (watcher) => !badgeFilter
|
|
2620
2814
|
|| repoBadges(watcher.repoAccess).some((badge) => badge.text === badgeFilter)
|
|
2621
2815
|
const hasProblem = (watcher) => Boolean(watcher.lastError)
|
|
2816
|
+
|| Boolean(watcher.lastReopened)
|
|
2622
2817
|
|| Number(watcher.silentWakes) >= 2
|
|
2623
2818
|
|| Boolean(repoStructureNote(watcher.repoAccess))
|
|
2624
2819
|
|| repoBadges(watcher.repoAccess).some((badge) => badge.tone === 'warning' || badge.tone === 'danger')
|
|
@@ -2633,6 +2828,10 @@ window.__ModuleLoader__.load({
|
|
|
2633
2828
|
const visible = watchers.filter((watcher) => matches(watcher) && matchesBadge(watcher) && stateMatches(watcher)
|
|
2634
2829
|
&& (!problemsOnly || hasProblem(watcher))
|
|
2635
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
|
+
}
|
|
2636
2835
|
|
|
2637
2836
|
// T24 W1:「全部暂停/全部恢复」对**这一屏**生效,可用性也按这一屏算(同口径)。
|
|
2638
2837
|
const pausable = countPausable(visible)
|
|
@@ -2658,11 +2857,7 @@ window.__ModuleLoader__.load({
|
|
|
2658
2857
|
})(),
|
|
2659
2858
|
...chips.map((chip) => h(Pill, { key: chip.label, onClick: chip.clear }, chip.label + ' ✕')),
|
|
2660
2859
|
chips.length > 1
|
|
2661
|
-
? h(Pill, {
|
|
2662
|
-
key: '__all', onClick: () => {
|
|
2663
|
-
setBadgeFilter(null); setStateFilter(null); setSearch(''); setProblemsOnly(false); setReasonFilter(null)
|
|
2664
|
-
},
|
|
2665
|
-
}, '全部清除')
|
|
2860
|
+
? h(Pill, { key: '__all', onClick: clearAllFilters }, '全部清除')
|
|
2666
2861
|
: null)
|
|
2667
2862
|
})()
|
|
2668
2863
|
|
|
@@ -2677,6 +2872,11 @@ window.__ModuleLoader__.load({
|
|
|
2677
2872
|
return acc
|
|
2678
2873
|
}, { woken: 0, acked: 0 })
|
|
2679
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
|
+
|
|
2680
2880
|
const overview = [
|
|
2681
2881
|
filterSummary,
|
|
2682
2882
|
h('div', { className: 'dt-stats', key: 'stats' },
|
|
@@ -2705,12 +2905,22 @@ window.__ModuleLoader__.load({
|
|
|
2705
2905
|
key: 'dormant', value: dormant, unit: '时段外',
|
|
2706
2906
|
active: stateFilter === 'dormant', onClick: () => setStateFilter(stateFilter === 'dormant' ? null : 'dormant'),
|
|
2707
2907
|
}) : null),
|
|
2708
|
-
|
|
2908
|
+
filteredEntries.length > 0
|
|
2709
2909
|
? h(Section, { key: 'filtered', title: '最近被过滤' },
|
|
2710
2910
|
h(CollapsibleList, {
|
|
2711
2911
|
title: '看被过滤的条目',
|
|
2712
|
-
items:
|
|
2713
|
-
|
|
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
|
+
}),
|
|
2714
2924
|
}))
|
|
2715
2925
|
: null,
|
|
2716
2926
|
// 排序:会丢消息的(失败/没回音)排前面;静态提示(仓库归档、只读)排后面
|
|
@@ -2752,7 +2962,16 @@ window.__ModuleLoader__.load({
|
|
|
2752
2962
|
watchers.length === 0
|
|
2753
2963
|
? h(Onboarding, { onStart: () => setTab('trigger') })
|
|
2754
2964
|
: visible.length === 0
|
|
2755
|
-
? h(
|
|
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)
|
|
2756
2975
|
: h('ul', { className: 'dt-list' }, visible.map(row))),
|
|
2757
2976
|
]
|
|
2758
2977
|
|
|
@@ -2785,12 +3004,15 @@ window.__ModuleLoader__.load({
|
|
|
2785
3004
|
className: 'dt-textlink',
|
|
2786
3005
|
type: 'button',
|
|
2787
3006
|
onClick: async () => {
|
|
3007
|
+
const seq = ++traceSeqRef.current
|
|
2788
3008
|
setTraceResult({ loading: true, number: asNumber })
|
|
2789
3009
|
try {
|
|
2790
3010
|
const query = '/trace?number=' + encodeURIComponent(asNumber) + (onlyRepo ? '&repo=' + encodeURIComponent(onlyRepo) : '')
|
|
2791
3011
|
const payload = await call(query)
|
|
3012
|
+
if (seq !== traceSeqRef.current) return
|
|
2792
3013
|
setTraceResult(payload || { text: '没有结果', traces: [] })
|
|
2793
3014
|
} catch (error) {
|
|
3015
|
+
if (seq !== traceSeqRef.current) return
|
|
2794
3016
|
setTraceResult({ error: String((error && error.message) || error), number: asNumber })
|
|
2795
3017
|
}
|
|
2796
3018
|
},
|
|
@@ -2900,7 +3122,13 @@ window.__ModuleLoader__.load({
|
|
|
2900
3122
|
h('time', { className: 'dt-event-time', dateTime: entry.at, title: entry.at }, ageText(entry.at)))))
|
|
2901
3123
|
}
|
|
2902
3124
|
|
|
2903
|
-
// 迷你时间线:回答"为什么这一轮没叫醒我"
|
|
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)
|
|
2904
3132
|
const timeline = h(Section, {
|
|
2905
3133
|
key: 'timeline',
|
|
2906
3134
|
title: '运行时事件(最近 20 条)',
|
|
@@ -2909,19 +3137,24 @@ window.__ModuleLoader__.load({
|
|
|
2909
3137
|
},
|
|
2910
3138
|
watchers.length === 0
|
|
2911
3139
|
? h(Hint, null, '还没有守。添加一条之后,这里会记录每次唤醒、攒着、限流、回收。')
|
|
2912
|
-
:
|
|
2913
|
-
|
|
2914
|
-
className: 'dt-event',
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
:
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
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)))))
|
|
2925
3158
|
|
|
2926
3159
|
// 按仓库汇总:守多个仓库时先看哪个健康,再看明细(渐进披露)
|
|
2927
3160
|
const problemCount = watchers.filter(hasProblem).length
|
|
@@ -2955,7 +3188,9 @@ window.__ModuleLoader__.load({
|
|
|
2955
3188
|
]
|
|
2956
3189
|
})())
|
|
2957
3190
|
: null,
|
|
2958
|
-
visible.length === 0
|
|
3191
|
+
visible.length === 0 && watchers.length > 0
|
|
3192
|
+
? h(Hint, null, '按仓库汇总也为空;请用上方「清除全部筛选」恢复。')
|
|
3193
|
+
: null,
|
|
2959
3194
|
h('div', { className: 'dt-rows' }, ...summarizeByRepo(visible).map((group) => h('div', { key: 'repo-' + group.repo, className: 'dt-row' },
|
|
2960
3195
|
h('div', { className: 'dt-row-main' },
|
|
2961
3196
|
h('div', { className: 'dt-row-title' },
|
|
@@ -3006,7 +3241,7 @@ window.__ModuleLoader__.load({
|
|
|
3006
3241
|
? '不需要(没有 GitHub 主理鱼)' + (body.gh.skipped ? ' · ' + String(body.gh.skipped) : '')
|
|
3007
3242
|
: body.gh.ok
|
|
3008
3243
|
? '可用 · ' + (body.gh.version || '')
|
|
3009
|
-
: '不可用 —— 先跑 gh auth login(或装 gh CLI
|
|
3244
|
+
: '不可用 —— 先跑 gh auth login(或装 gh CLI);也可以去「凭证」填 token · ' + String(body.gh.error || '').slice(0, 80)],
|
|
3010
3245
|
// 标签要能和左栏「凭证」分区区分开;值要写出「面板 token / gh 登录态」二选一。
|
|
3011
3246
|
['GitHub 凭证', credentials.token === 'none' ? '回退到已登录的 gh CLI' : '用面板 token(不再需要 gh login)'],
|
|
3012
3247
|
['权限范围', (() => {
|
|
@@ -3038,12 +3273,14 @@ window.__ModuleLoader__.load({
|
|
|
3038
3273
|
credentials.ghConfigDir === 'configured'
|
|
3039
3274
|
? h('div', { className: 'dt-actions' }, h(Btn, { variant: 'ghost', size: 'sm', onClick: clearGhDir }, '解绑 gh 账号目录'))
|
|
3040
3275
|
: null,
|
|
3041
|
-
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 }, '保存凭证')),
|
|
3042
3277
|
h(Hint, null, '不填也能用:插件直接复用已登录的 gh CLI。填了 gh 账号目录,插件就用那个目录里的账号发言(git push 仍用会话自己的身份,唤醒消息里会提醒会话)。')),
|
|
3043
3278
|
h(Section, { key: 'update', title: '版本与更新' },
|
|
3044
3279
|
h(KeyValues, { rows: [
|
|
3045
3280
|
['当前版本', (update && update.current) || CLIENT_VERSION],
|
|
3046
|
-
['npm 最新', !update ? '检测中…' : update.error
|
|
3281
|
+
['npm 最新', !update ? '检测中…' : update.error
|
|
3282
|
+
? h('span', { className: 'dt-error', role: 'alert', 'aria-atomic': 'true' }, '检测失败 · ' + update.error)
|
|
3283
|
+
: (update.latest || '未知')],
|
|
3047
3284
|
['状态', updateResult && updateResult.resultUnknown
|
|
3048
3285
|
? UPDATE_UNKNOWN_HINT
|
|
3049
3286
|
: updateAwaitingReload
|
|
@@ -3113,9 +3350,11 @@ window.__ModuleLoader__.load({
|
|
|
3113
3350
|
h(Section, { key: 'goal', title: '会话 goal' },
|
|
3114
3351
|
h('textarea', {
|
|
3115
3352
|
className: 'dt-textarea', rows: 3, value: goalDraft,
|
|
3353
|
+
'aria-label': '会话 goal', disabled: !sessionId,
|
|
3116
3354
|
placeholder: '这个会话要达成什么(会写进 /goal)',
|
|
3117
3355
|
onChange: (e) => { goalDraftVersionRef.current += 1; setGoalTouched(true); setGoalDraft(e.target.value) },
|
|
3118
3356
|
}),
|
|
3357
|
+
!sessionId ? h(Hint, null, '没有会话上下文,无法编辑或保存 goal;请先在会话里打开本面板。') : null,
|
|
3119
3358
|
h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveGoal, disabled: !sessionId }, '保存 goal'))),
|
|
3120
3359
|
]
|
|
3121
3360
|
|
|
@@ -3367,7 +3606,7 @@ window.__ModuleLoader__.load({
|
|
|
3367
3606
|
],
|
|
3368
3607
|
value: tab, onChange: setTab, label: '主理鱼分区',
|
|
3369
3608
|
}),
|
|
3370
|
-
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,
|
|
3371
3610
|
// 有新版本时在顶部提示一次;已装到 latest 且等待重载时完全隐藏,避免重复安装入口。
|
|
3372
3611
|
update && update.hasUpdate && !updateAwaitingReload
|
|
3373
3612
|
? h('div', { className: 'dt-banner dt-banner-actions' },
|
|
@@ -3378,7 +3617,7 @@ window.__ModuleLoader__.load({
|
|
|
3378
3617
|
snap.error
|
|
3379
3618
|
? h('div', { className: 'dt-card dt-error-card', key: 'read-error' },
|
|
3380
3619
|
h('div', { className: 'dt-card-head' }, h('span', { className: 'dt-card-title' }, '读不到面板数据')),
|
|
3381
|
-
h('p', { className: 'dt-error' }, humanizeError(snap.error)),
|
|
3620
|
+
h('p', { className: 'dt-error', role: 'alert', 'aria-atomic': 'true' }, humanizeError(snap.error)),
|
|
3382
3621
|
h('div', { className: 'dt-actions' }, h(Btn, { size: 'sm', variant: 'primary', onClick: () => load() }, '重试')))
|
|
3383
3622
|
: null,
|
|
3384
3623
|
snap.loading && !snap.body ? h(Hint, null, '正在读取…') : null,
|
|
@@ -3394,6 +3633,21 @@ window.__ModuleLoader__.load({
|
|
|
3394
3633
|
snap.body && tab === 'settings' ? h('div', {
|
|
3395
3634
|
id: 'sa-main-panel-settings', role: 'tabpanel', 'aria-labelledby': 'sa-main-tab-settings', className: 'dt-tabpanel',
|
|
3396
3635
|
}, settings) : null,
|
|
3636
|
+
glossary && glossary.type === 'watcher-draft' ? h(ConfirmDialog, {
|
|
3637
|
+
open: true,
|
|
3638
|
+
label: '放弃未保存的修改',
|
|
3639
|
+
title: '放弃未保存的修改?',
|
|
3640
|
+
confirmLabel: glossary.nextKey ? '放弃并切换' : '放弃并收起',
|
|
3641
|
+
message: glossary.nextKey
|
|
3642
|
+
? '当前 watcher 有未保存的修改。切换到 ' + glossary.watcher.repo + ' 会丢弃这些修改;取消会继续编辑当前草稿。'
|
|
3643
|
+
: '当前 watcher 有未保存的修改。收起会丢弃这些修改;取消会继续编辑当前草稿。',
|
|
3644
|
+
onClose: dismissWatcherDraft,
|
|
3645
|
+
onConfirm: () => {
|
|
3646
|
+
watcherDraftConfirmedRef.current = true
|
|
3647
|
+
applyWatcherEditor(glossary.watcher, glossary.nextKey)
|
|
3648
|
+
return true
|
|
3649
|
+
},
|
|
3650
|
+
}) : null,
|
|
3397
3651
|
typeof glossary === 'string' ? h(PanelModal, {
|
|
3398
3652
|
open: true,
|
|
3399
3653
|
title: '建议追加到 ' + String(glossary).replace('rules:', '') + ' 的 AGENTS.md',
|
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.
|
|
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.
|
|
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",
|