fix(widget): restore the unread flag for EVERY launcher, not just the pill - #57
Open
lonormaly wants to merge 1 commit into
Open
fix(widget): restore the unread flag for EVERY launcher, not just the pill#57lonormaly wants to merge 1 commit into
lonormaly wants to merge 1 commit into
Conversation
… pill v0.2.1 taught the widget to remember an unread message across a navigation. It only ever remembered it for tenants who had opted into the pill launcher — which is nobody by default. `restoreUnread()` was called from inside applyTheme's `launcherStyle === "pill"` branch. So on the default circle the flag was WRITTEN on every inbound message and never READ back: `krispy_unread_<tenant>` accumulated in localStorage while the launcher went quiet on the next page, which is the exact failure persisting it was supposed to fix. My bug, in the commit that added the feature. It now runs at boot, next to renderMute(), for every launcher. OUTSIDE applyTheme for a second reason, not just to escape the branch: the flag has nothing to do with the theme, and applyTheme only runs if the boot config fetch SUCCEEDS. A visitor returning to a page whose config request failed — a blip, an ad blocker, a cold edge — should still be told that somebody answered them. Verified as an A/B on ONE origin, so both builds share the localStorage the test is actually about. No theme at all, i.e. the default circle: write the key, reload, read the launcher. before (master) class="btn" kunread absent dot hidden after (this) class="btn kunread" kunread present dot visible and the key is still stored in both, which is what makes it a read bug rather than a write bug. `bun run check` green: 201 edge tests, 0 fail, 0 lint errors. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
v0.2.1 taught the widget to remember an unread message across a navigation. It only ever remembered it for tenants who had opted into the pill launcher — which is nobody by default.
restoreUnread()was called from insideapplyTheme'slauncherStyle === "pill"branch (widget.js:644 at v0.2.1). So on the default circle the flag was written on every inbound message and never read back:krispy_unread_<tenant>accumulated in localStorage while the launcher went quiet on the next page — the exact failure persisting it was supposed to fix.My bug, in the commit that added the feature (PR 55).
The fix
It now runs at boot, next to
renderMute(), for every launcher.Outside
applyThemefor a second reason, not just to escape the branch: the flag has nothing to do with the theme, andapplyThemeonly runs if the boot config fetch succeeds. A visitor returning to a page whose config request failed — a blip, an ad blocker, a cold edge — should still be told that somebody answered them.restoreUnreadis a function declaration, so it hoists;panel(559) andlauncher(784) are both live well before the new call site.Verified
An A/B on one origin, so both builds share the localStorage the test is actually about. No theme at all — the default circle. Write the key, reload, read the launcher:
kunreadbtnbtn kunreadThe key is still stored in both, which is what makes this a read bug rather than a write bug.
bun run checkgreen: 201 edge tests, 0 fail, 0 lint errors.Small and self-contained; worth a patch release when convenient, since the feature it repairs is already tagged.
🤖 Generated with Claude Code