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

Function executeStepAndWait

background.js:4690–4730  ·  view source on GitHub ↗

* Execute a step and wait for it to complete before returning. * @param {number} step * @param {number} delayAfter - ms to wait after completion (for page transitions)

(step, delayAfter = 2000)

Source from the content-addressed store, hash-verified

4688 * @param {number} delayAfter - ms to wait after completion (for page transitions)
4689 */
4690async function executeStepAndWait(step, delayAfter = 2000) {
4691 throwIfStopped();
4692
4693 const delaySeconds = normalizeAutoStepDelaySeconds((await getState()).autoStepDelaySeconds, null);
4694 if (delaySeconds > 0) {
4695 await addLog(
4696 `自动运行:步骤 ${step} 执行前额外等待 ${delaySeconds} 秒,避免节奏过快。`,
4697 'info'
4698 );
4699 await sleepWithStop(delaySeconds * 1000);
4700 }
4701
4702 if (AUTO_RUN_BACKGROUND_COMPLETED_STEPS.has(step)) {
4703 await addLog(`自动运行:步骤 ${step} 由后台流程负责收尾,执行函数返回后将直接进入下一步。`, 'info');
4704 await executeStep(step);
4705 const latestState = await getState();
4706 await addLog(`自动运行:步骤 ${step} 已执行返回,当前状态为 ${latestState.stepStatuses?.[step] || 'pending'},准备继续后续步骤。`, 'info');
4707 } else if (doesStepUseCompletionSignal(step)) {
4708 await addLog(`自动运行:步骤 ${step} 已发起,正在等待完成信号(超时 ${AUTO_RUN_SIGNAL_COMPLETION_TIMEOUT_MS / 1000} 秒)。`, 'info');
4709 await executeStepViaCompletionSignal(step, AUTO_RUN_SIGNAL_COMPLETION_TIMEOUT_MS);
4710 await addLog(`自动运行:步骤 ${step} 已收到完成信号,准备继续后续步骤。`, 'info');
4711 } else {
4712 await executeStep(step);
4713 }
4714
4715 if (step === 5) {
4716 const signupTabId = await getTabId('signup-page');
4717 if (signupTabId) {
4718 await addLog('自动运行:步骤 5 已收到完成信号,正在等待当前页面完成加载...', 'info');
4719 await waitForTabComplete(signupTabId, {
4720 timeoutMs: 15000,
4721 retryDelayMs: 300,
4722 });
4723 }
4724 }
4725
4726 // Extra delay for page transitions / DOM updates
4727 if (delayAfter > 0) {
4728 await sleepWithStop(delayAfter + Math.floor(Math.random() * 1200));
4729 }
4730}
4731
4732function getEmailGeneratorLabel(generator) {
4733 if (generator === 'custom') {

Callers 1

runAutoSequenceFromStepFunction · 0.85

Calls 10

getStateFunction · 0.85
sleepWithStopFunction · 0.85
throwIfStoppedFunction · 0.70
addLogFunction · 0.70
executeStepFunction · 0.70
getTabIdFunction · 0.70
waitForTabCompleteFunction · 0.70

Tested by

no test coverage detected