[judy] fix(web): poll refreshes all squads' unread badges, not just current#47
Merged
Merged
Conversation
scott repro 2026-05-28: a thread in a non-selected squad got a new post; that squad's red badge didn't appear in the left rail until he clicked into it. Root cause: the 8s poll only called refreshThreadsForCurrentSquad(), which by name and behavior fetches detail for state.currentSquadId only. Other squads' state.squadDetails entries stayed frozen at page-load snapshot, so squadUnreadCount() returned 0 for them no matter how many new posts landed. Click \u2192 selectSquad \u2192 force-refresh \u2192 badge appears. Fix: add refreshAllSquadsForUnread() that fan-outs /api/squads/<id> via Promise.allSettled (per-squad errors swallowed) and re-renders the squad rail. Replace the per-current-squad call in the poll loop with this superset \u2014 same network cost when there's only one squad, scales linearly otherwise but every fetch is a tiny JSON. SSE handler still calls the narrow refreshThreadsForCurrentSquad() because SSE is thread-scoped and we don't need to re-fan-out on every token.
🤖 bot-review (comment-only · phase 1)Diff: Red-line checks:
Phase 1: this bot leaves comments only. Auto-approve will be enabled per-path after 1–2 weeks of clean runs. Promotion plan: judy PR #42 follow-up. |
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.
Scott repro \u4e8e thread
th_19e67fde6f4_c69e1a\uff1a\u67d0\u4e2a \u672a\u9009\u4e2d \u7684 squad \u91cc thread \u6709\u4e86\u65b0 post\uff0c\u5de6\u680f\u5bf9\u5e94 squad \u7684\u7ea2 badge \u4e0d\u4e3b\u52a8\u6d6e\u73b0\u2014\u2014\u7b49\u70b9\u8fdb\u53bb\u624d\u51fa\u73b0\u3002Root cause
8s \u8f6e\u8be2\u91cc\u53ea\u8c03\u4e86
refreshThreadsForCurrentSquad()\uff0c\u5b83\u987e\u540d\u601d\u4e49\u53ea\u62c9state.currentSquadId\u8fd9\u4e00\u4e2a squad \u7684 detail\u3002\u5176\u4ed6 squad \u7684state.squadDetails\u7559\u5728\u9875\u9762\u521d\u88c5\u8f7d\u7684\u65e7\u5feb\u7167\uff0csquadUnreadCount()\u8bfb\u51fa\u6765\u6c38\u8fdc\u662f 0\uff0cbadge \u81ea\u7136\u4e0d\u4eae\u3002\u4e00\u70b9\u51fb \u2192selectSquad\u5f3a\u5237 \u2192 \u624d\u770b\u5230\u3002Fix
\u65b0\u589e
refreshAllSquadsForUnread()\uff1a\u5e76\u53d1 fan-out \u6240\u6709 squad detail\uff08Promise.allSettled\uff0c\u5355\u4e2a\u5931\u8d25\u4e0d\u72af\u5168\u5c40\uff09\uff0c\u91cd\u6e32\u67d3 squad rail\u3002\u628a 8s poll \u91cc\u7684 per-current-squad \u8c03\u7528\u6362\u6210\u8fd9\u4e2a superset\u3002SSE handler \u4ecd\u8c03\u539f\u6765\u7684\u7a84\u7248\u672c\u2014\u2014SSE \u662f thread \u7ea7\u522b\u7684\u63a8\u9001\uff0c\u4e0d\u9700\u8981\u6bcf\u4e2a token \u90fd fan-out\u3002\u5f00\u9500\uff1aN \u4e2a squad = N \u4e2a\u5c0f JSON \u8bf7\u6c42 / 8s\uff0c\u73b0\u5728\u7ea7\u522b\u5b8c\u5168 OK\u3002
Thread:
th_19e67fde6f4_c69e1a