Skip to content

social: the face-rooms page keeps a 5 s poll timer while the tab is hidden #3334

Closed

Description

@HugoXK

Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment on this issue.

Written-by: FlyBot Lead
Claimed-by: FlyBot Lead
Claim-Id: fb1a35cf6a99462fa0d9bb38e0b7a05f
Branch: dev/3-face-rooms-poll
Base: e48bf75
At: 2026-11-23T15:21:30Z

Bot: FlyBot Dev-3

What happens now

FaceRooms (plugins/social/client.js:3102, the effect at :3114–:3125) polls social/face-rooms every 5 s on a bare interval, whatever the tab is doing:

  • :3122 — const timer = setInterval(tick, 5000) is created unconditionally at mount. The hidden check sits inside tick (:3119), so a hidden tab wakes every 5 s and returns before reading: a timer spinning for nothing until unmount.
  • :3116 — load(true) reads once at mount with no visibility check at all, so opening the client in a hidden tab still issues one social/face-rooms read.
  • The effect registers no visibilitychange listener, so a tab that comes back waits out the rest of the current period (0–5 s) instead of reading at once.

This is the same family as #3315 (① waiting 2 s, ② FaceRoomOverview 3 s, ③ PausedChat 5 s, ④ connecting settings 2 s), continued by #3327 (③④) and #3332 (the peer-thinking row). #3327's body names this page-level 5 s timer as a follow-up candidate outside its own diff; every other poll in this client already goes through the file's own pollWhileVisible (:3055).

Reproduction on live main e48bf75eebfdb93d21e18e41d0e43ead679c24d7

cd plugins/social && node --import ./test/resolve.mjs --test test/poll-visibility.test.js

The new case with the base plugins/social/client.js (test file from the worktree), same command twice, identical both runs: # tests 8 / # pass 7 / # fail 1

not ok 8 - the face-rooms page stops while hidden and reads once when the tab returns
  error: 'a hidden page holds no poll timer'
  actual: [ 5000 ]   expected: []
  at plugins/social/test/poll-visibility.test.js:299

The other two halves were probed on the same base with a throwaway copy of the case (deleted after the run, nothing committed): a hidden mount still issues one read (load(true) with no visibility check), and a visibilitychange back to visible reads 0 times — PROBE: coming back made 0 read(s), not one, because the effect holds no listener. The committed case asserts all three; the first to fire is the timer.

Expected behaviour

While the tab is hidden the page holds no poll timer and issues no social/face-rooms read; when the tab becomes visible it reads immediately once and restarts the 5 s cadence from that read; unmounting removes the timer and the listener. The visible cadence (one read at mount, then every 5 s) and everything on screen stay exactly as they are.

Verified fix

useEffect(() => {
  if (!enabled) return undefined
  return pollWhileVisible(() => load(true), 5000)
}, [enabled])

plugins/social/client.js +1/−9 — no new helper, the file's existing pollWhileVisible (:3055, already serving ①②③④ and the peer-thinking row). The helper's start() calls fn() once and then setInterval(fn, 5000), which is the same "read at mount, then every 5 s" shape the old load(true); setInterval(tick, 5000) had, so the visible cadence is unchanged: a hidden mount no longer reads, and coming back reads once at once and rebuilds the 5 s period from that read.

Readings at that fix on the same base: the file 8/8 (# fail 0); npm --prefix plugins/social test 769/769 rc 0 (unchanged base 768/768, so only the new case is added); node scripts/lint-plugins.mjs social → Found 42 warnings and 0 errors. rc 0; node .github/scripts/changelog.mjs check → changelog: 10 fragment(s) in changelog.d/ are well formed; ARCH_DOCS_BASE=e48bf75e… node core/scripts/check-arch-docs.mjs → arch-docs: OK (4 changed file(s)).

Scope

  • Lane: plugins/social/client.js (+1/−9), plugins/social/test/poll-visibility.test.js (+27, one case on the shipped component through the file's existing scene() / mount() harness), one sentence in docs/subsystems/social.md after the peer-thinking line, and one changelog.d/<this issue>.fixed.md.
  • No plugins/social/src/**, no core/**, no core/src/client/i18n.js, no patches/**, no client bundle, no generated file.
  • The remaining same-shape poll points (FriendsBots, ManageAccess, ShareWithFriend, ChatApprovalDock, the 30 s status timer) stay out of this issue.

No UI face

The room list, its rows and the Past rooms area do not change; only whether the 5 s read happens while the tab is hidden changes. Nothing is drawn differently — no text, row or layout moves — so there is nothing for a before/after screenshot to show.

Duplicate check

Grepped live main for FaceRooms, face-rooms, setInterval, pollWhileVisible; searched issues and PRs for FaceRooms, face-rooms hidden poll, face-rooms setInterval. Only adjacent, none covering this page-level 5 s poll: #3315 / #3316 (the table lists ①②③④ only and marks ③④ as follow-ups), #3327 / #3328 (③④, closed), #3332 / #3333 (peer-thinking row, closed). No open or closed issue reports this page's hidden-tab polling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions