Skip to content

πŸ› fix(web): self-host the Star History chart after upstream outage - #672

Merged
scttbnsn merged 2 commits into
dev/v1.6from
fix/v1.6-star-history-selfhost
Aug 7, 2026
Merged

scttbnsn merged 2 commits into
dev/v1.6from
fix/v1.6-star-history-selfhost

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Star History chart on the homepage and in the README stopped rendering because api.star-history.com is down globally (GitHub restricted their starred-data access; upstream issue star-history/star-history#548 β€” every repo 404s/500s, and starchart.cc 400s too). This self-hosts the chart so no third party sits between us and the image again.

  • New route GET /api/star-history?theme=light|dark (apps/web/src/app/api/star-history/route.ts): pages the GitHub stargazers API (application/vnd.github.star+json) for starred_at timestamps and renders an SVG. Cached 6h at the edge (s-maxage=21600, stale-while-revalidate=604800); on fetch failure it serves a short-lived (5 min) fallback SVG instead of a broken image. Optional GITHUB_TOKEN env raises the rate limit but is not required (unauthenticated 60/hr is plenty at one origin fetch per 6h per theme).
  • Pure render lib (apps/web/src/lib/star-history-svg.mjs): cumulative-series builder, nice y-scale (3–5 integer ticks, tightest ceiling β€” 215 stars scales to 250, not 400), XML escaping, light/dark palettes using the site's ink/muted tokens with the sky-600 accent, transparent background so the homepage card and GitHub README canvas supply their own surface.
  • Component (star-history-chart.tsx): swaps the third-party URLs for /api/star-history?theme=…; link now points at the stargazers page instead of star-history.com.
  • CSP: https://api.star-history.com removed from img-src (route is same-origin).
  • README: <picture> element with dark/light sources pointing at https://getdrydock.com/api/star-history.

Testing

  • 11 new node:test tests in apps/web/scripts/star-history-svg.test.mjs (series building, theme resolution, escaping, empty-series, nice-scale, fallback) + a guard in marketing-performance.test.mjs asserting no third-party chart host remains. 55 web scripts tests pass.
  • tsc clean; biome clean.
  • Rendered the route's SVG against the real 215-star dataset and visually verified both themes.

Deployment note

README (GitHub) and getdrydock.com both serve from main, so this goes live at the next dev→main sync (GA cut, 2026-08-12) unless we sync earlier. Until then the embed URLs 404 by design — the current state is already broken, so nothing regresses.

Fixes #671

✨ Added

  • Added GET /api/star-history?theme=light|dark.
  • Added server-side GitHub stargazer fetching with optional GITHUB_TOKEN.
  • Added six-hour caching with stale-while-revalidate.
  • Added themed chart and fallback SVG rendering.
  • Added a shared pagination timeout.
  • Added tests for SVG rendering, pagination, timeout bounds, and third-party-host removal.

πŸ”§ Changed

  • Updated homepage and README embeds to use getdrydock.com.
  • Updated the chart link to GitHub’s stargazers page.
  • Added runtime = "nodejs" to the API route.
  • Treats failed or capped pagination as a fallback condition.

πŸ—‘οΈ Removed

  • Removed api.star-history.com from the image CSP.

  • Removed third-party chart hosts from the request path.

  • Verify the configured repository slug in every deployment environment.

  • Verify GitHub rate-limit and incomplete-pagination behavior.

  • Verify cache behavior in the production runtime.

  • Confirm GITHUB_TOKEN remains server-only.

api.star-history.com went down globally (their GitHub tokens rate-limited,
star-history/star-history#548), breaking the homepage card and README
embed; starchart.cc is failing too. Remove the third-party dependency:

- ✨ /api/star-history route renders the cumulative-stars SVG from our own
  origin: stargazer timestamps fetched server-side (optional GITHUB_TOKEN,
  graceful anonymous fallback), edge-cached 6h with stale-while-revalidate,
  short-lived fallback SVG when the fetch fails outright
- 🎨 chart drawn in the site ocean accent (sky-600, validated against both
  card surfaces) with neutral ink tokens and a tight nice-ceiling y-scale
- πŸ”„ homepage chart component points at the self-hosted endpoint; link
  target now the GitHub stargazers page
- πŸ“ README swaps the embed for a theme-aware <picture> pair on
  getdrydock.com and links to the stargazers page
- πŸ”’ api.star-history.com dropped from the CSP img-src

Fixes #671
@vercel

vercel Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
drydock-website Ready Ready Preview Aug 7, 2026 7:27pm
drydockdemo-website Ready Ready Preview Aug 7, 2026 7:27pm

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

The change replaces third-party Star History images with a self-hosted flow. A Node.js API route fetches GitHub stargazer timestamps, applies caching and failure handling, and returns theme-aware SVG output. New utilities build cumulative series and render chart or fallback SVGs. The homepage and README use local light and dark endpoints. The CSP removes the external image source. Tests cover route behavior and SVG rendering.

Possibly related PRs

  • CodesWhat/drydock#524 β€” Updates overlapping marketing-performance assertions for removal of the external Star History URL.
  • CodesWhat/drydock#567 β€” Modifies the application CSP configuration in the same file.
πŸš₯ Pre-merge checks | βœ… 2
βœ… Passed checks (2 passed)
Check name Status Explanation
Linked Issues check βœ… Passed The PR replaces third-party charts with a self-hosted route, GitHub timestamp fetching, themed SVGs, caching, fallbacks, bounded pagination, origin links, and CSP cleanup.
Out of Scope Changes check βœ… Passed All changes support the linked issue, including the API route, SVG renderer, homepage and README updates, CSP cleanup, and focused tests.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v1.6-star-history-selfhost

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/src/components/star-history-chart.tsx (1)

21-24: 🎯 Functional Correctness | 🟑 Minor | ⚑ Quick win

Make the accessible name match the link destination.

CHART_HREF opens the GitHub stargazers page. The current label says it opens the chart. Rename the link to describe the actual destination.

Proposed fix
-      aria-label="Open the Star History chart"
+      aria-label="Open the GitHub stargazers page"
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/components/star-history-chart.tsx` around lines 21 - 24, Update
the aria-label on the link using CHART_HREF to describe the GitHub stargazers
destination rather than the Star History chart, while leaving the link behavior
unchanged.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/app/api/star-history/route.ts`:
- Around line 16-18: Update the star-history route’s pagination flow around
MAX_PAGES and the later-page failure handling to require complete stargazer
retrieval before calling renderStarHistorySvg or storing SUCCESS_CACHE. If
pagination is capped or any page fetch fails, return the existing fallback
response; do not render or cache partial data as the repository’s total history.
- Around line 37-40: Update fetchStarredTimestamps() to create one
AbortSignal.timeout(...) before the pagination loop, then pass that shared
signal in the options for every GitHub fetch call. Keep the deadline shared
across all pages rather than creating a new timeout per request.

---

Outside diff comments:
In `@apps/web/src/components/star-history-chart.tsx`:
- Around line 21-24: Update the aria-label on the link using CHART_HREF to
describe the GitHub stargazers destination rather than the Star History chart,
while leaving the link behavior unchanged.
πŸͺ„ Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ed2ee8a-984b-4251-aea3-00b126545f31

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 3118850 and 48be12f.

β›” Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
πŸ“’ Files selected for processing (7)
  • README.md
  • apps/web/scripts/marketing-performance.test.mjs
  • apps/web/scripts/star-history-svg.test.mjs
  • apps/web/src/app/api/star-history/route.ts
  • apps/web/src/components/star-history-chart.tsx
  • apps/web/src/lib/content-security-policy.mjs
  • apps/web/src/lib/star-history-svg.mjs

…nd fetches

- πŸ› fix: any failed/capped page now returns the fallback SVG instead of rendering and caching a truncated star total
- πŸ› fix: one shared AbortSignal.timeout deadline across the pagination run so a stalled GitHub request can't hang the response
- πŸ§ͺ test: source guards for the no-partial-render and shared-deadline invariants

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/scripts/marketing-performance.test.mjs`:
- Around line 62-65: Strengthen the source assertion for the pagination
implementation to verify that the shared
`AbortSignal.timeout(FETCH_DEADLINE_MS)` is created before the `fetch(...)` call
or pagination loop, not merely present in the source. Update the assertions
around `starHistoryRouteSource` to enforce one signal reused across pages while
preserving the existing headers/signal/next coverage.
πŸͺ„ Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a4bf8e14-42fb-451a-8e83-c91e837e6d38

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 48be12f and 7b457e7.

πŸ“’ Files selected for processing (2)
  • apps/web/scripts/marketing-performance.test.mjs
  • apps/web/src/app/api/star-history/route.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/app/api/star-history/route.ts

Comment on lines +62 to +65
// One shared deadline across the whole pagination run.
assert.match(starHistoryRouteSource, /AbortSignal\.timeout\(FETCH_DEADLINE_MS\)/u);
assert.match(starHistoryRouteSource, /\{ headers, signal, next:/u);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟑 Minor | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate file =="
git ls-files | rg 'apps/web/scripts/marketing-performance.test.mjs|marketing-performance' || true

echo "== relevant test lines =="
if [ -f apps/web/scripts/marketing-performance.test.mjs ]; then
  nl -ba apps/web/scripts/marketing-performance.test.mjs | sed -n '1,120p'
fi

echo "== search timeout usage in target/router source =="
rg -n "starHistoryRouteSource|AbortSignal\.timeout|FETCH_DEADLINE_MS|for \\(let page|fetch\\(" apps/web -S || true

Repository: CodesWhat/drydock

Length of output: 287


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== relevant test lines =="
awk '{printf "%7d\t%s\n", NR, $0}' apps/web/scripts/marketing-performance.test.mjs | sed -n '1,140p'

echo "== timeout/fetch/route usages =="
rg -n -S "starHistoryRouteSource|AbortSignal\.timeout|FETCH_DEADLINE_MS|for \\(let page|for \\(.*page|fetch\\(" apps/web -g '!node_modules' || true

Repository: CodesWhat/drydock

Length of output: 5323


Enforce signal-share coverage in the assertion.

The current check only proves AbortSignal.timeout(FETCH_DEADLINE_MS) exists, not that it is created before fetch(...) in the pagination loop. A timeout created inside the loop would still pass but give each page its own deadline.

Minimal source-level fix
-  assert.match(starHistoryRouteSource, /AbortSignal\.timeout\(FETCH_DEADLINE_MS\)/u);
+  assert.match(
+    starHistoryRouteSource,
+    /const signal = AbortSignal\.timeout\(FETCH_DEADLINE_MS\);[\s\S]*?for \(\$1=let page = 1;/u,
+  );
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/scripts/marketing-performance.test.mjs` around lines 62 - 65,
Strengthen the source assertion for the pagination implementation to verify that
the shared `AbortSignal.timeout(FETCH_DEADLINE_MS)` is created before the
`fetch(...)` call or pagination loop, not merely present in the source. Update
the assertions around `starHistoryRouteSource` to enforce one signal reused
across pages while preserving the existing headers/signal/next coverage.

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM β€” self-hosting kills the third-party dependency, and the fallback-on-incomplete-pagination behavior is the right call.

@scttbnsn
scttbnsn merged commit 322c7fd into dev/v1.6 Aug 7, 2026
25 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.6-star-history-selfhost branch August 7, 2026 19:44
scttbnsn added a commit that referenced this pull request Aug 9, 2026
17-file identity roll-forward from rc.12 to rc.13, dated 2026-08-08.

- CHANGELOG: new `[1.6.0-rc.13]` section from Unreleased content β€” #670
digest re-anchoring, #672 self-hosted Star History, #673 nanoid pin,
#682 node 24.19.0 + trivy 0.73.0 base-image bumps, #683 icon-bundle
alias resolution β€” plus compare-link rotation
- README: version badge + rc.13 highlights block
- Demo mocks, site config/content, docs API pages, quickstart, updates
highlights, identity-test constants, changelog-link pairs

Guarded by `scripts/release-identity.test.mjs` (4/4) and the web scripts
suite (56/56). Once merged: dev→main wholesale-tree sync, then dispatch
`release-cut.yml` for `v1.6.0-rc.13`. GA candidate clock restarts β€”
earliest GA β‰ˆ Aug 16.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Changelog

πŸ”§ **Changed**
- Advanced the release identity from `1.6.0-rc.12` to `1.6.0-rc.13`,
dated August 8, 2026.
- Updated README, demo mocks, site configuration, roadmap content, API
examples, quickstart, and update highlights.
- Updated changelog comparison links and release identity test
constants.
- Added release notes for digest re-anchoring, self-hosted Star History,
`nanoid` pins, Node 24.19.0 and Trivy 0.73.0 base images, and
icon-bundle alias resolution.

πŸ”’ **Security**
- Documented workspace-wide `nanoid` security pinning.
- Documented base-image CVE remediation.

## Concerns

- Sync the `dev` tree to `main` after merge.
- Dispatch `release-cut.yml` for `v1.6.0-rc.13`.
- Confirm the expected GA date remains approximately August 16.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
scttbnsn added a commit that referenced this pull request Aug 9, 2026
Wholesale-tree sync ahead of the v1.6.0-rc.13 cut (same pattern as
#667). The single commit carries the exact tree of `dev/v1.6` at
b98808e onto `main` β€” after merge, `git diff --quiet origin/main
origin/dev/v1.6` holds.

Content on dev since rc.12:
- #669/#670 β€” release-cut digest re-anchoring
- #672 β€” self-hosted Star History chart
- #673 β€” NAS acceptance follow-ups
- #681 β€” v1.7 dependency ordering (forward-ported)
- #682 β€” CVE base-image bumps + digest-pinned Node base guard test
- #683 β€” icon-bundle alias resolution (fixes blank Audit/registry icons
shipped in rc.12)
- #684 β€” rc.13 identity roll-forward (17 files, CHANGELOG, README)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Changelog

- ✨ Added repository-aware Docker digest selection and multi-anchor
comparison.
- ✨ Added self-hosted, theme-aware Star History SVG API with pagination,
caching, deadlines, and fallback rendering.
- ✨ Added icon alias resolution and bundle coverage tests.
- ✨ Added required icon bundle entries and updated icon mappings.
- πŸ”§ Updated Node and Trivy image digests.
- πŸ”’ Pinned `nanoid` to `3.3.18` across workspaces.
- πŸ”’ Added a digest-pinned Node 24 Alpine base-image guard test.
- πŸ”§ Updated `js-yaml` override to `3.15.1`.
- πŸ”§ Updated release documentation, examples, mocks, badges, and tests to
`1.6.0-rc.13`.
- πŸ”§ Removed the external Star History CSP allowlist and embed.

## Concerns

- Verify the Star History route stays within GitHub API rate limits
under concurrent requests.
- Verify cache headers do not serve incomplete or repository-specific
fallback responses incorrectly.
- Verify Docker digest re-anchoring preserves legacy behavior for stored
containers without `repoDigests`.
- Verify icon aliases with rotation or flipping have acceptable fallback
behavior.
- Run the Docker, Star History, icon-bundle, release-identity, and
workspace dependency tests.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

This branch was successfully deployed

2 active deployments
Preview – drydock-website β€” 7b457e7a Deployed Aug 7, 2026 by vercel[bot]
Preview – drydockdemo-website β€” 7b457e7a Deployed Aug 7, 2026 by vercel[bot]
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.

2 participants