Skip to content

Add a Copy button to debug toolbar errors - #4203

Merged
T4rk1n merged 6 commits into
plotly:nextfrom
agamsiingh:copy-error-button-debug-toolbar
Nov 26, 2026
Merged

T4rk1n merged 6 commits into
plotly:nextfrom
agamsiingh:copy-error-button-debug-toolbar

Conversation

@agamsiingh

Copy link
Copy Markdown

Closes #3624

Each error in the debug toolbar now has a Copy button. It copies the error message and the traceback to the clipboard, so several errors can be copied and pasted one at a time.

For backend errors it copies the plain traceback from the Werkzeug debugger page when there is one, and the text of the HTML otherwise. Frontend errors copy the message and the stack trace.

Changes

  • FrontEndError.react.js: add the Copy button to each error header. Clicking it does not collapse or expand the error. The label shows "Copied" or "Copy failed" for 1.5 seconds.
  • errorText.js (new): errorToText builds the text to copy. copyToClipboard uses the Clipboard API and falls back to document.execCommand('copy') when the API is missing or denied, for example inside an iframe.
  • FrontEndError.css: styles for the button. The title group in the header goes from 77% to 65% width so the timestamp does not wrap onto a second line.
  • tests/errorText.test.js (new): 5 unit tests for errorToText.
  • CHANGELOG.md: entry under Added.

Testing

What I ran:

  • Renderer unit tests (karma, headless Chrome 153): 143 of 143 passed, including the 5 new tests.
  • eslint and prettier on the changed files: no findings.
  • Manual check in a running app (a throwaway app with two callbacks that raise, driven with headless Chrome through puppeteer-core): both errors show a Copy button, the clipboard holds the message and the traceback, the label goes to "Copied" and back to "Copy", and clicking it does not toggle the error. I checked both the Clipboard API path and the execCommand fallback.

What I did not run:

  • The Python and Selenium integration tests (tests/integration/devtools). The environment I worked in could not get a ChromeDriver that matches the installed Chrome, so I did not add an integration test for the button. I am relying on CI for the existing ones.
  • Percy snapshots: the new button and the header width change will probably change them.

Contributor Checklist

  • This PR targets next (feature)
  • I have run the tests locally and they passed. Partly: the renderer unit tests passed, the integration tests were not run (see above).
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR (unit tests for the text builder; no integration test)
  • I have added entry in the CHANGELOG.md

AI disclosure

This PR was prepared with Claude (Anthropic), an AI assistant, acting for agamsiingh, who authorized opening it. The code, tests and manual checks above were produced in that session.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YajzBFUtT3d7kErLkqaMr6

agamsiingh and others added 6 commits November 26, 2026 02:16
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YajzBFUtT3d7kErLkqaMr6
Each error in the debug toolbar now has a Copy button that copies the error message and its traceback.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YajzBFUtT3d7kErLkqaMr6
errorToText joins the message, frontend stack and backend traceback. copyToClipboard uses the Clipboard API and falls back to execCommand when it is unavailable or denied.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YajzBFUtT3d7kErLkqaMr6
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YajzBFUtT3d7kErLkqaMr6
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YajzBFUtT3d7kErLkqaMr6
@sonarqubecloud

Copy link
Copy Markdown

@T4rk1n
T4rk1n merged commit 84e69f5 into plotly:next Nov 26, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants