Repository navigation
Web UI as Preact components (vendored, no build step) - #22
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 buildstays the only step.Why: the old UI rendered
innerHTMLstrings from a global state and restored focus and scroll by hand. Every refresh could disturb what was being typed.What changes for a user
For developers
vdom.jslists what htm does differently from HTML (closed<input />, spaces at line ends, entities).CLAUDE.md: vendored files also go intoSCRIPTS..vscode/extensions.jsonrecommends lit-html, which highlights the templates.Checked
cargo test128/128.