fix(ai): name stripped scripts and head-only elements in HTML import results - #493
Draft
DavidBabinec wants to merge 1 commit into
Draft
fix(ai): name stripped scripts and head-only elements in HTML import results#493DavidBabinec wants to merge 1 commit into
DavidBabinec wants to merge 1 commit into
Conversation
…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.
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.
Refs #490
The bug
Two of the report's findings are about silence, not breakage. A bare
<link rel="icon">handed tosite_insert_htmlcame back as "HTML contained no importable elements" with no hint why: the browser parser places it in<head>, which the walker never visits. Andsite_replace_node_htmlgiven 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
importHtmlnow returnsheadOnly, the tag names the parser placed in<head>. Both HTML tools report stripped and ignored constructs as sentences inwarningsnext 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 saywarningsexists so a model reads it.Verification
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.