Skip to content

feat(spx-gui): separate generation entry#2963

Merged
cn0809 merged 9 commits intogoplus:devfrom
cn0809:issue-2770
Mar 25, 2026
Merged

feat(spx-gui): separate generation entry#2963
cn0809 merged 9 commits intogoplus:devfrom
cn0809:issue-2770

Conversation

@cn0809
Copy link
Collaborator

@cn0809 cn0809 commented Mar 18, 2026

close: #2770

@gemini-code-assist

This comment was marked as outdated.

gemini-code-assist[bot]

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AssetGenModal and useGenerateAsset() hook to launch AI generation from multiple editor entry points.
  • Refactor asset library generation to use shared useAssetGen() / AssetGenComp plumbing 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.

@xgopilot
Copy link
Contributor

xgopilot bot commented Mar 19, 2026

Good refactor overall — extracting useAssetGen, addAssetToProject, and makeGenCollapseHandler reduces duplication meaningfully. A few issues worth addressing before merge: (1) createAssetGen eagerly instantiates both SpriteGen and BackdropGen and leaks the unused one; (2) useAssetSuggestions has no stale-response guard and no teardown for the debounce timer; (3) AssetGenModal's close confirmation can fire after a successful resolution; (4) the BackdropGen collapse asymmetry in AssetGen.vue needs a comment or fix.

gen,
descriptionPlaceholder: keyword.value.trim(),
onCollapse: handleGenCollapse,
onResolved: handleGenFinished
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 这个逻辑(以及上边的 genCollapseHandler)看着怪别扭的;我感觉根本原因还是这边的交互的问题,毕竟这边的交互对用户来说也不是特别自然:

  • 对初次进入,点“收起”就能保留,点“关闭”就会丢弃
  • 对非初次进入,不管点“收起”还是“关闭”都还是保留而不会丢弃

对我来说是有点反直觉的

之前需要点“关闭”就会丢弃,有一定的原因是需要一个给用户“不要”这个 gen 的机会,因为 sprite panel (list) 中的项不可被选中(也就不可被删除/丢弃)

如果我们给用户随时删除/丢弃一个 gen 的手段(比如 sprite panel (list) 中的项可选中,且选中后有个删除操作),那么就可以做成更早地(比如在 gen 进入 phase-content 时)把 gen 添加到项目中,在此后不管是“收起”还是“关闭”都不会丢弃,逻辑可能会更顺畅些

建议后边考虑下这个问题

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xgopilot 记录一个 issue,后续支持 gen (生成中素材)的删除操作,然后统一“收起”和“关闭”的交互逻辑

Copy link
Contributor

@xgopilot xgopilot bot Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已根据讨论创建 issue:#2982 - feat(spx-gui): support deletion of in-progress gen assets and unify collapse/close interaction

Issue 记录了以下两个待解决问题:

  1. 支持删除生成中的素材:collapsed 状态下的 gen item(精灵/背景)目前没有删除/取消操作入口。GenState 中已有 removeSprite / removeBackdrop 方法,但未在 UI 中暴露。

  2. 统一"收起"和"关闭"的交互逻辑SpriteGenModal 支持"收起"(保持后台运行)和"关闭"(取消生成)两种行为,但 BackdropGenModal 目前只有"关闭"(缺少 genCollapseHandler 和收起按钮),两者行为不一致。

View job run

@cn0809 cn0809 merged commit d0485a5 into goplus:dev Mar 25, 2026
4 checks passed
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.

Seperate generation entry

3 participants