dsh-progress-union 0.6.1 → 0.6.2
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 +363 -340
- package/LICENSE +21 -21
- package/README.md +282 -272
- package/anchor.js +39 -39
- package/client.js +2990 -2973
- package/cordis.patch.yml +4 -4
- package/docs/slot-models-comparison.md +23 -23
- package/docs/slot-trail-fanout.md +31 -31
- package/docs/spirit-reference.md +38 -38
- package/icon.svg +7 -7
- package/index.js +4568 -4466
- package/package.json +79 -79
- package/test/anchor.test.mjs +139 -139
- package/test/assistant.test.mjs +214 -214
- package/test/client.test.mjs +181 -172
- package/test/e2e.test.mjs +77 -77
- package/test/goal-drive.test.mjs +17 -17
- package/test/harness.mjs +249 -249
- package/test/host.test.mjs +251 -251
- package/test/observer.test.mjs +170 -170
- package/test/restore-hydrate.test.mjs +185 -0
- package/test/settings.test.mjs +81 -81
- package/test/star-panel.test.mjs +181 -181
- package/test/time.test.mjs +147 -147
- package/test/todo-sync.test.mjs +155 -155
package/test/client.test.mjs
CHANGED
|
@@ -1,172 +1,181 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 4 验收:client 契约守卫。
|
|
3
|
-
* 1) 客户端文件不得残留 board 旧命名空间/旧 API 调用(fork 改造回归);
|
|
4
|
-
* 2) 客户端消费的两条路由形状(snapshot / status)由宿主实测钉住。
|
|
5
|
-
*/
|
|
6
|
-
import assert from 'node:assert/strict'
|
|
7
|
-
import fs from 'node:fs'
|
|
8
|
-
import os from 'node:os'
|
|
9
|
-
import path from 'node:path'
|
|
10
|
-
import test from 'node:test'
|
|
11
|
-
|
|
12
|
-
import { fileURLToPath } from 'node:url'
|
|
13
|
-
|
|
14
|
-
process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
|
|
15
|
-
const { SESSION, createHarness, jsonReq, callRoute } = await import('./harness.mjs')
|
|
16
|
-
|
|
17
|
-
// 必须用 fileURLToPath:`new URL(...).pathname` 在 Windows 得到 `/E:/...`(需去前导斜杠),
|
|
18
|
-
// 但 Linux 的 `/` 是根目录,`.replace(/^[/]/,'')` 会把它变成相对路径 → CI 上 ENOENT。
|
|
19
|
-
const clientFile = fileURLToPath(new URL('../client.js', import.meta.url))
|
|
20
|
-
const packageFile = fileURLToPath(new URL('../package.json', import.meta.url))
|
|
21
|
-
|
|
22
|
-
test('client.js 命名空间已切到 union,无 progress-board API 残留', () => {
|
|
23
|
-
const src = fs.readFileSync(clientFile, 'utf8')
|
|
24
|
-
assert.match(src, /id: 'dsh-progress-union'/)
|
|
25
|
-
assert.match(src, /const API = '\/progress-union'/)
|
|
26
|
-
assert.match(src, /STATUS_API = '\/dsh-progress\/status'/)
|
|
27
|
-
assert.doesNotMatch(src, /fetch\(`\/progress-board/, '不得残留旧 API 前缀的直接调用')
|
|
28
|
-
assert.match(src, /useUnionTiming/, '迷你条时间面钩子必须在')
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('迷你条暂停/继续按钮接线齐全(渲染 + 请求 + 状态门控)', () => {
|
|
32
|
-
const src = fs.readFileSync(clientFile, 'utf8')
|
|
33
|
-
// 渲染:两个按钮都在 dock actions 区
|
|
34
|
-
assert.match(src, /className: 'pb-dock-btn pb-dock-goal pb-dock-goal-pause'/, '暂停按钮必须在')
|
|
35
|
-
assert.match(src, /className: 'pb-dock-btn pb-dock-goal pb-dock-goal-resume'/, '继续按钮必须在')
|
|
36
|
-
// 请求面:走 /progress-union/goal 控制路由
|
|
37
|
-
assert.match(src, /fetch\(`\$\{API\}\/goal`/, '必须调用目标控制路由')
|
|
38
|
-
assert.match(src, /action: 'pause'|onGoalControl\('pause'\)/, '暂停必须接线')
|
|
39
|
-
assert.match(src, /onGoalControl\('resume'\)/, '继续必须接线')
|
|
40
|
-
// 门控:只有目标 active 才给暂停,只有 paused/blocked 才给继续
|
|
41
|
-
assert.match(src, /goalActive = goalPhase === 'active'/, '暂停按钮必须按 phase 门控')
|
|
42
|
-
assert.match(src, /goalStopped = goalPhase === 'paused' \|\| goalPhase === 'blocked'/, '继续按钮必须按 phase 门控')
|
|
43
|
-
// 按钮样式必须真的存在(否则是裸浏览器按钮):背景=主色实心,前景=宿主 on-color 令牌。
|
|
44
|
-
assert.match(src, /\.pb-dock-goal-resume \{[^}]*background: var\(--dsw-alias-brand-primary\)/, '继续按钮需要有主色实心样式')
|
|
45
|
-
assert.match(src, /\.pb-dock-goal-resume \{[^}]*color: var\(--dsw-alias-label-on-color/, '继续按钮前景必须用 on-color 令牌')
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test('主色实心按钮的前景色不得用 bg-base(玻璃皮肤会把它设成 transparent)', () => {
|
|
49
|
-
const src = fs.readFileSync(clientFile, 'utf8')
|
|
50
|
-
// 事故:maid-atelier 皮肤在 body 上把 --dsw-alias-bg-base 设为 transparent,
|
|
51
|
-
// 拿它当 color 会让「继续」渲染成透明字 → 看着像一块纯色块盖住了按钮。
|
|
52
|
-
assert.doesNotMatch(src, /color:\s*var\(--dsw-alias-bg-base/, '--dsw-alias-bg-base 是页面底色语义,不能当前景色')
|
|
53
|
-
assert.match(src, /\.pb-btn-primary \{[^}]*color: var\(--dsw-alias-label-on-color/, '主按钮前景必须用 on-color 令牌')
|
|
54
|
-
// 选择态底板同样不能用 bg-base(透明后选中段会"消失")。
|
|
55
|
-
assert.doesNotMatch(src, /\[data-on="true"\] \{[^}]*background: var\(--dsw-alias-bg-base/, '分段控件选中态不得用 bg-base 做底板')
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test('目标文案区分「板目标」与宿主 goal,完成态不报时间面', () => {
|
|
59
|
-
const src = fs.readFileSync(clientFile, 'utf8')
|
|
60
|
-
// 官方 GoalBar 与 /progress-goal 是两套状态机,并排在同一 input dock:文案必须能分辨。
|
|
61
|
-
assert.match(src, /goalPaused: '板目标已暂停'/, 'zh 文案需带「板目标」前缀')
|
|
62
|
-
assert.match(src, /goalPaused: 'Board goal paused'/, 'en 文案需带 Board goal 前缀')
|
|
63
|
-
assert.match(src, /独立于宿主的 \/goal/, '悬停提示需说明与宿主 /goal 的关系')
|
|
64
|
-
assert.match(src, /const allDone = summary\.total > 0 && summary\.done === summary\.total/, '完成态需跳过时间面')
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test('W1: 头部入口注册仍在,且带渲染兜底与分面隔离', () => {
|
|
68
|
-
// 仓内文件是 CRLF:多行断言前先归一,否则 \n 永远匹配不到 \r\n。
|
|
69
|
-
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
70
|
-
// 入口本体:槽位 + id + 顺序(5 = 排在宿主自带入口之后、其余插件之前,窄窗口不会被裁掉)
|
|
71
|
-
assert.match(src, /name: 'conversation\.session\.header\.utilities'/, '头部工具区槽位注册必须在')
|
|
72
|
-
assert.match(src, /id: 'progress-union-header'/, '头部入口 id 必须在')
|
|
73
|
-
assert.match(src, /order: 5,/, '头部入口顺序必须提前到 5')
|
|
74
|
-
// 渲染兜底:组件抛错只让这一枚消失,不拖垮整排 utilities
|
|
75
|
-
assert.match(src, /class HeaderEntryBoundary extends React\.Component/, '头部入口必须有错误边界')
|
|
76
|
-
assert.match(src, /getDerivedStateFromError/, '错误边界必须真的降级渲染')
|
|
77
|
-
assert.match(src, /function ProgressHeaderButton\(props\) \{\n return h\(HeaderEntryBoundary/, '导出组件必须包在错误边界里')
|
|
78
|
-
// 分面隔离:任一入口注册失败不得中止 apply(否则图标/迷你条/右栏页签一起消失)
|
|
79
|
-
assert.match(src, /const safeEffect = \(label, register\) =>/, '必须有分面隔离助手')
|
|
80
|
-
const safeCalls = src.match(/^\s+safeEffect\($/gm) || []
|
|
81
|
-
assert.equal(safeCalls.length, 6, '六个入口面(设置×2 / 右栏类型 / 右栏面板 / 头部 / 迷你条)都必须经 safeEffect 注册')
|
|
82
|
-
const bare = src.match(/ctx\.effect\(\s*\n\s*\(\) =>\s*\n\s*ctx\.(slots|sidebarRightTabs)/g) || []
|
|
83
|
-
assert.equal(bare.length, 0, '不得残留裸 ctx.effect 入口注册')
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
test('W2: better-sidebar 页签是独立入口,内容仍是自有板子', () => {
|
|
87
|
-
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
88
|
-
assert.match(src, /const BS_TAB_ID = 'dsh-progress-union:board'/, 'better-sidebar 页签 id 必须在')
|
|
89
|
-
assert.doesNotMatch(src, /const BS_TAB_ID = 'progress-union'|const BS_TAB_ID = 'dsh-progress-union'\n/, '页签 id 不得与原生 kind 混用')
|
|
90
|
-
// 服务可能晚于 apply 就绪 → 必须 deferred inject,不能一次性 ctx.get
|
|
91
|
-
assert.match(src, /ctx\.inject\(\['betterSidebar'\], \(bs\) => \{/, '必须用 deferred inject 等待 betterSidebar')
|
|
92
|
-
assert.match(src, /typeof service\.registerTab !== 'function'/, '调用前必须探测 registerTab')
|
|
93
|
-
// 描述符字段齐全
|
|
94
|
-
assert.match(src, /id: BS_TAB_ID,/)
|
|
95
|
-
assert.match(src, /title: \(\) => t\('nav'\),/)
|
|
96
|
-
assert.match(src, /description: \(\) => t\('bsDesc'\),/)
|
|
97
|
-
assert.match(src, /icon: \(size\) => h\(ProgressNavIcon, \{ size: size \|\| 16 \}\)/)
|
|
98
|
-
assert.match(src, /order: 120,/)
|
|
99
|
-
assert.match(src, /single: true,/)
|
|
100
|
-
// 内容是自有板子,且拿到当前会话
|
|
101
|
-
assert.match(src, /h\(ProgressSidePanel, \{/, '页签正文必须是自有 ProgressSidePanel')
|
|
102
|
-
assert.match(src, /sessionId: tabProps && tabProps\.scope \? tabProps\.scope\.sessionId : undefined/)
|
|
103
|
-
// 不传 collapse / toggleFullscreen,避免 better-sidebar 里出现死按钮
|
|
104
|
-
const block = src.slice(src.indexOf("ctx.inject(['betterSidebar']"), src.indexOf("'progress-union: better-sidebar tab'"))
|
|
105
|
-
assert.doesNotMatch(block, /collapse:/, '不得向 better-sidebar 页签传 collapse')
|
|
106
|
-
assert.doesNotMatch(block, /toggleFullscreen:/, '不得向 better-sidebar 页签传 toggleFullscreen')
|
|
107
|
-
// 明确不复用 better-sidebar 的「任务管理」
|
|
108
|
-
assert.doesNotMatch(block, /task.?manage|subagent|后台命令/iu, '不得复用 better-sidebar 的任务管理视图')
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
test('W2: better-sidebar 只是软依赖(未装者必须照常加载)', () => {
|
|
112
|
-
const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf8'))
|
|
113
|
-
const declared = pkg.dsh?.client?.inject ?? []
|
|
114
|
-
assert.equal(declared.includes('dsh-better-sidebar'), false, 'dsh.client.inject 不得声明 dsh-better-sidebar')
|
|
115
|
-
assert.equal('dsh-better-sidebar' in (pkg.dependencies ?? {}), false, 'dependencies 不得声明 dsh-better-sidebar')
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
test('S2: bsDesc 在 zh/en 两个字典里都存在', () => {
|
|
119
|
-
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
120
|
-
assert.match(src, /bsDesc: '任务串联的进度板(不是 better-sidebar 的「任务管理」)'/, 'zh 文案必须在')
|
|
121
|
-
assert.match(src, /bsDesc: 'Linked-task progress board \(not better-sidebar task manager\)'/, 'en 文案必须在')
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
test('宿主 snapshot/status 两路由的客户端消费形状', async () => {
|
|
125
|
-
const harness = createHarness()
|
|
126
|
-
await harness.run()
|
|
127
|
-
await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
|
|
128
|
-
await harness.toolMap.get('progress_update').definition.execute(
|
|
129
|
-
{ changes: [{ title: '渲染截图', status: 'doing', current: '渲染第 7/24 张' }, { title: '合成音轨' }] },
|
|
130
|
-
{ agent: harness.agent },
|
|
131
|
-
)
|
|
132
|
-
harness.emit('turn/start', {})
|
|
133
|
-
harness.emit('step/start', {})
|
|
134
|
-
|
|
135
|
-
const snap = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
|
|
136
|
-
assert.equal(snap.ok, true)
|
|
137
|
-
assert.equal(snap.enabled, true)
|
|
138
|
-
assert.deepEqual(snap.items.map((i) => i.title), ['渲染截图', '合成音轨'])
|
|
139
|
-
assert.equal(typeof snap.summary.percent, 'number')
|
|
140
|
-
assert.equal('pendingUserChanges' in snap, true)
|
|
141
|
-
|
|
142
|
-
const status = (await callRoute(harness, '/dsh-progress/status', { method: 'GET', url: '/dsh-progress/status', headers: {} })).json()
|
|
143
|
-
assert.equal(status.ok, true)
|
|
144
|
-
assert.equal(status.config.pollMs, 1000)
|
|
145
|
-
assert.ok(status.task, 'status.task 必须存在(迷你条数据源)')
|
|
146
|
-
assert.equal(String(status.task.id), String(SESSION))
|
|
147
|
-
// 板开:阶段直接取板 items,不再走关键词猜测
|
|
148
|
-
assert.deepEqual(status.task.stages, ['渲染截图', '合成音轨'])
|
|
149
|
-
assert.equal(status.task.boardDriven, true)
|
|
150
|
-
assert.equal(status.task.current, 0)
|
|
151
|
-
assert.ok(Array.isArray(status.tasks))
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
test('W3: 板只住在右侧边栏——不再注册主区完整面板', () => {
|
|
155
|
-
// 事故:主区面板没有收拢入口,点进去就回不到会话(进去出不来)。
|
|
156
|
-
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
157
|
-
assert.match(src, /const openPanel = \(\) => ctx\.sidebarRight\.openTab\(RIGHT_TAB_KIND\)/, '头部/迷你条入口必须打开右栏页签')
|
|
158
|
-
assert.match(src, /inject: \(\) => \(\{ openPanel, togglePanel \}\)/, '头部入口注入的必须是右栏开关(可见则收起,不可见则打开)')
|
|
159
|
-
assert.doesNotMatch(src, /ctx\.slots\.inject\('main'/, '不得再注册主区完整面板')
|
|
160
|
-
assert.doesNotMatch(src, /layout\.selectPanel/, '不得再切主区面板')
|
|
161
|
-
assert.doesNotMatch(src, /function ProgressPanel\(/, '完整面板组件应已移除')
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
test('W4: 侧栏顶部不再画自带的 全面展开/收起/完整面板 按钮(交给右栏 chrome)', () => {
|
|
165
|
-
// 事故:三个按钮都在,但 toggleFullscreen / collapse 在右栏页签里根本没注入(better-sidebar 里更没处传),
|
|
166
|
-
// 点了没反应才是常态。右栏自身的 chrome 已经有全屏与关闭,不再重复造。
|
|
167
|
-
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
168
|
-
assert.doesNotMatch(src, /props\.toggleFullscreen/, '不得再渲染自带的全屏按钮')
|
|
169
|
-
assert.doesNotMatch(src, /props\.collapse/, '不得再渲染自带的收起按钮')
|
|
170
|
-
assert.doesNotMatch(src, /t\('sideFull'\)|t\('sideHalf'\)|t\('sideCollapse'\)/, '三个死按钮的文案不得残留')
|
|
171
|
-
assert.doesNotMatch(src, /toggleFullscreen/, '注入面不得再传全屏切换')
|
|
172
|
-
})
|
|
1
|
+
/**
|
|
2
|
+
* Phase 4 验收:client 契约守卫。
|
|
3
|
+
* 1) 客户端文件不得残留 board 旧命名空间/旧 API 调用(fork 改造回归);
|
|
4
|
+
* 2) 客户端消费的两条路由形状(snapshot / status)由宿主实测钉住。
|
|
5
|
+
*/
|
|
6
|
+
import assert from 'node:assert/strict'
|
|
7
|
+
import fs from 'node:fs'
|
|
8
|
+
import os from 'node:os'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import test from 'node:test'
|
|
11
|
+
|
|
12
|
+
import { fileURLToPath } from 'node:url'
|
|
13
|
+
|
|
14
|
+
process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
|
|
15
|
+
const { SESSION, createHarness, jsonReq, callRoute } = await import('./harness.mjs')
|
|
16
|
+
|
|
17
|
+
// 必须用 fileURLToPath:`new URL(...).pathname` 在 Windows 得到 `/E:/...`(需去前导斜杠),
|
|
18
|
+
// 但 Linux 的 `/` 是根目录,`.replace(/^[/]/,'')` 会把它变成相对路径 → CI 上 ENOENT。
|
|
19
|
+
const clientFile = fileURLToPath(new URL('../client.js', import.meta.url))
|
|
20
|
+
const packageFile = fileURLToPath(new URL('../package.json', import.meta.url))
|
|
21
|
+
|
|
22
|
+
test('client.js 命名空间已切到 union,无 progress-board API 残留', () => {
|
|
23
|
+
const src = fs.readFileSync(clientFile, 'utf8')
|
|
24
|
+
assert.match(src, /id: 'dsh-progress-union'/)
|
|
25
|
+
assert.match(src, /const API = '\/progress-union'/)
|
|
26
|
+
assert.match(src, /STATUS_API = '\/dsh-progress\/status'/)
|
|
27
|
+
assert.doesNotMatch(src, /fetch\(`\/progress-board/, '不得残留旧 API 前缀的直接调用')
|
|
28
|
+
assert.match(src, /useUnionTiming/, '迷你条时间面钩子必须在')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('迷你条暂停/继续按钮接线齐全(渲染 + 请求 + 状态门控)', () => {
|
|
32
|
+
const src = fs.readFileSync(clientFile, 'utf8')
|
|
33
|
+
// 渲染:两个按钮都在 dock actions 区
|
|
34
|
+
assert.match(src, /className: 'pb-dock-btn pb-dock-goal pb-dock-goal-pause'/, '暂停按钮必须在')
|
|
35
|
+
assert.match(src, /className: 'pb-dock-btn pb-dock-goal pb-dock-goal-resume'/, '继续按钮必须在')
|
|
36
|
+
// 请求面:走 /progress-union/goal 控制路由
|
|
37
|
+
assert.match(src, /fetch\(`\$\{API\}\/goal`/, '必须调用目标控制路由')
|
|
38
|
+
assert.match(src, /action: 'pause'|onGoalControl\('pause'\)/, '暂停必须接线')
|
|
39
|
+
assert.match(src, /onGoalControl\('resume'\)/, '继续必须接线')
|
|
40
|
+
// 门控:只有目标 active 才给暂停,只有 paused/blocked 才给继续
|
|
41
|
+
assert.match(src, /goalActive = goalPhase === 'active'/, '暂停按钮必须按 phase 门控')
|
|
42
|
+
assert.match(src, /goalStopped = goalPhase === 'paused' \|\| goalPhase === 'blocked'/, '继续按钮必须按 phase 门控')
|
|
43
|
+
// 按钮样式必须真的存在(否则是裸浏览器按钮):背景=主色实心,前景=宿主 on-color 令牌。
|
|
44
|
+
assert.match(src, /\.pb-dock-goal-resume \{[^}]*background: var\(--dsw-alias-brand-primary\)/, '继续按钮需要有主色实心样式')
|
|
45
|
+
assert.match(src, /\.pb-dock-goal-resume \{[^}]*color: var\(--dsw-alias-label-on-color/, '继续按钮前景必须用 on-color 令牌')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('主色实心按钮的前景色不得用 bg-base(玻璃皮肤会把它设成 transparent)', () => {
|
|
49
|
+
const src = fs.readFileSync(clientFile, 'utf8')
|
|
50
|
+
// 事故:maid-atelier 皮肤在 body 上把 --dsw-alias-bg-base 设为 transparent,
|
|
51
|
+
// 拿它当 color 会让「继续」渲染成透明字 → 看着像一块纯色块盖住了按钮。
|
|
52
|
+
assert.doesNotMatch(src, /color:\s*var\(--dsw-alias-bg-base/, '--dsw-alias-bg-base 是页面底色语义,不能当前景色')
|
|
53
|
+
assert.match(src, /\.pb-btn-primary \{[^}]*color: var\(--dsw-alias-label-on-color/, '主按钮前景必须用 on-color 令牌')
|
|
54
|
+
// 选择态底板同样不能用 bg-base(透明后选中段会"消失")。
|
|
55
|
+
assert.doesNotMatch(src, /\[data-on="true"\] \{[^}]*background: var\(--dsw-alias-bg-base/, '分段控件选中态不得用 bg-base 做底板')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('目标文案区分「板目标」与宿主 goal,完成态不报时间面', () => {
|
|
59
|
+
const src = fs.readFileSync(clientFile, 'utf8')
|
|
60
|
+
// 官方 GoalBar 与 /progress-goal 是两套状态机,并排在同一 input dock:文案必须能分辨。
|
|
61
|
+
assert.match(src, /goalPaused: '板目标已暂停'/, 'zh 文案需带「板目标」前缀')
|
|
62
|
+
assert.match(src, /goalPaused: 'Board goal paused'/, 'en 文案需带 Board goal 前缀')
|
|
63
|
+
assert.match(src, /独立于宿主的 \/goal/, '悬停提示需说明与宿主 /goal 的关系')
|
|
64
|
+
assert.match(src, /const allDone = summary\.total > 0 && summary\.done === summary\.total/, '完成态需跳过时间面')
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('W1: 头部入口注册仍在,且带渲染兜底与分面隔离', () => {
|
|
68
|
+
// 仓内文件是 CRLF:多行断言前先归一,否则 \n 永远匹配不到 \r\n。
|
|
69
|
+
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
70
|
+
// 入口本体:槽位 + id + 顺序(5 = 排在宿主自带入口之后、其余插件之前,窄窗口不会被裁掉)
|
|
71
|
+
assert.match(src, /name: 'conversation\.session\.header\.utilities'/, '头部工具区槽位注册必须在')
|
|
72
|
+
assert.match(src, /id: 'progress-union-header'/, '头部入口 id 必须在')
|
|
73
|
+
assert.match(src, /order: 5,/, '头部入口顺序必须提前到 5')
|
|
74
|
+
// 渲染兜底:组件抛错只让这一枚消失,不拖垮整排 utilities
|
|
75
|
+
assert.match(src, /class HeaderEntryBoundary extends React\.Component/, '头部入口必须有错误边界')
|
|
76
|
+
assert.match(src, /getDerivedStateFromError/, '错误边界必须真的降级渲染')
|
|
77
|
+
assert.match(src, /function ProgressHeaderButton\(props\) \{\n return h\(HeaderEntryBoundary/, '导出组件必须包在错误边界里')
|
|
78
|
+
// 分面隔离:任一入口注册失败不得中止 apply(否则图标/迷你条/右栏页签一起消失)
|
|
79
|
+
assert.match(src, /const safeEffect = \(label, register\) =>/, '必须有分面隔离助手')
|
|
80
|
+
const safeCalls = src.match(/^\s+safeEffect\($/gm) || []
|
|
81
|
+
assert.equal(safeCalls.length, 6, '六个入口面(设置×2 / 右栏类型 / 右栏面板 / 头部 / 迷你条)都必须经 safeEffect 注册')
|
|
82
|
+
const bare = src.match(/ctx\.effect\(\s*\n\s*\(\) =>\s*\n\s*ctx\.(slots|sidebarRightTabs)/g) || []
|
|
83
|
+
assert.equal(bare.length, 0, '不得残留裸 ctx.effect 入口注册')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('W2: better-sidebar 页签是独立入口,内容仍是自有板子', () => {
|
|
87
|
+
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
88
|
+
assert.match(src, /const BS_TAB_ID = 'dsh-progress-union:board'/, 'better-sidebar 页签 id 必须在')
|
|
89
|
+
assert.doesNotMatch(src, /const BS_TAB_ID = 'progress-union'|const BS_TAB_ID = 'dsh-progress-union'\n/, '页签 id 不得与原生 kind 混用')
|
|
90
|
+
// 服务可能晚于 apply 就绪 → 必须 deferred inject,不能一次性 ctx.get
|
|
91
|
+
assert.match(src, /ctx\.inject\(\['betterSidebar'\], \(bs\) => \{/, '必须用 deferred inject 等待 betterSidebar')
|
|
92
|
+
assert.match(src, /typeof service\.registerTab !== 'function'/, '调用前必须探测 registerTab')
|
|
93
|
+
// 描述符字段齐全
|
|
94
|
+
assert.match(src, /id: BS_TAB_ID,/)
|
|
95
|
+
assert.match(src, /title: \(\) => t\('nav'\),/)
|
|
96
|
+
assert.match(src, /description: \(\) => t\('bsDesc'\),/)
|
|
97
|
+
assert.match(src, /icon: \(size\) => h\(ProgressNavIcon, \{ size: size \|\| 16 \}\)/)
|
|
98
|
+
assert.match(src, /order: 120,/)
|
|
99
|
+
assert.match(src, /single: true,/)
|
|
100
|
+
// 内容是自有板子,且拿到当前会话
|
|
101
|
+
assert.match(src, /h\(ProgressSidePanel, \{/, '页签正文必须是自有 ProgressSidePanel')
|
|
102
|
+
assert.match(src, /sessionId: tabProps && tabProps\.scope \? tabProps\.scope\.sessionId : undefined/)
|
|
103
|
+
// 不传 collapse / toggleFullscreen,避免 better-sidebar 里出现死按钮
|
|
104
|
+
const block = src.slice(src.indexOf("ctx.inject(['betterSidebar']"), src.indexOf("'progress-union: better-sidebar tab'"))
|
|
105
|
+
assert.doesNotMatch(block, /collapse:/, '不得向 better-sidebar 页签传 collapse')
|
|
106
|
+
assert.doesNotMatch(block, /toggleFullscreen:/, '不得向 better-sidebar 页签传 toggleFullscreen')
|
|
107
|
+
// 明确不复用 better-sidebar 的「任务管理」
|
|
108
|
+
assert.doesNotMatch(block, /task.?manage|subagent|后台命令/iu, '不得复用 better-sidebar 的任务管理视图')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
test('W2: better-sidebar 只是软依赖(未装者必须照常加载)', () => {
|
|
112
|
+
const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf8'))
|
|
113
|
+
const declared = pkg.dsh?.client?.inject ?? []
|
|
114
|
+
assert.equal(declared.includes('dsh-better-sidebar'), false, 'dsh.client.inject 不得声明 dsh-better-sidebar')
|
|
115
|
+
assert.equal('dsh-better-sidebar' in (pkg.dependencies ?? {}), false, 'dependencies 不得声明 dsh-better-sidebar')
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test('S2: bsDesc 在 zh/en 两个字典里都存在', () => {
|
|
119
|
+
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
120
|
+
assert.match(src, /bsDesc: '任务串联的进度板(不是 better-sidebar 的「任务管理」)'/, 'zh 文案必须在')
|
|
121
|
+
assert.match(src, /bsDesc: 'Linked-task progress board \(not better-sidebar task manager\)'/, 'en 文案必须在')
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
test('宿主 snapshot/status 两路由的客户端消费形状', async () => {
|
|
125
|
+
const harness = createHarness()
|
|
126
|
+
await harness.run()
|
|
127
|
+
await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
|
|
128
|
+
await harness.toolMap.get('progress_update').definition.execute(
|
|
129
|
+
{ changes: [{ title: '渲染截图', status: 'doing', current: '渲染第 7/24 张' }, { title: '合成音轨' }] },
|
|
130
|
+
{ agent: harness.agent },
|
|
131
|
+
)
|
|
132
|
+
harness.emit('turn/start', {})
|
|
133
|
+
harness.emit('step/start', {})
|
|
134
|
+
|
|
135
|
+
const snap = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json()
|
|
136
|
+
assert.equal(snap.ok, true)
|
|
137
|
+
assert.equal(snap.enabled, true)
|
|
138
|
+
assert.deepEqual(snap.items.map((i) => i.title), ['渲染截图', '合成音轨'])
|
|
139
|
+
assert.equal(typeof snap.summary.percent, 'number')
|
|
140
|
+
assert.equal('pendingUserChanges' in snap, true)
|
|
141
|
+
|
|
142
|
+
const status = (await callRoute(harness, '/dsh-progress/status', { method: 'GET', url: '/dsh-progress/status', headers: {} })).json()
|
|
143
|
+
assert.equal(status.ok, true)
|
|
144
|
+
assert.equal(status.config.pollMs, 1000)
|
|
145
|
+
assert.ok(status.task, 'status.task 必须存在(迷你条数据源)')
|
|
146
|
+
assert.equal(String(status.task.id), String(SESSION))
|
|
147
|
+
// 板开:阶段直接取板 items,不再走关键词猜测
|
|
148
|
+
assert.deepEqual(status.task.stages, ['渲染截图', '合成音轨'])
|
|
149
|
+
assert.equal(status.task.boardDriven, true)
|
|
150
|
+
assert.equal(status.task.current, 0)
|
|
151
|
+
assert.ok(Array.isArray(status.tasks))
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
test('W3: 板只住在右侧边栏——不再注册主区完整面板', () => {
|
|
155
|
+
// 事故:主区面板没有收拢入口,点进去就回不到会话(进去出不来)。
|
|
156
|
+
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
157
|
+
assert.match(src, /const openPanel = \(\) => ctx\.sidebarRight\.openTab\(RIGHT_TAB_KIND\)/, '头部/迷你条入口必须打开右栏页签')
|
|
158
|
+
assert.match(src, /inject: \(\) => \(\{ openPanel, togglePanel \}\)/, '头部入口注入的必须是右栏开关(可见则收起,不可见则打开)')
|
|
159
|
+
assert.doesNotMatch(src, /ctx\.slots\.inject\('main'/, '不得再注册主区完整面板')
|
|
160
|
+
assert.doesNotMatch(src, /layout\.selectPanel/, '不得再切主区面板')
|
|
161
|
+
assert.doesNotMatch(src, /function ProgressPanel\(/, '完整面板组件应已移除')
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
test('W4: 侧栏顶部不再画自带的 全面展开/收起/完整面板 按钮(交给右栏 chrome)', () => {
|
|
165
|
+
// 事故:三个按钮都在,但 toggleFullscreen / collapse 在右栏页签里根本没注入(better-sidebar 里更没处传),
|
|
166
|
+
// 点了没反应才是常态。右栏自身的 chrome 已经有全屏与关闭,不再重复造。
|
|
167
|
+
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
168
|
+
assert.doesNotMatch(src, /props\.toggleFullscreen/, '不得再渲染自带的全屏按钮')
|
|
169
|
+
assert.doesNotMatch(src, /props\.collapse/, '不得再渲染自带的收起按钮')
|
|
170
|
+
assert.doesNotMatch(src, /t\('sideFull'\)|t\('sideHalf'\)|t\('sideCollapse'\)/, '三个死按钮的文案不得残留')
|
|
171
|
+
assert.doesNotMatch(src, /toggleFullscreen/, '注入面不得再传全屏切换')
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
test('0.6.2:面板来源行只在 snapshot.restoredFrom 存在时渲染', () => {
|
|
175
|
+
const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
|
|
176
|
+
assert.match(src, /\.pb-side-restore \{/, '来源行样式缺失')
|
|
177
|
+
assert.match(src, /sideRestore: '已从归档 v\{seq\} · rev \{revision\} 恢复,共 \{n\} 项'/, 'zh 文案缺失')
|
|
178
|
+
assert.match(src, /sideRestore: 'Restored from archive/, 'en 文案缺失')
|
|
179
|
+
assert.match(src, /snapshot\?\.restoredFrom\s*\n?\s*\? h\(/, '渲染必须由 restoredFrom 门控')
|
|
180
|
+
assert.match(src, /replace\('\{seq\}', String\(snapshot\.restoredFrom\.seq\)\)/, 'seq 未注入')
|
|
181
|
+
})
|
package/test/e2e.test.mjs
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 5 端到端冒烟(task_22):建板 → 用户改 → 不 ack 读锚点 → ack 后再读 →
|
|
3
|
-
* 时钟推进 12 分钟读 staleMin;另验 KV 缺席时锚点仍出且 persistent=false。
|
|
4
|
-
*/
|
|
5
|
-
import assert from 'node:assert/strict'
|
|
6
|
-
import fs from 'node:fs'
|
|
7
|
-
import os from 'node:os'
|
|
8
|
-
import path from 'node:path'
|
|
9
|
-
import test from 'node:test'
|
|
10
|
-
|
|
11
|
-
process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
|
|
12
|
-
const { SESSION, createHarness, jsonReq, callRoute, withClock } = await import('./harness.mjs')
|
|
13
|
-
|
|
14
|
-
function execUpdate(harness, args) {
|
|
15
|
-
return harness.toolMap.get('progress_update').definition.execute(args, { agent: harness.agent })
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
test('端到端:建板→用户改→ack→陈旧推进,锚点各阶段状态正确迁移', async () => {
|
|
19
|
-
const harness = createHarness()
|
|
20
|
-
await harness.run()
|
|
21
|
-
await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
|
|
22
|
-
const anchor = () => harness.provided.get('progressAnchor').get(SESSION)
|
|
23
|
-
|
|
24
|
-
// 阶段 0:启用但空板
|
|
25
|
-
assert.equal(anchor().board.summary.total, 0)
|
|
26
|
-
assert.match(harness.contexts.get('progress-union-kickoff')(), /第一个工具调用必须是 progress_update/)
|
|
27
|
-
|
|
28
|
-
// 阶段 1:建板(3 项,1 doing)
|
|
29
|
-
const added = await execUpdate(harness, {
|
|
30
|
-
changes: [{ title: '抓帧', status: 'doing', current: '渲染第 1/900 帧' }, { title: '合成' }, { title: '字幕' }],
|
|
31
|
-
})
|
|
32
|
-
assert.equal(added.summary.total, 3)
|
|
33
|
-
assert.equal(anchor().board.inFlight.length, 1)
|
|
34
|
-
assert.equal(anchor().board.inFlight[0].title, '抓帧')
|
|
35
|
-
|
|
36
|
-
// 阶段 2:用户面板改"合成"备注 → pending=1,userEdits 出现,时间戳推进
|
|
37
|
-
const itemId = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json().items[1].id
|
|
38
|
-
await callRoute(harness, '/progress-union/action', jsonReq('POST', '/progress-union/action', { sessionId: SESSION, changes: [{ id: itemId, note: '用 4K' }] }))
|
|
39
|
-
const pending = anchor()
|
|
40
|
-
assert.equal(pending.board.pendingUserChanges, 1)
|
|
41
|
-
assert.equal(pending.userEdits[0].fields[0].field, 'note')
|
|
42
|
-
assert.ok(pending.revision > added.revision)
|
|
43
|
-
|
|
44
|
-
// 阶段 3:agent ack → pending=0,锚点 revision 不因确认增长
|
|
45
|
-
const acked = await execUpdate(harness, { changes: [], ackUserRevision: pending.revision })
|
|
46
|
-
assert.equal(acked.revision, pending.revision)
|
|
47
|
-
assert.equal(anchor().board.pendingUserChanges, 0)
|
|
48
|
-
assert.equal(anchor().userEdits.length, 0)
|
|
49
|
-
|
|
50
|
-
// 阶段 4:真实时钟推进 12 分钟无更新 → staleMin=12 且 kickoff 提醒复现
|
|
51
|
-
const clock = withClock()
|
|
52
|
-
try {
|
|
53
|
-
clock.advance(12 * 60 * 1000)
|
|
54
|
-
const later = harness.provided.get('progressAnchor').get(SESSION)
|
|
55
|
-
assert.equal(later.time.staleMin, 12)
|
|
56
|
-
assert.match(harness.contexts.get('progress-union-kickoff')(), /12 分钟没有更新/)
|
|
57
|
-
} finally {
|
|
58
|
-
clock.restore()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 阶段 5:完成推进 → percent 迁移
|
|
62
|
-
await execUpdate(harness, { changes: [{ id: added.changed[0].id, status: 'done' }] })
|
|
63
|
-
const afterDone = anchor()
|
|
64
|
-
assert.equal(afterDone.board.summary.done, 1)
|
|
65
|
-
assert.equal(afterDone.board.summary.percent, 33) // (100+0+0)/3
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test('KV 缺席:内存态可用,锚点照出且 persistent=false', async () => {
|
|
69
|
-
const harness = createHarness({ storageless: true })
|
|
70
|
-
await harness.run()
|
|
71
|
-
await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
|
|
72
|
-
await execUpdate(harness, { changes: [{ title: '仅内存', status: 'doing' }] })
|
|
73
|
-
const anchor = harness.provided.get('progressAnchor').get(SESSION)
|
|
74
|
-
assert.equal(anchor.persistent, false)
|
|
75
|
-
assert.equal(anchor.board.summary.total, 1)
|
|
76
|
-
assert.equal(anchor.board.inFlight[0].title, '仅内存')
|
|
77
|
-
})
|
|
1
|
+
/**
|
|
2
|
+
* Phase 5 端到端冒烟(task_22):建板 → 用户改 → 不 ack 读锚点 → ack 后再读 →
|
|
3
|
+
* 时钟推进 12 分钟读 staleMin;另验 KV 缺席时锚点仍出且 persistent=false。
|
|
4
|
+
*/
|
|
5
|
+
import assert from 'node:assert/strict'
|
|
6
|
+
import fs from 'node:fs'
|
|
7
|
+
import os from 'node:os'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
import test from 'node:test'
|
|
10
|
+
|
|
11
|
+
process.env.DSH_HOME = fs.mkdtempSync(path.join(os.tmpdir(), 'union-test-'))
|
|
12
|
+
const { SESSION, createHarness, jsonReq, callRoute, withClock } = await import('./harness.mjs')
|
|
13
|
+
|
|
14
|
+
function execUpdate(harness, args) {
|
|
15
|
+
return harness.toolMap.get('progress_update').definition.execute(args, { agent: harness.agent })
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
test('端到端:建板→用户改→ack→陈旧推进,锚点各阶段状态正确迁移', async () => {
|
|
19
|
+
const harness = createHarness()
|
|
20
|
+
await harness.run()
|
|
21
|
+
await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
|
|
22
|
+
const anchor = () => harness.provided.get('progressAnchor').get(SESSION)
|
|
23
|
+
|
|
24
|
+
// 阶段 0:启用但空板
|
|
25
|
+
assert.equal(anchor().board.summary.total, 0)
|
|
26
|
+
assert.match(harness.contexts.get('progress-union-kickoff')(), /第一个工具调用必须是 progress_update/)
|
|
27
|
+
|
|
28
|
+
// 阶段 1:建板(3 项,1 doing)
|
|
29
|
+
const added = await execUpdate(harness, {
|
|
30
|
+
changes: [{ title: '抓帧', status: 'doing', current: '渲染第 1/900 帧' }, { title: '合成' }, { title: '字幕' }],
|
|
31
|
+
})
|
|
32
|
+
assert.equal(added.summary.total, 3)
|
|
33
|
+
assert.equal(anchor().board.inFlight.length, 1)
|
|
34
|
+
assert.equal(anchor().board.inFlight[0].title, '抓帧')
|
|
35
|
+
|
|
36
|
+
// 阶段 2:用户面板改"合成"备注 → pending=1,userEdits 出现,时间戳推进
|
|
37
|
+
const itemId = (await callRoute(harness, '/progress-union/snapshot', { method: 'GET', url: `/progress-union/snapshot?sessionId=${SESSION}`, headers: {} })).json().items[1].id
|
|
38
|
+
await callRoute(harness, '/progress-union/action', jsonReq('POST', '/progress-union/action', { sessionId: SESSION, changes: [{ id: itemId, note: '用 4K' }] }))
|
|
39
|
+
const pending = anchor()
|
|
40
|
+
assert.equal(pending.board.pendingUserChanges, 1)
|
|
41
|
+
assert.equal(pending.userEdits[0].fields[0].field, 'note')
|
|
42
|
+
assert.ok(pending.revision > added.revision)
|
|
43
|
+
|
|
44
|
+
// 阶段 3:agent ack → pending=0,锚点 revision 不因确认增长
|
|
45
|
+
const acked = await execUpdate(harness, { changes: [], ackUserRevision: pending.revision })
|
|
46
|
+
assert.equal(acked.revision, pending.revision)
|
|
47
|
+
assert.equal(anchor().board.pendingUserChanges, 0)
|
|
48
|
+
assert.equal(anchor().userEdits.length, 0)
|
|
49
|
+
|
|
50
|
+
// 阶段 4:真实时钟推进 12 分钟无更新 → staleMin=12 且 kickoff 提醒复现
|
|
51
|
+
const clock = withClock()
|
|
52
|
+
try {
|
|
53
|
+
clock.advance(12 * 60 * 1000)
|
|
54
|
+
const later = harness.provided.get('progressAnchor').get(SESSION)
|
|
55
|
+
assert.equal(later.time.staleMin, 12)
|
|
56
|
+
assert.match(harness.contexts.get('progress-union-kickoff')(), /12 分钟没有更新/)
|
|
57
|
+
} finally {
|
|
58
|
+
clock.restore()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 阶段 5:完成推进 → percent 迁移
|
|
62
|
+
await execUpdate(harness, { changes: [{ id: added.changed[0].id, status: 'done' }] })
|
|
63
|
+
const afterDone = anchor()
|
|
64
|
+
assert.equal(afterDone.board.summary.done, 1)
|
|
65
|
+
assert.equal(afterDone.board.summary.percent, 33) // (100+0+0)/3
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('KV 缺席:内存态可用,锚点照出且 persistent=false', async () => {
|
|
69
|
+
const harness = createHarness({ storageless: true })
|
|
70
|
+
await harness.run()
|
|
71
|
+
await callRoute(harness, '/progress-union/active', jsonReq('POST', '/progress-union/active', { sessionId: SESSION, active: true, source: 'command' }))
|
|
72
|
+
await execUpdate(harness, { changes: [{ title: '仅内存', status: 'doing' }] })
|
|
73
|
+
const anchor = harness.provided.get('progressAnchor').get(SESSION)
|
|
74
|
+
assert.equal(anchor.persistent, false)
|
|
75
|
+
assert.equal(anchor.board.summary.total, 1)
|
|
76
|
+
assert.equal(anchor.board.inFlight[0].title, '仅内存')
|
|
77
|
+
})
|
package/test/goal-drive.test.mjs
CHANGED
|
@@ -176,23 +176,23 @@ test('重启自愈:armed 目标在会话重新挂载时自动补点火(无
|
|
|
176
176
|
assert.equal(restarted.agent.followups[0].source.round, 2)
|
|
177
177
|
})
|
|
178
178
|
|
|
179
|
-
test('重启自愈:上一次进程遗留的排队轮次被清掉并重排(否则它既不跑又挡新轮)', async () => {
|
|
180
|
-
const h = await booted()
|
|
181
|
-
await update(h, [{ title: 't1', status: 'doing' }])
|
|
182
|
-
await goalCmd(h, '目标S')
|
|
183
|
-
const stranded = h.claim(h.agent.followups[0]) // 崩在「已排队、未执行」之间
|
|
184
|
-
|
|
185
|
-
// 用同一份持久化记录重开宿主:attempt 空,但 inbox 里还留着上一轮
|
|
186
|
-
const restarted = await booted({}, { seed: h.records })
|
|
187
|
-
restarted.agent.inbox.nextTurn.push(stranded)
|
|
188
|
-
await new Promise((resolve) => setTimeout(resolve, 2800))
|
|
189
|
-
|
|
190
|
-
assert.equal(restarted.agent.followups.length, 1, '重启后必须重排一轮')
|
|
191
|
-
assert.equal(restarted.agent.inbox.nextTurn.includes(stranded), false, '孤儿轮次必须被撤掉')
|
|
192
|
-
assert.equal(restarted.agent.inbox.nextTurn.length, 1)
|
|
193
|
-
assert.notEqual(restarted.agent.inbox.nextTurn[0].id, stranded.id)
|
|
194
|
-
})
|
|
195
|
-
|
|
179
|
+
test('重启自愈:上一次进程遗留的排队轮次被清掉并重排(否则它既不跑又挡新轮)', async () => {
|
|
180
|
+
const h = await booted()
|
|
181
|
+
await update(h, [{ title: 't1', status: 'doing' }])
|
|
182
|
+
await goalCmd(h, '目标S')
|
|
183
|
+
const stranded = h.claim(h.agent.followups[0]) // 崩在「已排队、未执行」之间
|
|
184
|
+
|
|
185
|
+
// 用同一份持久化记录重开宿主:attempt 空,但 inbox 里还留着上一轮
|
|
186
|
+
const restarted = await booted({}, { seed: h.records })
|
|
187
|
+
restarted.agent.inbox.nextTurn.push(stranded)
|
|
188
|
+
await new Promise((resolve) => setTimeout(resolve, 2800))
|
|
189
|
+
|
|
190
|
+
assert.equal(restarted.agent.followups.length, 1, '重启后必须重排一轮')
|
|
191
|
+
assert.equal(restarted.agent.inbox.nextTurn.includes(stranded), false, '孤儿轮次必须被撤掉')
|
|
192
|
+
assert.equal(restarted.agent.inbox.nextTurn.length, 1)
|
|
193
|
+
assert.notEqual(restarted.agent.inbox.nextTurn[0].id, stranded.id)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
196
|
test('resume 接受 active:重新武装 + 点火', async () => {
|
|
197
197
|
const h = await booted()
|
|
198
198
|
await update(h, [{ title: 't1', status: 'doing' }])
|