GeezerVison is showing github.com — id(web): peers auto-refresh nests a duplicate #peers-content — /api/peers returns the full page wrapper, but fetchPartial assigns it as innerHTML · Issue #6956 · developing-today/code
id(web): peers auto-refresh nests a duplicate #peers-content — /api/peers returns the full page wrapper, but fetchPartial assigns it as innerHTML #6956Descriptionid(web): peers auto-refresh nests a duplicate #peers-content — /api/peers returns the full page wrapper, but fetchPartial assigns it as innerHTML
Problem
The peers page auto-refreshes every 10 seconds, and every refresh leaves the DOM with two elements carrying id="peers-content" (and two [data-auto-refresh] elements), nested inside each other. The partial-response contract is mismatched between the server and the client:
pkgs/id/src/web/templates.rs — render_peers (line 1101) renders the whole peers block, starting with the wrapper itself (line 1103):
html.push_str("<div id=\"peers-content\" data-auto-refresh=\"10\">\n");
pkgs/id/src/web/routes.rs — the same render_peers is used for the full page (peers_handler, line 719) and for the partial endpoint (peers_partial_handler, line 1058: Html(render_peers(&peers_data))), even though that handler's own doc comment (line 1038) says it "Returns just the peers content fragment for replacing #peers-content".
pkgs/id/web/src/main.ts — initPeersAutoRefresh (lines 571–585) polls with fetchPartial("/api/peers", "#peers-content").
pkgs/id/web/src/navigation.ts — fetchPartial applies the response as target.innerHTML = html, i.e. the response must be the target's inner content only.
So each tick inserts a fresh <div id="peers-content" data-auto-refresh="10">…</div> inside the existing #peers-content. The file-list partial gets this contract right and is the pattern to follow: the full page wraps render_file_list_content in #file-list-content (templates.rs lines 225–227), while files_list_handler returns only render_file_list_content — "just the inner content (list + pagination) for partial replacement" (routes.rs, files_list_handler).
Evidence
Verified this run on the laptop against origin/main @ 4adffb688e, probe ~/git/fleet/probe-peers-partial (real navigation.ts copied verbatim, md5 ff08399b58cdfa0c9ce1b10bbf076f54 matching the repo file; happy-dom; fetch stubbed to return the exact render_peers(&[]) output transcribed from templates.rs; two fetchPartial("/api/peers", "#peers-content") calls simulating two auto-refresh ticks):
| State |
#peers-content elements |
[data-auto-refresh] elements |
| Initial page load |
1 |
1 |
| After tick 1 |
2 (outer contains a nested #peers-content descendant) |
2 |
| After tick 2 |
2 (stable — querySelector keeps hitting the outer element by document order, so the stale outer wrapper is never replaced) |
2 |
| Control: file-list partial (inner-only response) |
1, content replaced correctly |
— |
Why it matters
- Duplicate IDs are invalid HTML and make every
#peers-content lookup ambiguous. Today querySelector/getElementById happen to return the outer element first, so the page looks fine — that is document-order luck, not a contract. Anything that ever targets the inner (live) copy, or assumes uniqueness, breaks silently.
- The e2e suite is one tick away from a strict-mode failure:
pkgs/id/e2e/tests/navigation.spec.ts ("peers page has auto-refresh attribute") uses page.locator("#peers-content") with toHaveAttribute("data-auto-refresh", "10") — a Playwright locator that resolves to two elements once a 10-second tick has landed fails strict mode, so the test is timing-flaky by construction.
- The stale outer wrapper shadows the partial's own attributes:
initPeersAutoRefresh reads the interval from document.querySelector("[data-auto-refresh]") — the outer, first-render element. If the server ever changes what render_peers emits on that wrapper (interval, attributes), already-loaded pages keep reading the stale outer copy while the refreshed content carries a dead duplicate.
- The nested wrapper also adds a spurious DOM level (wrapper inside wrapper) around the card on every refreshed page, diverging the refreshed DOM from the first-render DOM that templates tests and e2e selectors were written against.
Acceptance criteria
-
GET /api/peers returns only the inner content of #peers-content (no <div id="peers-content"> wrapper, no data-auto-refresh attribute in the partial body) — e.g. split render_peers into an inner renderer plus the wrapper, mirroring render_file_list / render_file_list_content.
- The full peers page (
GET /peers, including its SPA partial form) still renders exactly one #peers-content element with data-auto-refresh="10", and the existing template tests still pass.
- After any number of auto-refresh ticks, the DOM contains exactly one
#peers-content and one [data-auto-refresh] element, with the peer rows updated in place.
- A regression test pins the contract: a Rust test that the partial handler's body does not contain
id="peers-content", and/or a web test (navigation.test.ts style, using the real partial shape) asserting the element count stays 1 across repeated fetchPartial("/api/peers", "#peers-content") swaps.
Activitydeveloping-today commented on Nov 7, 2026 added kind/bugSomething isn't working (prefixed form of the classic bug label) task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests app/idPackage/app: id (pkgs/ or apps/ in this repo) effort/sSmall: expected under 2 hours of work on Nov 7, 2026dezren39 commented on Nov 7, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (lane A, new-issue-creator-code-a)
- Session / ID: cron new-issue-creator-code-a, run 2026-11-07 15:05 CST
- Found via: filed this run
- Task: Stop the peers auto-refresh from nesting a duplicate #peers-content — split render_peers into an inner renderer for the /api/peers partial, mirroring render_file_list_content.
- Expectation: effort s; done when the acceptance criteria on issue id(web): peers auto-refresh nests a duplicate #peers-content — /api/peers returns the full page wrapper, but fetchPartial assigns it as innerHTML #6956 pass, including a regression test pinning that the partial body carries no #peers-content wrapper and the DOM keeps exactly one such element across ticks.
- Links: probe
~/git/fleet/probe-peers-partial (laptop); pattern precedent: files_list_handler / render_file_list_content in the same files
dezren39 commented on Nov 8, 2026 🤖 Agent note · parked (correction)
dezren39 commented on Nov 8, 2026 🤖 Agent note · correction
- Agent: queue worker (repo-worker-code), lane code-f
- Session / ID: task 11343
- Found via: queue claim (this lane's claim; the task has since been parked by the concurrent OpenChamber scheduled lane)
- Task: Correction to the parked note on issue id(web): peers auto-refresh nests a duplicate #peers-content — /api/peers returns the full page wrapper, but fetchPartial assigns it as innerHTML #6956: PR fix(id): peers partial returns inner content only (#6956) #7050 is NOT a Drew-owned PR — it was opened by lane code-f this shift as the task 11343 fix (all fleet PRs carry the dezren39 author token). Commit b9be1c8 is PR fix(id): peers partial returns inner content only (#6956) #7050's head on branch queue/11343-6956-peers-inner, NOT current main; main does not yet contain the render_peers split. The fix: render_peers split into render_peers + render_peers_content, peers_partial_handler returns the inner renderer only, plus two regression tests (test_render_peers_content_has_no_wrapper, test_render_peers_wrapper_exactly_once). Codex review on PR fix(id): peers partial returns inner content only (#6956) #7050 completed with no findings; basic CI was still QUEUED (fleet-wide stall) at last check; a laptop cargo test run did not finish compiling the id crate within 540s (warnings only, no result), so targeted-test verification rests with CI.
- Expectation: on resume, treat PR fix(id): peers partial returns inner content only (#6956) #7050 as a normal fleet PR: check CI, merge when green/verified, then complete task 11343 — do not re-park it as Drew-owned.
- Links: task 11343; issue id(web): peers auto-refresh nests a duplicate #peers-content — /api/peers returns the full page wrapper, but fetchPartial assigns it as innerHTML #6956; PR fix(id): peers partial returns inner content only (#6956) #7050
dezren39 commented on Nov 9, 2026 agent-note:v1 -- task 11343 completed by lane code-u (2026-11-09): resumed the canonical PR #7050 (branch queue/11343-6956-peers-inner) from the prior attempt instead of duplicating it. Verified fresh: PR diff is exactly the render_peers_content split + peers_partial_handler inner-only change with regression tests; no hard-stop labels; no Codex findings. Targeted tests on the laptop: cargo test --features web test_render_peers -- 4 passed (incl. new test_render_peers_content_has_no_wrapper and test_render_peers_wrapper_exactly_once). Merged PR #7050 (merge commit 7242351); issue auto-closed; render_peers_content confirmed at main head.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|