fix: address review feedback on skills and session compaction

This commit is contained in:
Dotta
2026-03-17 09:21:44 -05:00
parent 4323d4bbda
commit 4d9769c620
4 changed files with 61 additions and 10 deletions

View File

@@ -61,6 +61,10 @@ export interface MarkdownEditorRef {
focus: () => void;
}
function escapeRegExp(value: string): string {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
/* ---- Mention detection helpers ---- */
interface MentionState {
@@ -255,9 +259,10 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
// so the cursor isn't stuck right next to the image.
setTimeout(() => {
const current = latestValueRef.current;
const escapedSrc = escapeRegExp(src);
const updated = current.replace(
/!\[([^\]]*)\]\(([^)]+)\)(?!\n\n)/g,
"![$1]($2)\n\n",
new RegExp(`(!\\[[^\\]]*\\]\\(${escapedSrc}\\))(?!\\n\\n)`, "g"),
"$1\n\n",
);
if (updated !== current) {
latestValueRef.current = updated;