Skip to content

v0.3.6: opt-in, capped create preview (#20)#21

Merged
JLay2026 merged 11 commits into
mainfrom
feat/optional-preview
Jun 12, 2026
Merged

v0.3.6: opt-in, capped create preview (#20)#21
JLay2026 merged 11 commits into
mainfrom
feat/optional-preview

Conversation

@digispark-bot

Copy link
Copy Markdown
Collaborator

Theme 4 (validated quality). Resolves #20. Fixes the oversized auto-preview that overflowed the client response budget on every create_model (you hit it again on 0.3.5).

Root cause

_do_create() unconditionally rendered a full 800×600 iso PNG and embedded it as inline base64 (preview_data_b64) in every create/modify/load result — ~75–150 KB → ~25 K+ tokens. Non-blocking (the model registered fine) but it overflowed/cluttered the response for no benefit, and it never went through the v0.3.5 file-delivery machinery.

What changed (src/mcp_transport.py)

  1. Preview is opt-in, default off. New include_preview: bool = False on create_model / modify_model / load_design. Default response is just success + geometry + stdout (tiny).
  2. When requested, it's downscaled + capped. Rendered at 384×288, gated behind PARTSMITH_PREVIEW_INLINE_MAX (default 48 KB); over the cap → bytes dropped + preview_note pointing at partsmith_render_3d. Inline previews carry preview_size_bytes + preview_sha256 (parity with the v0.3.5 contract).

Decisions / scope

  • Default-off inverts prior behavior — but the always-on full preview is the bug. Most creates are followed by measure or an explicit render; visuals are now a deliberate, bounded request.
  • REST create_model left unchanged — HTTP clients aren't subject to the chat token cap.
  • Migration note in the CHANGELOG: preview_data_b64 no longer appears unless include_preview=True.

Tests / verification

  • New test_create_model_preview_optional: default create carries no preview_data_b64; include_preview=True yields either a capped sha-verifiable inline preview or a preview_note — never an unbounded raw embed.
  • Updated the existing round-trip test to assert the default-no-preview contract (it previously required the auto-preview).
  • py_compile + ruff clean.

Bump 0.3.5 → 0.3.6 + CHANGELOG + ROADMAP. This closes the last unbounded inline payload (exports verifiable in #18, preview bounded here).

_do_create no longer embeds a full 800x600 iso PNG on every call.
include_preview defaults False; when True the preview is rendered at
384x288 and gated behind PARTSMITH_PREVIEW_INLINE_MAX (~48 KB), with
preview_sha256/size_bytes for parity with the v0.3.5 file contract.
Kills the last unbounded inline payload that overflowed the client
response budget.
…lure)

Rewrote pure-ASCII (dropped em-dashes/any ambiguous unicode) and
re-verified with `ruff check` under the repo's E,F,I,W + line-length 100
config. Same coverage: default-no-preview, preview opt-in (capped +
sha-verifiable), export integrity metadata, section/drawing round-trips.
Unpinned `pip install ruff` made CI nondeterministic: ruff 0.15.17
(released since the last green run) flags pre-existing code that 0.15.16
accepted, so a docs/feature PR fails lint for unrelated reasons. Pin to
the known-good version; bump deliberately in its own PR when adopting a
newer ruff + fixing whatever new rules it introduces.
The v0.3.6 push accidentally appended the heredoc delimiter as a literal
trailing line, which ruff flagged as F821 (undefined name) + W292. This
was the real CI ruff failure (not a ruff-version regression). File is
otherwise unchanged and ruff-clean.
…ot ruff

The ruff failure was F821 from a stray MCPEOF line in mcp_transport.py
(now fixed), reproduced across ruff 0.15.15/16/17 — not a version
regression. Restore the original unpinned install; pinning can be a
separate, deliberate hardening if desired.
@JLay2026 JLay2026 merged commit 3584ca0 into main Jun 12, 2026
3 checks passed
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.

create_model auto-embeds an oversized inline preview PNG (blows client token budget)

2 participants