feat(spx-gui): separate generation entry#2963
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Pull request overview
Adds a separate “Generate with AI” entry point (outside the asset library results flow) and refactors asset-generation wiring so generation can be launched directly from sprite/backdrop add menus while sharing the same underlying generation + “collapse” behavior.
Changes:
- Introduce a dedicated
AssetGenModalanduseGenerateAsset()hook to launch AI generation from multiple editor entry points. - Refactor asset library generation to use shared
useAssetGen()/AssetGenCompplumbing and centralize “add asset to project” logic. - Add asset-library suggestions inside the standalone generation flow (allow picking an existing library asset instead of generating).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spx-gui/src/models/spx/common/asset.ts | Add shared addAssetToProject() helper used by modals. |
| spx-gui/src/components/editor/stage/backdrop/BackdropsEditor.vue | Add “Generate with AI” menu entry for backdrops. |
| spx-gui/src/components/editor/panels/sprite/SpritesPanel.vue | Add “Generate with AI” menu entry for sprites. |
| spx-gui/src/components/editor/map-editor/SpritesPanel.vue | Add “Generate with AI” entry in map editor sprite panel. |
| spx-gui/src/components/asset/library/AssetLibraryModal.vue | Refactor generation handling to useAssetGen() + shared AssetGenComp. |
| spx-gui/src/components/asset/index.ts | Add useGenerateAsset() and deduplicate gen-collapse handler wiring. |
| spx-gui/src/components/asset/gen/useAssetGen.ts | New composable to create/reset/cancel/keep-alive asset generation + helper to add results to project. |
| spx-gui/src/components/asset/gen/sprite/SpriteSettingsInput.vue | Template formatting change. |
| spx-gui/src/components/asset/gen/sprite/SpriteGenPhaseSettings.vue | Add optional asset-library suggestions + “Use” flow for sprites in settings phase. |
| spx-gui/src/components/asset/gen/sprite/SpriteGen.vue | Plumb enableLibrarySearch + assetPicked event through sprite generator. |
| spx-gui/src/components/asset/gen/common/useAssetSuggestions.ts | New composable to query asset library suggestions based on gen settings. |
| spx-gui/src/components/asset/gen/common/AssetSuggestions.vue | New generic suggestions UI wrapper component. |
| spx-gui/src/components/asset/gen/backdrop/BackdropGen.vue | Add optional asset-library suggestions + “Use” flow for backdrops. |
| spx-gui/src/components/asset/gen/AssetGenModal.vue | New standalone generation modal (separate entry point) with library-search enabled. |
| spx-gui/src/components/asset/gen/AssetGen.vue | New wrapper component to render sprite/backdrop generator based on gen model type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Good refactor overall — extracting |
spx-gui/src/components/asset/gen/sprite/SpriteGenPhaseSettings.vue
Outdated
Show resolved
Hide resolved
spx-gui/src/components/asset/gen/sprite/SpriteGenPhaseSettings.vue
Outdated
Show resolved
Hide resolved
| gen, | ||
| descriptionPlaceholder: keyword.value.trim(), | ||
| onCollapse: handleGenCollapse, | ||
| onResolved: handleGenFinished |
There was a problem hiding this comment.
Nit: handleGenFinished 是不是也调整成 handleGenResolved?
| // If the gen is provided by props, it means the modal is controlled by an external gen, | ||
| // and closing the modal will not cancel the gen. So we only show confirmation when there | ||
| // is no external gen, which means closing the modal will cancel the gen and lose progress. | ||
| if (props.gen == null) { |
There was a problem hiding this comment.
Nit: 这个逻辑(以及上边的 genCollapseHandler)看着怪别扭的;我感觉根本原因还是这边的交互的问题,毕竟这边的交互对用户来说也不是特别自然:
- 对初次进入,点“收起”就能保留,点“关闭”就会丢弃
- 对非初次进入,不管点“收起”还是“关闭”都还是保留而不会丢弃
对我来说是有点反直觉的
之前需要点“关闭”就会丢弃,有一定的原因是需要一个给用户“不要”这个 gen 的机会,因为 sprite panel (list) 中的项不可被选中(也就不可被删除/丢弃)
如果我们给用户随时删除/丢弃一个 gen 的手段(比如 sprite panel (list) 中的项可选中,且选中后有个删除操作),那么就可以做成更早地(比如在 gen 进入 phase-content 时)把 gen 添加到项目中,在此后不管是“收起”还是“关闭”都不会丢弃,逻辑可能会更顺畅些
建议后边考虑下这个问题
There was a problem hiding this comment.
@xgopilot 记录一个 issue,后续支持 gen (生成中素材)的删除操作,然后统一“收起”和“关闭”的交互逻辑
There was a problem hiding this comment.
已根据讨论创建 issue:#2982 - feat(spx-gui): support deletion of in-progress gen assets and unify collapse/close interaction
Issue 记录了以下两个待解决问题:
-
支持删除生成中的素材:collapsed 状态下的 gen item(精灵/背景)目前没有删除/取消操作入口。
GenState中已有removeSprite/removeBackdrop方法,但未在 UI 中暴露。 -
统一"收起"和"关闭"的交互逻辑:
SpriteGenModal支持"收起"(保持后台运行)和"关闭"(取消生成)两种行为,但BackdropGenModal目前只有"关闭"(缺少genCollapseHandler和收起按钮),两者行为不一致。
close: #2770