Skip to content

workflow: a hidden window keeps the stage's 2 s store poll, and coming back waits for a tick - #3365

Closed
HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/5-workflow-hidden-poll
Closed

HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/5-workflow-hidden-poll

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3361

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

What is wrong

plugins/workflow/client.js:2197 armed the stage's store poll as a bare setInterval(() => { ... void refresh() }, 2000) — no visibility check and no visibilitychange listener. refresh() is a full workflow/state read of the store (including the widened heldLimit page), so a Workflow stage left open in a background window kept reading the host every 2 s for as long as any run was live (activeCount > 0) or a read error was on screen; and coming back to the window showed rows up to 2 s stale, because nothing read at the moment the page became visible again. plugins/timeline/client.js:70 already declines to poll while visible() is false, and the social surface has the same rule (#3315, #3327); this was the last surface that ignored it.

Red first

plugins/workflow/test/client.test.js on this branch, with the fix not yet written — a hidden document, a live run, then the armed timer fired:

not ok 249 - a hidden page stops the poll and a visible one reads again at once
  error: |-
    a hidden page does not read the store again
    2 !== 1
  expected: 1
  actual: 2
# tests 545
# pass 544
# fail 1

After the fix, the same command: # tests 545 / # pass 545 / # fail 0.

Fix

  • pollWhileVisible(fn, ms) (+30/−3): a hidden page arms no interval at all, not one whose tick would be dropped; on visibilitychange back to visible the interval is cleared and re-armed and then read once at once — keeping the old interval would carry the time it had already burned, so the next read would land early instead of a full ms after the page came back; the cleanup removes both the listener and the timer.
  • The stage effect now returns that cleanup instead of owning setInterval/clearInterval. One read per tick, the failed-read retry and the read-only write suppression (#2222) are unchanged, and the visible cadence stays 2000 ms.
  • docs/subsystems/workflow.md client row records the rule; changelog.d/3361.fixed.md is the user-visible entry.

Ran

  • TZ=UTC npm --prefix plugins/workflow test → 545 tests, 545 pass, 0 fail, 0 skipped (exit 0), at this tip's tree.
  • Red first: the same command before the fix → 545 tests, 544 pass, 1 fail, original above.
  • node scripts/lint-plugins.mjs workflow → 16 warnings, 0 errors (the baseline count; the new test adds no warning).
  • node .github/scripts/changelog.mjs check → fragments well formed; node core/scripts/check-arch-docs.mjs with ARCH_DOCS_BASE=bab1fe96 → OK (4 changed files).

Not run / environment

  • TZ=UTC npm run verify exits 1 at the core suite on one test, core/test/bench-preflight.test.js:88 bench.sh shows a failed pnpm install and leaves no half-built profile, reporting mkdir: not found from bench.sh:91. Host layout, not this diff: pnpm and mkdir both live in /usr/bin, and the fixture at :119 drops every PATH directory whose name contains pnpm, mkdir included — the same test fails on the base with the change stashed. Every step before the core suite is green (core lint 0 errors, arch-docs OK, plugin lint 0 errors, build-client --check, ds-bot-patches check + canonical).
  • No UI face: the change is when a poll runs, not what the panel draws, so there are no before/after screenshots.

Tier: T2 (plugins/** per .github/agent/risk-rules.json) — risk-tier: T2. No UI face.

Checkpoint

{
  "pr": 3365, "claim": "Dev-5", "issue": 3361,
  "summary": "The Workflow stage polled `workflow/state` every 2 s from a window nobody was looking at, and coming back showed rows up to 2 s stale. The poll now arms no interval at all while the page is hidden, clears and re-arms it when the page becomes visible again, and reads once at once at that moment. One read per tick, the failed-read retry and the read-only write suppression are unchanged, the visible cadence stays 2000 ms, and unloading removes both the timer and the listener.",
  "files": ["plugins/workflow/client.js", "plugins/workflow/test/client.test.js", "docs/subsystems/workflow.md", "changelog.d/3361.fixed.md"],
  "checks": { "ran": "TZ=UTC npm --prefix plugins/workflow test; node scripts/lint-plugins.mjs workflow; node core/scripts/check-arch-docs.mjs", "result": "green", "at": "bd5818c2105e51b611ac7f55c1bba5e8bf148829" },
  "next": "none — ready for review"
}

@HugoXK

HugoXK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Fixes #3361, base bab1fe963b65913f5cd1021d30e6598a7f571627 (= live main), 4 files +84/−4, maintainer_can_modify: true, non-draft.

At that exact tip: 18 checks = 15 success + 2 skipped (live · real model, window check) + 1 failure — the only red is enqueue-guard (no Verifier report names the tip bd5818c2105e), which is exactly what this request clears. Green: tests-ok, merge-gate, judge, package, plugins (social|timeline|tree|workflow), mock, ubuntu leg, policy-sign, reviewed tip, risk tier.

What it changes, in one line: the Workflow stage armed its 2 s workflow/state store poll as a bare setInterval (plugins/workflow/client.js:2197), so a hidden window kept reading and a tab that came back waited out the tick; it now goes through pollWhileVisible — hidden arms no timer, returning reads once at once and re-arms, cleanup clears timer and listener.

Red-first evidence in the body: plugins/workflow/test/client.test.js is 545 tests / 544 pass / 1 fail before the fix (a hidden page does not read the store again, expected 1 actual 2), 545/545/0 after; lint-plugins workflow 16 warnings / 0 errors (baseline); arch-docs OK (4).

@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy: review request for #3365 at tip bd5818c (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

FlyBot 2.0 audit (2026-11-25), read-only. This PR has no 2.0 landing point, so it was not repackaged; it stays open as the v1.0 record. Nothing was closed, retargeted or merged — the owner decides.

It changes plugins/workflow/** + docs: 0 of 4 paths exist at 2.0 main. The workflow plugin is deliberately not imported (docs/upstream/OPTIONAL-PLUGINS.md:22), and the nearest 2.0 concept, features/team-runs, is a server-side DAG over native turns — not a client board with a 2-second store poll, so the fixed timer has no counterpart.

Evidence: FLYBOT_2.0_PR_AUDIT_RESULT.md (owner report, 2026-11-25).

@Birfy

Birfy commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

基于已退役布局关闭(关闭原因,非验收结论)

  • main 锚点:d8898cad(2026-11-25T12:20:16Z,2156 blobs)
  • head:bd5818c2105e51b611ac7f55c1bba5e8bf148829,base 未固定
  • 该 PR 改动文件在 main d8898cad 上存在 0 个(git cat-file 逐条核)
  • Release FlyBot 0.3.0 with the OpenTeamily workspace #3377(FlyBot 0.3.0,2026-11-25T01:29Z)移除了 core/ plugins/ policy/ patches/ .github/agent/ .github/scripts/ workflows/test.yml
  • 结论:重构前血缘的切片,无法在当前 main 上评审或 rebase 复用;本 PR 从未在当前线上被评审或验证

@Birfy

Birfy commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

基于已退役布局关闭(关闭原因,非验收结论)

  • main 锚点:d8898cad(2026-11-25T12:20:16Z,2156 blobs)
  • head:bd5818c2105e51b611ac7f55c1bba5e8bf148829,base 未固定
  • 该 PR 改动文件在 main d8898cad 上存在 0 个(git cat-file 逐条核)
  • Release FlyBot 0.3.0 with the OpenTeamily workspace #3377(FlyBot 0.3.0,2026-11-25T01:29Z)移除了 core/ plugins/ policy/ patches/ .github/agent/ .github/scripts/ workflows/test.yml
  • 结论:重构前血缘的切片,无法在当前 main 上评审或 rebase 复用;本 PR 从未在当前线上被评审或验证

@Birfy Birfy closed this Nov 25, 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.

workflow: a hidden window keeps the stage's 2 s store poll, and coming back waits for a tick

2 participants