Skip to content

Gate hub-client remote edits + presence notifications while tab hidden#134

Merged
shikokuchuo merged 2 commits intomainfrom
hub-client-visibility-gating
Apr 24, 2026
Merged

Gate hub-client remote edits + presence notifications while tab hidden#134
shikokuchuo merged 2 commits intomainfrom
hub-client-visibility-gating

Conversation

@shikokuchuo
Copy link
Copy Markdown
Member

@shikokuchuo shikokuchuo commented Apr 24, 2026

Fixes #133.

Problem

Backgrounded tabs queue Automerge change events and ephemeral presence messages. On refocus the queue drains as per-event executeEdits and per-message subscriber callbacks, which users see as remote text being typed at super-speed and cursors sweeping through intermediate positions.

Fix

Defer Monaco edits and presence subscriber notifications while document.visibilityState === 'hidden' — data still lands in React state and remotePresences, so nothing goes stale — and flush once on visibilitychange → visible, with a window focus fallback for the documented browsers/modes where visibilitychange doesn't fire.

Repro and design in claude-notes/plans/2026-04-24-hub-client-visibility-gating.md.

Defer per-change executeEdits and per-message subscriber notifications
while document.visibilityState is 'hidden'; flush once on
visibilitychange → visible (or window focus, for browsers that skip
visibilitychange). Eliminates the replay-animation users saw when
refocusing a backgrounded tab. Plan at
claude-notes/plans/2026-04-24-hub-client-visibility-gating.md.
@shikokuchuo shikokuchuo force-pushed the hub-client-visibility-gating branch from 4693852 to c8f1122 Compare April 24, 2026 13:54
@shikokuchuo shikokuchuo merged commit 86bbe0a into main Apr 24, 2026
4 checks passed
@shikokuchuo shikokuchuo deleted the hub-client-visibility-gating branch April 24, 2026 14:08
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.

hub-client: missed changes are replayed when focus returns

1 participant