From b6a4d20cd962c7b0a966dace3b72e4eabee60b45 Mon Sep 17 00:00:00 2001 From: GeneAI Date: Sun, 14 Jun 2026 19:45:30 -0400 Subject: [PATCH 1/3] =?UTF-8?q?docs(specs):=20living-docs-poller-testing?= =?UTF-8?q?=20=E2=80=94=20Phase=201=20requirements=20(draft)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-on to dashboard-js-testing. Scope: extract + Vitest-test the Living Docs poll state machine (shouldKeepPolling / scheduling) using the approved no-build ES-module pattern. Behavior-preserving; no API change. The Jinja↔JS badge/action mapping duplication is noted but explicitly deferred to its own follow-up spec (needs an API-payload decision). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../requirements.md | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 specs/living-docs-poller-testing/requirements.md diff --git a/specs/living-docs-poller-testing/requirements.md b/specs/living-docs-poller-testing/requirements.md new file mode 100644 index 0000000..542bd9b --- /dev/null +++ b/specs/living-docs-poller-testing/requirements.md @@ -0,0 +1,125 @@ +# Spec: Testable Living Docs poll state machine + +> Single-layer feature (attune-gui). Follow-on to +> [`dashboard-js-testing`](../dashboard-js-testing/) — reuses its +> approved no-build ES-module + Vitest pattern (build strategy and test +> runner are already settled there; this spec does not re-litigate them). + +--- + +## Phase 1: Requirements + +**Status**: draft + +### Problem statement + +The Living Docs page polls `/api/living-docs/rows` while any document is +regenerating +([`living_docs.html`](attune-gui/sidecar/attune_gui/templates/living_docs.html), +`{% block scripts %}`). The poller — `_startPoll` / `_stopPoll` / +`_scheduleNextPoll` / `_poll` — is a recursive-`setTimeout` state machine +that must: + +- **stop** once no row is `regenerating` + ([`:200`](attune-gui/sidecar/attune_gui/templates/living_docs.html)), +- **pause** on a hidden tab and resume on `visibilitychange`, +- keep going on a transient fetch error (don't give up mid-regeneration). + +This is exactly the kind of decision logic that breaks silently — polls +forever, stops too early, or hammers a backgrounded tab — and it is +**untested**. It's the next-richest untested inline block after the batch +panel, and migrating it applies the pattern established in +`dashboard-js-testing`. + +### Scope + +**In scope:** + +- **Extract the poll decision logic** into a `static_cw/*.js` ES module — + the pure parts: `shouldKeepPolling(rows)` (stop when none regenerating) + and any next-delay helper. The module is DOM-free / timer-free so + Vitest imports it in Node. +- **Vitest coverage** for the extracted logic, run by the existing + `frontend (Vitest)` CI job (the include glob from + `dashboard-js-testing`). +- **Shrink the inline script** to a `