Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
Release the last closed rich Markdown editor (#35227)
OrcaWin008a1e848057
diff --git a/src/renderer/src/components/editor/rich-markdown-extension-retention.test.ts b/src/renderer/src/components/editor/rich-markdown-extension-retention.test.tsnew file mode 100644index 00000000000..e795e0531a1--- /dev/null+++ b/src/renderer/src/components/editor/rich-markdown-extension-retention.test.ts@@ -0,0 +1,41 @@+// @vitest-environment happy-dom+import { Editor } from '@tiptap/core'+import { expect, it } from 'vitest'+import { createRichMarkdownExtensions } from './rich-markdown-extensions'+import { createRichMarkdownEditorCodec } from './rich-markdown-source-transport'+import { encodeRawMarkdownHtmlForRichEditor } from './raw-markdown-html'++function closeMarkdownEditor() {+ const source = Array.from(+ { length: 100 },+ (_, index) => `_Block ${index} ${'x'.repeat(1024)}_`+ ).join('\n\n')+ const codec = createRichMarkdownEditorCodec()+ const editor = new Editor({+ element: document.createElement('div'),+ extensions: createRichMarkdownExtensions({ codec }),+ content: encodeRawMarkdownHtmlForRichEditor(source, codec),+ contentType: 'markdown'+ })+ const closed = { editor: new WeakRef(editor), document: new WeakRef(editor.state.doc) }+ editor.destroy()+ return closed+}++async function collect(): Promise<void> {+ if (typeof globalThis.gc !== 'function') {+ throw new Error('Run with the repository Vitest --expose-gc config')+ }+ await new Promise<void>((resolve) => setTimeout(resolve, 0))+ for (let round = 0; round < 4; round++) {+ await new Promise<void>((resolve) => setImmediate(resolve))+ globalThis.gc()+ }+}++it('releases the destroyed Markdown editor after the last rich editor closes', async () => {+ const closed = closeMarkdownEditor()+ await collect()+ expect(closed.editor.deref()).toBeUndefined()+ expect(closed.document.deref()).toBeUndefined()+})diff --git a/src/renderer/src/components/editor/rich-markdown-extension.ts b/src/renderer/src/components/editor/rich-markdown-extension.tsindex 06d93579abf..252da67ba25 100644--- a/src/renderer/src/components/editor/rich-markdown-extension.ts+++ b/src/renderer/src/components/editor/rich-markdown-extension.ts@@ -20,7 +20,8 @@ export function createRichMarkdownExtension(codec: RichMarkdownEditorCodec,htmlSuperscriptLinks = false) {- return RichMarkdownExtension.extend({+ // configure() first so extend() does not link this per-editor child onto the shared module extension.+ return RichMarkdownExtension.configure().extend({onBeforeCreate(event) {this.parent?.(event)preserveLiteralMarkdownSource(this.editor, codec, htmlSuperscriptLinks)