Skip to content

Load daisyUI and Headless UI at runtime for searchable Guild WebUI selects - #85

Merged
jatmn merged 9 commits into
mainfrom
webui-daisyui-headless-search-select
Sep 22, 2026
Merged

jatmn merged 9 commits into
mainfrom
webui-daisyui-headless-search-select

Conversation

@jatmn

@jatmn jatmn commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Guild WebUI searchable selects (server picker, rule actions, plan steps, audit event type, copy-source server) use daisyUI CSS and Headless UI Combobox loaded at runtime from jsDelivr/esm.sh (overridable via window.JMODGUARD_DAISYUI_HREF and window.JMODGUARD_ESM_BASE). Library source is not vendored in git.
  • Existing pale-blue / navy theme tokens are unchanged; daisyUI --color-* aliases map to them. Native <select> remains if the vendor runtime cannot load. Bunny/embed publication stays the three first-party files.
  • Operator copy in WEBUI, INSTALL, DEPLOY-BUNNY, UPDATES, README, AGENTS, ARCHITECTURE, and OVERHAUL states the same runtime-CDN contract.

Test plan

  • node --test scripts/frontend-state-test.mjs (pins, theme tokens, vm does not fetch CDN modules)
  • node --test scripts/frontend-warmup-test.mjs
  • node --test scripts/publish-frontend-test.mjs (still three files)
  • bash scripts/ci-preflight.sh on this head
  • Sign in locally, confirm guild picker is searchable and keeps pale-blue/navy colors
  • Disable network after load fallback: native selects still usable on a fresh load with CDN blocked
  • Confirm Storage/CDN inventory is still only index.html, app.js, style.css

Final reviewed SHA: 71a1916b585bfe62ff861de171c6e56dd37a2645

Summary by Sourcery

Enable searchable Guild WebUI selects with runtime daisyUI and Headless UI dependencies while preserving the existing theme, native fallback, and lightweight frontend distribution.

New Features:

  • Add searchable Guild WebUI selects powered by runtime-loaded Headless UI Combobox components.
  • Load pinned daisyUI styles and Headless UI dependencies from configurable runtime CDNs without vendoring them or expanding the frontend artifact set.

Bug Fixes:

  • Preserve usable native select controls when the runtime vendor dependencies cannot be loaded.

Enhancements:

  • Adopt daisyUI component styling across the dashboard while retaining the existing pale-blue and navy theme tokens.
  • Improve dashboard layout, navigation, cards, forms, tables, modals, and responsive behavior.

Deployment:

  • Document the runtime CDN configuration and keep Bunny Storage publication limited to the three first-party frontend files.

Documentation:

  • Document runtime daisyUI and Headless UI loading, CDN overrides, fallback behavior, and deployment requirements across WebUI and operational guides.

Tests:

  • Extend frontend tests to verify CDN pins, theme mappings, fallback behavior, and the unchanged three-file publication contract.

…archable without vendoring libraries or changing the pale-blue theme.
…sible input, and portal option lists so the guild picker is not clipped.
… loads.

daisyUI defines those same class names as stacked grid/flex components, which overlapped the dashboard chrome.
@jatmn jatmn self-assigned this Sep 22, 2026
…croller.

The CDN stylesheet hid :root overflow and reserved a stable gutter, and the fixed 100vh sidebar added a second scrollbar; the workspace now fills the viewport as one flex page.
…its tokens.

First-party CSS was restyling hero, stats, cards, and nav back into the old SPA look. Keep the existing colors as daisyUI theme variables and use the library's menu, navbar, stats, join, alert, and card components instead.
…n both themes.

The searchable control used a navy join button inside a nested sidebar card, which read as a foreign widget. Reuse the same select chrome as the rest of the shell.
daisyUI navbar flex-1 left the save-status overlapping the server name; space-between plus a dedicated title block keeps them apart. Appearance belongs with the account controls at the bottom of the sidebar.
@jatmn
jatmn marked this pull request as ready for review September 22, 2026 14:12

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="frontend/index.html" line_range="19-29" />
<code_context>
   document.documentElement.dataset.theme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
 }
 </script>
+<script>
+window.JMODGUARD_DAISYUI_HREF = window.JMODGUARD_DAISYUI_HREF || "https://cdn.jsdelivr.net/npm/daisyui@5.7.43/daisyui.css";
+window.JMODGUARD_ESM_BASE = window.JMODGUARD_ESM_BASE || "https://esm.sh";
+</script>
+<link rel="stylesheet" id="jmodguard-daisyui" href="https://cdn.jsdelivr.net/npm/daisyui@5.7.43/daisyui.css">
+<script>
+(function () {
+  const link = document.getElementById("jmodguard-daisyui");
+  if (link && window.JMODGUARD_DAISYUI_HREF && link.getAttribute("href") !== window.JMODGUARD_DAISYUI_HREF) {
+    link.href = window.JMODGUARD_DAISYUI_HREF;
+  }
+})();
+</script>
</code_context>
<issue_to_address>
**issue (bug_risk):** The documented daisyUI stylesheet override is applied only after the default stylesheet link has already been created and its IIFE has already run. An operator setting `window.JMODGUARD_DAISYUI_HREF` before `app.js`, as documented, but after the head section cannot replace the default stylesheet, so the configured CDN is ignored for CSS.

**Triggers:** When the override is injected in the usual page configuration location before `app.js` but after the existing head markup.

**Suggested fix:** Set the link's initial `href` from `window.JMODGUARD_DAISYUI_HREF` before creating the link, or move the override/configuration point before the stylesheet link and document that ordering explicitly.
</issue_to_address>

### Comment 2
<location path="frontend/app.js" line_range="296-299" />
<code_context>
+      import(`${esm}/react-dom@${reactV}/client?deps=react@${reactV}`),
+      import(`${esm}/@headlessui/react@${headlessV}?deps=react@${reactV},react-dom@${reactV}`),
+    ]).then(([reactMod, reactDomMod, headlessMod]) => {
+      const React = vendorModule(reactMod, ["createElement", "useState"]);
+      const ReactDOM = vendorModule(reactDomMod, ["createRoot"]);
+      const Headless = vendorModule(headlessMod, ["Combobox", "ComboboxInput", "ComboboxOptions", "ComboboxOption"]);
+      if (typeof React?.createElement !== "function" || typeof ReactDOM?.createRoot !== "function" || !Headless?.Combobox) {
+        throw new Error("vendor runtime missing Combobox exports");
+      }
</code_context>
<issue_to_address>
**issue (bug_risk):** The runtime validation checks only `Headless.Combobox`, but `makeSearchSelect` unconditionally passes `ComboboxInput`, `ComboboxOptions`, and `ComboboxOption` to `React.createElement`. A partially incompatible or incorrectly cached Headless UI override therefore throws during widget rendering while the native select remains marked as enhanced and hidden, so the fallback select is not restored.

**Triggers:** When the configured ESM host serves a Headless UI module with `Combobox` but without one of the other required Combobox exports.

**Suggested fix:** Validate every required Headless export before mounting, and attach an error boundary or synchronous render failure path that calls `restoreNativeSelect`.
</issue_to_address>

### Comment 3
<location path="frontend/app.js" line_range="286-305" />
<code_context>
+function loadSearchSelectRuntime() {
</code_context>
<issue_to_address>
**nitpick (bug_risk):** A failed runtime import is cached as a rejected `vendorRuntimePromise`, so every subsequent enhancement attempt immediately fails even if the CDN becomes reachable later. The searchable controls remain native for the rest of the page lifetime after one transient vendor-load failure, with no retry path.

**Triggers:** When the initial CDN request fails transiently and the operator later regains connectivity without reloading the page.

**Suggested fix:** Clear `vendorRuntimePromise` in the rejection path or add an explicit retry that creates a fresh import promise.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and this adds remote JavaScript dependencies from esm.sh to an authenticated admin UI, creating a new runtime trust boundary: a compromised or incorrect CDN module could read dashboard data or issue API mutations as the signed-in user. Reverting prevents future exposure, but any data disclosed or actions performed before the revert cannot be undone.

Blocking findings: frontend/index.html:29, frontend/app.js:299

Comment thread frontend/index.html Resolved
Comment thread frontend/app.js Resolved
Comment thread frontend/app.js Resolved
…ete Combobox exports.

The head IIFE never saw an override placed before app.js, and a partial Headless module could hide the native select. Fail closed before mount instead of adding CDN retry.
…box lists above modals.

A hardcoded stylesheet href still fetched jsDelivr when the override sat above the link, and portaled options sat under daisyUI modal stacking.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@jatmn
jatmn merged commit 7035684 into main Sep 22, 2026
2 checks passed
@jatmn
jatmn deleted the webui-daisyui-headless-search-select branch September 22, 2026 15:17
@jatmn jatmn mentioned this pull request Sep 22, 2026
3 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant