Fix extension not working on PR and issue pages#11
Merged
Conversation
The extension failed to inject the button on PR and issue pages because it relied on '.gh-header-actions' which no longer exists in GitHub's UI. Changes: - findButtonContainer: use 'ul.pagehead-actions' for all page types (verified present on repo, PR, and issue pages) - getRepositoryInfo: add fallback branch detection using the new 'a[class*=BranchName]' selector when 'span.head-ref' is absent - getPRForkInfo: add fallback fork detection by comparing the head branch link's owner against the repo owner in the URL All selectors verified against live GitHub pages (repo, fork PR, non-fork PR, issue). Co-authored-by: openhands <openhands@all-hands.dev>
GitHub's new UI (especially on private repos and the new PR layout) no longer renders ul.pagehead-actions. The extension now uses a fallback chain: 1. ul.pagehead-actions (old layout - public repos) 2. .gh-header-actions (legacy PR/issue header) 3. Re-use previously injected container 4. Create a new container after the repo tab navigation (.UnderlineNav / nav[aria-label=Repository] / .js-repo-nav) Also bumps version to 1.2. Tested against mock layouts for: - Public repo PR (old layout with pagehead-actions) ✓ - Private repo PR (new layout without pagehead-actions) ✓ - Issue page (no pagehead-actions) ✓ Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The extension fails to inject the "Launch with OpenHands" button on pages using GitHub's new UI layout (notably private repos and the new PR layout), because the
ul.pagehead-actionscontainer no longer exists.Root Cause
GitHub's new React-based UI replaces the server-rendered HTML after hydration. The old
ul.pagehead-actions(Watch/Fork/Star row),.gh-header-actions,span.head-ref, and.fork-flagselectors no longer exist in the rendered DOM on the new layout.Changes
Button container (
findButtonContainer) — Fallback chainInstead of relying on a single selector, the function now tries multiple approaches in order:
ul.pagehead-actions— old layout (public repos).gh-header-actions— legacy PR/issue header.openhands-injected-container— re-use our own container if already created.UnderlineNav/nav[aria-label="Repository"]/.js-repo-nav)This ensures the button appears regardless of which GitHub layout is active.
PR branch detection (
getRepositoryInfo)span.head-ref(no longer exists)a[class*="BranchName"]links, correctly parsing branch names and stripping fork owner prefixes (e.g.afangster:local-step→local-step)PR fork detection (
getPRForkInfo).fork-flagelement (no longer exists)hrefowner against the repo owner from the URLAll changes retain legacy selectors as a first attempt for backward compatibility.
Version
1.1→1.2Testing
Visual injection test against mock GitHub layouts: