Skip to content

fix(web): repo links land on prod, not the default branch (#880) - #985

Merged
aking526 merged 1 commit into
prodfrom
agent/880-prod-branch-links
Aug 5, 2026
Merged

fix(web): repo links land on prod, not the default branch (#880)#985
aking526 merged 1 commit into
prodfrom
agent/880-prod-branch-links

Conversation

@aking526

@aking526 aking526 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

The bug

GitHub resolves a bare repository URL to the default branch, which on this
repo is main (gh api repos/ccb/agent-sandbox --jq .default_branch). So two of
the three links added in #984 were sending readers to main while the site is
built and deployed from prod:

Link Before After
Hero Code button main /tree/prod
"…in the repository" main /tree/prod
godot-generative-agents/README.md /blob/prod/… (hand-typed) repoFile(…)
BibTeX url bare repo URL unchanged, deliberately

The fix

home/links.ts owns the branch now:

const BRANCH = "prod";
export const repoTree = `${REPO_URL}/tree/${BRANCH}`;
export const repoFile = (path: string) => `${REPO_URL}/blob/${BRANCH}/${path}`;

One string to change on a rename, and a new link can't silently omit the branch.
The BibTeX url keeps the bare REPO_URL on purpose — a citation cites the
repository, not a branch that may not exist in five years.

CodeRef.tsx renders no anchor, so there was nothing else on the page to sweep.

The guard

links.test.ts pins both halves of the invariant: the helpers name prod, and no
component spells the repo URL out by hand instead of importing them. It globs its
sources via import.meta.glob(..., {query: '?raw'}), so a file added later is
covered without anyone remembering to list it — and it asserts the glob actually
matched HomeView.tsx/RunLocallySection.tsx, so a glob that silently matches
nothing can't make the rule vacuous.

Both rules mutation-checked, not just observed green:

  • hard-coding https://github.com/ccb/agent-sandbox back into RunLocallySection
    ./RunLocallySection.tsx builds repo links from links.ts fails.
  • flipping BRANCH to "main" → both points … at prod tests fail.

Verification

  • pnpm lint (0 errors), pnpm test 234 passed / 17 files, pnpm build clean.
  • Grepped the built bundle rather than trusting a browser: it minifies to
    Vo="https://github.com/ccb/agent-sandbox", Rh="prod", Lh=${Vo}/tree/${Rh}, `op=e=>`${Vo}/blob/${Rh}/${e} — the branch is in every derived link, and zero
    occurrences of the retired aking526/penn-generative-agents remain.

Refs #880.

🤖 Generated with Claude Code

GitHub resolves a bare repository URL to the default branch, which is `main`
— so the hero's Code button and Run locally's "repository" link were sending
readers to `main` while the site itself is built from `prod`. Only the README
link was right, because its `/blob/prod/` was typed by hand.

`links.ts` now owns the branch: `repoTree` and `repoFile(path)` build every
link from one `BRANCH` constant, so the next link can't forget it and a
rename is a one-line change. The BibTeX `url` deliberately keeps the bare
`REPO_URL` — a citation cites the repository, not a branch that may not
exist in five years.

`links.test.ts` pins both halves: the helpers name `prod`, and no component
spells the repo URL out by hand instead of importing them. It globs its
sources, so a file added later is covered without anyone remembering to list
it, and asserts the glob is non-empty so the rule can't go vacuous. Both
rules were mutation-checked: hard-coding the URL back into
RunLocallySection fails one test, and flipping BRANCH to `main` fails the
other two.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@aking526
aking526 merged commit 2b62870 into prod Aug 5, 2026
7 checks passed
@aking526
aking526 deleted the agent/880-prod-branch-links branch August 5, 2026 03:57
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.

1 participant