Repository navigation
feat(web): link the mainnet and testnet sites to each other - #685
Conversation
Each web build targets one network, and the mainnet and testnet builds are separate sites, so nothing pointed from one to the other. NEXT_PUBLIC_MAINNET_SITE_URL / NEXT_PUBLIC_TESTNET_SITE_URL (https origins, from the PAGES_MAINNET_SITE_URL / PAGES_TESTNET_SITE_URL repository variables) add an "Open Forge on <Network>" link on /networks for a live network, a dismissible "Forge is live on mainnet" banner on test-network builds once the bundled mainnet record is live, and a footer "Testnet" link on the mainnet build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The banner hides itself on the mainnet site's own origin, the testnet link needs the testnet record live like the mainnet one, and the hosting doc says to set the variables only once each origin serves its network's build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: changes requested
The web change is sound. I'd approve it as is once the branch only carries it and CI has run on it. Right now the PR can't merge (GitHub reports CONFLICTING) and no CI job has run on it: the only check is CodeRabbit, and it was rate limited.
Blocking
1. Medium: the branch carries two commits from #676, which causes the conflict and stops CI. .github/workflows/contracts.yml:248, forge-contracts/scripts/launch-network.{mjs,test.mjs}, docs/deploying-to-a-network.md
15c6a7b2andd735746fare #676's first two commits. #676's later fixcf515d46(the dry run fails on a warning and checks the signed sums) is not on this branch.git merge-tree origin/master pr685conflicts incontracts.yml. Because of that conflict, vitest, tsc, copy-lint and the CSP-hash check have not run on this PR in CI.- Whoever resolves that conflict could also land the pre-fix
launch-network.mjsunder a web PR's title. - Fix: rebase onto
masterand drop those two commits, so #676 lands them on its own. Then let CI go green.pages.ymlalready auto-merges cleanly with #677's guard changes, and the unset loop keeps both new variables.
Non-blocking
2. Nit (copy / style guide §C rule 3, a11y): forge-web/components/mainnet-live-banner.tsx:64
- The copy is "You’re on Forge testnet: DASH here is test money. Forge is live on mainnet → forge.dashhq.org".
- The colon doesn't introduce a value or a list, which rule 3 requires.
- The header already says "test DASH, no cash value", so "test money" adds a second term for the same fact.
- Screen readers read "→" aloud as "right arrow".
- Suggested copy:
You’re on Forge testnet, where DASH has no cash value. Forge is live on mainnet at <a>forge.dashhq.org</a>.Update the test string and the PR/CHANGELOG wording to match. copy-lint passes either version, because none of these is a banned term.
3. Nit (style guide rule 5, one banner): forge-web/components/app-shell.tsx:63
- On a devnet build,
MainnetLiveBannercan stack underDevnetNoticeBannerorPagesNoticeBanner. - Consider rendering it only when neither of those strips shows. It's rare enough to leave as is.
4. Nit: forge-web/app/networks/page.tsx:25
- The banner hides itself on the mainnet origin, but
SiteLinkand the footer link have no such check. - So a test build still served at forge.dashhq.org, with
PAGES_MAINNET_SITE_URLset, links to itself from /networks. docs/hosting.mdalready says to set the variables only after the hosts move, so that's enough. Just keep that order today.
5. Nit (tests): forge-web/components/mainnet-live-banner.test.tsx
- No test covers the path where storage refuses the dismissal (
setItemthrows →memoryDismissed). - One test with a
localStorage.setItemspy that throws would cover it.
Checked, no issues
- URL validation (
lib/network-sites.tssiteOrigin):- Only
https:is accepted. - A path, query, hash or userinfo is rejected.
javascript:,http:and a bare host are rejected.- A trailing slash and surrounding whitespace are normalised.
- The default port drops out through
URL.origin. - The tests cover each case.
- Only
- Visibility rules:
otherNetworkSitereturns null unlessforgeV2Ids(DEPLOYMENTS[key])is non-null.forgeV2Idsneeds core, collab, community and the group allregistered, and a recorded forge-meta must also be registered.- Today's
mainnet.jsonhas onlydapiAddresses, so nothing shows until a v2 record is committed and the testnet site is rebuilt. - A mainnet build never renders the banner.
- The banner hides on
window.location.origin === site.url. - The Networks page's
standing === 'live'uses the sameforgeV2Ids, so the page and the banner agree. network-sites.test.tscovers partial records, a missing file and a missing URL, plus devnet → mainnet.
- Hydration:
- The banner uses the same
useSyncExternalStorepattern asDevnetNoticeBanner. The server snapshot is "hidden", so the static HTML is empty and the banner appears only after mount. There is no mismatch, and nobody who dismissed it sees a flash. - The
renderToString(...) === ''test pins this. - Storage reads and writes are in try/catch, with a fallback for the current page only.
- The banner uses the same
- CSP: no inline
<script>orstyle=is added. Only Tailwind classes are used, andcoarse:exists intailwind.config.js. Plain same-tab<a href>links to an https origin need no CSP change, andcsp-hashes.mjsis unaffected. - Accessibility:
role="status"matches the devnet banner, so it doesn't interrupt on every navigation.- The icons have
aria-hidden. - The dismiss button has an
aria-label. - The link gets a 44px tap target on coarse pointers.
pages.yml:- Both variables are passed in, and both are in the empty → unset loop, so Next never inlines
"". - The workflow header and
docs/guides/verify-the-app.mdlist the new rebuild inputs.
- Both variables are passed in, and both are in the empty → unset loop, so Next never inlines
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: approve
The earlier blocker is resolved. The branch now carries only the web change, and it merges cleanly with master.
What I checked
-
The diff holds only this PR.
git diff origin/master...origin/launch/web-network-switchtouches 11 files:pages.yml,CHANGELOG.md,docs/hosting.md,docs/guides/verify-the-app.md,app/networks/page.tsx,app-footer.tsx,app-shell.tsx,lib/network-sites{,.test}.tsandmainnet-live-banner{,.test}.tsx. It has nolaunch-network.mjs,contracts.ymlordeploying-to-a-network.mdedits.origin/master..has 5 commits: 178c36a, 97ffc09, 0589fdf, the merge and the new test. #676's 15c6a7b and d735746 are gone. -
The merge is clean.
git show --remerge-diff cc21cc53is empty, so the merge has no hand edits.git merge-treeagainst the current master is also clean, and GitHub reportsMERGEABLE.pages.ymlkeeps all of #677's changes: the header note onconfirm_network, theconfirm_networkdispatch input, and theNetwork guardstep (pages-network-guard.mjswithPAGES_CONFIRM: ${{ inputs.confirm_network }}). It also keeps this PR'sNEXT_PUBLIC_MAINNET_SITE_URLandNEXT_PUBLIC_TESTNET_SITE_URL, and both are still in the empty → unset loop. -
The new test is sound. It spies on
Storage.prototype.setItemwith a mock that throws, clicks dismiss, and asserts both that the banner is gone and thatgetItemreturns null. The test can't pass by accident: if the spy didn't intercept the write,getItemwould return'1', and if thememoryDismissedfallback were missing, the listeners would re-render the banner.mockRestoresits infinally. The test is placed last, with a comment explaining why:memoryDismissedis module state and would hide the banner in later tests. The vitest config sets no shuffle or concurrency, so file order holds.npx vitest run components/mainnet-live-banner.test.tsxpasses 6 of 6 tests. This also closes the earlier nit 5. -
Nothing regressed from the earlier "checked, no issues" list:
siteOriginstill accepts only https and rejects a path, query, hash, userinfo or a bare host.- Visibility still depends on
forgeV2Ids. - The banner still uses the
useSyncExternalStorepattern with a "hidden" server snapshot, which therenderToString === ''test pins. - The banner still hides on the mainnet origin.
role="status",aria-hiddenicons, the dismissaria-labeland thecoarse:min-h-11link are all still there.- There is still no inline script or style.
Nit 2 was also addressed (0589fdf). The copy now reads "You’re on Forge testnet, where DASH has no cash value. Forge is live on mainnet at ", with no colon and no arrow, and the test matches it.
Nits deliberately left (acceptable)
- 3. Banner stacking. The banner can stack only on a devnet build whose deploy sets
PAGES_MAINNET_SITE_URLwhile mainnet is live and a devnet or operator notice shows. That is rare and harmless. Fine to leave. - 4. Self-link before the hosts move.
docs/hosting.mdnow says to set the variables only after each origin serves its own network. It also notes that the banner hides itself on that origin. That's an adequate guard for an operator-controlled variable. Fine to leave.
Note
CI was still queued when I checked (web, changes (contracts) and the others). It needs to go green before merge, but I don't expect it to fail.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
Problem
Forge launches on mainnet with two sites: the mainnet build at forge.dashhq.org and the testnet build at testnet-forge.dashhq.org. Each web build targets one network at build time, and neither site links to the other. Someone who lands on testnet has nothing telling them that mainnet is live, or where to find it.
Change
NEXT_PUBLIC_MAINNET_SITE_URL/NEXT_PUBLIC_TESTNET_SITE_URL, set from the Pages variablesPAGES_MAINNET_SITE_URL/PAGES_TESTNET_SITE_URL, are optional. Only an https origin is accepted; any other value is ignored (forge-web/lib/network-sites.ts:siteUrlFor,otherNetworkSite).mainnet.jsonrecord is live and the mainnet URL is set. The dismissal is kept in localStorage, with try/catch. The banner also hides itself when served from the mainnet origin, so a testnet build still at forge.dashhq.org won't link to itself.pages.ymlpasses both variables and unsets them when empty. Both are documented in the workflow header and indocs/hosting.md, and listed in the verify-the-app rebuild env. Added a CHANGELOG entry.Network selection and storage are unchanged.
mainnet.jsonhas no v2 record today, so nothing new shows on the current testnet build until mainnet registration lands.Rollout
Set
PAGES_MAINNET_SITE_URL=https://forge.dashhq.organdPAGES_TESTNET_SITE_URL=https://testnet-forge.dashhq.orgonly once each origin serves its own network's build.Verified
Done in a boat.dev sandbox:
pnpm install --frozen-lockfileand the affected vitest files: 61 tests pass.NEXT_PUBLIC_NETWORK=testnet pnpm buildsucceeds.Local checks:
tsc --noEmit,next lint(no new warnings) and copy-lint are clean.🤖 Generated with Claude Code