pbakaus/impeccable · warning

Copy failed

Error message

Copy failed

What it means

The DevTools panel's copyToClipboard wraps navigator.clipboard.writeText in try/catch to copy formatted findings. If the promise rejects — clipboard-write denied by permissions policy, document not focused, API unavailable in the panel context — it logs 'Copy failed' with the error and leaves the clipboard untouched; the button briefly shows the copied state only on success paths controlled elsewhere.

Source

Thrown at extension/devtools/panel.js:359

  lines.push(`Suggested Impeccable skill(s) to fix: ${fixSkillFor(finding.type)}`);
  return lines.join('\n');
}

async function copyToClipboard(text, btn) {
  if (text instanceof Promise) text = await text;
  try {
    await navigator.clipboard.writeText(text);
    if (btn) {
      const orig = btn.title;
      btn.title = 'Copied!';
      btn.classList.add('copied');
      setTimeout(() => {
        btn.title = orig;
        btn.classList.remove('copied');
      }, 1200);
    }
  } catch (err) {
    console.warn('Copy failed', err);
  }
}

btnCopyAll.addEventListener('click', () => {
  copyToClipboard(formatFindingsForCopy(currentFindings), btnCopyAll);
});

// Delegated hover tracking on the findings container.
// Reliably handles cursor moving between items, into children, or out of the panel.
let currentHoverSelector = null;
function setHoveredItem(selector) {
  if (selector === currentHoverSelector) return;
  currentHoverSelector = selector;
  if (selector) {
    postToPort({ action: 'highlight', selector });
  } else {
    postToPort({ action: 'unhighlight' });
  }

View on GitHub (pinned to f88b2837a7)

Solutions

  1. Click directly on the Copy button so the user gesture is unambiguous, then retry
  2. Select the findings text in the panel and use Cmd/Ctrl+C as the manual fallback
  3. If building similar UI, fall back to a hidden textarea + document.execCommand('copy') on rejection

Example fix

// before
await navigator.clipboard.writeText(text);
// after
try { await navigator.clipboard.writeText(text); }
catch {
  const ta = document.createElement('textarea');
  ta.value = text; document.body.appendChild(ta); ta.select();
  document.execCommand('copy'); ta.remove();
}
Defensive patterns

Strategy: fallback

Validate before calling

if (!navigator.clipboard?.writeText) { useLegacyCopy(text); return; }

Try / catch

try {
  await navigator.clipboard.writeText(text);
} catch (err) {
  console.warn('Copy failed', err);
  const ta = document.createElement('textarea');
  ta.value = text; ta.style.position = 'fixed'; ta.style.opacity = '0';
  document.body.appendChild(ta); ta.select();
  document.execCommand('copy'); ta.remove();
}

Prevention

When it happens

Trigger: Clicking Copy when the devtools panel iframe is not the focused document; a permissions policy that withlays clipboard-write from the panel; headless/automated contexts where the Clipboard API is disabled.

Common situations: Focus sits in the inspected page or another window when the click lands; enterprise browser policies disabling clipboard API; older Chrome where writeText requires a tightly-scoped user gesture.

Related errors


AI-assisted analysis of pbakaus/impeccable@f88b2837a7 (2026-08-18). Data as JSON: /api/errors/f5a29af185f11949. Report an issue: GitHub.