Skip to content

fix: close race window that dropped active channel messages#410

Merged
wesbillman merged 1 commit into
mainfrom
fix/dropped-active-channel-messages
Apr 27, 2026
Merged

fix: close race window that dropped active channel messages#410
wesbillman merged 1 commit into
mainfrom
fix/dropped-active-channel-messages

Conversation

@wesbillman

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed a race condition where messages for the active channel were silently dropped during the handoff between two subscription layers
  • The global stream subscription (useLiveChannelUpdates) was skipping cache writes for the active channel, relying on the per-channel subscription (useChannelSubscription) — but that subscription connects asynchronously, creating a window where neither path writes to the cache
  • Removed the active-channel early return so both subscriptions write to the cache; mergeTimelineCacheMessages deduplicates by event ID, making double-writes harmless

Changes

  • desktop/src/features/channels/useLiveChannelUpdates.ts — 7 insertions, 6 deletions

Review notes

  • Beth (reviewer): APPROVE — no BLOCK or CHANGE items. Confirmed dedup safety, no notification behavior change, acceptable performance at high message rates
  • Summer (refactor): no structural changes needed — code is already clean
  • NIT: if (!current) return current guard differs from useChannelSubscription's (current = []) pattern — intentionally different semantics (global listener should not seed cache for unvisited channels)
  • NIT: no regression test added — no existing test infrastructure for this hook

Test plan

  • TypeScript typecheck passes
  • Biome lint/check passes (2 pre-existing warnings in unrelated forum files)
  • All pre-commit hooks green (desktop-check, desktop-tauri-fmt, mobile-check, rust-fmt)
  • Manual verification: open a channel, confirm messages appear immediately without requiring a second event to trigger re-render

🤖 Generated with Claude Code

useLiveChannelUpdates skipped cache writes for the active channel,
relying on useChannelSubscription to handle them. But
useChannelSubscription connects asynchronously, so messages arriving
in the gap were dropped by both paths.

Remove the early return for the active channel so the global
subscription always writes to the message cache. The merge function
deduplicates by event ID, so double-writes from both subscriptions
are harmless.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@wesbillman wesbillman merged commit ed5dad7 into main Apr 27, 2026
13 checks passed
@wesbillman wesbillman deleted the fix/dropped-active-channel-messages branch April 27, 2026 23:49
tlongwell-block added a commit that referenced this pull request Apr 28, 2026
* origin/main:
  Add multi-workspace support to desktop app (#409)
  feat(mobile): add #channel autocomplete to compose bar (#411)
  fix: close race window that dropped active channel messages (#410)
  feat(pulse): rich text editor with @mentions, media uploads, and formatting (#407)
  feat(mobile): multi-workspace support (#408)
  feat: always notify on DM messages like Slack/Discord (#405)
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