diff --git a/src/signals/local-branch.ts b/src/signals/local-branch.ts index 5b6a40875a..096b3d64a2 100644 --- a/src/signals/local-branch.ts +++ b/src/signals/local-branch.ts @@ -378,7 +378,7 @@ export function buildLocalBranchAnalysis(args: { queueHealth: buildQueueHealth(args.repo, args.issues, args.pullRequests, buildCollisionReport(args.input.repoFullName, args.issues, args.pullRequests)), roleContext, contributorOpenPrCount: (args.contributorPullRequests ?? args.pullRequests).filter( - (pr) => pr.state === "open" && (pr.authorLogin ?? "").toLowerCase() === args.input.login.toLowerCase(), + (pr) => pr.repoFullName === args.input.repoFullName && pr.state === "open" && (pr.authorLogin ?? "").toLowerCase() === args.input.login.toLowerCase(), ).length, }); const scenarioSummary = renderPublicScenarioSummary({ diff --git a/test/unit/local-branch.test.ts b/test/unit/local-branch.test.ts index 9d0e4a7a94..3aa5d633e3 100644 --- a/test/unit/local-branch.test.ts +++ b/test/unit/local-branch.test.ts @@ -1604,6 +1604,32 @@ describe("local MCP git metadata collection", () => { expect(analysis.scenarioSummary.dataClassification.facts).toEqual(expect.arrayContaining(["Contributor", "Repository", "Branch"])); }); + it("ignores contributor open PRs from other repos when ranking pressure options", () => { + const analysis = buildLocalBranchAnalysis({ + input: { + login: "oktofeesh1", + repoFullName: repo.fullName, + changedFiles: [{ path: "src/util.ts", additions: 30, deletions: 2, status: "modified" }], + localScorer: { mode: "external_command", sourceTokenScore: 40, totalTokenScore: 60, sourceLines: 38 }, + }, + repo, + issues: [{ repoFullName: repo.fullName, number: 9, title: "Improve util", state: "open", labels: [], linkedPrs: [] }], + pullRequests: [], + contributorPullRequests: [ + { repoFullName: "someone-else/other-repo", number: 4, title: "Cross-repo WIP", state: "open", authorLogin: "oktofeesh1", labels: [], linkedIssues: [] }, + ], + profile, + outcomeHistory, + scoringSnapshot, + scoringProfile, + }); + + const options = analysis.scenarioSummary.options; + expect(options[0]).toMatchObject({ label: "Open another PR now", recommended: true }); + expect(options[0]?.rationale).toContain("Repo queue pressure is low."); + expect(options[0]?.obstacles).toEqual([]); + }); + it("wires open-PR pressure strategy options into scenarioSummary.options (#348)", () => { const analysis = buildLocalBranchAnalysis({ input: {