// Pure heuristic from public/js/correctionTracker.js — used by // EditableResult to decide whether a user's inline edit to AI output // is "meaningful" enough to push to /api/memories/correction. // // The threshold matches vanilla exactly so we don't drift behaviour // between the two clients during the migration window. export function isMeaningfulChange(original: string, current: string): boolean { if (!original || !current) return false; if (original.trim() === current.trim()) return false; const origWords = original.split(/\s+/).length; const currWords = current.split(/\s+/).length; const wordDiff = Math.abs(origWords - currWords); if (wordDiff < 2 && original.length > 100) { const charDiff = Math.abs(original.length - current.length); if (charDiff < 20) return false; } return true; }