Skip to content

fix(ai): name stripped scripts and head-only elements in HTML import results - #493

Draft
DavidBabinec wants to merge 1 commit into
mainfrom
fix/html-import-head-elements
Draft

fix(ai): name stripped scripts and head-only elements in HTML import results#493
DavidBabinec wants to merge 1 commit into
mainfrom
fix/html-import-head-elements

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

Refs #490

The bug

Two of the report's findings are about silence, not breakage. A bare <link rel="icon"> handed to site_insert_html came back as "HTML contained no importable elements" with no hint why: the browser parser places it in <head>, which the walker never visits. And site_replace_node_html given markup with a <script> inside inserted the rest and dropped the script with no trace in the result, so an agent pushing a site had no way to know its behaviour was gone.

The fix

importHtml now returns headOnly, the tag names the parser placed in <head>. Both HTML tools report stripped and ignored constructs as sentences in warnings next to the importer's existing reference warnings, and fold the same sentences into the error when nothing was importable, so the <link> case reads "Ignored <link>: these belong in the document <head>…". The paste modal's toast gains the same "ignored" detail. Tool descriptions say warnings exists so a model reads it.

Verification

bun run build   # clean
bun run lint    # clean
bun test        # 6843 pass, 0 fail

Notes

The head placement of a bare <link> is browser parser behaviour; the unit tests spell the <head> out because the test polyfill keeps a top-level <link> in the body. The new tests were run against the pre-fix source and fail there.

…results

A bare <link rel="icon"> handed to site_insert_html came back as "no
importable elements" without saying why: the browser parser places it
in <head>, which the walker never visits. A <script> inside otherwise
valid markup for site_replace_node_html vanished with no trace at all.
importHtml now reports the head-only tags it skipped, and both tools
return stripped and ignored constructs as warnings, or fold them into
the error when nothing was importable. The paste modal's toast says the
same.

The two HTML tools move into htmlTools.ts with the shared node-lookup
helpers in documentTools.ts, which keeps executor.ts under the module
size ceiling.
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