dsh-session-superagent 0.9.282 → 0.9.283

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,29 @@
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.283] - 2026-11-06 —— 保存 pending 状态机修复
6
+
7
+ ### 新草稿不再被旧响应覆盖
8
+
9
+ - 凭证与 goal 使用独立草稿版本号和保存序号。
10
+ - pending 后产生的新输入不会被旧响应清空或覆盖。
11
+ - 重复保存时,只有最新保存且草稿版本未变的响应能清理对应草稿。
12
+
13
+ ### 严格回读与 null 同步
14
+
15
+ - 保存必须回读成功后才 Toast 成功;POST200+GET500 显示可重试错误,不回写旧 goal。
16
+ - `sessionGoal:null` 清空干净 goal 草稿,dirty 草稿仍由用户决定。
17
+ - 已有快照时 304 也视为成功回读,保存反馈可依赖它。
18
+
19
+ ### 验证
20
+
21
+ - 新增回归修复前 5/7,修复后 7/7。
22
+ - 联合 144/144,全量 637/637。
23
+ - 主线 Chromium 47/47;pending/GET500/null 等专项合计 52/52。
24
+ - UI 体检 11/11=100。
25
+
26
+ 未验真实 DSH Web GUI 与真实 watcher 写操作。按 Git 工作流保留本地候选。
27
+
5
28
  ## [0.9.282] - 2026-11-06 —— CollapsibleList 与首载/校验修复
6
29
 
7
30
  ### 折叠列表
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.282-green.svg)](https://github.com/MYCF711/dsh-session-superagent/releases)
6
+ [![Version](https://img.shields.io/badge/version-0.9.283-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 # 630 项单测(带离线开关;裸 node --test 会真去 spawn gh,两分半)
151
+ npm test # 637 项单测(带离线开关;裸 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 # 630 项单测(带离线开关,约 1.6 秒)
211
+ npm test # 637 项单测(带离线开关,约 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.282'
421
+ const CLIENT_VERSION = '0.9.283'
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.
@@ -1990,6 +1990,11 @@ window.__ModuleLoader__.load({
1990
1990
  const createTouchedRef = useRef(new Set())
1991
1991
  const createSnapshotRef = useRef({ ...CREATE_WATCHER_VALUES })
1992
1992
  const editSnapshotRef = useRef(null)
1993
+ // 保存期间仍可输入:旧响应只能清理它提交的那份草稿,不能覆盖 pending 后的新输入。
1994
+ const credentialsDraftVersionRef = useRef(0)
1995
+ const credentialsSaveSeqRef = useRef(0)
1996
+ const goalDraftVersionRef = useRef(0)
1997
+ const goalSaveSeqRef = useRef(0)
1993
1998
  const setField = (next) => {
1994
1999
  const opening = editSnapshotRef.current && editSnapshotRef.current.values
1995
2000
  for (const key of Object.keys(next)) {
@@ -2053,7 +2058,8 @@ window.__ModuleLoader__.load({
2053
2058
  if (seq !== loadSeqRef.current) return null // 已经有更新的一次请求在飞:这次结果作废
2054
2059
  // 304:内容没变,别白白重渲染 —— 前提是本地已经有一份能渲染的 body
2055
2060
  if (payload && payload.notModified) {
2056
- if (hasBodyRef.current) return null
2061
+ // 有本地快照时,304 也是一次成功回读;保存后的成功反馈可以依赖它。
2062
+ if (hasBodyRef.current) return payload
2057
2063
  // 本地没有数据:这次 304 是被状态栏的 etag 带出来的,清掉 etag 重取一次全量
2058
2064
  stateEtag = null
2059
2065
  return load()
@@ -2079,8 +2085,9 @@ window.__ModuleLoader__.load({
2079
2085
  const credentials = body.credentials || { token: 'none', sshKeyPath: 'none' }
2080
2086
 
2081
2087
  useEffect(() => {
2082
- if (goalTouched || !sessionGoal) return
2083
- setGoalDraft(sessionGoal.objective || '')
2088
+ if (goalTouched) return
2089
+ // null 也是服务端事实:干净草稿要同步清空;dirty 草稿仍由用户自己决定保存或放弃。
2090
+ setGoalDraft(sessionGoal ? sessionGoal.objective || '' : '')
2084
2091
  }, [goalTouched, sessionGoal])
2085
2092
 
2086
2093
  const busyRef = useRef(false)
@@ -2097,8 +2104,14 @@ window.__ModuleLoader__.load({
2097
2104
  setNotice(null)
2098
2105
  try {
2099
2106
  await work()
2107
+ if (options.requireReload) {
2108
+ const body = await load()
2109
+ if (!body) throw new Error(options.reloadError || '操作已提交,但回读失败,请重试')
2110
+ if (options.afterReload) options.afterReload(body)
2111
+ }
2112
+ // 必须回读的保存只有在确认成功后才提示;其它动作保留原有通知/刷新契约。
2100
2113
  if (done) notify(done)
2101
- await load()
2114
+ if (!options.requireReload) await load()
2102
2115
  return true
2103
2116
  } catch (error) {
2104
2117
  const text = String((error && error.message) || error)
@@ -2251,30 +2264,52 @@ window.__ModuleLoader__.load({
2251
2264
  return warnings
2252
2265
  }, null, { rethrow: true })
2253
2266
 
2254
- const saveCredentials = () => run(async () => {
2255
- const payload = {}
2256
- if (token.trim()) payload.token = token.trim()
2257
- if (giteeToken.trim()) payload.giteeToken = giteeToken.trim()
2258
- // 审核 T24 M3:这里以前无条件带 "ghConfigDir" —— ghDir 初值恒为空串且从不回填服务端值,
2259
- // 于是「只改 token」也会发 ghConfigDir:"",服务端把它当「显式清空」,
2260
- // 已绑定的 gh 账号目录被静默解绑(评论改回宿主账号)。
2261
- // 现在只有**填了东西**才发;要解绑请用旁边的「清除」按钮(它显式发空串)。
2262
- if (ghDir.trim()) payload.ghConfigDir = ghDir.trim()
2263
- await call('/credentials', { method: 'POST', body: JSON.stringify(payload) })
2264
- setToken('')
2265
- setGhDir('')
2266
- setGiteeToken('')
2267
- }, '凭证已保存')
2267
+ const saveCredentials = () => {
2268
+ const draftVersion = credentialsDraftVersionRef.current
2269
+ let saveSeq = 0
2270
+ return run(async () => {
2271
+ saveSeq = ++credentialsSaveSeqRef.current
2272
+ const payload = {}
2273
+ if (token.trim()) payload.token = token.trim()
2274
+ if (giteeToken.trim()) payload.giteeToken = giteeToken.trim()
2275
+ // 审核 T24 M3:这里以前无条件带 "ghConfigDir" —— ghDir 初值恒为空串且从不回填服务端值,
2276
+ // 于是「只改 token」也会发 ghConfigDir:"",服务端把它当「显式清空」,
2277
+ // 已绑定的 gh 账号目录被静默解绑(评论改回宿主账号)。
2278
+ // 现在只有**填了东西**才发;要解绑请用旁边的「清除」按钮(它显式发空串)。
2279
+ if (ghDir.trim()) payload.ghConfigDir = ghDir.trim()
2280
+ await call('/credentials', { method: 'POST', body: JSON.stringify(payload) })
2281
+ }, '凭证已保存', {
2282
+ requireReload: true,
2283
+ reloadError: '凭证已提交,但回读失败,请重试',
2284
+ afterReload: () => {
2285
+ if (saveSeq !== credentialsSaveSeqRef.current || draftVersion !== credentialsDraftVersionRef.current) return
2286
+ setToken('')
2287
+ setGhDir('')
2288
+ setGiteeToken('')
2289
+ },
2290
+ })
2291
+ }
2268
2292
 
2269
2293
  /** 显式解绑 gh 账号目录(T24 M3:不能在「只改 token」时顺带清掉)。 */
2270
2294
  const clearGhDir = () => run(async () => {
2271
2295
  await call('/credentials', { method: 'POST', body: JSON.stringify({ ghConfigDir: '' }) })
2272
2296
  }, '已解绑 gh 账号目录(评论改回宿主账号)')
2273
2297
 
2274
- const saveGoal = () => run(async () => {
2275
- await call('/goal', { method: 'POST', body: JSON.stringify({ sessionId, objective: goalDraft }) })
2276
- setGoalTouched(false)
2277
- }, 'goal 已保存')
2298
+ const saveGoal = () => {
2299
+ const draftVersion = goalDraftVersionRef.current
2300
+ let saveSeq = 0
2301
+ return run(async () => {
2302
+ saveSeq = ++goalSaveSeqRef.current
2303
+ await call('/goal', { method: 'POST', body: JSON.stringify({ sessionId, objective: goalDraft }) })
2304
+ }, 'goal 已保存', {
2305
+ requireReload: true,
2306
+ reloadError: 'goal 已提交,但回读失败,请重试',
2307
+ afterReload: () => {
2308
+ if (saveSeq !== goalSaveSeqRef.current || draftVersion !== goalDraftVersionRef.current) return
2309
+ setGoalTouched(false)
2310
+ },
2311
+ })
2312
+ }
2278
2313
 
2279
2314
  // 四个数字必须加得上总数(以前「已暂停」按 enabled 数、「异常」按 lastError 数:
2280
2315
  // 一条已暂停又有错误的守会被数两次,而「时段外」根本没被数)
@@ -2952,9 +2987,9 @@ window.__ModuleLoader__.load({
2952
2987
  h(KeyValues, { rows: [['GitHub token', credentials.token === 'none' ? '未配置(回退到已登录的 gh CLI)' : '已配置'], ['SSH 私钥', credentials.sshKeyPath === 'none' ? '未配置(当前版本不使用)' : '已配置'],
2953
2988
  ['gh 账号', credentials.ghConfigDir === 'configured' ? '已绑定独立配置目录(评论挂智能体账号)' : '宿主当前登录的账号'],
2954
2989
  ['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) })),
2990
+ field('Token', h(Input, { type: 'password', value: token, placeholder: 'ghp_… / github_pat_…(留空不改)', onChange: (e) => { credentialsDraftVersionRef.current += 1; setToken(e.target.value) } })),
2991
+ field('Gitee 令牌', h(Input, { type: 'password', value: giteeToken, placeholder: '私人令牌(留空不改);只盯 GitHub 可以不管' , onChange: (e) => { credentialsDraftVersionRef.current += 1; setGiteeToken(e.target.value) } })),
2992
+ field('gh 账号目录', h(Input, { value: ghDir, placeholder: '绝对路径(留空 = 用宿主账号)', onChange: (e) => { credentialsDraftVersionRef.current += 1; setGhDir(e.target.value) } })),
2958
2993
  // 解绑要**显式**:以前只改 token 时会顺带把已绑定的目录清掉,客户不知道评论为什么换回了宿主账号。
2959
2994
  credentials.ghConfigDir === 'configured'
2960
2995
  ? h('div', { className: 'dt-actions' }, h(Btn, { variant: 'ghost', size: 'sm', onClick: clearGhDir }, '解绑 gh 账号目录'))
@@ -3035,7 +3070,7 @@ window.__ModuleLoader__.load({
3035
3070
  h('textarea', {
3036
3071
  className: 'dt-textarea', rows: 3, value: goalDraft,
3037
3072
  placeholder: '这个会话要达成什么(会写进 /goal)',
3038
- onChange: (e) => { setGoalTouched(true); setGoalDraft(e.target.value) },
3073
+ onChange: (e) => { goalDraftVersionRef.current += 1; setGoalTouched(true); setGoalDraft(e.target.value) },
3039
3074
  }),
3040
3075
  h('div', { className: 'dt-actions' }, h(Btn, { variant: 'primary', onClick: saveGoal, disabled: !sessionId }, '保存 goal'))),
3041
3076
  ]
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.282'
52
+ export const SERVER_VERSION = '0.9.283'
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.282",
3
+ "version": "0.9.283",
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",