fix(web): hide unenriched PR diff stats (#1912)

Co-authored-by: i-trytoohard <193449657+i-trytoohard@users.noreply.github.com>
This commit is contained in:
i-trytoohard 2026-05-18 03:48:28 +05:30 committed by GitHub
parent eac581768d
commit 87c6a3d9f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 47 additions and 4 deletions

View File

@ -178,6 +178,7 @@ export function SessionDetailPRCard({
const allGreen = isPRMergeReady(pr);
const blockerIssues = buildBlockerChips(pr, metadata, lifecyclePrReason);
const fileCount = pr.changedFiles ?? 0;
const showDiffStats = !isPRUnenriched(pr);
const showConflictActions = hasMergeConflicts(pr) && pr.state === "open";
const compareUrl = showConflictActions ? buildGitHubCompareUrl(pr) : "";
@ -213,10 +214,12 @@ export function SessionDetailPRCard({
>
PR #{pr.number}: {pr.title}
</a>
<span className="session-detail-pr-card__diff-stats">
<span className="session-detail-diff--add">+{pr.additions}</span>{" "}
<span className="session-detail-diff--del">-{pr.deletions}</span>
</span>
{showDiffStats ? (
<span className="session-detail-pr-card__diff-stats">
<span className="session-detail-diff--add">+{pr.additions}</span>{" "}
<span className="session-detail-diff--del">-{pr.deletions}</span>
</span>
) : null}
{fileCount > 0 ? (
<span className="session-detail-pr-card__diff-label">
{fileCount} file{fileCount !== 1 ? "s" : ""}

View File

@ -0,0 +1,40 @@
import { render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { SessionDetailPRCard } from "../SessionDetailPRCard";
import { makePR } from "../../__tests__/helpers";
describe("SessionDetailPRCard diff stats", () => {
it("shows diff stats for enriched PRs", () => {
render(
<SessionDetailPRCard
pr={makePR({
enriched: true,
additions: 629,
deletions: 44,
})}
metadata={{}}
onAskAgentToFix={vi.fn()}
/>,
);
expect(screen.getByText("+629")).toBeInTheDocument();
expect(screen.getByText("-44")).toBeInTheDocument();
});
it("hides diff stats for unenriched PRs", () => {
render(
<SessionDetailPRCard
pr={makePR({
enriched: false,
additions: 629,
deletions: 44,
})}
metadata={{}}
onAskAgentToFix={vi.fn()}
/>,
);
expect(screen.queryByText("+629")).not.toBeInTheDocument();
expect(screen.queryByText("-44")).not.toBeInTheDocument();
});
});