问数据页的复核修正(前端):使用者不给「继续运行」,两个标签页同时打开停在半路的一轮时后到的那个接着看

- 使用者(user 角色)续不了运行(服务端照 POST /api/runs/{id}/continue 的老规矩回 403):补救区不摆「继续运行」,服务重启打断的
  那一轮说明里也不叫它去点,改说「如需整轮重来,请点击「重新运行本轮」」(lib/terms 的 CHAT_TURN_TEXT);重试本轮、重新运行本轮照常。
  以前这个按钮对使用者也摆着,点了只弹一句 403。
- 两个标签页同时打开停在半路的一轮:都会请服务端接着收尾,服务端现在只起得来一次,后到的那个收到 409 chat_turn_busy 时不再说
  「无法确认本轮的当前状态」,改成问一下这一轮现在怎样——在跑就从这一次尝试的第一条接着播,收了尾就照那一行摆。
- scripts/check-chat.mjs 新加两段:「使用者(user 角色)」(伪造 /api/auth/me 认出使用者:中断的、跑挂的都不给继续运行,一次续跑都
  不发)、「两个标签页同时打开」(服务端只接着收尾一次,两边都收尾、答案一样、都不写库)。去掉修复回跑,这两段都会失败。
This commit is contained in:
ThearchyHelios
2026-10-18 18:07:03 +08:00
parent 85eee89799
commit d6318b639d
4 changed files with 82 additions and 4 deletions
+52 -1
View File
@@ -46,7 +46,9 @@
// 按新目录新出现几条错误级问题),看的人手上有说的是这个答案的召回待办时链到待办;没比对的答案照样写依据有变;做完的
// 对账卡上写「差在哪」、问说明有没有帮助(说明有用 / 看不懂)。
// 20. 一轮在服务端跑:实时流断了按收到的最后一个 seq 重连,补齐、不重复;刷新、关掉再打开,服务端那一轮照跑,页面从
// 这一次尝试的第一条接着播;停止发给服务端的这一轮(建图中也停得下);发起、重试、继续运行的请求体照实。
// 这一次尝试的第一条接着播;停止发给服务端的这一轮(建图中也停得下);发起、重试、继续运行的请求体照实;
// 使用者(user 角色)不给「继续运行」(服务端照 POST /api/runs/{id}/continue 的老规矩不让它续跑);两个标签页同时打开
// 停在半路的一轮,服务端只接着收尾一次,后到的那个接着看同一轮。
//
// 所有写请求都被拦在浏览器里,不碰任何库。
// 跑之前前端得起着(./scripts/dev.sh),默认连 5273。对别的实例(比如一份沙箱拷贝)跑时
@@ -2743,6 +2745,55 @@ for (const theme of THEMES) {
await ctx.close()
})
await section('userrole', '使用者(user 角色):不给「继续运行」(服务端照老规矩不让使用者续跑),重试、重新运行本轮照常', async () => {
const { page, ctx, errors } = await open(theme)
// 开了登录、认出来是使用者、管理员开了问数据
await page.route('**/api/auth/me', (route) => route.fulfill({ json: { mode: 'local', username: 'uma', display_name: 'uma',
role: 'user', groups: [], verified: true, user_can_chat: true } }))
const continuesBefore = log.continues.length
await goto(page, 'c0suspo')
await shows(page, '服务重启,本轮已中断')
const card = page.locator('[data-remedy="suspended"]')
await card.waitFor({ timeout: 6000 }).catch(() => {})
const cardText = (await card.innerText().catch(() => '')).replace(/\n/g, ' / ')
check('中断的一轮:使用者看不到「继续运行」,说明里也不叫它去点', await card.getByRole('button', { name: '继续运行' }).count() === 0
&& !cardText.includes('继续运行') && cardText.includes('重新运行本轮'), cardText)
check('……「重新运行本轮」照常给', await card.getByRole('button', { name: '重新运行本轮' }).count() === 1)
await goto(page, 'c0histf')
await shows(page, '步数用满的那一轮')
await page.waitForTimeout(600)
const failed = page.locator('[data-turn="tf2"] + * [data-remedy="failed"]')
check('跑挂了的一轮:使用者也看不到「继续运行」,「重试本轮」照常给',
await page.getByRole('button', { name: '继续运行' }).count() === 0
&& await failed.getByRole('button', { name: /重试本轮|重新问一次/ }).count() === 1,
(await failed.innerText().catch(() => '')).replace(/\n/g, ' / '))
check('一次续跑都没发', log.continues.length === continuesBefore)
check('没有运行时报错', errors.length === 0, errors[0] ?? '')
await ctx.close()
})
await section('twotabs', '两个标签页同时打开停在半路的一轮:服务端只接着收尾一次,两边都接着看同一轮', async () => {
const a = await open(theme)
const b = await open(theme)
ctl.reviewDelay['run-late'] = 1200
const startsBefore = log.turnStarts.length
const postsBefore = log.patches.length
await Promise.all([goto(a.page, 'c0lateq'), goto(b.page, 'c0lateq')])
const done = (page) => page.waitForFunction(() => window.__chat.getState().byConversation.c0lateq?.[0]?.phase === 'done',
null, { timeout: 8000 }).then(() => true, () => false)
const [okA, okB] = await Promise.all([done(a.page), done(b.page)])
check('两边都收尾了,答案一样', okA && okB && await shows(a.page, '补交付的答案:三条记录。') && await shows(b.page, '补交付的答案:三条记录。'))
const resumed = log.turnStarts.slice(startsBefore).filter((x) => x.mode === 'resume' && x.retry_of === 'tq1')
check('服务端只接着收尾了一次(后到的那个 409,改成接着看)', resumed.length === 1, `${resumed.length} 次`)
const phases = await Promise.all([a.page, b.page].map((p) => p.evaluate(() => window.__chat.getState().byConversation.c0lateq?.[0]?.phase)))
check('后到的那个不说「无法确认本轮的当前状态」', !phases.includes('unknown'), phases.join(','))
check('两边都不写库(不 PATCH)', log.patches.length === postsBefore)
delete ctl.reviewDelay['run-late']
check('没有运行时报错', a.errors.length === 0 && b.errors.length === 0, a.errors[0] ?? b.errors[0] ?? '')
await a.ctx.close()
await b.ctx.close()
})
await section('steps', '历史轮次的执行过程:点开、收起', async () => {
const { page, ctx, errors } = await open(theme)
await goto(page, 'c0idleb')