feat: improve share text to be friendly and accessible across all platforms#104
Conversation
…tforms Agent-Logs-Url: https://github.com/nitrocode/token-deathclock/sessions/073f30f0-6505-43c3-9cc2-025e845baa4f Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
📝 WalkthroughWalkthroughThe share functionality in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #104 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 242 242
Branches 109 109
=========================================
Hits 242 242
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (1)
src/js/11-share.js


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:
After (one of 4 rotating hooks):
Changes
buildShareText()— no "tokens", no hashtags,👉CTA instead of→REDDIT_SHARE_TITLEconstant (was duplicated in panel + footer)Agent Checklist
npm run test:cipasses (all unit tests green, coverage not decreased)npm run build && npm run test:e2epasses (all E2E tests green)script.js,styles.css,*-data.js)innerHTMLvalues pass throughescHtml()death-clock-core.jsuses:pins use a full commit SHA + inline semver commentfeat:,fix:,docs:,chore:, etc.)project-stats.yamlupdated if this session merges one or more PRsdocs/LEARNINGS.md(new pattern or lesson learned)Summary by CodeRabbit