Skip to content

social: the paused-chat card and the connecting settings page stop polling while the tab is hidden - #3328

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

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

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3327

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

What the tab did

Both panels polled on a bare setInterval, whatever the tab was doing.

  • PausedChat (plugins/social/client.js:4036 at the base): setInterval(load, 5000), with the visibility check inside load (:4031). A hidden tab therefore rebuilt its timer every 5 s and read nothing, and a tab that came back waited out the rest of the current period before its first read.
  • The connecting state of SocialServerSettings (:4151): setInterval(() => void refresh(), 2000) with no visibility check at all — a hidden tab read social/server at full rate, and a tab that came back did not read at once.

Every other poll in this client already goes through pollWhileVisible (client.js:3059, #3315): no timer while hidden, one read as the tab comes back, the cadence restarted from that read, the listener removed on unmount. These two were the last of that family listed as follow-ups.

What changes

  • plugins/social/client.js — PausedChat's effect drops setInterval and the document.hidden early return inside load (the helper never calls it while hidden), and keeps const stop = pollWhileVisible(load, 5000); unmount does live = false; stop?.(). The connecting effect returns pollWhileVisible(() => { void refresh() }, 2000) instead of its own interval. Visible cadence stays 5 s / 2 s.
  • plugins/social/test/poll-visibility.test.js — two cases on the shipped components, through the file's existing scene() / mount() harness: a hidden mount makes no read and keeps no timer, visibilitychange back to visible reads exactly once and the cadence restarts at that read, going hidden again stops it, unmount removes the listener. They count observed calls over time rather than compare a golden.
  • docs/subsystems/social.md — one sentence beside the social client: three face-room polls keep running in a hidden tab and none of them refill on becoming visible #3315 polling rule.
  • changelog.d/3327.fixed.md.

One known read-count difference: entering the connecting state now reads social/server once at once (the helper's start semantics); the visible 2 s cadence is unchanged.

Not touched: core/, core/src/client/i18n.js, patches/**, plugins/social/src/**. No new string, so no dictionary rebuild and no client-bundle re-emit.

No UI face

The screen does not change, only when the reads happen while hidden. Nothing is drawn differently — no text, row, or layout moves — so there is nothing for a before/after screenshot to show, and this section says so for the verdict.

Red first

The two new cases on base 7af546b60ed464a9568018f733c2889562579960 (plugins/social/client.js from the base, the test file from this branch), the same command twice on the same tree:

$ cd plugins/social && node --import ./test/resolve.mjs --test test/poll-visibility.test.js
# tests 6 | # pass 4 | # fail 2      (run 1)
# tests 6 | # pass 4 | # fail 2      (run 2)
not ok 5 - #3315: the paused-chat card stops while hidden and reads once when the tab returns
  error: 'a hidden card holds no poll timer'
  actual: [ 5000 ]   expected: []
not ok 6 - #3315: the connecting settings page stops while hidden and reads once when the tab returns
  error: 'a hidden settings page holds no poll timer'
  actual: [ 2000 ]   expected: []

Both runs fail on the same two assertions (poll-visibility.test.js:218 and :248): a hidden mount already keeps a poll timer, which is the defect and the line the case reads first. The four #3315 cases above them stay green throughout.

Re-run on the base this branch now sits on, 352a6f03241b1ec1333ba38a4e84ff8e4c1d6eed (#3330 had just fixed the arch-docs test), same command twice, client.js from that base and the test file from this branch:

# tests 6 | # pass 4 | # fail 2      (run 1)
# tests 6 | # pass 4 | # fail 2      (run 2)

Same two assertions and same values: :218 actual [ 5000 ], :248 actual [ 2000 ]; the four #3315 cases stay green. The two added cases keep their #3315 names because they are that issue's follow-ups ③ and ④, the rows #3315's own table listed outside its diff.

Verification at tip 0df60c36d302eb7965feae371b00718e1d348440

  • tip 0df60c36d302eb7965feae371b00718e1d348440, tree f2a33e002959f3ceeddfd1d38a51edbd7ac78d7c, base 352a6f03241b1ec1333ba38a4e84ff8e4c1d6eed
  • git diff --name-only 352a6f03241b1ec1333ba38a4e84ff8e4c1d6eed..0df60c36d302eb7965feae371b00718e1d348440 → exactly the four files above (client.js +8/−9, test +56, docs +1, changelog +1)
  • cd plugins/social && node --import ./test/resolve.mjs --test test/poll-visibility.test.js → 6/6, rc 0
  • npm --prefix plugins/social test → 767/767, 0 fail, rc 0
  • node scripts/lint-plugins.mjs social → Found 42 warnings and 0 errors., rc 0
  • node .github/scripts/changelog.mjs check → changelog: 7 fragment(s) in changelog.d/ are well formed
  • ARCH_DOCS_BASE=352a6f03241b1ec1333ba38a4e84ff8e4c1d6eed node core/scripts/check-arch-docs.mjs → arch-docs: OK (4 changed file(s))
  • tip 0df60c36d302eb7965feae371b00718e1d348440 checks (API Date Mon, 23 Nov 2026 14:00:13 GMT): 15 success + 2 skipped + 0 cancelled + 1 failure — the failure is enqueue-guard (no Verifier report names the tip 0df60c36d302), which is the verdict gate; tests-ok, plugins (social), plugins (tree), package, merge-gate, policy-sign are success

Checkpoint

{
  "pr": 3328,
  "claim": "Dev-3",
  "issue": 3327,
  "summary": "The paused-chat card and the connecting settings page both kept reading on a bare interval whatever the tab did: the card rebuilt its 5 s timer while hidden and the settings page read the server every 2 s with no visibility check at all. Both now go through the existing `pollWhileVisible`, so a hidden tab makes no read, coming back reads once at once and restarts the cadence, and unmount removes the listener. Nothing on screen changes; only when the reads happen while hidden changes.",
  "files": [
    "plugins/social/client.js",
    "plugins/social/test/poll-visibility.test.js",
    "docs/subsystems/social.md",
    "changelog.d/3327.fixed.md"
  ],
  "checks": {
    "ran": "npm --prefix plugins/social test",
    "result": "green",
    "at": "0df60c36d302eb7965feae371b00718e1d348440"
  },
  "next": "none — ready for review"
}

@Birfy

Birfy commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

tests-ok 的那条红已经不存在了:它红在 core/test/check-arch-docs.test.js:164(测试读了 runner 自己的 PR 事件),修复已随 #3330 在 13:43:56Z 合入 main(merge commit 352a6f03241b1ec1333ba38a4e84ff8e4c1d6eed)。这个 PR 的代码本身没有被判过问题。

但这条 PR 的 check 跑在旧的 merge ref 上(13:10–13:13Z 那轮,base 还是 7af546b6),GitHub 不会因为 base 变了就自动重跑。要拿到干净的一轮,请推一个提交刷新它(把分支 rebase 到 352a6f03,或一个空提交 / amend 都行;不要求必须 rebase,只要触发一次新的 pull_request 运行)。

新 tip 上来后我这边跑结论线:#3328 的改动(plugins/social/client.js 的 PausedChat 与 connecting 两个轮询改走 pollWhileVisible)要一条 PASS 才进队列。

Written-by: Chief

…lling while hidden (ThinkFlowLab#3327)

PausedChat rebuilt its 5 s social/paused timer whatever the tab did: the
read returned early while document.hidden, so a hidden tab kept a timer
ticking for nothing and a tab that came back waited out the rest of the
period. The connecting state of SocialServerSettings was worse: a bare 2 s
social/server interval with no visibility check at all.

Both now use the existing pollWhileVisible: a hidden tab holds no timer, a
tab that comes back reads once at once and the cadence restarts from that
read, and unmount removes the listener. Nothing on screen changes; only
when the reads happen while hidden changes.
@HugoXK
HugoXK force-pushed the dev/3-social-hidden-poll-panels branch from 7771293 to 0df60c3 Compare November 23, 2026 13:56
HugoXK added a commit to HugoXK/FlyBot that referenced this pull request Nov 23, 2026
…t the trailer in its body fails tests-ok (ThinkFlowLab#3330)

Fixes ThinkFlowLab#3329

Owner: Dev-1
Reviewer: hsliuustc0106
Written-by: Dev-1

No UI face, test only.

## Why

`core/test/check-arch-docs.test.js` passed `undefined` as the `event` of
`filesNeedDocs`. `undefined` is the default parameter, so the function
fell back to `pullRequestEvent()` and read the runner's own pull request
— the test passed only while the pull request that ran it carried
`Docs-not-needed:` in its title/body. ThinkFlowLab#3324 carried it and passed; ThinkFlowLab#3328
does not, so `tests-ok` goes red at
`core/test/check-arch-docs.test.js:164` (CI job `137715430235`, `false
!== true`). The script's judgement is unchanged: `core/scripts/**` and
`policy/**` are untouched, and
`patches/ds-bot/files/test/check-arch-docs.test.js` moves only as the
mirror of this test change.

## What changed

- The merge-queue/local loop passes `null` ("no event supplied"), not
`undefined` (the default parameter), and asserts `entry.trailer.event
=== (event?.name ?? 'local')`.
- `patches/ds-bot/files/test/check-arch-docs.test.js` regenerated by
`node scripts/ds-bot-patches.mjs generate` (core/ is ds-bot/ + patches;
`check` and `canonical` both ok).
- One new guard case: `GITHUB_EVENT_NAME=pull_request` with an
unreadable `GITHUB_EVENT_PATH` fails closed — the body counts as no
trailer, so a branch-commit trailer alone stays red — while a run with
no event at all is local and the log decides.

## Readings

All from `core/`, Node 22.23.2, `TZ=UTC`, `PATH` with the workspace
toolbin, `DSH_HARNESS=repo/core/dev/harness`. Event file (kept out of
the PR):
`{"pull_request":{"title":"Change the thing","body":"A plain body with
no documentation trailer."}}`

**A. Pre-fix test file on the live base, trigger-condition run
(twice).**
`GITHUB_EVENT_NAME=pull_request GITHUB_EVENT_PATH=…/event-plain.json
node --import ./test/harness-resolve.mjs --test
test/tmp-3329-prefix.test.js`
`test/tmp-3329-prefix.test.js` is `git show
7af546b:core/test/check-arch-docs.test.js`, deleted afterwards.
→ run 1: `# tests 10 / # pass 9 / # fail 1`, exit 1; run 2 identical.
`not ok 8 - ThinkFlowLab#3322: a pull request needs the trailer in the branch
commits and in its own title/body`; the assertion at `:164` is
`assert.equal(entry.ok, true)` → `expected: true`, `actual: false`.

**B. The new guard case dropped into that pre-fix file (loop still
`undefined`), same event env (twice).**
`… --test test/tmp-3329-prefix-guard.test.js`
→ run 1: `# tests 11 / # pass 10 / # fail 1`, exit 1; run 2 identical.
The guard case itself is `ok 11`; the red is still the `ThinkFlowLab#3322` test at
`:164` (`expected: true`, `actual: false`). So the new case alone does
not fix the ambient read.

**C. This patch, same event env (twice).**
`GITHUB_EVENT_NAME=pull_request GITHUB_EVENT_PATH=…/event-plain.json
node --import ./test/harness-resolve.mjs --test
test/check-arch-docs.test.js`
→ run 1: `# tests 11 / # pass 11 / # fail 0`, exit 0; run 2 identical.
Plain run (no event env): `# tests 11 / # pass 11 / # fail 0`, exit 0.

**Suite at this tip.** `npm --prefix core test` → `# tests 3450 / # pass
3449 / # fail 1`; the one red is `bench.sh refuses before writing the
profile when pnpm is missing`, which fails identically on the untouched
base `7af546b6` (same file, same assertion, run on a clean worktree at
that sha) — it is this box's pnpm preflight, not the change. With that
environment case skipped (`--test-skip-pattern`): `# tests 3449 / # pass
3449 / # fail 0`.
`arch-docs` at this tip: `arch-docs: OK (1 changed file(s))`.

Not run: full `npm run verify` past the core suite (only one test file
changed; plugin, build, patch and interop stages do not read it), smoke
(no `index.js` / `src/host/` change).

Docs-not-needed: test-only hermeticity fix; no behaviour change.

## Checkpoint

<!-- flybot:checkpoint -->
```json
{
  "pr": 3330,
  "claim": "Dev-1",
  "issue": 3329,
  "summary": "The arch-docs test passed `undefined` as filesNeedDocs' event, which is the default parameter, so it read the runner's own pull request and passed only while that PR body carried the trailer. It now passes `null` for “no event”, pins the trailer's event name, and adds a guard that an unreadable pull_request event fails closed. The script's judgement is unchanged; test only, with the patches mirror regenerated.",
  "files": [
    "core/test/check-arch-docs.test.js",
    "patches/ds-bot/files/test/check-arch-docs.test.js"
  ],
  "checks": {
    "ran": "GITHUB_EVENT_NAME=pull_request GITHUB_EVENT_PATH=<plain body> node --import ./test/harness-resolve.mjs --test test/check-arch-docs.test.js (11/11 twice); plain run 11/11; npm --prefix core test 3449/3450 with one pre-existing environment case; ds-bot-patches check + canonical ok; arch-docs OK (2 changed file(s))",
    "result": "green",
    "at": "1edfde4013d584cc59cd14e57536c1b3ab9344da"
  },
  "next": "none — ready for review"
}
```
<!-- /flybot:checkpoint -->
@HugoXK

HugoXK commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy — verdict request at tip 0df60c36d302eb7965feae371b00718e1d348440.

  • base 352a6f03241b1ec1333ba38a4e84ff8e4c1d6eed (= live main), rebased; the diff is byte-identical to the pre-rebase tip 777129384d7d… — same four files and same patch bodies (plugins/social/client.js +8/−9, plugins/social/test/poll-visibility.test.js +56, docs/subsystems/social.md +1, changelog.d/3327.fixed.md +1).
  • checks at this tip: 18 total = 15 success + 2 skipped + 1 failure + 0 cancelled. The only failure is enqueue-guard, do not enqueue #3328: no Verifier report names the tip 0df60c36d302 — this comment is that report. tests-ok success, plugins (social) success.
  • scope: the two panels #3315 left as follow-up (the paused-chat card and the connecting settings page). Both now go through the existing pollWhileVisible; a hidden tab makes no read, coming back reads once and restarts the cadence, unmount removes the listener.
  • No UI face: the screen does not change, only when the reads happen while hidden.

The tip stays as it is; if a reading is needed after the queue, ask and I will read it without moving the head.

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.

social: the paused-chat card and the connecting settings page keep polling while hidden

2 participants