fix(web): repo links land on prod, not the default branch (#880) - #985
Merged
Conversation
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>
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.
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 ofthe three links added in #984 were sending readers to
mainwhile the site isbuilt and deployed from
prod:main/tree/prodmain/tree/prodgodot-generative-agents/README.md/blob/prod/…(hand-typed)repoFile(…)urlThe fix
home/links.tsowns the branch now:One string to change on a rename, and a new link can't silently omit the branch.
The BibTeX
urlkeeps the bareREPO_URLon purpose — a citation cites therepository, not a branch that may not exist in five years.
CodeRef.tsxrenders no anchor, so there was nothing else on the page to sweep.The guard
links.test.tspins both halves of the invariant: the helpers nameprod, and nocomponent 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 iscovered without anyone remembering to list it — and it asserts the glob actually
matched
HomeView.tsx/RunLocallySection.tsx, so a glob that silently matchesnothing can't make the rule vacuous.
Both rules mutation-checked, not just observed green:
https://github.com/ccb/agent-sandboxback into RunLocallySection→
./RunLocallySection.tsx builds repo links from links.tsfails.BRANCHto"main"→ bothpoints … at prodtests fail.Verification
pnpm lint(0 errors),pnpm test234 passed / 17 files,pnpm buildclean.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 zerooccurrences of the retired
aking526/penn-generative-agentsremain.Refs #880.
🤖 Generated with Claude Code