Skip to content

Web UI as Preact components (vendored, no build step) - #22

Merged
Harted merged 6 commits into
mainfrom
ui-preact-targets
Sep 30, 2026
Merged

Harted merged 6 commits into
mainfrom
ui-preact-targets

Conversation

@Harted

@Harted Harted commented Sep 30, 2026

Copy link
Copy Markdown
Member

Every page of the web UI is now Preact components written with htm. Both are vendored in src/web/ui/js/vendor/, so there is still no bundler: cargo build stays the only step.

Why: the old UI rendered innerHTML strings from a global state and restored focus and scroll by hand. Every refresh could disturb what was being typed.

What changes for a user

  • The pages look the same.
  • A refresh no longer disturbs typing: Targets keeps refreshing the status while a target is edited, and the audit trail's Live mode leaves the filters alone.
  • Leaving a page drops an unsaved edit.
  • Fixed: the target name's pattern was invalid, so browsers skipped the check.
  • Fixed: the Account page said HTTPS for MCP could be turned on under Settings; it now names the config file.

For developers

  • vdom.js lists what htm does differently from HTML (closed <input />, spaces at line ends, entities).
  • CLAUDE.md: vendored files also go into SCRIPTS.
  • .vscode/extensions.json recommends lit-html, which highlights the templates.

Checked

  • Side-by-side headless Chrome against main (normalised page text) and an interaction script.
  • Tried by hand.
  • cargo test 128/128.

The Targets page is a set of Preact components written with htm instead of
JSX. What is edited lives in the page's useState and the form's fields are
controlled by it, so the periodic refresh no longer has to pause while a
target is edited. The other pages stay string views; main.js draws either.

Preact, its hooks and htm are vendored unchanged in js/vendor/ (about 7 kB
gzipped). vdom.js binds them to the UI: the html tag, Raw for string markup
inside a component, safe for request handlers, Fold.

The name field's pattern was invalid (a lost escape in the template), so
browsers skipped it; it works now.

Claude-Session: https://claude.ai/code/session_01CQDJE2yLKsp2t1WtNgWryv
A target deleted or renamed while it is edited drops the edit, instead of
hiding the form and the Add and Edit buttons. "Check now" is enabled again
even if the status cannot be read. Raw escapes anything that is not html
output.

Claude-Session: https://claude.ai/code/session_01CQDJE2yLKsp2t1WtNgWryv
The whole UI is now one Preact tree drawn from the shared state; redraw()
diffs it into the page. The string views, html.js, Raw, the data-action and
data-form delegation and the focus and scroll restoring are gone. Forms that
are not controlled take their start values with defaultValue, so a refresh
never touches what is typed; dialogs are drawn with Preact too.

The pages look the same (compared with main in headless Chrome, page by
page). The screenshot tool selects by role and text instead of data-action.

Claude-Session: https://claude.ai/code/session_01CQDJE2yLKsp2t1WtNgWryv
@Harted
Harted merged commit af834fa into main Sep 30, 2026
9 checks passed
@Harted
Harted deleted the ui-preact-targets branch September 30, 2026 22:16
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