Skip to content

Commit 8823dec

Browse files
committed
refactor: update formatToolResult to accept runType parameter and enhance critical message for non-percy-web runs
1 parent 8b5a86c commit 8823dec

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/tools/sdk-utils/common/schema.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ export const SetUpPercyParamsShape = {
2828
export const RunTestsOnBrowserStackParamsShape = {
2929
projectName: z
3030
.string()
31-
.describe(
32-
"A single name for your project to organize all your tests. This is required for Percy.",
33-
),
31+
.describe("A single name for your project to organize all your tests."),
3432
detectedLanguage: z.nativeEnum(SDKSupportedLanguageEnum),
3533
detectedBrowserAutomationFramework: z.nativeEnum(
3634
SDKSupportedBrowserAutomationFrameworkEnum,

src/tools/sdk-utils/common/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export function checkPercyIntegrationSupport(input: {
4747

4848
export async function formatToolResult(
4949
resultPromise: Promise<RunTestsInstructionResult> | RunTestsInstructionResult,
50+
runType?: "percy-web" | "bstack" | "percy-bstack" | "percy-automate",
5051
): Promise<CallToolResult> {
5152
const { steps, requiresPercy, missingDependencies, shouldSkipFormatting } =
5253
await resultPromise;
@@ -75,6 +76,13 @@ export async function formatToolResult(
7576
{ type: "text" as const, text: verificationMessage },
7677
];
7778

79+
if (runType != "percy-web") {
80+
finalContent.push({
81+
type: "text",
82+
text: "CRITICAL: After the build is run, you MUST explicitly ask the user if they want to perform RCA (Root Cause Analysis) for any failed tests. This step is mandatory and should not be skipped.",
83+
});
84+
}
85+
7886
return {
7987
content: finalContent,
8088
isError: steps.some((s) => s.isError),

src/tools/sdk-utils/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export async function setUpPercyHandler(
6969
);
7070

7171
const result = runPercyWeb(percyInput, percyToken);
72-
return await formatToolResult(result);
72+
return await formatToolResult(result, "percy-web");
7373
} else if (input.integrationType === PercyIntegrationTypeEnum.AUTOMATE) {
7474
// First try Percy with BrowserStack SDK
7575
const percyWithBrowserstackSDKResult = runPercyWithBrowserstackSDK(

0 commit comments

Comments
 (0)