Skip to content

Recognize GitHub thread links with query strings or fragments - #1039

Open
PeterDaveHello wants to merge 1 commit into
masterfrom
fix/github-thread-path-matching
Open

Recognize GitHub thread links with query strings or fragments#1039
PeterDaveHello wants to merge 1 commit into
masterfrom
fix/github-thread-path-matching

Conversation

@PeterDaveHello

@PeterDaveHello PeterDaveHello commented Aug 6, 2026

Copy link
Copy Markdown
Member

Problem

GitHub notification links and comment anchors add query or fragment data without changing the underlying issue or pull request. The adapter matched the complete location.href with an end-anchored expression, so those otherwise supported thread links were not recognized.

After switching recognition to pathname, fragment-only changes also needed to be excluded from the polling remount path; otherwise clicking a comment permalink could discard an existing or in-progress summary.

Changes

  • Match issue and pull request thread paths through location.pathname.
  • Allow an optional trailing slash.
  • Refresh the site adapter only when the pathname actually changes, not for query- or fragment-only updates.
  • Continue excluding issue lists, new-issue pages, and pull request subpages such as /files, /commits, and /checks.
  • Add focused path and navigation regression tests.

Validation

  • node --test tests/unit/content-script/github-path-matching.test.mjs — 4 tests passed.
  • The combined focused suite for all five independent fixes — 39 tests passed.
  • node --check passed for the changed JavaScript modules.
  • CodeRabbit and Greptile completed their amended-head reviews successfully with no new comments.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

GitHub route detection now uses shared pathname helpers. Navigation handling compares pathnames and skips unchanged paths. Tests cover valid thread paths, URL suffixes, navigation changes, and rejected routes.

Changes

GitHub path matching

Layer / File(s) Summary
Path-matching helpers and validation
src/content-script/site-adapters/github/path-matching.mjs, tests/unit/content-script/github-path-matching.test.mjs
Added helpers for pathname changes and numeric issue or pull-request paths with optional trailing slashes. Tests cover query strings, fragments, navigation changes, and rejected routes.
Adapter navigation integration
src/content-script/site-adapters/github/index.mjs
Replaced inline URL checks with shared matchers. Navigation polling now compares and stores pathnames before handling issue, pull-request, and patch routes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: GitHub thread links with query strings or fragments are now recognized.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/github-thread-path-matching

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Recognize GitHub issue/PR thread links with query, fragments, and trailing slash

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Fix GitHub thread detection by matching against location.pathname, not full URL.
• Accept optional trailing slashes on issue and pull thread routes.
• Add unit tests covering query/fragment URLs and excluded non-thread paths.
Diagram

graph TD
A["GitHub adapter (index.mjs)"] --> B["Path matching (path-matching.mjs)"] --> C["Regex: /issues|/pull + id + optional '/' "]
D["Unit tests (github-path-matching.test.mjs)"] --> B
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Parse location.href with URL and then test url.pathname
  • ➕ Works even if callers only have an href string
  • ➕ Centralizes URL normalization in the matcher
  • ➖ Extra parsing overhead and potential exceptions for non-absolute inputs
  • ➖ Less direct than using location.pathname where available
2. Use a single router-style regex with named groups (or URLPattern)
  • ➕ Can make route intent clearer and easier to extend (e.g., enterprise GitHub hostnames)
  • ➕ Potentially simpler to add future exclusions via groups
  • ➖ URLPattern is not universally available without polyfills
  • ➖ Overkill for two simple end-anchored path checks

Recommendation: The chosen approach (matching against location.pathname and factoring it into a small helper module) is the best fit: it directly fixes query/fragment false negatives, keeps the matching logic reusable/testable, and avoids introducing heavier URL parsing or router dependencies. Consider URL parsing inside the matcher only if future call sites pass full href strings rather than pathnames.

Files changed (3) +45 / -6

Bug fix (1) +3 / -6
index.mjsSwitch issue/PR detection to pathname-based matching helpers +3/-6

Switch issue/PR detection to pathname-based matching helpers

• Replaces end-anchored location.href regex checks with calls to isGitHubIssuePath/isGitHubPullPath using location.pathname. This ensures query strings, fragments, and trailing slashes no longer prevent thread recognition.

src/content-script/site-adapters/github/index.mjs

Refactor (1) +10 / -0
path-matching.mjsAdd dedicated GitHub thread pathname matcher module +10/-0

Add dedicated GitHub thread pathname matcher module

• Introduces reusable helpers for identifying issue and pull-request thread paths. Patterns allow an optional trailing slash while still requiring the numeric thread id at the end of the pathname.

src/content-script/site-adapters/github/path-matching.mjs

Tests (1) +32 / -0
github-path-matching.test.mjsAdd regression tests for GitHub thread pathname recognition +32/-0

Add regression tests for GitHub thread pathname recognition

• Adds unit tests verifying optional trailing slashes, ignoring query/fragment data by testing pathname, and excluding lists/new-issue pages and PR subpages like /files, /commits, and /checks.

tests/unit/content-script/github-path-matching.test.mjs

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

This PR changes GitHub issue and pull-request recognition to use location.pathname, allowing query strings, fragments, and optional trailing slashes without matching thread subpages.

  • Extracts GitHub path matching into a dedicated module.
  • Refreshes the adapter only when the pathname changes.
  • Adds focused tests for supported and excluded path forms.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains within the eligible follow-up review scope.

Important Files Changed

Filename Overview
src/content-script/site-adapters/github/index.mjs Integrates pathname-based thread recognition and pathname-only navigation refresh behavior.
src/content-script/site-adapters/github/path-matching.mjs Defines reusable issue, pull-request, and pathname-change matching helpers.
tests/unit/content-script/github-path-matching.test.mjs Covers trailing slashes, query strings, fragments, path changes, and excluded GitHub subpages.

Reviews (2): Last reviewed commit: "Recognize GitHub thread links with query..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/content-script/site-adapters/github/index.mjs (1)

20-22: 📐 Maintainability & Code Quality | 🔵 Trivial

Run and document the required validation.

This change affects content-script runtime behavior. Before merge, run npm run lint, npm test, and npm run build. Verify the expected build artifacts. Perform manual smoke tests in Chromium and Firefox. If a check is skipped, document the reason and the skipped check in the pull request description.

As per coding guidelines, JavaScript runtime changes require these checks and documentation for skipped checks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/content-script/site-adapters/github/index.mjs` around lines 20 - 22, For
the runtime changes around isPull and isIssue, run npm run lint, npm test, and
npm run build; verify the expected build artifacts and manually smoke-test the
behavior in Chromium and Firefox. Document the validation results in the pull
request, including the specific check and reason for any skipped validation.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/content-script/site-adapters/github/index.mjs`:
- Around line 20-22: For the runtime changes around isPull and isIssue, run npm
run lint, npm test, and npm run build; verify the expected build artifacts and
manually smoke-test the behavior in Chromium and Firefox. Document the
validation results in the pull request, including the specific check and reason
for any skipped validation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d8c0bac3-3cac-4a5e-a74f-fe74c00874b7

📥 Commits

Reviewing files that changed from the base of the PR and between 6b2b2f5 and 8e331be.

📒 Files selected for processing (3)
  • src/content-script/site-adapters/github/index.mjs
  • src/content-script/site-adapters/github/path-matching.mjs
  • tests/unit/content-script/github-path-matching.test.mjs

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e331bef18

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/content-script/site-adapters/github/index.mjs
@PeterDaveHello
PeterDaveHello requested a lite review from Copilot August 6, 2026 18:58
Notification links and comment anchors add query or fragment data without
changing the underlying issue or pull request path. Full-URL matching skips
those supported pages, while treating every fragment change as navigation can
unnecessarily discard an existing summary.

Match and monitor pathname only, allow an optional trailing slash, and keep
pull request subpages such as /files excluded.
@PeterDaveHello
PeterDaveHello force-pushed the fix/github-thread-path-matching branch from 8e331be to 3675ddf Compare August 6, 2026 19:05
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Introduces centralized GitHub pathname matching utilities and updates the GitHub content script to refresh only on meaningful navigation changes (pathname changes), with unit tests covering expected path behavior.

Changes:

  • Added isGitHubIssuePath, isGitHubPullPath, and hasGitHubPathChanged helpers for GitHub URL/path detection.
  • Updated the GitHub site adapter to use location.pathname (ignoring query/hash) when deciding whether to re-mount.
  • Added unit tests for trailing slashes, ignoring query/fragment, and excluding non-thread paths.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/unit/content-script/github-path-matching.test.mjs Adds unit tests for GitHub path matching and navigation-change logic.
src/content-script/site-adapters/github/path-matching.mjs New helper module encapsulating GitHub path regex matching and change detection.
src/content-script/site-adapters/github/index.mjs Switches thread detection and refresh logic to use the new helpers and pathname-based comparison.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +6
export function isGitHubIssuePath(pathname) {
return issuePathPattern.test(pathname)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants