Skip to content

social: the chat approval dock and the friends panel stop polling a hidden tab - #3356

Closed
HugoXK wants to merge 2 commits into
ThinkFlowLab:mainfrom
HugoXK:dev/3-social-hidden-poll-timer
Closed

HugoXK wants to merge 2 commits into
ThinkFlowLab:mainfrom
HugoXK:dev/3-social-hidden-poll-timer

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3354

Bot: FlyBot Dev-3
Owner: Dev-3
Written-by: Dev-3
Reviewer: Birfy

What the two mounts did

  • Chat approval dock (ChatApprovalDock, plugins/social/client.js:2596-2607 at the base): load() starts with if (document.hidden) return, but the effect still runs setInterval(load, 5000) — a hidden tab keeps a 5 s timer that wakes up only to return, and a separate visibilitychange listener does the catch-up read.
  • Friends settings panel (FriendsBots, :3311-3321): the effect calls loadApprovals() before any visibility check and then holds setInterval(tick, 15_000), whose tick also returns while document.hidden; there is no visibilitychange listener at all, so a tab that comes back waits out the rest of the period before its first read.

Both are the rule #3315/#3327/#3332/#3334 applied to every other poll in this file: a poll exists to refresh what the person can see.

What changes

Both effects now return pollWhileVisible(fn, ms) — the dock at 5000, the panel at 15_000:

  • a hidden mount makes no read and holds no timer;
  • a tab that comes back reads once at once and the cadence restarts from that read;
  • unmount removes the listener and the timer;
  • the panel gains the catch-up read it never had; the visible cadence and everything on screen are unchanged.

Red first

plugins/social/test/poll-visibility.test.js, on the test-only tree 461f3936dd (branch tip 64cf2a60f8512294003af5965be3aff0a862ed92 before the fix, base bab1fe963b65913f5cd1021d30e6598a7f571627), same command twice:

TMPDIR=/tmp DSH_HARNESS=… node --import ./test/resolve.mjs --test --test-timeout=60000 test/poll-visibility.test.js

Both runs # tests 10 | # pass 8 | # fail 2:

  1. not ok 9 - the chat approval dock stops while hidden and reads once when the tab returns — a hidden dock holds no poll timer, actual [5000] vs [], poll-visibility.test.js:330 (test at :324).
  2. not ok 10 - the friends settings panel stops while hidden and reads once when the tab returns — a hidden panel made 1 read(s) actual 1 vs 0, poll-visibility.test.js:355 (test at :350); the next assertion in the same test, :356, expects periods [] vs the [15000] the base holds.

Each assertion has exactly one expected value.

Ran / Not run

  • ran test/poll-visibility.test.js → 10/10, 0 fail (twice).
  • ran npm --prefix plugins/social test → 782/782, 0 fail, rc 0.
  • ran node .github/scripts/changelog.mjs check → changelog: 4 fragment(s) in changelog.d/ are well formed.
  • ran ARCH_DOCS_BASE=bab1fe963b65913f5cd1021d30e6598a7f571627 node core/scripts/check-arch-docs.mjs → arch-docs: OK (4 changed file(s)).
  • not run npm run verify as one command: the other plugin suites and the interop stages are outside this change; each stage this change touches is listed above.

No UI face

The dock and the panel draw exactly what they drew before; only when the reads happen while the tab is hidden changes, so there is no before/after screenshot to take.

Verification at tip 33ffe5beac5ba498c48db5910fdbf3cbc74a2473

  • tip 33ffe5beac5ba498c48db5910fdbf3cbc74a2473, tree 99489dee956d8dec923309c85444c91d5b3778c8, base bab1fe963b65913f5cd1021d30e6598a7f571627
  • 4 files, +63/−23: plugins/social/client.js +7/−23, plugins/social/test/poll-visibility.test.js +54/−0, docs/subsystems/social.md +1/−0, changelog.d/3354.fixed.md +1/−0

Changelog fragment included: a background tab no longer reads for these two mounts, which is the same user-visible class the merged #3328/#3332/#3335 carried fragments for. Docs: one line per mount in docs/subsystems/social.md, after the face-rooms page entry of the same pollWhileVisible list.

Checkpoint

{
  "pr": 3356,
  "claim": "Dev-3",
  "issue": 3354,
  "summary": "The chat approval dock's 5 s `social/status` + `approvals` poll and the friends settings panel's 15 s `social/status` poll were bare `setInterval`s that kept a timer for a hidden tab (the dock skipped the read inside `load`; the panel skipped it inside `tick`) and the panel had no visibility listener at all. Both now go through `pollWhileVisible`: a hidden mount makes no read and holds no timer, a tab that comes back reads once at once, and the cadence restarts from that read. The visible cadence and everything on screen are unchanged.",
  "files": [
    "plugins/social/client.js",
    "plugins/social/test/poll-visibility.test.js",
    "docs/subsystems/social.md",
    "changelog.d/3354.fixed.md"
  ],
  "checks": {
    "ran": "npm --prefix plugins/social test",
    "result": "green",
    "at": "33ffe5beac5ba498c48db5910fdbf3cbc74a2473"
  },
  "next": "none — ready for review"
}

@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy — verdict request for this tip, once: 33ffe5beac5ba498c48db5910fdbf3cbc74a2473.

Tier T2 (Fixes #3354, social client). enqueue-guard is the only red at this tip and its text is do not enqueue #3356: no Verifier report names the tip 33ffe5beac5 — it waits for exactly this report, nothing else. 18 checks = 14 success + 1 failure (that guard) + 2 skipped (live · ubuntu · Node 24 · real model, window check) + 1 cancelled (agent-audience).

What to read: plugins/social/client.js — the approval dock's setInterval(load, 5000) and the friends panel's mount read now both go through pollWhileVisible (dock 5000, panel 15 000), so a hidden mount makes no read and holds no timer, and a tab that comes back reads once and restarts the cadence from that read. Nothing on screen changes; the visible cadence is unchanged.

Two new tests in plugins/social/test/poll-visibility.test.js assert one outcome each: a hidden dock's fake setInterval log is [], and a hidden panel makes 0 social/status + approvals calls. Red on main + tests 8/10 twice, green 10/10; plugins/social 782/782. One docs line beside docs/subsystems/social.md:127-130, fragment changelog.d/3354.fixed.md.

Body frozen at sha256[:16] bc434ea078b11748, 4836 bytes. Please name this 40-char sha in the verdict.

@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy: review request for #3356 at tip 33ffe5b (base bab1fe9)

@github-actions github-actions Bot added the risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff label Nov 24, 2026
@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Repackaged for FlyBot 2.0 / OpenTeamily in #3382 — same behaviour, reimplemented against the 2.0 tree (runtime/flybot/plugins/social/client.js, the vendored 2026-11-16 snapshot; the old diff does not apply because 2.0 predates the pollWhileVisible helper). Recorded in docs/upstream/migration-manifest.json → modified_files. This PR stays open as the v1.0 record; nothing was closed, merged or retargeted.

Ported part: the 5 s approval-dock poll and the 15 s requests-panel poll now run through pollWhileVisible (no timer or read while hidden, one read on return, cadence restarting from it).

Repo-wide evidence: FLYBOT_2.0_PR_AUDIT_RESULT.md (2026-11-25).

@Birfy

Birfy commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

按旧布局退役关闭。

本 PR 改的是 plugins/social/client.js,该路径在当前 main 1ae1e658(2026-11-25T14:41:26Z)上不存在(git cat-file -e 1ae1e658:plugins/social/client.js → ABSENT;0.3.0 之后社交插件在 runtime/flybot/plugins/social/client.js,EXISTS)。

同一批修正在新布局上已有一份移植版 #3382(改 runtime/flybot/plugins/social/client.js,并新增 runtime/flybot/plugins/social/test/poll-visibility.test.js),不再保留两份。

Related #3354 Refs #3382

@Birfy Birfy closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

social: the approval dock and the friends panel still hold a poll timer in a hidden tab

2 participants