diff --git a/packages/core/src/__tests__/utils.test.ts b/packages/core/src/__tests__/utils.test.ts index 10dee00e7..5cf410aaf 100644 --- a/packages/core/src/__tests__/utils.test.ts +++ b/packages/core/src/__tests__/utils.test.ts @@ -203,6 +203,15 @@ describe("parsePrFromUrl", () => { }); }); + it("parses GitHub pull request URLs with trailing path segments", () => { + expect(parsePrFromUrl("https://github.com/foo/bar/pull/123/files")).toEqual({ + owner: "foo", + repo: "bar", + number: 123, + url: "https://github.com/foo/bar/pull/123/files", + }); + }); + it("returns null when the URL has no PR number", () => { expect(parsePrFromUrl("https://example.com/foo/bar/pull/not-a-number")).toBeNull(); }); diff --git a/packages/core/src/utils/pr.ts b/packages/core/src/utils/pr.ts index 71ce6f2e1..1e6d590b8 100644 --- a/packages/core/src/utils/pr.ts +++ b/packages/core/src/utils/pr.ts @@ -9,7 +9,7 @@ export function parsePrFromUrl(prUrl: string): ParsedPrUrl | null { const pathSegments = parsedUrl?.pathname.split("/").filter(Boolean) ?? []; const githubStylePullIndex = pathSegments.findIndex((segment) => segment === "pull"); - if (githubStylePullIndex >= 2 && githubStylePullIndex === pathSegments.length - 2) { + if (githubStylePullIndex >= 2 && githubStylePullIndex + 1 < pathSegments.length) { const owner = pathSegments[githubStylePullIndex - 2]; const repo = pathSegments[githubStylePullIndex - 1]; const prNumber = pathSegments[githubStylePullIndex + 1]; diff --git a/packages/web/src/components/SessionDetailPRCard.tsx b/packages/web/src/components/SessionDetailPRCard.tsx index 15b0f0343..49046d49d 100644 --- a/packages/web/src/components/SessionDetailPRCard.tsx +++ b/packages/web/src/components/SessionDetailPRCard.tsx @@ -226,7 +226,8 @@ export function SessionDetailPRCard({ {pr.ciChecks.length > 0 ? ( <>
- {pr.ciChecks.map((check) => { + {pr.ciChecks.map((check, index) => { + const key = check.url ?? `${check.name}-${index}`; const chip = ( ) : ( - {chip} + {chip} ); })} > diff --git a/packages/web/src/components/__tests__/SessionDetail.desktop.test.tsx b/packages/web/src/components/__tests__/SessionDetail.desktop.test.tsx index 911ced5c6..f5a0209cc 100644 --- a/packages/web/src/components/__tests__/SessionDetail.desktop.test.tsx +++ b/packages/web/src/components/__tests__/SessionDetail.desktop.test.tsx @@ -1,6 +1,7 @@ import { act, fireEvent, render, screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { SessionDetail } from "../SessionDetail"; +import { buildAgentFixMessage } from "../session-detail-agent-actions"; import { makePR, makeSession } from "../../__tests__/helpers"; vi.mock("next/navigation", () => ({ @@ -243,6 +244,41 @@ describe("SessionDetail desktop layout", () => { expect(screen.getByRole("button", { name: "Ask Agent to Fix" })).toBeInTheDocument(); }); + it("builds branch links from the PR host for GitHub Enterprise repos", () => { + render( +