fix(github-actions-grafana-jump): show jump links on the repo home page at a branch - #54
Open
nsheaps-oura wants to merge 2 commits into
Open
fix(github-actions-grafana-jump): show jump links on the repo home page at a branch#54nsheaps-oura wants to merge 2 commits into
nsheaps-oura wants to merge 2 commits into
Conversation
Userscript Version PreviewPreview only — versions and CHANGELOGs are bumped automatically on merge to
|
…ge at a branch Switching the branch selector on a repo's home page navigates to /org/repo/tree/<ref>, a URL shape no page parser recognized - so no page kind matched and the toolbar buttons disappeared entirely until you went back to the default branch. Verified against the live github.com DOM that this is the same page as /org/repo: the repo header actions element the repoHome links are injected into is present there with the same shape, on a hard load and after the branch-selector navigation. It is absent on a directory view below the root (/tree/<ref>/<path>), which stays unmatched as before - that really is a different page with a different header. So the ref'd root resolves to the existing repoHome kind, now carrying the ref it's viewed at, and reads .github/jump-links.config.yaml from that ref - the same branch-aware config lookup a file view and a branch-filtered Actions tab already do (#51), and one of the pages you land on while trying a config change out on a branch. The ref is not exposed as a {{branch}} field: which fields the repo home page offers shouldn't change with how you got there. A ref containing a slash makes this URL ambiguous the same way it does for /blob/ (#53): /tree/renovate/all-patch is equally the root at that ref or directory all-patch at ref renovate. The single-segment form is read purely from the URL; the ambiguous form is settled against the ref GitHub itself resolved the page to, reusing #53's ref-picker/refInfo DOM reading, and stays unmatched when the DOM doesn't answer rather than being guessed at. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeMSMf28QJFLTiQ25sVM3S
nsheaps-oura
force-pushed
the
n8bot/tree-view-repohome
branch
from
August 11, 2026 00:04
392bdcb to
22bcad9
Compare
3 tasks
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.
Stacks on #53 and is based on its branch, so it should merge after it. Reuses the ref-disambiguation DOM reading that PR added.
The bug
Switching the branch selector on a repo's home page navigates to
/org/repo/tree/<ref>. No page parser recognized that URL shape, so nothing matched and the toolbar buttons vanished until you switched back to the default branch. Reproduced live before the fix: the "Set up links" button is in the header on/nsheaps/greasemonkey-scripts, and gone after picking a branch.What it does now
/org/repo/tree/<ref>(the repo root at a ref, nothing after it) resolves to the existingrepoHomepage kind, carrying the ref it's viewed at.repoHomeinstead of a new page kind — it is the same page. Verified against the live DOM that[data-testid="repo-header-actions"](the<ul>therepoHomelinks are injected into) is present with the same shape there, both on a hard load and after the branch-selector navigation./tree/<ref>/<path>) stays unmatched, as the existing comment said it should — that element is genuinely absent there, so it really is a different page with a different header. Out of scope here.repo-header-actions/org/repo<ul>)repoHome, no ref/org/repo/tree/main<ul>)repoHomeatmain/org/repo/tree/n8bot/branch-ref-disambiguation<ul>)repoHomeat that ref (via DOM)/org/repo/tree/main/packagesBranch-aware config, too
The page reads
.github/jump-links.config.yamlfrom the ref it's showing, the same lookup a file view and a branch-filtered Actions tab already do since #51. This is one of the pages you actually land on while trying a config change out on a branch before merging it, so it would be odd for it to keep reading the default branch.The ref is deliberately not exposed as a
{{branch}}field. Which fields the repo home page offers shouldn't depend on whether you got there with a ref in the URL, or a link configured for that page would appear and disappear as you switch branches.The slashed-ref ambiguity
/tree/renovate/all-patchis equally readable as the root at refrenovate/all-patchor directoryall-patchat refrenovate— the same ambiguity #53 documents for/blob/.flowchart TD A["/org/repo/tree/<rest>"] --> B{"one segment<br/>after /tree/?"} B -->|yes| C["repoHome at that ref<br/>(pure, from the URL)"] B -->|no: ambiguous| D{"does the page's own<br/>resolved ref account for<br/>the whole remainder?"} D -->|yes| E["repoHome at that ref"] D -->|"no (leftover path)"| F["no match: directory view"] D -->|"DOM hasn't answered yet"| G["no match; re-check on<br/>the next DOM mutation"]The single-segment form is read purely from the URL. The ambiguous form is settled against the ref GitHub itself resolved the page to, read from #53's same two DOM sources (the ref-picker
aria-labeland the embeddedrefInfo.name) and only trusted when it accounts for the whole path. When neither source answers, the URL stays unmatched rather than being guessed at — andmayBeUnresolvedTreeRoot()keeps it re-checking on later DOM mutations so a header that hadn't rendered on the first pass is still picked up.Verification
Live, in the browser (github.com, this repo):
/nsheaps/greasemonkey-scripts, gone after switching ton8bot/branch-ref-disambiguationvia the branch selector.repo-header-actionspresence/absence per the table above, on hard loads and after the client-side branch switch./tree/<slashed ref>—aria-label="n8bot/branch-ref-disambiguation branch"andrefInfo.name— on a hard load and after the soft navigation.<li>+ Primer classes) into that page's header: it renders inline and styled like GitHub's own buttons.Code-correct:
yarn test— 87/87 pass, including new coverage for the tree-root parser, the ambiguous multi-segment cases,refMatchesTreeRootPath,mayBeUnresolvedTreeRoot, and the branch threading throughrepoContextForJump/repoConfigCacheKey/repoConfigUrl.yarn install --immutable,yarn build,yarn lintall clean. Additionally ran the builtdist/index.jsDOM path against the exact strings captured from those live pages.Not verified: the finished userscript running end-to-end as an installed script on a
/tree/<ref>page. The built script couldn't be injected into github.com (its CSP blocks loading it), and installing a dev build into the browser's script manager would change local browser config, so it wasn't done. The rendering half is unchanged code already working on/org/repo, and its injection point was confirmed live on the tree page.Co-Authored-By: Claude noreply@anthropic.com
https://claude.ai/code/session_01LeMSMf28QJFLTiQ25sVM3S