Skip to content

Commit 15c21c1

Browse files
committed
fix(init): tighten stale-step detection and show reconnecting feedback
Two review recommendations from /review: 1. Tighten isStepAlreadyAdvancedError to match "was not suspended" instead of "not suspended" — both Mastra error variants use the more specific phrase, which reduces the false-positive surface area. 2. Show "Reconnecting..." spinner message before the runById recovery call so the user sees feedback during a potentially slow state fetch instead of watching a stale spinner message. Passes spin through ResumeRetryArgs to give resumeWithRetry access to the running spinner handle.
1 parent 90e8017 commit 15c21c1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/lib/init/wizard-runner.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ type ResumeRetryArgs = {
433433
stepId: string;
434434
resumeData: Record<string, unknown>;
435435
tracingOptions: Record<string, unknown>;
436+
spin: SpinnerHandle;
436437
ui: WizardUI;
437438
};
438439

@@ -444,7 +445,7 @@ type ResumeRetryArgs = {
444445
* "HTTP error! status: 500 - {"error":"This workflow step 'X' was not suspended..."}"
445446
*/
446447
function isStepAlreadyAdvancedError(err: unknown): boolean {
447-
return err instanceof Error && err.message.includes("not suspended");
448+
return err instanceof Error && err.message.includes("was not suspended");
448449
}
449450

450451
/**
@@ -474,7 +475,7 @@ async function tryRecoverCurrentRunState(
474475
async function resumeWithRetry(
475476
args: ResumeRetryArgs
476477
): Promise<WorkflowRunResult> {
477-
const { run, workflow, stepId, resumeData, tracingOptions, ui } = args;
478+
const { run, workflow, stepId, resumeData, tracingOptions, spin, ui } = args;
478479
let lastError: unknown;
479480
for (let attempt = 0; attempt <= MAX_RESUME_RETRIES; attempt++) {
480481
try {
@@ -505,6 +506,7 @@ async function resumeWithRetry(
505506
// so the main loop can continue from whichever step is actually suspended.
506507
if (isStepAlreadyAdvancedError(err)) {
507508
ui.clearOverlay?.();
509+
spin.message("Reconnecting...");
508510
const recovered = await tryRecoverCurrentRunState(workflow, run.runId);
509511
if (recovered) {
510512
return recovered;
@@ -739,6 +741,7 @@ export async function runWizard(initialOptions: WizardOptions): Promise<void> {
739741
stepId: extracted.stepId,
740742
resumeData,
741743
tracingOptions,
744+
spin,
742745
ui,
743746
});
744747
}

0 commit comments

Comments
 (0)