Skip to content

fix(widget): restore the unread flag for EVERY launcher, not just the pill - #57

Open
lonormaly wants to merge 1 commit into
masterfrom
fix/unread-restore-all-launchers
Open

fix(widget): restore the unread flag for EVERY launcher, not just the pill#57
lonormaly wants to merge 1 commit into
masterfrom
fix/unread-restore-all-launchers

Conversation

@lonormaly

Copy link
Copy Markdown
Collaborator

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 (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 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.

restoreUnread is a function declaration, so it hoists; panel (559) and launcher (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:

build class kunread unread dot
before (master) btn absent hidden
after (this) btn kunread present visible

The key is still stored in both, which is what makes this a read bug rather than a write bug.

bun run check green: 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

… 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>
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.

1 participant