Skip to content

feat(ui): add bounded static SVG image and code previews - #6292

Draft
Sun-GLiang wants to merge 7 commits into
apache:mainfrom
Sun-GLiang:codex/svg-static-preview
Draft

Sun-GLiang wants to merge 7 commits into
apache:mainfrom
Sun-GLiang:codex/svg-static-preview

Conversation

@Sun-GLiang

@Sun-GLiang Sun-GLiang commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Saved SVG images and SVG code fences are unsupported by the existing image display path. Add bounded static previews for archived SVG files and completed svg / SVG-root xml blocks, including source toggling and sanitized SVG downloads.

  • Carry SVG through Host validation, Artifact storage and desktop attachment-byte IPC. Strip executable content and external dependencies before display; preserve raster-only avatar and model-image admission.
  • Use the shared session image presentation foundation, lazy parsing, viewport admission, document preview budgets, and bounded image/conversion caches. This branch alone retains the existing 2 MiB chat admission limit.
  • Bound source highlighting above 20,000 characters while retaining complete source/copy. Use the fallback consistently in lazy, deferred, rejected and source views.
  • Document the policy and limits in docs/architecture/svg-preview.zh-CN.md.

Split from #6230. This PR independently supports SVG on main and contains no ACP mixed-tool-result protocol change or durable receive-job feature. #6230 owns reception recovery and saved-original presentation.

Verification

Tested head: 4f1c86a94b6a0894c93415baeb7d49ac583d5a0c; build/test baseline: 222a06fe316f12df3129eff1c16ab3bfaf85c479.

  • Independent branch: 114 focused tests and all 35 Chromium image/SVG tests passed; full workspace typecheck, lint, changed-file format and ASF headers passed; UI and desktop rebuilt.
  • Combined with feat(media): recover image reception and publish ordered ACP results #6230: full workspace build, typecheck, lint, headers, format, renderer architecture (168 checks) and surface inventory passed. All 417 tests in changed test files and 35 Chromium image/SVG tests passed. The 276-test focused subset also passed; these counts overlap.
  • Real official Antigravity ACP 1.1.1 with the existing Google login and Gemini 3.8 Flash High created diagram.svg and returned a Markdown file image plus an XML fence. The live run verified exact archived bytes. Final independent and combined binaries replayed those same real outputs, exercised source toggling and actual sanitized download, deleted the task-owned source, fully restarted Electron and verified both previews and the original SHA-256. Eight assertions passed per replay. No new generation was requested during final replay.
  • Earlier identical foreground-scroll runs measured main p95 291.0/281.5 ms and SVG p95 68.8/58.6 ms after bounding source highlighting, versus 1,545.7/1,421.7 ms before that fix. SVG median remained higher than main; this is historical evidence, not a new benchmark or a stable-60-FPS claim. Browser regressions for source fallback and complexity limits passed again.
  • Packaged Windows/Linux applications were not tested. Adversarial SVG and long-session behavior are regression coverage, not claims about the live model output.

Governance acceptance report · Assertion records, merge simulations and checksums. Earlier before/after, desktop IPC and performance evidence remains in the acceptance release.

Actual SVG displayed after source deletion and restart

Merge independence

Both PRs target main and can land in either order. They share a behavior-preserving image presentation/admission foundation; neither requires the other feature. Normal Git merges produce identical trees in both orders. This repository permits squash merges only: after either lands, sync the other with main and reconcile packages/core/src/image-delivery.ts, packages/ui/src/attachment-image.tsx, and packages/ui/src/session-media-image.tsx. Both squash orders were simulated against main a4b5f86c5256044d063a62045754e4a3411a8426; the reconciled trees are identical and retain the tested combined implementation. There is no prescribed merge order.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex implemented the split and reception governance, added regression tests, performed real-account Electron acceptance, and updated documentation. Retain Generated-by: Codex in the squash commit.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Support archived SVG files and settled SVG/XML fences using a shared bounded sanitizer, lazy image presentation and caches. Preserve source access, sanitized downloads and raster-only model/avatar admission. This change is independent of ACP media publication and does not change the tool-result protocol.

Generated-by: Codex
@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Oct 25, 2026
Keep complete SVG source available without building an oversized syntax-token DOM in fallback, deferred, and source views.

Generated-by: Codex
Keep the existing limits and UI behavior while extracting the shared image component, retaining structured loader outcomes, and separating avatar and chat admission policies for independent media changes.

Generated-by: Codex

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant