MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / requestStop

Function requestStop

background.js:4575–4641  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

4573}
4574
4575async function requestStop(options = {}) {
4576 const { logMessage = '已收到停止请求,正在取消当前操作...' } = options;
4577 const state = await getState();
4578 const timerPlan = getPendingAutoRunTimerPlan(state);
4579
4580 if (timerPlan?.kind === AUTO_RUN_TIMER_KIND_SCHEDULED_START && !autoRunActive) {
4581 await cancelScheduledAutoRun({
4582 logMessage: options.logMessage === false
4583 ? false
4584 : (options.logMessage || '已取消自动运行倒计时计划。'),
4585 });
4586 return;
4587 }
4588
4589 if (timerPlan && !autoRunActive) {
4590 autoRunCurrentRun = timerPlan.currentRun;
4591 autoRunTotalRuns = timerPlan.totalRuns;
4592 autoRunAttemptRun = timerPlan.attemptRun;
4593 if (options.logMessage !== false) {
4594 await addLog(options.logMessage || '已停止等待中的自动流程。', 'warn');
4595 }
4596 await broadcastAutoRunStatus('stopped', {
4597 currentRun: timerPlan.currentRun,
4598 totalRuns: timerPlan.totalRuns,
4599 attemptRun: timerPlan.attemptRun,
4600 }, {
4601 autoRunSkipFailures: timerPlan.autoRunSkipFailures,
4602 autoRunRoundSummaries: serializeAutoRunRoundSummaries(timerPlan.totalRuns, timerPlan.roundSummaries),
4603 autoRunTimerPlan: null,
4604 scheduledAutoRunPlan: null,
4605 });
4606 await clearAutoRunTimerAlarm();
4607 clearStopRequest();
4608 return;
4609 }
4610
4611 if (stopRequested) return;
4612
4613 stopRequested = true;
4614 cancelPendingCommands();
4615 cleanupStep8NavigationListeners();
4616 rejectPendingStep8(new Error(STOP_ERROR_MESSAGE));
4617
4618 await addLog(logMessage, 'warn');
4619 await broadcastStopToContentScripts();
4620
4621 for (const waiter of stepWaiters.values()) {
4622 waiter.reject(new Error(STOP_ERROR_MESSAGE));
4623 }
4624 stepWaiters.clear();
4625
4626 if (resumeWaiter) {
4627 resumeWaiter.reject(new Error(STOP_ERROR_MESSAGE));
4628 resumeWaiter = null;
4629 }
4630
4631 await markRunningStepsStopped();
4632 autoRunActive = false;

Callers 1

handleMessageFunction · 0.85

Calls 13

getStateFunction · 0.85
cancelScheduledAutoRunFunction · 0.85
broadcastAutoRunStatusFunction · 0.85
clearAutoRunTimerAlarmFunction · 0.85
clearStopRequestFunction · 0.85
rejectPendingStep8Function · 0.85
markRunningStepsStoppedFunction · 0.85
addLogFunction · 0.70

Tested by

no test coverage detected