feat(miner-extension): dynamic toolbar badge for local cache state - #5449
Conversation
Show the count of currently ranked opportunities on the extension's toolbar icon, painted on service-worker startup and kept live via chrome.storage.onChanged. Distinguishes a never-populated cache (a dash) from a populated-but-empty one (cleared text) so "no data yet" is never shown as a zero, with distinct badge colors for the has-data vs empty/stale states. Reuses the existing action key, so no new host permissions are requested. Fixes JSONbored#5193
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5449 +/- ##
==========================================
- Coverage 94.46% 94.42% -0.04%
==========================================
Files 554 554
Lines 44438 44438
Branches 14663 14663
==========================================
- Hits 41979 41962 -17
- Misses 1784 1801 +17
Partials 675 675
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-12 20:00:49 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|

What
Adds dynamic badge text to the miner extension's toolbar icon reflecting the local
rankedCandidatescache, per #5193.computeToolbarBadge(rankedCandidates)(toolbar-badge.js) maps the rawchrome.storage.localvalue to{ text, backgroundColor }, distinguishing three states:undefined, or any malformed value) → a dash (TOOLBAR_BADGE_NO_DATA_TEXT), never a count[]) → cleared text[…]) → the countbackground.jsreads the cache without a default (soundefinedsurvives as never-populated), paints on service-worker startup, and stays live viachrome.storage.onChanged(only for localrankedCandidateschanges). DistinctsetBadgeBackgroundColorfor has-data vs empty/stale. The refresh is wrapped in try/catch so a transientchrome.action/storage rejection can't leak an unhandled rejection in the service worker.actionkey — no new host permissions. Scoped strictly to the toolbar icon; the per-issue-page badge and options schema are untouched.Tests
test/unit/miner-toolbar-badge.test.ts— full coverage of the pure state map (populated / empty / never-populated / malformed) incl. the invariant that a never-written cache is never rendered as a numeric count, plus VM-harness wiring tests for startup paint, liveonChangedrepaint (ignoring unrelated keys/areas), the error-path swallow, and clean no-op when theactionAPI is unavailable.Fixes #5193