{"record":{"id":"19f8371b756fba29","repo":"pbakaus/impeccable","slug":"impeccable-some-copy-edits-failed","errorCode":null,"errorMessage":"[impeccable] some copy edits failed:","messagePattern":"\\[impeccable\\] some copy edits failed:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"skill/scripts/live-browser.js","lineNumber":4138,"sourceCode":"    setPendingApplyLoading(true, count);\n    try {\n      const res = await fetch(\n        'http://localhost:' + PORT + '/manual-edit-commit?token=' + encodeURIComponent(TOKEN) + '&pageUrl=' + encodeURIComponent(location.pathname) + '&async=1',\n        { method: 'POST', keepalive: true },\n      );\n      if (!res.ok) {\n        const errBody = await res.json().catch(() => ({}));\n        throw new Error(errBody.error || ('HTTP ' + res.status));\n      }\n      const result = await res.json();\n      if (res.status === 202 || result.status === 'started') {\n        waitForSseCompletion = true;\n        return;\n      }\n      const remaining = remainingManualEditCount(result);\n      updatePendingCounter(remaining);\n      if (result.failed && result.failed.length > 0) {\n        console.warn('[impeccable] some copy edits failed:', result.failed);\n        showToast('Applied ' + (result.applied?.length || 0) + ', ' + result.failed.length + ' failed - see console', 5000);\n      } else {\n        const n = Array.isArray(result.applied) ? result.applied.length : (result.cleared || 0);\n        if (n > 0) {\n          showToast('Applied ' + n + ' edit' + (n === 1 ? '' : 's'), 2500);\n        } else {\n          console.warn('[impeccable] apply returned no verified edits:', result);\n          showToast('No edits applied - see console', 4000);\n        }\n      }\n    } catch (err) {\n      console.error('[impeccable] commit failed:', err);\n      showToast('Apply failed - see console', 4000);\n    } finally {\n      if (waitForSseCompletion) return;\n      const remainingCount = parseInt(pendingPillEl?.dataset.count || '0', 10) || 0;\n      if (remainingCount > 0) setPendingApplyLoading(false);\n      else hidePendingApplyDock();","sourceCodeStart":4120,"sourceCodeEnd":4156,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/skill/scripts/live-browser.js#L4120-L4156","documentation":"After applying the stashed manual (copy) edits, the server result reported one or more failed edits. The script warns with the failed list, shows a toast with applied/failed counts, and updates the pending counter to the remaining edits.","triggerScenarios":"onPendingPillClick applies manual edits; the response's result.failed array is non-empty, triggering the warn at skill/scripts/live-browser.js:4138 and a 5s toast 'Applied N, M failed - see console'.","commonSituations":"A copy edit targets a text node that no longer exists (page re-rendered since stashing); edit selector/anchor became stale after framework re-render; server-side edit application rejected an ambiguous match.","solutions":["Open the browser console and inspect the logged result.failed array for the specific failed edits.","Re-apply the remaining edits via the pending pill after the page settled (counter shows what is left).","If edits are stale after a re-render, re-create the affected copy edits and clear the stash.","Reload the page and retry if anchors are temporarily missing due to HMR."],"exampleFix":"// before (failures only visible in console)\nconsole.warn('[impeccable] some copy edits failed:', result.failed);\n// after (defensive: skip edits whose target vanished)\nconst failed = result.failed.filter(f => f.reason !== 'target-missing');\nconsole.warn('[impeccable] some copy edits failed:', failed.length ? failed : 'none actionable');","handlingStrategy":"fallback","validationCode":"function editsTargetLiveNodes(result) {\n  return result.failed.every(f => document.querySelector(f.selector ?? '[data-impeccable-edit]') !== null);\n}","typeGuard":null,"tryCatchPattern":"if (result.failed && result.failed.length > 0) {\n  console.warn('[impeccable] some copy edits failed:', result.failed);\n  showToast('Applied ' + (result.applied?.length || 0) + ', ' + result.failed.length + ' failed - see console', 5000);\n}","preventionTips":["Apply stashed edits promptly before the page re-renders","Invalidate stash entries whose target text/selector no longer matches","Show remaining count after partial failure so users know what is left","Log failed edit details to the console (already done) and surface actionable reasons"],"tags":["edits","partial-failure","browser"],"backgroundTag":"partial-operation-failure","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}