From b4b4967ec9850d206371d67a1706e42bd9e1afb3 Mon Sep 17 00:00:00 2001 From: iris Date: Sun, 16 Aug 2026 17:16:27 +0200 Subject: [PATCH] address review: trim JobqGraph.tsx's comment under 30 lines, fix stale .jsx ref Both introduced by this PR's own JSX->TSX conversion, caught by argus: the top-of-file comment grew to 42 lines converting it, and JobsPage.css still pointed at 'JobqGraph.jsx's own comment' after the rename. --- .../shared/src/jobq-graph/JobqGraph.tsx | 48 +++++++------------ .../packages/swarm-ui/src/pages/JobsPage.css | 2 +- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/frontend/packages/shared/src/jobq-graph/JobqGraph.tsx b/frontend/packages/shared/src/jobq-graph/JobqGraph.tsx index bc635509..3c549f83 100644 --- a/frontend/packages/shared/src/jobq-graph/JobqGraph.tsx +++ b/frontend/packages/shared/src/jobq-graph/JobqGraph.tsx @@ -5,41 +5,29 @@ // hand). Renders an indented state tree: `payload.label` verbatim, // `payload.data` as a generic key/value list. Light DOM, shared by the // dashboard and swarm-ui — both esbuild configs run `jsx: 'automatic', -// jsxImportSource: 'preact'`, and esbuild transpiles `.tsx` (types -// stripped, not checked) the same way regardless of whether the -// consuming package runs `tsc` itself — swarm-ui does (`npm run -// typecheck`), dashboard doesn't, both build clean off the same file. -// -// Real TypeScript rather than a hand-maintained ambient `.d.ts` at each -// TS consumer: a `declare module` block duplicates the prop list and -// drifts the moment this file's signature changes without the -// declaration being touched. Typing the source once means every -// consumer's typecheck is checking the real shape, not a copy of it. +// jsxImportSource: 'preact'` and transpile `.tsx` (types stripped, not +// checked) the same way regardless of whether the consumer runs `tsc` +// itself — swarm-ui does (`npm run typecheck`), dashboard doesn't, both +// build clean off this one file. Real TypeScript rather than a hand- +// maintained ambient `.d.ts` at each TS consumer, which would duplicate +// the prop list and drift the moment this file's signature changes. // // `cancellable` adds a per-node cancel button calling `onCancel(id)` -// directly (a plain prop). `onUpdate(nodes)` fires after every fetch, -// for a host needing the raw list (a count badge, a live-log panel) -// without its own parallel fetch. +// directly. `onUpdate(nodes)` fires after every fetch, for a host +// needing the raw list (a count badge, a live-log panel) without its +// own parallel fetch. // -// Two ways to use this: JSX (swarm-ui, or any future dashboard page -// that renders it directly) — ``, a normal component. Or imperative -// mount (dashboard/src/builds.js, which stays plain `.js` — a `.tsx` -// call site still needs a JSX-aware file, mounting doesn't) — -// `mountJobqGraph(container, props)` returns a `{ refresh(), -// update(props) }` handle. +// Two ways to use this: JSX (swarm-ui, or any dashboard page that +// renders it directly) — ``. Or imperative mount +// (dashboard/src/builds.js, plain `.js` — mounting needs no JSX pragma) +// — `mountJobqGraph(container, props)` returns `{ refresh(), update(props) }`. // // Styles live in `@hive/shared/jobq-graph.css`, `@import`ed from a -// page/component CSS file rather than imported here. This one stays -// necessary regardless of the JSX/TS question above: dashboard bundles -// every page entry (including this component, pulled in transitively) -// through one esbuild call whose `.css` loader is `text` — a handful of -// shadow-DOM components (modal.js, hive-btn.js) need their CSS as a -// literal string to inject into a shadow root, and esbuild's loader map -// is global per call, not per-module. Importing `.css` here would -// silently pick up that `text` loader too and bind a useless string -// instead of applying styles, so this file imports no CSS at all; -// each consumer's own page/component CSS `@import`s it instead. +// page/component CSS file rather than imported here — dashboard bundles +// this component transitively through an esbuild call whose `.css` +// loader is `text` (for unrelated shadow-DOM components' CSS-as-string +// needs), and that loader is global per call, not per-module. import { h, render } from 'preact'; import { useState, useEffect, useCallback } from 'preact/hooks'; diff --git a/frontend/packages/swarm-ui/src/pages/JobsPage.css b/frontend/packages/swarm-ui/src/pages/JobsPage.css index c9e89ff0..beb79c0a 100644 --- a/frontend/packages/swarm-ui/src/pages/JobsPage.css +++ b/frontend/packages/swarm-ui/src/pages/JobsPage.css @@ -2,6 +2,6 @@ swarm-controller's own /api/jobq/graph endpoint (same wire shape hive-c0re's dashboard consumes, see hive-jobq-wire's README). Styles are @hive/shared's jobq-graph.css, @import'ed here rather than from - the component file itself — see JobqGraph.jsx's own comment for why + the component file itself — see JobqGraph.tsx's own comment for why that split exists (esbuild's loader map is global per bundle call). */ @import "@hive/shared/jobq-graph.css";