Skip to content

feat: improve share text to be friendly and accessible across all platforms#104

Merged
nitrocode merged 1 commit into
mainfrom
copilot/update-share-text-for-whatsapp
Apr 27, 2026
Merged

feat: improve share text to be friendly and accessible across all platforms#104
nitrocode merged 1 commit into
mainfrom
copilot/update-share-text-for-whatsapp

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

Summary

Share text read as spam — led with technical "tokens" jargon nobody outside AI understands, included hashtags that look terrible in WhatsApp/iMessage/Telegram, and opened with a 💀 skull + doomsday tone. Rewrote buildShareText() to lead with a relatable real-world equivalence (energy/CO₂/water), use plain language, drop hashtags, and vary the hook so repeated shares don't look copy-pasted.

Before:

💀 I just watched AI consume 1.23 Million tokens in the 2m 30s I spent on this site.
That's the CO₂ of driving 0.5 km.
And it never stops.
→ https://nitrocode.github.io/token-deathclock/ #AIDeathClock #TokenDeathClock

After (one of 4 rotating hooks):

🤖 I just spent 2m 30s watching a live counter of how much energy AI is burning. It's a lot.
In that time alone: the CO₂ of driving 0.5 km.
👉 https://nitrocode.github.io/token-deathclock/

Changes

  • Rewrote buildShareText() — no "tokens", no hashtags, 👉 CTA instead of
  • 4 randomised conversational hooks so repeated shares feel fresh
  • Equivalence (CO₂/energy/water) promoted to main supporting stat instead of token count
  • Updated Reddit share title to drop "millions of tokens" jargon
  • Extracted Reddit title to REDDIT_SHARE_TITLE constant (was duplicated in panel + footer)

Agent Checklist

  • npm run test:ci passes (all unit tests green, coverage not decreased)
  • npm run build && npm run test:e2e passes (all E2E tests green)
  • No generated files committed (script.js, styles.css, *-data.js)
  • All dynamic innerHTML values pass through escHtml()
  • No DOM references introduced in death-clock-core.js
  • No new runtime npm packages added
  • GitHub Actions uses: pins use a full commit SHA + inline semver comment
  • PR title follows Conventional Commits (feat:, fix:, docs:, chore:, etc.)
  • project-stats.yaml updated if this session merges one or more PRs
  • Relevant entry added to docs/LEARNINGS.md (new pattern or lesson learned)

Summary by CodeRabbit

  • New Features
    • Share messaging now features randomized, friendly alternatives emphasizing a live energy counter with contextual equivalence information, creating a more engaging and dynamic sharing experience

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

The share functionality in src/js/11-share.js has been refactored to generate dynamic, randomized share messages instead of a fixed deterministic message. A new REDDIT_SHARE_TITLE constant centralizes the Reddit share title, and both Reddit share buttons now reference this constant for consistency.

Changes

Cohort / File(s) Summary
Share Text Generation
src/js/11-share.js
Replaced static "AI consumed X tokens" message with randomly selected friendly hooks. Introduced REDDIT_SHARE_TITLE constant for Reddit share button text. Updated share message structure to include live energy counter emphasis and "In that time alone…" equivalence information, followed by site link.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main objective of the PR—improving share text to be friendlier and more accessible—which directly aligns with the core changes made to buildShareText().
Description check ✅ Passed The description covers the summary, lists all discrete changes with checkmarks, and includes the Agent Checklist, but two items remain unchecked (E2E tests and docs updates).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 copilot/update-share-text-for-whatsapp

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

@nitrocode nitrocode marked this pull request as ready for review April 27, 2026 02:29
@nitrocode nitrocode self-requested a review as a code owner April 27, 2026 02:29
github-actions Bot added a commit that referenced this pull request Apr 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (44cfda6) to head (3604187).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #104   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          242       242           
  Branches       109       109           
=========================================
  Hits           242       242           
Flag Coverage Δ
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 44cfda6...3604187. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

👁️ PR Preview

🚀 Open Preview

Deployed from commit 3604187 · Updates on every push to this PR
(Preview is removed automatically when the PR is closed.)

Screenshots

Desktop Mobile
Desktop Mobile

github-actions Bot added a commit that referenced this pull request Apr 27, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/js/11-share.js (1)

20-27: Prevent back-to-back hook repeats so shares feel truly varied.

Right now Line 26 can pick the same hook twice in a row, which undercuts the “less copy-pasted” goal.

Suggested diff
+  let lastShareHookIndex = -1;
+
   function buildShareText() {
@@
-    const hook = hooks[Math.floor(Math.random() * hooks.length)];
+    let hookIndex = Math.floor(Math.random() * hooks.length);
+    if (hooks.length > 1 && hookIndex === lastShareHookIndex) {
+      hookIndex = (hookIndex + 1 + Math.floor(Math.random() * (hooks.length - 1))) % hooks.length;
+    }
+    lastShareHookIndex = hookIndex;
+    const hook = hooks[hookIndex];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/js/11-share.js` around lines 20 - 27, The hook selection can repeat the
same string back-to-back; modify the logic that picks from the hooks array (the
code that assigns const hook = ... using hooks and Math.random()) to avoid
returning the same entry twice in a row by tracking the previous chosen index
(e.g., a module- or closure-scoped lastHookIndex) and re-rolling the random
index until it differs from lastHookIndex (handle the hooks.length === 1 case by
returning that single entry), then set lastHookIndex to the newly chosen index
and construct hook using timeStr as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/js/11-share.js`:
- Around line 20-27: The hook selection can repeat the same string back-to-back;
modify the logic that picks from the hooks array (the code that assigns const
hook = ... using hooks and Math.random()) to avoid returning the same entry
twice in a row by tracking the previous chosen index (e.g., a module- or
closure-scoped lastHookIndex) and re-rolling the random index until it differs
from lastHookIndex (handle the hooks.length === 1 case by returning that single
entry), then set lastHookIndex to the newly chosen index and construct hook
using timeStr as before.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dcb63c1c-1bc2-416c-bbc1-e10cf5cfccd5

📥 Commits

Reviewing files that changed from the base of the PR and between 44cfda6 and 3604187.

📒 Files selected for processing (1)
  • src/js/11-share.js

@nitrocode nitrocode merged commit eb6fe3b into main Apr 27, 2026
10 checks passed
@nitrocode nitrocode deleted the copilot/update-share-text-for-whatsapp branch April 27, 2026 02:37
github-actions Bot added a commit that referenced this pull request Apr 27, 2026
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