Skip to content

Fix extension not working on PR and issue pages#11

Merged
xingyaoww merged 5 commits into
mainfrom
fix-github-ui-selectors
Mar 7, 2026
Merged

Fix extension not working on PR and issue pages#11
xingyaoww merged 5 commits into
mainfrom
fix-github-ui-selectors

Conversation

@xingyaoww
Copy link
Copy Markdown
Collaborator

@xingyaoww xingyaoww commented Mar 7, 2026

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-actions container 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-flag selectors no longer exist in the rendered DOM on the new layout.

Changes

Button container (findButtonContainer) — Fallback chain

Instead of relying on a single selector, the function now tries multiple approaches in order:

  1. ul.pagehead-actions — old layout (public repos)
  2. .gh-header-actions — legacy PR/issue header
  3. .openhands-injected-container — re-use our own container if already created
  4. Create a new container after the repo tab navigation (.UnderlineNav / nav[aria-label="Repository"] / .js-repo-nav)

This ensures the button appears regardless of which GitHub layout is active.

PR branch detection (getRepositoryInfo)

  • Old: span.head-ref (no longer exists)
  • New: Falls back to a[class*="BranchName"] links, correctly parsing branch names and stripping fork owner prefixes (e.g. afangster:local-steplocal-step)

PR fork detection (getPRForkInfo)

  • Old: .fork-flag element (no longer exists)
  • New: Falls back to comparing the head branch link's href owner against the repo owner from the URL

All changes retain legacy selectors as a first attempt for backward compatibility.

Version

  • Bumped from 1.11.2

Testing

Visual injection test against mock GitHub layouts:

  • ✅ Public repo PR (old layout with pagehead-actions) — button in pagehead row
  • ✅ Private repo PR (new layout, NO pagehead-actions) — button via injected container below tab nav
  • ✅ Issue page (no pagehead-actions) — button via injected container below tab nav

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>
@xingyaoww xingyaoww marked this pull request as ready for review March 7, 2026 06:35
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
@xingyaoww xingyaoww merged commit e956b75 into main Mar 7, 2026
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