{"record":{"id":"4f165a735e1d4120","repo":"pbakaus/impeccable","slug":"impeccable-skipped-unsafe-copy-edit-dom-restore-4f165a","errorCode":null,"errorMessage":"[impeccable] skipped unsafe copy edit DOM restore for","messagePattern":"\\[impeccable\\] skipped unsafe copy edit DOM restore for","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"skill/scripts/live-browser.js","lineNumber":4362,"sourceCode":"      fetchPendingCount();\n    }\n  }\n\n  function restoreDiscardedManualEdits(entries) {\n    let failures = 0;\n    for (const entry of entries || []) {\n      for (const op of entry.ops || []) {\n        if (restoreMixedTextNodeManualEdit(op)) continue;\n        const el = findManualEditRestoreElement(op);\n        if (!el || typeof op.originalText !== 'string' || !canRestoreManualEditElement(el, op)) {\n          failures += 1;\n          continue;\n        }\n        el.textContent = op.originalText;\n      }\n    }\n    if (failures > 0) {\n      console.warn('[impeccable] skipped unsafe copy edit DOM restore for', failures, 'edit(s). Refresh to reset the page DOM.');\n    }\n    return failures;\n  }\n\n  function canRestoreManualEditElement(el, op) {\n    if (!el || typeof op?.originalText !== 'string') return false;\n    if (el.children && el.children.length > 0) return false;\n    return normalizeManualContextText(el.textContent) === normalizeManualContextText(op.newText);\n  }\n\n  function mixedTextWrapRestoreHint(el) {\n    if (!el || !el.dataset || el.dataset.impeccableTextWrap !== 'true' || !el.parentElement) return null;\n    const siblings = directMixedTextRestoreNodes(el.parentElement);\n    const textIndex = siblings.indexOf(el);\n    return {\n      kind: 'mixedTextNode',\n      parentRef: documentRefForElement(el.parentElement),\n      textIndex,","sourceCodeStart":4344,"sourceCodeEnd":4380,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/skill/scripts/live-browser.js#L4344-L4380","documentation":"When the user discards pending copy edits, the script tries to restore each edit's original text back into the page DOM. This warning counts elements it refused to restore because it was unsafe: the target element was not found, lacked originalText, still had child elements, or its current text did not match the edit's recorded newText (i.e. the DOM changed since the edit). The page DOM may remain visually edited until a refresh.","triggerScenarios":"Clicking the trash/pending-pill discard action after the page DOM changed — the edited element was re-rendered by the framework, its text was edited again, it now contains child nodes, or canRestoreManualEditElement returns false for one or more stashed ops.","commonSituations":"Framework re-render or HMR replaced the edited node between edit and discard; the user edited an element whose text subsequently changed; edits made in one route/component, discard attempted after navigation; nested-element edits that fail the leaf-only safety check.","solutions":["Refresh the page — that resets the DOM to match the source, which is the documented remedy in the message itself.","Before discarding, avoid navigating or letting HMR re-render the edited elements.","If restores routinely fail, re-pick elements after any re-render rather than accumulating edits across renders.","Verify the edits are leaf text nodes (no child elements), which are the only ones safely restorable."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function canRestoreManualEditElement(el, op) {\n  if (!el || typeof op?.originalText !== 'string') return false;\n  if (el.children && el.children.length > 0) return false; // leaf nodes only\n  return normalize(el.textContent) === normalize(op.newText);\n}","tryCatchPattern":null,"preventionTips":["Discard edits before navigating, closing modals, or triggering re-renders.","Edit only leaf text elements; containers with children cannot be safely restored.","Refresh the page after discarding if the toast reports skipped restores.","Avoid stacking multiple edits on the same element between discards."],"tags":["browser","dom","state-sync","restore-failure"],"backgroundTag":"dom-state-mismatch","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}