Improve language consistency in enrichment and sprite-content generation#2939
Improve language consistency in enrichment and sprite-content generation#2939nighca merged 1 commit intogoplus:devfrom
Conversation
Summary of ChangesHello, 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 Highlights
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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
I18ninstances as raw to prevent Vue reactivity from auto-unwrapping thelangRef. - Add optional
langsupport to AIGC API request types/functions and propagatei18n.lang.valuethrough sprite/costume/animation/backdrop generation flows. - Update generator constructors/loaders and related tests to thread
i18nthrough 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.
| 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)) |
There was a problem hiding this comment.
方便具体的测试用例通过 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) |
There was a problem hiding this comment.
不会,它是避免把 i18n 这个整体做 reactive 的处理,不影响其内部更细的 reactive(ref)数据
close #2772.