From 1b17af3b608b2766ff167dbb163c9c0ce5520041 Mon Sep 17 00:00:00 2001 From: jsdevninja Date: Mon, 20 Jul 2026 07:25:17 -0500 Subject: [PATCH] fix(extension): drop dead issue-page content-script match Co-authored-by: Cursor --- apps/loopover-extension/content.js | 13 +++++++------ apps/loopover-extension/manifest.json | 2 +- test/unit/extension-content.test.ts | 20 ++++++++++++-------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/apps/loopover-extension/content.js b/apps/loopover-extension/content.js index 5cef4120a7..9c7b99fc57 100644 --- a/apps/loopover-extension/content.js +++ b/apps/loopover-extension/content.js @@ -1,20 +1,21 @@ const target = matchGitHubPageTarget(location.pathname); -if (target?.kind === "pull_request") { +if (target) { mountOverlay(target); } +// #7462: pull-request pages only — issue classification was dead (manifest matched issues/* +// but nothing consumed kind:"issue", and there is no issue-context backend route). function matchGitHubPageTarget(pathname) { - const match = String(pathname ?? "").match(/^\/([^/]+)\/([^/]+)\/(pull|issues)\/(\d+)(?:\/|$)/); + const match = String(pathname ?? "").match(/^\/([^/]+)\/([^/]+)\/pull\/(\d+)(?:\/|$)/); if (!match) return null; - const [, owner, repo, surface, number] = match; - if (surface === "pull") return { kind: "pull_request", owner, repo, pullNumber: Number(number) }; - return { kind: "issue", owner, repo, issueNumber: Number(number) }; + const [, owner, repo, number] = match; + return { kind: "pull_request", owner, repo, pullNumber: Number(number) }; } function matchPullRequestTarget(pathname) { const target = matchGitHubPageTarget(pathname); - if (target?.kind !== "pull_request") return null; + if (!target) return null; return { owner: target.owner, repo: target.repo, pullNumber: target.pullNumber }; } diff --git a/apps/loopover-extension/manifest.json b/apps/loopover-extension/manifest.json index 55671b2e48..20a236432a 100644 --- a/apps/loopover-extension/manifest.json +++ b/apps/loopover-extension/manifest.json @@ -11,7 +11,7 @@ }, "content_scripts": [ { - "matches": ["https://github.com/*/*/pull/*", "https://github.com/*/*/issues/*"], + "matches": ["https://github.com/*/*/pull/*"], "js": ["content.js"], "css": ["styles.css"], "run_at": "document_idle" diff --git a/test/unit/extension-content.test.ts b/test/unit/extension-content.test.ts index b6634bf430..ab75cbf9ef 100644 --- a/test/unit/extension-content.test.ts +++ b/test/unit/extension-content.test.ts @@ -3,9 +3,17 @@ import { Script, createContext } from "node:vm"; import { describe, expect, it, vi } from "vitest"; const contentScript = readFileSync("apps/loopover-extension/content.js", "utf8"); +const manifest = JSON.parse(readFileSync("apps/loopover-extension/manifest.json", "utf8")) as { + content_scripts: Array<{ matches: string[] }>; +}; describe("extension content script", () => { - it("detects GitHub pull request and issue routes while only mounting pull overlays", () => { + it("declares content-script matches for pull pages only (#7462)", () => { + expect(manifest.content_scripts[0]?.matches).toEqual(["https://github.com/*/*/pull/*"]); + expect(manifest.content_scripts[0]?.matches.join("\n")).not.toContain("issues"); + }); + + it("detects GitHub pull request routes and treats issue pages as out of scope", () => { const internals = loadContentInternals(); expect(internals.matchGitHubPageTarget("/JSONbored/loopover/pull/146")).toEqual({ @@ -14,12 +22,8 @@ describe("extension content script", () => { repo: "loopover", pullNumber: 146, }); - expect(internals.matchGitHubPageTarget("/JSONbored/loopover/issues/145")).toEqual({ - kind: "issue", - owner: "JSONbored", - repo: "loopover", - issueNumber: 145, - }); + // Issue pages are out of scope — no kind:"issue" classification, and no match. + expect(internals.matchGitHubPageTarget("/JSONbored/loopover/issues/145")).toBeNull(); expect(internals.matchGitHubPageTarget("/JSONbored/loopover/pulls")).toBeNull(); expect(internals.matchPullRequestTarget("/JSONbored/loopover/pull/146")).toEqual({ owner: "JSONbored", @@ -91,7 +95,7 @@ function loadContentInternals() { return vmContext.__loopoverContentInternals as { matchGitHubPageTarget: ( pathname: string, - ) => { kind: "pull_request"; owner: string; repo: string; pullNumber: number } | { kind: "issue"; owner: string; repo: string; issueNumber: number } | null; + ) => { kind: "pull_request"; owner: string; repo: string; pullNumber: number } | null; matchPullRequestTarget: (pathname: string) => { owner: string; repo: string; pullNumber: number } | null; renderPullContext: (payload: unknown) => string; };