feat(chat-theme): expand Chat UI customization#240
Draft
RachelForster wants to merge 6 commits into
Draft
Conversation
| "kind": _theme_asset_kind(asset), | ||
| "name": asset.name, | ||
| "path": relative, | ||
| "size": asset.stat().st_size, |
| if _read_manifest(theme_dir) is None: | ||
| raise FileNotFoundError(f"主题不存在或无效:{safe_id}") | ||
| rows = [] | ||
| for asset in theme_dir.rglob("*"): |
| raise ValueError("单个主题资源不能超过 16 MiB") | ||
|
|
||
| assets_dir = safe_child_path(theme_dir, "assets") | ||
| assets_dir.mkdir(parents=True, exist_ok=True) |
| filename = f"{stem}{suffix}" | ||
| destination = safe_child_path(assets_dir, filename) | ||
| counter = 2 | ||
| while destination.exists(): |
| while destination.exists(): | ||
| destination = safe_child_path(assets_dir, f"{stem}-{counter}{suffix}") | ||
| counter += 1 | ||
| shutil.copy2(source, destination) |
| if _manifest_references_asset(manifest, asset_path): | ||
| raise ValueError("该资源仍被主题引用,请先清除对应字段并保存主题") | ||
| target = safe_child_path(theme_dir, asset_path) | ||
| if not target.is_file(): |
| target = safe_child_path(theme_dir, asset_path) | ||
| if not target.is_file(): | ||
| raise FileNotFoundError(f"主题资源不存在:{asset_path}") | ||
| target.unlink() |
| raise FileNotFoundError(f"主题资源不存在:{asset_path}") | ||
| target.unlink() | ||
| parent = target.parent | ||
| while parent != theme_dir and parent.is_dir() and not any(parent.iterdir()): |
| target.unlink() | ||
| parent = target.parent | ||
| while parent != theme_dir and parent.is_dir() and not any(parent.iterdir()): | ||
| parent.rmdir() |
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.
Summary
Why
The existing Chat UI customization flow exposed only part of the theme model and did not provide a safe extension surface for plugins. This change makes the full theme schema editable, adds production-grade asset and preview workflows, and keeps plugin UI rendering under host control.
User and developer impact
Users can build, preview, diagnose, save, and export substantially richer Chat themes. Plugin authors can contribute safe Chat actions and output cards without injecting arbitrary HTML, JavaScript, React nodes, or CSS.
Validation