Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Disabling an existing widget can leave it visible across runtime instances or leak a model whose load is still pending.
2 open findings
What changed in this PR
This PR adds a mobile visibility setting for the Live2D widget, addressing the screen-space and performance concerns in issue #82 while preserving existing behavior by default.
Changes:
- Adds a default-on setting and exposes it in the public configuration.
- Skips frontend initialization and renderer loading when mobile display is disabled.
- Adds documentation and tests for device detection, configuration, and startup.
| File | Description |
|---|---|
src/test/java/run/halo/live2d/Live2dSettingProcessTest.java |
Tests public setting values and older configurations. |
src/main/resources/extensions/settings.yaml |
Adds the admin switch. |
src/main/java/run/halo/live2d/Live2dSettingProcess.java |
Exposes the setting publicly. |
README.md |
Documents the setting and device detection. |
packages/live2d/src/utils/mobile-visibility.ts |
Detects mobile devices and applies the setting. |
packages/live2d/src/utils/__tests__/mobile-visibility.test.ts |
Tests detection and default behavior. |
packages/live2d/src/live2d/runtime.ts |
Skips or removes the widget when disabled. |
packages/live2d/src/live2d/__tests__/runtime.test.ts |
Tests runtime visibility behavior. |
packages/live2d/src/halo.ts |
Skips loading the runtime when disabled. |
packages/live2d/src/context/config-context.ts |
Adds the setting to the configuration type. |
packages/live2d/src/config/normalize-config.ts |
Normalizes the setting as a boolean. |
packages/live2d/src/config/default-config.ts |
Enables mobile display by default. |
packages/live2d/src/__tests__/halo.test.ts |
Tests bootstrap behavior across configurations. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| init(path: string, config: LegacyLive2dConfigInput = {}): void { | ||
| if (!shouldShowLive2d(config)) { | ||
| this.rootElement?.remove(); |
There was a problem hiding this comment.
Fixed in 4e9e516. Disconnect now invalidates pending initialization and destroys late models without publishing them. Regression tests and production-bundle browser verification cover cleanup and reinitialization.
| this.rootElement?.remove(); | ||
| this.rootElement = undefined; |
There was a problem hiding this comment.
Fixed in 4e9e516. Mobile disable now removes the connected root by its shared ID, including roots created by another runtime. Regression tests cover cross-instance removal, stale cached roots, re-enabling, and desktop behavior.

What this PR does / why we need it:
新增「基本设置 → 在移动端显示」开关,默认开启以兼容已有配置。关闭后,手机和平板访问时会在导入渲染模块前跳过初始化,减少屏幕占用和资源开销;桌面端仍按原逻辑显示。
Which issue(s) this PR fixes:
Fixes #82
Does this PR introduce a user-facing change?