fix(docs): wire the savings leaderboard's Supabase anon key into the docs build#596
Open
jonsaadfalcon wants to merge 1 commit into
Open
fix(docs): wire the savings leaderboard's Supabase anon key into the docs build#596jonsaadfalcon wants to merge 1 commit into
jonsaadfalcon wants to merge 1 commit into
Conversation
…docs build The docs-site leaderboard (docs/javascripts/leaderboard.js) reads the public Supabase anon key from window.OPENJARVIS_SUPABASE_ANON_KEY, but nothing set it, so the published leaderboard always rendered "Leaderboard not configured yet". Add a generated config file (leaderboard-config.js) loaded before leaderboard.js that supplies the global, and inject its value at docs-build time from the existing VITE_SUPABASE_ANON_KEY repo secret. The committed default is empty, so local `mkdocs build` and fork PRs (no secret) degrade gracefully. The anon key is public by design (Supabase RLS protects the data). - docs/javascripts/leaderboard-config.js: empty-default global declaration. - mkdocs.yml: load leaderboard-config.js before leaderboard.js. - docs.yml: write the config from the secret (read via env, JSON-encoded into a JS string literal to avoid injection) before `mkdocs build`. - tests/deployment/test_docs_leaderboard.py: guard the wiring + load order. Verified with a local `mkdocs build`: the generated config ships in site/ and loads before leaderboard.js. Co-Authored-By: Claude Opus 4.8 (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.
Problem
The docs-site savings leaderboard (
docs/javascripts/leaderboard.js) reads the public Supabase anon key fromwindow.OPENJARVIS_SUPABASE_ANON_KEY, but nothing ever set that global. So the published leaderboard always shows "Leaderboard not configured yet." This is the docs half of the leaderboard wiring — the PyPI/desktop builds get the key via theVITE_SUPABASE_ANON_KEYbuild var (#588/#589), but the mkdocs site uses a separatewindow.*mechanism that was never connected.Fix
Inject the key at docs-build time, mirroring the build-var approach:
docs/javascripts/leaderboard-config.js(new) — declareswindow.OPENJARVIS_SUPABASE_ANON_KEY, empty by default.mkdocs.yml— loadleaderboard-config.jsbeforeleaderboard.jsso the global is set before it's read..github/workflows/docs.yml— beforemkdocs build, regenerate the config file from the existingVITE_SUPABASE_ANON_KEYsecret. The secret is read viaenv:(not inlined) and JSON-encoded into a JS string literal, so there's no injection surface.tests/deployment/test_docs_leaderboard.py(new) — guards the load order and that the workflow injects the key.The committed default is empty, so local
mkdocs buildand fork PRs (which have no secret) keep rendering the graceful "not configured" message. The anon key is public by design — Supabase Row-Level Security protects the data — so shipping it in the public docs bundle is expected.Verification
mkdocs buildwith a simulated injected key:site/javascripts/leaderboard-config.jsships with the value, and the built HTML loadsleaderboard-config.jsbeforeleaderboard.js.GET /rest/v1/savings_entriesreturned live rows), so once this deploys, the docs leaderboard will populate.tests/deployment/— 25 passed (4 new); ruff clean.🤖 Generated with Claude Code