Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

fix(editor): derive undo-reset poke transaction from live view.state

Sergey Kozyrenko6457a5a86a99
diff --git a/frontend/src/components/shared/markdown-editor/markdown-editor.tsx b/frontend/src/components/shared/markdown-editor/markdown-editor.tsx
index 872bb87f..595588cf 100644
--- a/frontend/src/components/shared/markdown-editor/markdown-editor.tsx
+++ b/frontend/src/components/shared/markdown-editor/markdown-editor.tsx
@@ -80,8 +80,11 @@ const resetUndoHistory = (editor: Editor): void => {
view.updateState(newState);
// `view.updateState` bypasses PM's dispatch pipeline, so tiptap's `transaction` subscription doesn't fire
- // and the toolbar keeps showing a stale `canUndo: true`. Dispatch an empty transaction to wake it.
- view.dispatch(newState.tr.setMeta('addToHistory', false));
+ // and the toolbar keeps showing a stale `canUndo: true`. Dispatch an empty transaction to wake it — built
+ // from the LIVE `view.state`, not `newState`: updateState can synchronously advance the view (a plugin
+ // view or tiptap's deferred initial-content transaction dispatching during reconfigure), and a tr whose
+ // `before` doc no longer matches `view.state.doc` throws "Applying a mismatched transaction".
+ view.dispatch(view.state.tr.setMeta('addToHistory', false));
};
interface MarkdownEditorToolbarProps {