From f839e5c13643c8358e309d4f1920fe8abf457af0 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Wed, 9 Jul 2025 19:10:53 +0800 Subject: [PATCH] fix(core): should use sonnet 4 for make it real (#13106) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### PR Dependency Tree * **PR #13106** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) ## Summary by CodeRabbit * **New Features** * Improved code highlighting performance and resource management for AI-generated code artifacts, resulting in smoother user experience and more efficient updates. * **Chores** * Updated underlying AI model for "Make it real" features, which may affect AI-generated outputs. --- .../server/src/plugins/copilot/prompt/prompts.ts | 4 ++-- .../ai/components/ai-tools/code-artifact.ts | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/backend/server/src/plugins/copilot/prompt/prompts.ts b/packages/backend/server/src/plugins/copilot/prompt/prompts.ts index debf812c4b..ff2b4b667d 100644 --- a/packages/backend/server/src/plugins/copilot/prompt/prompts.ts +++ b/packages/backend/server/src/plugins/copilot/prompt/prompts.ts @@ -1286,7 +1286,7 @@ If there are items in the content that can be used as to-do tasks, please refer { name: 'Make it real', action: 'Make it real', - model: 'gpt-4.1-2025-04-14', + model: 'claude-sonnet-4@20250514', messages: [ { role: 'system', @@ -1327,7 +1327,7 @@ When sent new wireframes, respond ONLY with the contents of the html file.`, { name: 'Make it real with text', action: 'Make it real with text', - model: 'gpt-4.1-2025-04-14', + model: 'claude-sonnet-4@20250514', messages: [ { role: 'system', diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-tools/code-artifact.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-tools/code-artifact.ts index e31d5077f5..caa541b091 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-tools/code-artifact.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-tools/code-artifact.ts @@ -103,6 +103,8 @@ export class CodeHighlighter extends SignalWatcher(WithDisposable(LitElement)) { override connectedCallback() { super.connectedCallback(); + this.highlighter.mounted(); + // recompute highlight when code / language changes this.disposables.add( effect(() => { @@ -111,17 +113,25 @@ export class CodeHighlighter extends SignalWatcher(WithDisposable(LitElement)) { ); } + override disconnectedCallback() { + super.disconnectedCallback(); + this.highlighter.unmounted(); + } + private _updateHighlightTokens() { let cancelled = false; const language = this.language; const highlighter = this.highlighter.highlighter$.value; + if (!highlighter) return; const updateTokens = () => { if (cancelled) return; - this.highlightTokens.value = highlighter.codeToTokensBase(this.code, { - lang: language, - theme: this.highlighter.themeKey, + requestIdleCallback(() => { + this.highlightTokens.value = highlighter.codeToTokensBase(this.code, { + lang: language, + theme: this.highlighter.themeKey, + }); }); };