Skip to content

fix(web): keep transparent images readable over a checkerboard canvas - #2022

Merged
wbxl2000 merged 1 commit into
mainfrom
fix/media-alpha-canvas
Jul 21, 2026
Merged

fix(web): keep transparent images readable over a checkerboard canvas#2022
wbxl2000 merged 1 commit into
mainfrom
fix/media-alpha-canvas

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Summary

  • In kimi-web, transparent images with white content vanished on light surfaces (and black-content ones on dark surfaces) across markdown inline images, tool-result media, and the FilePreview large view — e.g. a white logo on a transparent PNG was unreadable in light theme.
  • Add a shared --media-alpha-canvas checkerboard token (two mid-gray squares color-mixed from --color-bg/--color-text, each ≥3:1 against both white and black; 16px period) and paint it directly on the <img> elements on those paths. Opaque images fully cover the canvas, so their rendering is unchanged; only transparent pixels reveal it.

Details

  • apps/kimi-web/src/style.css: new --color-media-alpha-bg-1/-2 + --media-alpha-canvas tokens
  • components/chat/Markdown.vue: canvas behind .markdown-renderer img
  • components/chat/tool-calls/MediaTool.vue, components/FilePreview.vue: canvas behind .media-image / .fp-image
  • views/DesignSystemView.vue: register the new tokens
  • scripts/check-style.mjs: no-gradient-text now skips custom-property definitions (a token is never rendered text — same convention as no-hardcoded-font)

Test plan

  • Same change verified in the code-app repo in light + dark: white-text transparent PNG, black-text transparent PNG, opaque screenshot, and a rounded-corner transparent screenshot across markdown inline, tool-result inline, and FilePreview — both contents stay readable, opaque images pixel-identical
  • node apps/kimi-web/scripts/check-style.mjs — baseline unchanged (29 findings, none in the changed files)

White-on-transparent images disappeared on light surfaces and
black-on-transparent ones on dark surfaces (markdown inline images, tool
result media, and the file preview's large view). Add a shared
--media-alpha-canvas token — a checkerboard of two mid-gray squares mixed
from --color-bg/--color-text, each >=3:1 against both white and black —
and paint it directly on <img> so opaque images stay pixel-identical and
only transparent pixels reveal the canvas.

Also let check-style's no-gradient-text skip custom-property definitions
(a token is never rendered text), and register the new tokens in the
design system view.
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3b0e934

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@3b0e934
npx https://pkg.pr.new/@moonshot-ai/kimi-code@3b0e934

commit: 3b0e934

@wbxl2000
wbxl2000 merged commit 154e082 into main Jul 21, 2026
15 checks passed
@wbxl2000
wbxl2000 deleted the fix/media-alpha-canvas branch July 21, 2026 14:20
@github-actions github-actions Bot mentioned this pull request Jul 21, 2026
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.

1 participant