Skip to content

Improve language consistency in enrichment and sprite-content generation#2939

Merged
nighca merged 1 commit intogoplus:devfrom
nighca:issue-2772
Mar 12, 2026
Merged

Improve language consistency in enrichment and sprite-content generation#2939
nighca merged 1 commit intogoplus:devfrom
nighca:issue-2772

Conversation

@nighca
Copy link
Copy Markdown
Collaborator

@nighca nighca commented Mar 12, 2026

close #2772.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant improvement to the AI-generated content features by adding explicit language control. It integrates a lang parameter into the API calls for asset enrichment and sprite content generation, allowing the system to generate text in a specified language. This change enhances the application's internationalization capabilities, providing users with more precise control over the language of AI-generated names and descriptions.

Highlights

  • API Enhancements: Introduced a new optional lang parameter to the OpenAPI specification for enrichAssetSettings and genSpriteContentSettings endpoints, allowing explicit language control for AI-generated text.
  • Internationalization Integration: Integrated the i18n (internationalization) object into the constructors and load methods of AnimationGen, BackdropGen, CostumeGen, and SpriteGen classes, enabling these generation processes to utilize the selected language for API calls.
  • Backdrop Generation Refactor: Refactored the BackdropGen class to consistently pass and use the i18n object, ensuring language consistency during backdrop generation.
  • Test Suite Updates: Updated relevant test files (animation-gen.test.ts, backdrop-gen.test.ts, costume-gen.test.ts, gen.test.ts) to reflect the new i18n parameter in constructor and load method calls for the generation classes.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/openapi.yaml
    • Added lang parameter to enrichAssetSettings and genSpriteContentSettings API definitions.
  • spx-gui/src/apis/aigc.ts
    • Added lang property to EnrichAssetSettingsParams type.
    • Updated genSpriteContentSettings and enrich*Settings functions to accept and pass the lang parameter.
  • spx-gui/src/components/asset/library/AssetLibraryModal.vue
    • Updated BackdropGen instantiation to pass the i18n object.
  • spx-gui/src/components/editor/gen.test.ts
    • Updated BackdropGen constructor calls in tests to include the i18n object.
  • spx-gui/src/components/editor/gen.ts
    • Updated BackdropGen.loadAll call to pass the i18n object.
  • spx-gui/src/models/spx/gen/animation-gen.test.ts
    • Added i18n import and instantiation.
    • Updated AnimationGen constructor and load method calls in tests to include the i18n object.
  • spx-gui/src/models/spx/gen/animation-gen.ts
    • Imported I18n type.
    • Added i18n property to AnimationGen class.
    • Updated AnimationGen constructor and load static method to accept i18n.
    • Passed this.i18n.lang.value to enrichAnimationSettings.
  • spx-gui/src/models/spx/gen/backdrop-gen.test.ts
    • Added i18n instantiation.
    • Updated BackdropGen constructor, load, and loadAll method calls in tests to include the i18n object.
  • spx-gui/src/models/spx/gen/backdrop-gen.ts
    • Imported I18n type.
    • Added i18n property to BackdropGen class.
    • Updated BackdropGen constructor and load / loadAll static methods to accept i18n.
    • Passed this.i18n.lang.value to enrichBackdropSettings.
  • spx-gui/src/models/spx/gen/costume-gen.test.ts
    • Added i18n import and instantiation.
    • Updated CostumeGen constructor and load method calls in tests to include the i18n object.
  • spx-gui/src/models/spx/gen/costume-gen.ts
    • Imported I18n type.
    • Added i18n property to CostumeGen class.
    • Updated CostumeGen constructor and load static method to accept i18n.
    • Passed this.i18n.lang.value to enrichCostumeSettings.
  • spx-gui/src/models/spx/gen/sprite-gen.ts
    • Passed this.i18n.lang.value to enrichSpriteSettings and genSpriteContentSettings.
    • Updated CostumeGen and AnimationGen instantiations to pass the i18n object.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot]

This comment was marked as outdated.

@nighca nighca marked this pull request as ready for review March 12, 2026 08:49
Copilot AI review requested due to automatic review settings March 12, 2026 08:49
Copy link
Copy Markdown
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

This PR addresses issue #2772 by making AIGC enrichment and sprite-content generation use a deterministic language (driven by the app’s current i18n lang), and by hardening the i18n instance against Vue reactive ref-unwrapping.

Changes:

  • Mark I18n instances as raw to prevent Vue reactivity from auto-unwrapping the lang Ref.
  • Add optional lang support to AIGC API request types/functions and propagate i18n.lang.value through sprite/costume/animation/backdrop generation flows.
  • Update generator constructors/loaders and related tests to thread i18n through consistently.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
spx-gui/src/utils/i18n/index.ts Prevents Vue reactive proxies from unwrapping I18n.lang by marking the instance raw.
spx-gui/src/models/spx/gen/sprite-gen.ts Passes explicit lang into sprite enrichment and sprite content-settings generation; propagates i18n into child gens.
spx-gui/src/models/spx/gen/costume-gen.ts Stores i18n and forwards lang into costume enrichment.
spx-gui/src/models/spx/gen/costume-gen.test.ts Updates tests for new CostumeGen constructor/load signature requiring i18n.
spx-gui/src/models/spx/gen/backdrop-gen.ts Stores i18n and forwards lang into backdrop enrichment; threads i18n through load APIs.
spx-gui/src/models/spx/gen/backdrop-gen.test.ts Updates tests for new BackdropGen constructor/loadAll/load signatures requiring i18n.
spx-gui/src/models/spx/gen/animation-gen.ts Stores i18n and forwards lang into animation enrichment; threads i18n through load APIs.
spx-gui/src/models/spx/gen/animation-gen.test.ts Updates tests for new AnimationGen constructor/load signature requiring i18n.
spx-gui/src/components/editor/gen.ts Passes i18n through to BackdropGen.loadAll during editor state loading.
spx-gui/src/components/editor/gen.test.ts Updates tests for new BackdropGen constructor signature requiring i18n.
spx-gui/src/components/asset/library/AssetLibraryModal.vue Creates BackdropGen with i18n so enrichment uses the current language.
spx-gui/src/apis/aigc.ts Adds lang parameter/type for enrichment + sprite content-settings calls and includes it in request bodies.
docs/openapi.yaml Documents the new optional lang field for enrichment and sprite content-settings endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spx-gui/src/apis/aigc.ts
Comment thread spx-gui/src/models/spx/gen/sprite-gen.ts
vi.mocked(aigcApis.getTask).mockImplementation(this.getTask.bind(this))
vi.mocked(aigcApis.cancelTask).mockImplementation(this.cancelTask.bind(this))
vi.mocked(aigcApis.subscribeTaskEvents).mockImplementation(this.subscribeTaskEvents.bind(this))
this.enrichBackdropSettings = vi.fn(this.enrichBackdropSettings.bind(this))
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

方便具体的测试用例通过 vi.mocked(aigcMock.xxx).yyy 来对 aigc APIs 的调用行为做检查

// Prevent Vue from making this instance reactive. Without this, when an I18n
// instance is stored inside a reactive object, Vue would auto-unwrap `lang`
// (a Ref field), turning `this.i18n.lang` from a Ref into the raw string value.
markRaw(this)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

诶,这样不会影响语言切换么

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

不会,它是避免把 i18n 这个整体做 reactive 的处理,不影响其内部更细的 reactive(ref)数据

@nighca nighca merged commit 4d56fb8 into goplus:dev Mar 12, 2026
5 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.

Improve language stability in enrichment and sprite-content generation

3 participants