icon: Support SVG bytes in component icon slots - #2980
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2961
Description
Custom SVG bytes can now be passed to existing component icon slots with
Icon::data(&[u8]), without registering an asset path. The last.path()or.data()call selects the source, and existingIconNamedimplementations and component conversion APIs remain compatible.Icon sources and transformations are stored as cloneable configuration shared by both render paths. Native menus on macOS and Windows also resolve byte-backed icons. The change includes focused regression tests, Icon and NativeMenu Story examples, and English/Chinese documentation.
Screenshot
No screenshots attached. The macOS Icon Story was checked in a real window: byte-backed icons, rotated clones and entity views, custom loading icons, and button/dropdown-menu feedback. The new native-menu item was opened and selected; its OS popup image was not captured by the screenshot tool.
Breaking Changes
None. This is an additive API; existing path-based usage remains supported. Applications may opt into embedded bytes:
datacopies its input into shared storage, and cloning anIconshares those bytes. GPUI may copy the data again during rendering; this does not promise zero-copy rendering or binary-size savings.How to Test
Passed locally on macOS:
cargo test --locked --workspace --exclude gpui-shell --features gpui-component-story/test-supportcargo test --locked -p gpui-component --doc(3 passed, 30 ignored)cargo test --locked -p gpui-component --lib icon(18 passed)git diff --check.To inspect the examples, run
cargo run --locked -p gpui-component-story -- Icon, then open NativeMenu and selectSearch (SVG bytes).Windows/Linux runtime checks and the full website build have not been run locally and remain for CI/maintainer validation.
AI Assistance
Codex assisted with the implementation, regression tests, Story examples, documentation, and this PR description. Automated checks and agent-driven UI checks are reported above; human review and testing remain for the contributor/maintainers.
Checklist
cargo runfor the related Story examples on macOS.