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. 如果失败,根据设置决定: - 立即停止 - 当前轮重试