From 32e39733406e2ea26958a1cf3874e799db2c9d43 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Fri, 17 Apr 2026 10:14:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=81=9C=E6=AD=A2=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=87=AA=E5=8A=A8=E9=87=8D=E5=90=AF=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 4 ++++ tests/auto-run-step6-restart.test.js | 19 +++++++++++++++++++ 项目完整链路说明.md | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index 0bdf7b0..eeb4a0b 100644 --- a/background.js +++ b/background.js @@ -5062,6 +5062,10 @@ async function runAutoSequenceFromStep(startStep, context = {}) { } step += 1; } catch (err) { + if (isStopError(err)) { + throw err; + } + const restartDecision = await getPostStep6AutoRestartDecision(step, err); if (restartDecision.shouldRestart) { postStep6RestartCount += 1; diff --git a/tests/auto-run-step6-restart.test.js b/tests/auto-run-step6-restart.test.js index b189897..28f3be6 100644 --- a/tests/auto-run-step6-restart.test.js +++ b/tests/auto-run-step6-restart.test.js @@ -96,6 +96,9 @@ async function getState() { mailProvider: '163', }; } +function isStopError(error) { + return (error?.message || String(error || '')) === '流程已被用户停止。'; +} function isStepDoneStatus(status) { return status === 'completed' || status === 'manual_completed' || status === 'skipped'; } @@ -195,3 +198,19 @@ test('auto-run stops restarting once add-phone is detected', async () => { assert.deepStrictEqual(result.events.steps, [6]); assert.ok(result.events.logs.some(({ message }) => /进入 add-phone/.test(message))); }); + +test('auto-run stop errors after step 6 are rethrown immediately instead of restarting', async () => { + const harness = createHarness({ + failureStep: 8, + failureBudget: 1, + failureMessage: '流程已被用户停止。', + authState: { state: 'password_page', url: 'https://auth.openai.com/log-in' }, + }); + + const result = await harness.runAndCaptureError(); + + assert.equal(result?.error?.message, '流程已被用户停止。'); + assert.equal(result.events.invalidations.length, 0); + assert.deepStrictEqual(result.events.steps, [6, 7, 8]); + assert.ok(!result.events.logs.some(({ message }) => /回到步骤 6 重新开始授权流程/.test(message))); +}); diff --git a/项目完整链路说明.md b/项目完整链路说明.md index 56c563c..e2ab5b4 100644 --- a/项目完整链路说明.md +++ b/项目完整链路说明.md @@ -368,7 +368,8 @@ 3. 每轮执行前重置必要运行态 4. 执行 `runAutoSequenceFromStep` - 步骤 6 内部仍保留登录态恢复的有限重试 - - 一旦进入步骤 6~9,遇到报错且认证流程未进入 `add-phone`,则自动回到步骤 6 无限重开,直到成功、手动停止或命中 `add-phone` + - 一旦进入步骤 6~9,遇到普通报错且认证流程未进入 `add-phone`,则自动回到步骤 6 无限重开 + - 如果是手动停止,则立即退出自动流程,不会再触发“回到步骤 6 重开” 5. 如果失败,根据设置决定: - 立即停止 - 当前轮重试