Younes Beriane 026b6e172c
fix(design): keep icon generator from corrupting SVGs or truncating output (#526)
* fix(design): keep icon generator from corrupting SVGs or truncating output

apply_viewbox_size rewrote every width/height attribute in the document,
including stroke-width and child elements, and only handled double quotes.
Restrict it to the root <svg> tag and set width and height independently.

generate_icon capped output at 4096 tokens, which truncates detailed icons.
Raise it to 16384 and report finish_reason MAX_TOKENS separately from
empty or malformed output.

Fixes #525

* fix(design): apply the response guard and MAX_TOKENS diagnosis to icon batch

generate_batch still indexed candidates[0].content.parts unguarded and
printed a bare "No valid SVGs generated." Share the response-text
extraction and the no-SVG diagnosis with generate_icon, treat text=None
as an empty response, and warn when a batch is cut off at MAX_TOKENS
after returning fewer icons than requested.

Refs #525

* fix(design): match only real root attributes when sizing icon SVGs

_set_root_attr searched the root tag with a regex, so width= or height=
text inside another quoted attribute value (aria-label="height='2'") was
rewritten and the output stopped being valid XML. Walk the tag's
attributes instead, consuming each quoted value whole, and only replace
an attribute whose name is exactly width or height.

Refs #525
2026-10-12 12:05:52 +07:00
..