dsh-session-superagent 0.9.282 → 0.9.284
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 +45 -0
- package/README.md +3 -3
- package/client.js +143 -65
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,51 @@
|
|
|
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.9.284] - 2026-11-06 —— Orbit 并发与删除错误修复
|
|
6
|
+
|
|
7
|
+
### 写操作 busy 锁
|
|
8
|
+
|
|
9
|
+
- 立刻/暂停/恢复/删除按 watcherId+action 加同步锁。
|
|
10
|
+
- pending 禁止重复点击,显示处理中文字、aria-busy 与 busy 样式。
|
|
11
|
+
- 成功和失败都在 finally 解锁,fallback 的位置化 hook 契约不变。
|
|
12
|
+
|
|
13
|
+
### 轮询与删除
|
|
14
|
+
|
|
15
|
+
- 定时轮询和写后 /state 共用请求序号,旧成功/失败都不能覆盖新结果,最新成功清读取错误。
|
|
16
|
+
- 删除失败在当前确认 Modal 以 role=alert 显示,pending 禁止 dismiss,失败保留重试。
|
|
17
|
+
- 成功才自动关闭并回焦;失败后的主动 Escape/取消仍可用。
|
|
18
|
+
|
|
19
|
+
### 验证
|
|
20
|
+
|
|
21
|
+
- 新增用例先红复现双击 2 POST;最终定向 176/176、integration 15/15。
|
|
22
|
+
- 全量 643/643,UI 体检 11/11=100。
|
|
23
|
+
- 主线 Chromium 47/47,双击/删除重试/pending Escape/解锁专项合计 52/52。
|
|
24
|
+
|
|
25
|
+
未验真实 DSH Web GUI 与真实 watcher 写操作。按 Git 工作流保留本地候选。
|
|
26
|
+
|
|
27
|
+
## [0.9.283] - 2026-11-06 —— 保存 pending 状态机修复
|
|
28
|
+
|
|
29
|
+
### 新草稿不再被旧响应覆盖
|
|
30
|
+
|
|
31
|
+
- 凭证与 goal 使用独立草稿版本号和保存序号。
|
|
32
|
+
- pending 后产生的新输入不会被旧响应清空或覆盖。
|
|
33
|
+
- 重复保存时,只有最新保存且草稿版本未变的响应能清理对应草稿。
|
|
34
|
+
|
|
35
|
+
### 严格回读与 null 同步
|
|
36
|
+
|
|
37
|
+
- 保存必须回读成功后才 Toast 成功;POST200+GET500 显示可重试错误,不回写旧 goal。
|
|
38
|
+
- `sessionGoal:null` 清空干净 goal 草稿,dirty 草稿仍由用户决定。
|
|
39
|
+
- 已有快照时 304 也视为成功回读,保存反馈可依赖它。
|
|
40
|
+
|
|
41
|
+
### 验证
|
|
42
|
+
|
|
43
|
+
- 新增回归修复前 5/7,修复后 7/7。
|
|
44
|
+
- 联合 144/144,全量 637/637。
|
|
45
|
+
- 主线 Chromium 47/47;pending/GET500/null 等专项合计 52/52。
|
|
46
|
+
- UI 体检 11/11=100。
|
|
47
|
+
|
|
48
|
+
未验真实 DSH Web GUI 与真实 watcher 写操作。按 Git 工作流保留本地候选。
|
|
49
|
+
|
|
5
50
|
## [0.9.282] - 2026-11-06 —— CollapsibleList 与首载/校验修复
|
|
6
51
|
|
|
7
52
|
### 折叠列表
|
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 # 643 项单测(带离线开关;裸 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 # 643 项单测(带离线开关,约 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.
|
|
421
|
+
const CLIENT_VERSION = '0.9.284'
|
|
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.
|
|
@@ -1306,7 +1306,7 @@ window.__ModuleLoader__.load({
|
|
|
1306
1306
|
const PanelModal = hostUi ? hostUi.Modal : Modal
|
|
1307
1307
|
|
|
1308
1308
|
/** 确认层与触发器分离:DSH orbit 关闭后,同一个本地 Modal 仍能由 StatusOrbit 持有。 */
|
|
1309
|
-
function ConfirmDialog({ open, label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, onClose, modalContext = 'panel', ButtonComponent = Btn, danger = true, preventDismissOnBusy = false }) {
|
|
1309
|
+
function ConfirmDialog({ open, label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, onClose, modalContext = 'panel', ButtonComponent = Btn, danger = true, preventDismissOnBusy = false, error = null, busyLabel = confirmLabel, busyHint = '安装进行中,完成后才能关闭' }) {
|
|
1310
1310
|
const [busy, setBusy] = useState(false)
|
|
1311
1311
|
const busyRef = useRef(false)
|
|
1312
1312
|
const dismiss = () => {
|
|
@@ -1331,6 +1331,11 @@ window.__ModuleLoader__.load({
|
|
|
1331
1331
|
}
|
|
1332
1332
|
// orbit 删除明确保留 superagent 同源 Modal;普通主面板删除仍走 PanelModal,不换 RiskConfirmation。
|
|
1333
1333
|
const ModalView = modalContext === 'orbit' ? Modal : PanelModal
|
|
1334
|
+
const feedback = error || (preventDismissOnBusy && busy)
|
|
1335
|
+
? h(React.Fragment, null,
|
|
1336
|
+
error ? h('div', { className: 'dt-error', role: 'alert' }, error) : null,
|
|
1337
|
+
preventDismissOnBusy && busy ? h(Hint, null, busyHint) : null)
|
|
1338
|
+
: null
|
|
1334
1339
|
return h(ModalView, {
|
|
1335
1340
|
open,
|
|
1336
1341
|
title,
|
|
@@ -1345,12 +1350,12 @@ window.__ModuleLoader__.load({
|
|
|
1345
1350
|
'aria-label': confirmLabel,
|
|
1346
1351
|
'aria-busy': busy ? 'true' : undefined,
|
|
1347
1352
|
onClick: confirm,
|
|
1348
|
-
}, confirmLabel)),
|
|
1349
|
-
},
|
|
1353
|
+
}, busy ? busyLabel : confirmLabel)),
|
|
1354
|
+
}, feedback)
|
|
1350
1355
|
}
|
|
1351
1356
|
|
|
1352
1357
|
/** 官方 ConfirmButton 动线:触发按钮只开 Modal,取消不执行,确认期间 busy 防重复。 */
|
|
1353
|
-
function ConfirmButton({ label, confirmLabel = '确定执行', title = confirmLabel, message, onConfirm, variant = 'ghost', icon, size, modalContext = 'panel', ButtonComponent = Btn, danger = true, preventDismissOnBusy = false }) {
|
|
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 }) {
|
|
1354
1359
|
const [open, setOpen] = useState(false)
|
|
1355
1360
|
const close = useCallback(() => setOpen(false), [])
|
|
1356
1361
|
return h(React.Fragment, null,
|
|
@@ -1362,10 +1367,11 @@ window.__ModuleLoader__.load({
|
|
|
1362
1367
|
'aria-haspopup': 'dialog',
|
|
1363
1368
|
onClick: () => setOpen(true),
|
|
1364
1369
|
}, label),
|
|
1365
|
-
h(ConfirmDialog, { open, label, confirmLabel, title, message, onConfirm, onClose: close, modalContext, ButtonComponent, danger, preventDismissOnBusy }))
|
|
1370
|
+
h(ConfirmDialog, { open, label, confirmLabel, title, message, onConfirm, onClose: close, modalContext, ButtonComponent, danger, preventDismissOnBusy, error, busyLabel, busyHint }))
|
|
1366
1371
|
}
|
|
1367
1372
|
|
|
1368
1373
|
const watcherId = (w) => (w && w.id) || String((w && w.repo) || '') + '#' + String((w && w.sessionId) || '')
|
|
1374
|
+
const orbitActionKey = (w, action) => JSON.stringify([watcherId(w), action])
|
|
1369
1375
|
const short = (value, width = 19) => (typeof value === 'string' && value.length > width ? value.slice(0, width - 1) + '…' : (value ?? '—'))
|
|
1370
1376
|
const when = (iso) => (typeof iso === 'string' ? iso.replace('T', ' ').replace('Z', '').slice(5, 19) : '—')
|
|
1371
1377
|
|
|
@@ -1571,6 +1577,9 @@ window.__ModuleLoader__.load({
|
|
|
1571
1577
|
const [anchor, setAnchor] = useState(null)
|
|
1572
1578
|
const btnRef = useRef(null)
|
|
1573
1579
|
const panelRef = useRef(null)
|
|
1580
|
+
const actionLocks = useRef(new Set())
|
|
1581
|
+
const stateSequence = useRef(0)
|
|
1582
|
+
const orbitAlive = useRef(true)
|
|
1574
1583
|
const orbitConfirm = useOrbitConfirm({
|
|
1575
1584
|
orbitRef: btnRef,
|
|
1576
1585
|
onCloseOrbit: () => setOpen(false),
|
|
@@ -1578,28 +1587,36 @@ window.__ModuleLoader__.load({
|
|
|
1578
1587
|
onRequestConfirm: ({ watcher }) => setAnchor(watcher),
|
|
1579
1588
|
})
|
|
1580
1589
|
|
|
1590
|
+
const isReadError = (value) => typeof value === 'string'
|
|
1591
|
+
&& (value.startsWith('读取失败:') || value.startsWith('写成功了,但刷新列表失败:'))
|
|
1592
|
+
// 定时轮询与写后回读共用同一个代际:只允许最后一次请求改 watchers/读取错误。
|
|
1593
|
+
const loadState = async (failurePrefix = '读取失败:') => {
|
|
1594
|
+
const sequence = ++stateSequence.current
|
|
1595
|
+
try {
|
|
1596
|
+
const body = await call('/state')
|
|
1597
|
+
if (!orbitAlive.current || sequence !== stateSequence.current) return { applied: false, ok: true }
|
|
1598
|
+
setWatchers(Array.isArray(body && body.watchers) ? body.watchers : [])
|
|
1599
|
+
setOrbitError((current) => isReadError(current) ? null : current)
|
|
1600
|
+
return { applied: true, ok: true }
|
|
1601
|
+
} catch (error) {
|
|
1602
|
+
if (orbitAlive.current && sequence === stateSequence.current) {
|
|
1603
|
+
setOrbitError(failurePrefix + String((error && error.message) || error).slice(0, 160))
|
|
1604
|
+
}
|
|
1605
|
+
return { applied: orbitAlive.current && sequence === stateSequence.current, ok: false }
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1581
1609
|
// 弹层的样式(DOCK_CSS)挂在 PORTED_CSS 同一张 <style> 里,而那张表以前只有「主理鱼」面板挂载时才注入。
|
|
1582
1610
|
// 用户从没打开过面板就直接点状态栏圆环时,弹层就是一堆无样式的裸文字(真机复现过)。
|
|
1583
1611
|
useEffect(() => { ensurePortedCss() }, [])
|
|
1584
1612
|
|
|
1585
1613
|
useEffect(() => {
|
|
1586
|
-
|
|
1614
|
+
orbitAlive.current = true
|
|
1587
1615
|
noteOnce('orbit-mount', 'ok')
|
|
1588
|
-
const load =
|
|
1589
|
-
try {
|
|
1590
|
-
const body = await call('/state')
|
|
1591
|
-
if (alive) {
|
|
1592
|
-
setWatchers(Array.isArray(body && body.watchers) ? body.watchers : [])
|
|
1593
|
-
setOrbitError((current) => typeof current === 'string' && current.startsWith('读取失败:') ? null : current)
|
|
1594
|
-
}
|
|
1595
|
-
} catch (error) {
|
|
1596
|
-
// null=尚未读到,[]=成功读到空列表;首次失败不能伪造成“还没有主理鱼”。
|
|
1597
|
-
if (alive) setOrbitError('读取失败:' + String((error && error.message) || error).slice(0, 160))
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1616
|
+
const load = () => loadState()
|
|
1600
1617
|
load()
|
|
1601
1618
|
const timer = setInterval(load, POLL_MS)
|
|
1602
|
-
return () => {
|
|
1619
|
+
return () => { orbitAlive.current = false; clearInterval(timer) }
|
|
1603
1620
|
}, [])
|
|
1604
1621
|
|
|
1605
1622
|
// 弹层每次打开都把样式表钉一遍:宿主热重载可能把 <style> 清掉,
|
|
@@ -1634,7 +1651,7 @@ window.__ModuleLoader__.load({
|
|
|
1634
1651
|
}, [open])
|
|
1635
1652
|
|
|
1636
1653
|
const list = watchers || []
|
|
1637
|
-
const readError =
|
|
1654
|
+
const readError = isReadError(orbitError) ? orbitError : null
|
|
1638
1655
|
// Never hide the entry: with nothing being watched it stays as a grey
|
|
1639
1656
|
// ring, so the affordance is always findable in the dock row.
|
|
1640
1657
|
const running = list.filter((w) => orbitStateOf(w) === 'active').length
|
|
@@ -1683,24 +1700,33 @@ window.__ModuleLoader__.load({
|
|
|
1683
1700
|
const bottom = !hostOrbit && anchor ? Math.max(8, (window.innerHeight || 800) - anchor.y + 8) : 64
|
|
1684
1701
|
|
|
1685
1702
|
const act = async (w, action) => {
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1703
|
+
const key = orbitActionKey(w, action)
|
|
1704
|
+
if (actionLocks.current.has(key)) return false
|
|
1705
|
+
actionLocks.current.add(key)
|
|
1706
|
+
// 不新增根 useState:旧 fallback 的位置化 hook 契约必须保持不变。
|
|
1707
|
+
// 新数组只触发一次渲染,watcher 内容不变;可见 pending 直接读取同步锁集合。
|
|
1708
|
+
setWatchers((current) => Array.isArray(current) ? [...current] : current)
|
|
1709
|
+
if (action === 'delete') {
|
|
1710
|
+
setOrbitError((current) => typeof current === 'string' && current.startsWith('删除失败:') ? null : current)
|
|
1694
1711
|
}
|
|
1695
1712
|
try {
|
|
1696
|
-
|
|
1697
|
-
|
|
1713
|
+
// 删除只走 ConfirmButton + Modal;不要再叠一层原生确认框(同一动作问两次)。
|
|
1714
|
+
try {
|
|
1715
|
+
await call('/watch', { method: 'POST', body: JSON.stringify({ action, id: watcherId(w) }) })
|
|
1716
|
+
} catch (error) {
|
|
1717
|
+
const message = String((error && error.message) || error).slice(0, 160)
|
|
1718
|
+
setOrbitError(action === 'delete' ? '删除失败:' + message : message)
|
|
1719
|
+
return false
|
|
1720
|
+
}
|
|
1721
|
+
// 写已成功:清掉上一代操作/读取错误;回读失败会由 loadState 写入新的可见错误。
|
|
1698
1722
|
setOrbitError(null)
|
|
1699
|
-
|
|
1700
|
-
|
|
1723
|
+
await loadState('写成功了,但刷新列表失败:')
|
|
1724
|
+
// 刷新失败不等于删除失败:动作已成功,确认框仍应关闭。
|
|
1725
|
+
return true
|
|
1726
|
+
} finally {
|
|
1727
|
+
actionLocks.current.delete(key)
|
|
1728
|
+
setWatchers((current) => Array.isArray(current) ? [...current] : current)
|
|
1701
1729
|
}
|
|
1702
|
-
// 刷新失败不等于删除失败:动作已成功,确认框仍应关闭。
|
|
1703
|
-
return true
|
|
1704
1730
|
}
|
|
1705
1731
|
|
|
1706
1732
|
// fallback 完全保留原提前返回;DSH 即使 orbit 已关,也要继续渲染由本组件持有的确认 Modal。
|
|
@@ -1709,6 +1735,8 @@ window.__ModuleLoader__.load({
|
|
|
1709
1735
|
setAnchor(null)
|
|
1710
1736
|
orbitConfirm.onConfirmClose()
|
|
1711
1737
|
}
|
|
1738
|
+
const deleteError = typeof orbitError === 'string' && orbitError.startsWith('删除失败:') ? orbitError : null
|
|
1739
|
+
const actionPending = (w, action) => actionLocks.current.has(orbitActionKey(w, action))
|
|
1712
1740
|
|
|
1713
1741
|
// 悬浮面板也走移植来的 dt-* 设计系统(以前这里是一套自成体系的 inline style,
|
|
1714
1742
|
// 和原生界面放在一起能看出断层;ui-audit ⑥ 就是在盯这件事)。
|
|
@@ -1745,6 +1773,9 @@ window.__ModuleLoader__.load({
|
|
|
1745
1773
|
const key = String(w.repo || '') + '#' + String(w.sessionId || '')
|
|
1746
1774
|
const statusDot = h('span', { className: 'dt-state-dot', 'data-state': dotState })
|
|
1747
1775
|
const statusTag = h('span', { className: 'dt-tag', 'data-tone': tone }, STATE_TEXT[state])
|
|
1776
|
+
const pollPending = actionPending(w, 'poll')
|
|
1777
|
+
const toggleAction = w.enabled ? 'pause' : 'resume'
|
|
1778
|
+
const togglePending = actionPending(w, toggleAction)
|
|
1748
1779
|
const detailContent = h(React.Fragment, null,
|
|
1749
1780
|
h('div', { className: 'sa-dock-sub' }, shortSub(w)),
|
|
1750
1781
|
w.lastError
|
|
@@ -1752,9 +1783,16 @@ window.__ModuleLoader__.load({
|
|
|
1752
1783
|
: null)
|
|
1753
1784
|
const details = h('div', { className: 'sa-dock-body' }, detailContent)
|
|
1754
1785
|
const actions = h('div', { className: 'sa-dock-actions' },
|
|
1755
|
-
h(Btn, {
|
|
1756
|
-
|
|
1757
|
-
|
|
1786
|
+
h(Btn, {
|
|
1787
|
+
size: 'sm', variant: 'ghost', disabled: pollPending,
|
|
1788
|
+
className: cx(pollPending && 'dt-btn-busy'), 'aria-busy': pollPending ? 'true' : undefined,
|
|
1789
|
+
onClick: () => act(w, 'poll'),
|
|
1790
|
+
}, pollPending ? '轮询中…' : '立刻'),
|
|
1791
|
+
h(Btn, {
|
|
1792
|
+
size: 'sm', variant: 'ghost', disabled: togglePending,
|
|
1793
|
+
className: cx(togglePending && 'dt-btn-busy'), 'aria-busy': togglePending ? 'true' : undefined,
|
|
1794
|
+
onClick: () => act(w, toggleAction),
|
|
1795
|
+
}, togglePending ? (toggleAction === 'pause' ? '暂停中…' : '恢复中…') : (w.enabled ? '暂停' : '恢复')),
|
|
1758
1796
|
hostOrbit
|
|
1759
1797
|
? h(Btn, {
|
|
1760
1798
|
variant: 'ghost', size: 'sm', icon: h(Icon, { name: 'trash' }),
|
|
@@ -1765,7 +1803,8 @@ window.__ModuleLoader__.load({
|
|
|
1765
1803
|
: h(ConfirmButton, {
|
|
1766
1804
|
label: '删除', confirmLabel: '确认删除', variant: 'ghost', size: 'sm', modalContext: 'orbit',
|
|
1767
1805
|
icon: h(Icon, { name: 'trash' }),
|
|
1768
|
-
onConfirm: () => act(w, 'delete'),
|
|
1806
|
+
onConfirm: () => act(w, 'delete'), error: deleteError,
|
|
1807
|
+
preventDismissOnBusy: true, busyLabel: '删除中…', busyHint: '删除进行中,完成后才能关闭',
|
|
1769
1808
|
}))
|
|
1770
1809
|
|
|
1771
1810
|
if (hostOrbitRow) {
|
|
@@ -1855,6 +1894,10 @@ window.__ModuleLoader__.load({
|
|
|
1855
1894
|
modalContext: 'orbit',
|
|
1856
1895
|
onConfirm: () => act(anchor, 'delete'),
|
|
1857
1896
|
onClose: closeConfirm,
|
|
1897
|
+
error: deleteError,
|
|
1898
|
+
preventDismissOnBusy: true,
|
|
1899
|
+
busyLabel: '删除中…',
|
|
1900
|
+
busyHint: '删除进行中,完成后才能关闭',
|
|
1858
1901
|
})
|
|
1859
1902
|
: null
|
|
1860
1903
|
|
|
@@ -1990,6 +2033,11 @@ window.__ModuleLoader__.load({
|
|
|
1990
2033
|
const createTouchedRef = useRef(new Set())
|
|
1991
2034
|
const createSnapshotRef = useRef({ ...CREATE_WATCHER_VALUES })
|
|
1992
2035
|
const editSnapshotRef = useRef(null)
|
|
2036
|
+
// 保存期间仍可输入:旧响应只能清理它提交的那份草稿,不能覆盖 pending 后的新输入。
|
|
2037
|
+
const credentialsDraftVersionRef = useRef(0)
|
|
2038
|
+
const credentialsSaveSeqRef = useRef(0)
|
|
2039
|
+
const goalDraftVersionRef = useRef(0)
|
|
2040
|
+
const goalSaveSeqRef = useRef(0)
|
|
1993
2041
|
const setField = (next) => {
|
|
1994
2042
|
const opening = editSnapshotRef.current && editSnapshotRef.current.values
|
|
1995
2043
|
for (const key of Object.keys(next)) {
|
|
@@ -2053,7 +2101,8 @@ window.__ModuleLoader__.load({
|
|
|
2053
2101
|
if (seq !== loadSeqRef.current) return null // 已经有更新的一次请求在飞:这次结果作废
|
|
2054
2102
|
// 304:内容没变,别白白重渲染 —— 前提是本地已经有一份能渲染的 body
|
|
2055
2103
|
if (payload && payload.notModified) {
|
|
2056
|
-
|
|
2104
|
+
// 有本地快照时,304 也是一次成功回读;保存后的成功反馈可以依赖它。
|
|
2105
|
+
if (hasBodyRef.current) return payload
|
|
2057
2106
|
// 本地没有数据:这次 304 是被状态栏的 etag 带出来的,清掉 etag 重取一次全量
|
|
2058
2107
|
stateEtag = null
|
|
2059
2108
|
return load()
|
|
@@ -2079,8 +2128,9 @@ window.__ModuleLoader__.load({
|
|
|
2079
2128
|
const credentials = body.credentials || { token: 'none', sshKeyPath: 'none' }
|
|
2080
2129
|
|
|
2081
2130
|
useEffect(() => {
|
|
2082
|
-
if (goalTouched
|
|
2083
|
-
|
|
2131
|
+
if (goalTouched) return
|
|
2132
|
+
// null 也是服务端事实:干净草稿要同步清空;dirty 草稿仍由用户自己决定保存或放弃。
|
|
2133
|
+
setGoalDraft(sessionGoal ? sessionGoal.objective || '' : '')
|
|
2084
2134
|
}, [goalTouched, sessionGoal])
|
|
2085
2135
|
|
|
2086
2136
|
const busyRef = useRef(false)
|
|
@@ -2097,8 +2147,14 @@ window.__ModuleLoader__.load({
|
|
|
2097
2147
|
setNotice(null)
|
|
2098
2148
|
try {
|
|
2099
2149
|
await work()
|
|
2150
|
+
if (options.requireReload) {
|
|
2151
|
+
const body = await load()
|
|
2152
|
+
if (!body) throw new Error(options.reloadError || '操作已提交,但回读失败,请重试')
|
|
2153
|
+
if (options.afterReload) options.afterReload(body)
|
|
2154
|
+
}
|
|
2155
|
+
// 必须回读的保存只有在确认成功后才提示;其它动作保留原有通知/刷新契约。
|
|
2100
2156
|
if (done) notify(done)
|
|
2101
|
-
await load()
|
|
2157
|
+
if (!options.requireReload) await load()
|
|
2102
2158
|
return true
|
|
2103
2159
|
} catch (error) {
|
|
2104
2160
|
const text = String((error && error.message) || error)
|
|
@@ -2251,30 +2307,52 @@ window.__ModuleLoader__.load({
|
|
|
2251
2307
|
return warnings
|
|
2252
2308
|
}, null, { rethrow: true })
|
|
2253
2309
|
|
|
2254
|
-
const saveCredentials = () =>
|
|
2255
|
-
const
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2310
|
+
const saveCredentials = () => {
|
|
2311
|
+
const draftVersion = credentialsDraftVersionRef.current
|
|
2312
|
+
let saveSeq = 0
|
|
2313
|
+
return run(async () => {
|
|
2314
|
+
saveSeq = ++credentialsSaveSeqRef.current
|
|
2315
|
+
const payload = {}
|
|
2316
|
+
if (token.trim()) payload.token = token.trim()
|
|
2317
|
+
if (giteeToken.trim()) payload.giteeToken = giteeToken.trim()
|
|
2318
|
+
// 审核 T24 M3:这里以前无条件带 "ghConfigDir" —— ghDir 初值恒为空串且从不回填服务端值,
|
|
2319
|
+
// 于是「只改 token」也会发 ghConfigDir:"",服务端把它当「显式清空」,
|
|
2320
|
+
// 已绑定的 gh 账号目录被静默解绑(评论改回宿主账号)。
|
|
2321
|
+
// 现在只有**填了东西**才发;要解绑请用旁边的「清除」按钮(它显式发空串)。
|
|
2322
|
+
if (ghDir.trim()) payload.ghConfigDir = ghDir.trim()
|
|
2323
|
+
await call('/credentials', { method: 'POST', body: JSON.stringify(payload) })
|
|
2324
|
+
}, '凭证已保存', {
|
|
2325
|
+
requireReload: true,
|
|
2326
|
+
reloadError: '凭证已提交,但回读失败,请重试',
|
|
2327
|
+
afterReload: () => {
|
|
2328
|
+
if (saveSeq !== credentialsSaveSeqRef.current || draftVersion !== credentialsDraftVersionRef.current) return
|
|
2329
|
+
setToken('')
|
|
2330
|
+
setGhDir('')
|
|
2331
|
+
setGiteeToken('')
|
|
2332
|
+
},
|
|
2333
|
+
})
|
|
2334
|
+
}
|
|
2268
2335
|
|
|
2269
2336
|
/** 显式解绑 gh 账号目录(T24 M3:不能在「只改 token」时顺带清掉)。 */
|
|
2270
2337
|
const clearGhDir = () => run(async () => {
|
|
2271
2338
|
await call('/credentials', { method: 'POST', body: JSON.stringify({ ghConfigDir: '' }) })
|
|
2272
2339
|
}, '已解绑 gh 账号目录(评论改回宿主账号)')
|
|
2273
2340
|
|
|
2274
|
-
const saveGoal = () =>
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2341
|
+
const saveGoal = () => {
|
|
2342
|
+
const draftVersion = goalDraftVersionRef.current
|
|
2343
|
+
let saveSeq = 0
|
|
2344
|
+
return run(async () => {
|
|
2345
|
+
saveSeq = ++goalSaveSeqRef.current
|
|
2346
|
+
await call('/goal', { method: 'POST', body: JSON.stringify({ sessionId, objective: goalDraft }) })
|
|
2347
|
+
}, 'goal 已保存', {
|
|
2348
|
+
requireReload: true,
|
|
2349
|
+
reloadError: 'goal 已提交,但回读失败,请重试',
|
|
2350
|
+
afterReload: () => {
|
|
2351
|
+
if (saveSeq !== goalSaveSeqRef.current || draftVersion !== goalDraftVersionRef.current) return
|
|
2352
|
+
setGoalTouched(false)
|
|
2353
|
+
},
|
|
2354
|
+
})
|
|
2355
|
+
}
|
|
2278
2356
|
|
|
2279
2357
|
// 四个数字必须加得上总数(以前「已暂停」按 enabled 数、「异常」按 lastError 数:
|
|
2280
2358
|
// 一条已暂停又有错误的守会被数两次,而「时段外」根本没被数)
|
|
@@ -2952,9 +3030,9 @@ window.__ModuleLoader__.load({
|
|
|
2952
3030
|
h(KeyValues, { rows: [['GitHub token', credentials.token === 'none' ? '未配置(回退到已登录的 gh CLI)' : '已配置'], ['SSH 私钥', credentials.sshKeyPath === 'none' ? '未配置(当前版本不使用)' : '已配置'],
|
|
2953
3031
|
['gh 账号', credentials.ghConfigDir === 'configured' ? '已绑定独立配置目录(评论挂智能体账号)' : '宿主当前登录的账号'],
|
|
2954
3032
|
['Gitee 令牌', credentials.giteeToken === 'configured' ? '已配置' : '未配置(公开仓库也能读,私有仓库需要)']] }),
|
|
2955
|
-
field('Token', h(Input, { type: 'password', value: token, placeholder: 'ghp_… / github_pat_…(留空不改)', onChange: (e) => setToken(e.target.value) })),
|
|
2956
|
-
field('Gitee 令牌', h(Input, { type: 'password', value: giteeToken, placeholder: '私人令牌(留空不改);只盯 GitHub 可以不管' , onChange: (e) => setGiteeToken(e.target.value) })),
|
|
2957
|
-
field('gh 账号目录', h(Input, { value: ghDir, placeholder: '绝对路径(留空 = 用宿主账号)', onChange: (e) => setGhDir(e.target.value) })),
|
|
3033
|
+
field('Token', h(Input, { type: 'password', value: token, placeholder: 'ghp_… / github_pat_…(留空不改)', onChange: (e) => { credentialsDraftVersionRef.current += 1; setToken(e.target.value) } })),
|
|
3034
|
+
field('Gitee 令牌', h(Input, { type: 'password', value: giteeToken, placeholder: '私人令牌(留空不改);只盯 GitHub 可以不管' , onChange: (e) => { credentialsDraftVersionRef.current += 1; setGiteeToken(e.target.value) } })),
|
|
3035
|
+
field('gh 账号目录', h(Input, { value: ghDir, placeholder: '绝对路径(留空 = 用宿主账号)', onChange: (e) => { credentialsDraftVersionRef.current += 1; setGhDir(e.target.value) } })),
|
|
2958
3036
|
// 解绑要**显式**:以前只改 token 时会顺带把已绑定的目录清掉,客户不知道评论为什么换回了宿主账号。
|
|
2959
3037
|
credentials.ghConfigDir === 'configured'
|
|
2960
3038
|
? h('div', { className: 'dt-actions' }, h(Btn, { variant: 'ghost', size: 'sm', onClick: clearGhDir }, '解绑 gh 账号目录'))
|
|
@@ -3035,7 +3113,7 @@ window.__ModuleLoader__.load({
|
|
|
3035
3113
|
h('textarea', {
|
|
3036
3114
|
className: 'dt-textarea', rows: 3, value: goalDraft,
|
|
3037
3115
|
placeholder: '这个会话要达成什么(会写进 /goal)',
|
|
3038
|
-
onChange: (e) => { setGoalTouched(true); setGoalDraft(e.target.value) },
|
|
3116
|
+
onChange: (e) => { goalDraftVersionRef.current += 1; setGoalTouched(true); setGoalDraft(e.target.value) },
|
|
3039
3117
|
}),
|
|
3040
3118
|
h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveGoal, disabled: !sessionId }, '保存 goal'))),
|
|
3041
3119
|
]
|
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.
|
|
52
|
+
export const SERVER_VERSION = '0.9.284'
|
|
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.
|
|
3
|
+
"version": "0.9.284",
|
|
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",
|