@@ -164,7 +164,7 @@ const DocumentEditor = () => {
164164 // Initialize editor with default document on mount
165165 useEffect ( ( ) => {
166166 if ( ! editor || ! isMountedRef . current ) return ;
167- editor . commands . setContent ( fromMarkdown ( currentDocument ) ) ;
167+ editor . commands . setContent ( currentDocument ) ;
168168 } , [ editor , currentDocument ] ) ;
169169
170170 // Cleanup on unmount to prevent state updates after component is removed
@@ -237,9 +237,7 @@ const DocumentEditor = () => {
237237 if ( wasRunning . current && ! isLoading ) {
238238 if ( currentDocument . trim ( ) . length > 0 && currentDocument !== agentState ?. document ) {
239239 const newDocument = agentState ?. document || "" ;
240- const diff = diffPartialText ( currentDocument , newDocument , true ) ;
241- const markdown = fromMarkdown ( diff ) ;
242- editor ?. commands . setContent ( markdown ) ;
240+ editor ?. commands . setContent ( newDocument ) ;
243241 }
244242 }
245243 wasRunning . current = isLoading ;
@@ -249,18 +247,10 @@ const DocumentEditor = () => {
249247 useEffect ( ( ) => {
250248 if ( ! isMountedRef . current ) return ;
251249
252- if ( isLoading ) {
253- if ( currentDocument . trim ( ) . length > 0 ) {
254- const newDocument = agentState ?. document || "" ;
255- const diff = diffPartialText ( currentDocument , newDocument ) ;
256- const markdown = fromMarkdown ( diff ) ;
257- editor ?. commands . setContent ( markdown ) ;
258- } else {
259- const markdown = fromMarkdown ( agentState ?. document || "" ) ;
260- editor ?. commands . setContent ( markdown ) ;
261- }
250+ if ( isLoading && agentState ?. document ) {
251+ editor ?. commands . setContent ( agentState . document ) ;
262252 }
263- } , [ agentState ?. document , isLoading , currentDocument , editor ] ) ;
253+ } , [ agentState ?. document , isLoading , editor ] ) ;
264254
265255 const text = editor ?. getText ( ) || "" ;
266256
@@ -290,11 +280,11 @@ const DocumentEditor = () => {
290280 respond = { respond }
291281 status = { status }
292282 onReject = { ( ) => {
293- editor ?. commands . setContent ( fromMarkdown ( currentDocument ) ) ;
283+ editor ?. commands . setContent ( currentDocument ) ;
294284 setAgentState ( { document : currentDocument } ) ;
295285 } }
296286 onConfirm = { ( ) => {
297- editor ?. commands . setContent ( fromMarkdown ( agentState ?. document || "" ) ) ;
287+ editor ?. commands . setContent ( agentState ?. document || "" ) ;
298288 setCurrentDocument ( agentState ?. document || "" ) ;
299289 setAgentState ( { document : agentState ?. document || "" } ) ;
300290 } }
@@ -321,11 +311,11 @@ const DocumentEditor = () => {
321311 respond = { respond }
322312 status = { status }
323313 onReject = { ( ) => {
324- editor ?. commands . setContent ( fromMarkdown ( currentDocument ) ) ;
314+ editor ?. commands . setContent ( currentDocument ) ;
325315 setAgentState ( { document : currentDocument } ) ;
326316 } }
327317 onConfirm = { ( ) => {
328- editor ?. commands . setContent ( fromMarkdown ( agentState ?. document || "" ) ) ;
318+ editor ?. commands . setContent ( agentState ?. document || "" ) ;
329319 setCurrentDocument ( agentState ?. document || "" ) ;
330320 setAgentState ( { document : agentState ?. document || "" } ) ;
331321 } }
0 commit comments