Repository navigation
refactor(display): collapse publisher + subscriber into display-realtime - #106
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Merge display-publisher.ts (429 LOC) and display-subscriber.ts (232 LOC) into a single display-realtime.ts (231 LOC). Drops three failure state machines (silent-drop warning, terminal failure escalation, removeChannel failure counter), the PublisherMode enum, and the duplicated removeChannelSafe helper. Replace three test files that unit-tested Supabase channel internals with a single display-realtime.test.ts testing observable behavior: channel.send receives correct event and payload, handlers fire on incoming broadcasts, hello handshake round-trip. Net: -1,010 LOC source, -610 LOC tests, 2440 tests passing.
- P16-001: null-client branch in scheduleRetry stops reconnect loop,
calls onStatusChange('disconnected') instead of silently abandoning
- P16-002: clearTimeout pending retry before re-subscribing prevents
stale-gymId ghost subscription on useEffect re-run
- P16-004: removeSafe logs warn when client is null instead of silent return
- P16-005: unfocus broadcast handler wrapped in try-catch matching the
display_hello responder pattern — prevents throw propagating into Supabase
- P16-006: subscriber CHANNEL_ERROR/TIMED_OUT logged at error, CLOSED at info,
mirroring the publisher's existing conditional
- P16-007: empty-string gymId guard added to configureDisplayPublisher and
subscribeToDisplay — prevents display:gym: channel name
- P16-011: validated() logs r.error.toString() + raw payload instead of raw
ZodError instance — serializes correctly in Sentry/Datadog
- P16-014: pubSend widened to unknown payload, removes double-cast in
publishDisplaySnapshot
Review: Context/Reviews/0016-pr106-simplify-display-subsystem-2026-04-12.md
Tasks: S015-T through S021-T added to Steps.md for missing display-realtime test coverage (subscribeToDisplay throw, onStatusChange, focus/unfocus/idle handlers, gym-switch teardown, backoff sequencing, auto-publishHello, getters) ADR-015: documents shared _client teardown contract — publisher and subscriber are mutually exclusive by route structure; P16-001/P16-002 fixes mitigate the retry-window race without requiring a new co-existence mechanism Review: Context/Reviews/0016-pr106-simplify-display-subsystem-2026-04-12.md
…21-T) Adds 21 new tests across 7 task items from the P16 review: - S015-T: subscribeToDisplay throws when uninitialized or gymId is empty - S016-T: publishHello fires on reconnect but not on first connect - S017-T: onStatusChange asserted for SUBSCRIBED/TIMED_OUT/CHANNEL_ERROR/CLOSED - S018-T: focus, unfocus, idle_snapshot broadcast handler coverage - S019-T: gym-switch tears down old channel and creates new one - S020-T: backoff delay math (2000ms first, resets on reconnect, cap at 30s) - S021-T: getActiveGymId and getSubscriberStatus state transitions Introduces autoSubscribe option on createMockClient to accumulate _subRetryAttempt across consecutive errors without SUBSCRIBED resetting it. Tasks: S015-T, S016-T, S017-T, S018-T, S019-T, S020-T, S021-T Feature: 008-display-broadcast-infrastructure
rghamilton3
force-pushed
the
worktree-chore+simplify-display-subsystem
branch
from
April 13, 2026 00:09
a59a54c to
ded0e3e
Compare
rghamilton3
force-pushed
the
worktree-chore+simplify-display-subsystem
branch
from
April 13, 2026 00:14
ded0e3e to
f68501b
Compare
This branch was successfully deployed
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.
Summary
display-publisher.ts(429 LOC) anddisplay-subscriber.ts(232 LOC) into a singledisplay-realtime.ts(231 LOC)PublisherModeenum, and duplicatedremoveChannelSafedisplay-realtime.test.tscovering observable behaviorNet change: -1,010 LOC source, -610 LOC tests
Test plan
bun run buildpasses (TypeScript clean)bun run test-- 126 files / 2440 tests passingdisplay-realtime.tsexports same public API as the two modules it replaces (callers changed import path only)removeChannelcalled on destroy