Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: keep ticked check boxes when reading HTML files (#15601)

Nilayf2a1f32297c9
diff --git a/studio/backend/core/rag/parsers.py b/studio/backend/core/rag/parsers.py
index bc5542795a4..c79e409cf5f 100644
--- a/studio/backend/core/rag/parsers.py
+++ b/studio/backend/core/rag/parsers.py
@@ -269,6 +269,8 @@ class _Stripper(HTMLParser):
self._lists[-1][2].append(item)
self._label = f"\ue000{self.nonce}.{len(self.labels)}\ue001 "
self.labels.append("")
+ elif tag == "input" and (dict(attrs).get("type") or "").lower() in ("checkbox", "radio"):
+ self.handle_data(" ☒ " if "checked" in dict(attrs) else " ☐ ")
elif tag in _HTML_BOX_TAGS and not self._skip and not self._pre:
self._line.append(" ")
elif tag == "tspan" and not self._skip and any(k in ("x", "y") for k, _ in attrs):
diff --git a/studio/backend/tests/test_rag_parsing.py b/studio/backend/tests/test_rag_parsing.py
index fe3d457e831..43dd881e75a 100644
--- a/studio/backend/tests/test_rag_parsing.py
+++ b/studio/backend/tests/test_rag_parsing.py
@@ -1106,6 +1106,16 @@ def test_html_ordered_lists_keep_their_numbers(tmp_path):
)
+def test_html_check_boxes_keep_their_ticked_state(tmp_path):
+ text = _parse_html(
+ tmp_path,
+ '<ul><li><input type="checkbox" checked> Ship</li><li><input type="checkbox"> Docs</li></ul>'
+ '<ol><li><input type="checkbox" checked disabled />Test</ol>'
+ '<p>Smoker:<input type="radio" checked> Yes <input type="radio"> No <input type="text"> Age</p>',
+ )
+ assert text == "☒ Ship\n☐ Docs\n1. ☒ Test\nSmoker: ☒ Yes ☐ No Age"
+
+
def test_html_list_numbers_stay_in_their_cell(tmp_path):
text = _parse_html(tmp_path, '<table><tr><td><ol><li><img src="x"></td><td>B</td></tr></table>')
assert text == "1. | B"
diff --git a/studio/frontend/src/features/chat/attachment-content.ts b/studio/frontend/src/features/chat/attachment-content.ts
index 9adfb132a34..6107e5de2e1 100644
--- a/studio/frontend/src/features/chat/attachment-content.ts
+++ b/studio/frontend/src/features/chat/attachment-content.ts
@@ -1923,6 +1923,9 @@ function collectHtmlBlockText(
if (tag === "br") {
return "\n";
}
+ if (tag === "input" && /^(checkbox|radio)$/i.test(element.getAttribute("type") ?? "")) {
+ return element.hasAttribute("checked") ? " ☒ " : " ☐ ";
+ }
if (tag === "pre" && preformatted) {
const code = Array.from(element.childNodes)
diff --git a/studio/frontend/tests/attachment-preview-text.test.ts b/studio/frontend/tests/attachment-preview-text.test.ts
index 961e7a3b777..a73a7189146 100644
--- a/studio/frontend/tests/attachment-preview-text.test.ts
+++ b/studio/frontend/tests/attachment-preview-text.test.ts
@@ -304,6 +304,37 @@ test("extractHtmlAttachmentText keeps the line structure of the page", async ()
);
});
+test("extractHtmlAttachmentText keeps the ticked state of check boxes", async () => {
+ const input = (attrs: Record<string, string>) => ({
+ ...element("input"),
+ getAttribute: (name: string) => attrs[name] ?? null,
+ hasAttribute: (name: string) => name in attrs,
+ });
+ const extracted = await withStubDom(
+ () =>
+ element(
+ "body",
+ element(
+ "ul",
+ element("li", input({ type: "checkbox", checked: "" }), textNode("Ship")),
+ element("li", input({ type: "checkbox" }), textNode("Docs")),
+ ),
+ element(
+ "p",
+ textNode("Smoker:"),
+ input({ type: "radio", checked: "" }),
+ textNode("Yes"),
+ input({ type: "radio" }),
+ textNode("No"),
+ input({ type: "text" }),
+ ),
+ ),
+ () => extractHtmlAttachmentText("<html/>"),
+ );
+
+ assert.equal(extracted, "☒ Ship\n\n☐ Docs\n\nSmoker: ☒ Yes ☐ No");
+});
+
test("extractHtmlAttachmentText keeps the indentation of preformatted code", async () => {
const extracted = await withStubDom(
() =>