fix: counters/life-blocks broken due to missing Chart.js date adapter; dynamic rate; 22 milestones; E2E tests#16
Merged
Conversation
Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/e7e66a7b-8a0e-44c0-91ca-473ea4a3dcd3 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
…ix parse fn Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/e7e66a7b-8a0e-44c0-91ca-473ea4a3dcd3 Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
nitrocode
April 22, 2026 07:44
View session
nitrocode
reviewed
Apr 22, 2026
Contributor
👁️ PR Preview
|
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.
initChart()threw an uncaught exception ("This method is not implemented: Check that a complete date adapter is provided") because Chart.js 4.x requires an explicit date adapter fortype: 'time'axes. This crashedinit()beforeinitLifeBlocks()andrequestAnimationFrame(updateCounters)could run — leaving the total counter on "Loading…", session tokens at 0, and life blocks blank.Root fix — self-hosted Chart.js date adapter
New
chart-date-adapter.jsimplements the full_adapters._dateinterface (no external deps, loaded fromself).initChart()is also wrapped intry/catchso future chart failures can't cascade.Dynamic rate display
TOKENS_PER_SECONDwas hardcoded in HTML and never updated. AddedRATE_SCHEDULE(14 entries keyed to landmark AI events: ChatGPT launch, GPT-4, Claude 3 Opus, GPT-4o, Llama 3.1, DeepSeek R1, Claude Code GA, etc.) andgetRateAtDate(date)todeath-clock-core.js. The rate box is now updated every RAF cycle showing the current rate and the triggering event.Milestones
Expanded from 7 → 22 milestones spanning 1 Trillion to 10 Quintillion tokens. New entries include near-term upcoming thresholds (Power Grid Strain, Arctic Ice-Free Summer, Wildfire Crisis, Permafrost Methane Bomb, Ocean Acidification Threshold, Jet Stream Collapse, etc.) and far-future collapse events.
DOM safety
With the last milestone at 10 Quintillion tokens (~1.2 M days away),
lbRenderDays()would have created 1.2 million DOM elements. Capped at 3,650 blocks (~10 years) with a+Xyoverflow indicator.CSP
Added the Firefox-reported
sha256-ZswfTY7H35rbv8WC7NXBoiC7WNu86vSzCDChNWwZZDM=hash to thescript-srcdirective.Tests
getRateAtDate,RATE_SCHEDULEinvariants (monotonic dates/rates, required events present), and extended milestone checks (uniqueness, field presence, magnitude span).tests/e2e/): counter liveness, milestone card count/triggered state, life-block drill-down, chart canvas dimensions, theme toggle, XSS guard, zero uncaught JS errors.