drop the mountJobqRollup wrapper, render(h(...)) directly

mara, on review: expected the plain Preact pattern (render(h(Widget,
props), container), call again to update) rather than a custom
mountX() returning {refresh(), update()}. Preact's own render is
already the re-render/diff entry point, so the wrapper was indirection
this component didn't need - swarm.js (plain .js, no JSX pragma
required for h()/render() either) now calls render(h(JobqRollup,
{...refreshToken}), root) directly, bumping a module-level token to
force a refetch instead of holding a mount handle.

JobqGraph/mountJobqGraph (a separate, already-merged component) is
untouched - out of scope for this PR, flagged as a possible follow-up
if she wants the same simplification there.

Re-verified: npm run build (whole workspace) + swarm-ui typecheck
clean, comment-block + issue-ref lints clean, re-screenshotted the
dashboard SW4RM tab against the same mocked payload - identical
render, spinner now visibly mid-rotation in the frame (confirms the
animation is live, not just present in markup).
This commit is contained in:
iris 2026-08-16 21:47:11 +02:00 committed by mara
commit 5c9d89dc64
2 changed files with 23 additions and 38 deletions

View file

@ -18,17 +18,16 @@
// /builds.html; swarm-ui's /jobs page omits it — a link to the page
// you're already on is noise).
//
// The glyph carries `.spinner` (`@hive/shared/base.css`, already
// imported by both consumers) for the "actively happening" spin —
// not redeclared in jobq-rollup.css, since a static screenshot can't
// tell a frozen spinner from a missing one; caught by argus's review.
// The glyph carries `.spinner` (`@hive/shared/base.css`, imported by
// both consumers) for the "actively happening" spin — a static
// screenshot can't tell a frozen spinner from a missing one.
//
// Two ways to use this, same shape as JobqGraph: JSX (swarm-ui) —
// `<JobqRollup endpoint="..." queueHref="..." />`. Or imperative mount
// (dashboard/src/swarm.js, plain `.js`) — `mountJobqRollup(container,
// props)` returns `{ refresh(), update(props) }`.
// JSX (swarm-ui) — `<JobqRollup endpoint="..." queueHref="..." />`. Or
// plain `render(h(JobqRollup, props), container)` (dashboard/src/
// swarm.js, no JSX pragma needed) — call again with a bumped
// `refreshToken` to force a refetch. No mount wrapper: `render` is
// already the re-render/diff entry point.
import { h, render } from 'preact';
import { useState, useEffect } from 'preact/hooks';
// Mirrors `hive_jobq_wire::StateSchema` — only the subset this banner
@ -89,17 +88,3 @@ export function JobqRollup({ endpoint, queueHref, refreshToken = 0 }: JobqRollup
</div>
);
}
// Imperative mount helper — same shape as `mountJobqGraph`. Returns
// `.refresh()` (bump the refresh token, re-fetch) and `.update(props)`
// (merge new props and re-render).
export function mountJobqRollup(container: Element, initialProps: JobqRollupProps) {
let props = initialProps;
let token = 0;
const draw = () => render(h(JobqRollup, { ...props, refreshToken: token }), container);
draw();
return {
refresh() { token += 1; draw(); },
update(next: Partial<JobqRollupProps>) { props = { ...props, ...next }; draw(); },
};
}