Skip to content

feat: integrate Monaco Editor workers for enhanced code editing support#7249

Merged
Soulter merged 1 commit intomasterfrom
fix/5587
Mar 31, 2026
Merged

feat: integrate Monaco Editor workers for enhanced code editing support#7249
Soulter merged 1 commit intomasterfrom
fix/5587

Conversation

@Soulter
Copy link
Copy Markdown
Member

@Soulter Soulter commented Mar 31, 2026

fixes: #5587

Modifications / 改动点

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Enhancements:

  • Update Monaco editor loader configuration to rely on the imported monaco instance rather than a remote CDN path.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 31, 2026
@Soulter Soulter merged commit 4d9dce1 into master Mar 31, 2026
6 checks passed
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Switching loader.config from an explicit CDN paths.vs entry to loader.config({ monaco }) makes the Monaco source location implicit; consider adding a short comment or centralizing the Monaco configuration so future changes to bundler/asset paths don’t silently break the editor.
  • If monaco is imported or initialized elsewhere, it might be safer to guard this configuration with a runtime check (e.g., verifying monaco is defined and has the expected shape) to avoid hard-to-trace failures when the dashboard bootstraps in unexpected environments.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Switching `loader.config` from an explicit CDN `paths.vs` entry to `loader.config({ monaco })` makes the Monaco source location implicit; consider adding a short comment or centralizing the Monaco configuration so future changes to bundler/asset paths don’t silently break the editor.
- If `monaco` is imported or initialized elsewhere, it might be safer to guard this configuration with a runtime check (e.g., verifying `monaco` is defined and has the expected shape) to avoid hard-to-trace failures when the dashboard bootstraps in unexpected environments.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the area:webui The bug / feature is about webui(dashboard) of astrbot. label Mar 31, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request transitions the Monaco Editor configuration from a CDN-based approach to a local bundle using dedicated web workers for various languages. The review feedback highlights that the current static import of the 'monaco-editor' library will significantly increase the initial bundle size and recommends using dynamic imports to optimize application load performance.

Comment thread dashboard/src/main.ts

import print from 'vue3-print-nb';
import { loader } from '@guolao/vue-monaco-editor'
import * as monaco from 'monaco-editor';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Importing monaco-editor statically in the main entry file will cause the entire library (which is several megabytes) to be bundled into the initial chunk. This significantly increases the application's initial load time. It is recommended to remove this static import and use a dynamic import instead.

Comment thread dashboard/src/main.ts
vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.54.0/min/vs',
},
})
loader.config({ monaco })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To optimize performance, use a dynamic import for the Monaco Editor. This allows Vite to split the library into a separate chunk that is only loaded when needed. The @guolao/vue-monaco-editor loader handles Promises passed to the monaco property correctly.

Suggested change
loader.config({ monaco })
loader.config({ monaco: import('monaco-editor') })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

希望Monaco编辑器从cdn部署改为本地部署

1 participant