Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/lib/init/wizard-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ async function preamble(
confirmed = await confirmExperimental(options, ui);
} catch (err) {
if (err instanceof WizardCancelledError) {
captureException(err);
setTag("wizard.outcome", "bailed");
showCancelledFeedback(ui);
process.exitCode = 0;
Expand Down Expand Up @@ -958,7 +957,6 @@ export async function runWizard(initialOptions: WizardOptions): Promise<void> {
// active step as `in_progress` rather than flipping it to
// failed; the post-dispose report shows the cancel message
// instead.
captureException(err);
setTag("wizard.outcome", "bailed");
showCancelledFeedback(ui);
process.exitCode = 0;
Expand Down
34 changes: 24 additions & 10 deletions test/lib/init/wizard-runner.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { MastraClient } from "@mastra/client-js";
// biome-ignore lint/performance/noNamespaceImport: spyOn requires object reference
import * as Sentry from "@sentry/node-core/light";
import {
afterEach,
beforeEach,
Expand Down Expand Up @@ -435,13 +437,19 @@ describe("runWizard", () => {
const { ui, calls, respond } = createMockUI({ welcome: true });
respond.welcome(CANCELLED);
useMockUI(ui, calls);
const captureSpy = vi.spyOn(Sentry, "captureException");

await forceStdinTty(() => runWizard(makeOptions({ yes: false })));
try {
await forceStdinTty(() => runWizard(makeOptions({ yes: false })));

expect(process.exitCode).toBe(0);
expect(lastCancelMessage()).toBe("Setup cancelled.");
expect(lastFeedbackOutcome()).toBe("cancelled");
expect(getWorkflowSpy).not.toHaveBeenCalled();
expect(process.exitCode).toBe(0);
expect(lastCancelMessage()).toBe("Setup cancelled.");
expect(lastFeedbackOutcome()).toBe("cancelled");
expect(getWorkflowSpy).not.toHaveBeenCalled();
expect(captureSpy).not.toHaveBeenCalled();
} finally {
captureSpy.mockRestore();
}
});

test("falls back to generic continue prompt without rich welcome", async () => {
Expand Down Expand Up @@ -659,6 +667,7 @@ describe("runWizard", () => {
});

test("tears down forwarding and stops the spinner on cancellation", async () => {
const captureSpy = vi.spyOn(Sentry, "captureException");
const payload: ToolPayload = {
type: "tool",
operation: "run-commands",
Expand All @@ -674,12 +683,17 @@ describe("runWizard", () => {
};
executeToolSpy.mockRejectedValue(new WizardCancelledError());

await runWizard(makeOptions());
try {
await runWizard(makeOptions());

expect(process.exitCode).toBe(0);
expect(spinnerMock.stop).toHaveBeenCalledWith("Cancelled", 0);
expect(lastCancelMessage()).toBe("Setup cancelled.");
expect(lastFeedbackOutcome()).toBe("cancelled");
expect(process.exitCode).toBe(0);
expect(spinnerMock.stop).toHaveBeenCalledWith("Cancelled", 0);
expect(lastCancelMessage()).toBe("Setup cancelled.");
expect(lastFeedbackOutcome()).toBe("cancelled");
expect(captureSpy).not.toHaveBeenCalled();
} finally {
captureSpy.mockRestore();
}
});

test("tears down forwarding when a WizardError is rethrown from a tool", async () => {
Expand Down
Loading