From 7f24bdb26efc4181d7ef38d31bb5460d7963d6da Mon Sep 17 00:00:00 2001 From: Bjorn Pagen <11238136+bjornpagen@users.noreply.github.com> Date: Sun, 27 Oct 2024 20:32:22 -0400 Subject: [PATCH] fix: improve GitHub Actions detection messaging Clarify to users that GitHub Actions is needed for test log analysis by adding PR number and repo details to the error message when Actions is not enabled. This helps users understand why Actions access is required for the test-fixing functionality to work properly. --- app/(dashboard)/dashboard/pull-request.tsx | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/(dashboard)/dashboard/pull-request.tsx b/app/(dashboard)/dashboard/pull-request.tsx index 45b8b4dc..dab94634 100644 --- a/app/(dashboard)/dashboard/pull-request.tsx +++ b/app/(dashboard)/dashboard/pull-request.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState, useCallback } from "react"; +import { useState, useCallback, useEffect } from "react"; import { experimental_useObject as useObject } from "ai/react"; import Link from "next/link"; import dynamic from "next/dynamic"; @@ -76,8 +76,8 @@ export function PullRequestItem({ }, } ); - - const { data: latestRunId } = useSWR( + + const { data: latestRunId, error: latestRunIdError } = useSWR( pullRequest.buildStatus === "success" || pullRequest.buildStatus === "failure" ? [ @@ -87,13 +87,22 @@ export function PullRequestItem({ pullRequest.branchName, ] : null, - () => - getLatestRunId( - pullRequest.repository.owner.login, - pullRequest.repository.name, - pullRequest.branchName - ) + () => getLatestRunId( + pullRequest.repository.owner.login, + pullRequest.repository.name, + pullRequest.branchName + ) ); + + useEffect(() => { + if (latestRunId === null && !latestRunIdError) { + toast({ + title: `GitHub Actions needed for PR #${initialPullRequest.number}`, + description: `Repository "${initialPullRequest.repository.full_name}" needs GitHub Actions to analyze test failures. Without access to test logs via Actions, we can't help fix failing tests.`, + variant: "destructive", + }); + } + }, [latestRunId]); const { data: logs, error: logsError } = useSWR( showLogs || latestRunId