Skip to content

Error message UI#1485

Draft
maxelkins wants to merge 5 commits into
mainfrom
error-message-ui
Draft

Error message UI#1485
maxelkins wants to merge 5 commits into
mainfrom
error-message-ui

Conversation

@maxelkins
Copy link
Copy Markdown
Contributor

@maxelkins maxelkins commented May 29, 2026

Summary

  • Moves ErrorMessage to input side of editor (TBC)
  • Adds FriendlyErrorMessage component to house the output from pfem
  • Adds FriendlyErrorMessage to ErrorMessage (currently hidden)

Notes

Copilot AI review requested due to automatic review settings May 29, 2026 16:54
@maxelkins maxelkins temporarily deployed to previews/1485/merge May 29, 2026 16:54 — with GitHub Actions Inactive
@maxelkins maxelkins marked this pull request as draft May 29, 2026 16:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR relocates the Python error message UI from inside the runner panels (Skulpt/Pyodide) to the editor input pane (above the run bar), introduces a new FriendlyErrorMessage component (currently stubbed and feature-gated behind a hardcoded fem = false flag), and restyles ErrorMessage with the design-system typography mixin, a new red color scheme, and a cancel icon.

Changes:

  • Move <ErrorMessage /> out of SkulptRunner / PyodideRunner and into EditorInput; update related tests.
  • Add FriendlyErrorMessage component + stub API + SCSS, gated by a temporary boolean in ErrorMessage.
  • Restyle ErrorMessage (new colors, typography mixin, cancel icon, structural split into __python / __fem / __error).

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/web-component.html Prettier-style reformatting; also comments out use_editor_styles attribute (looks unrelated/accidental).
src/components/Editor/Runners/PythonRunner/SkulptRunner/SkulptRunner.jsx Remove ErrorMessage rendering and isOutputOnly selector.
src/components/Editor/Runners/PythonRunner/SkulptRunner/SkulptRunner.test.js Replace two error-display tests with single negative assertion.
src/components/Editor/Runners/PythonRunner/PyodideRunner/PyodideRunner.jsx Remove ErrorMessage rendering in both layouts.
src/components/Editor/EditorInput/EditorInput.jsx Render <ErrorMessage /> inside the per-panel Tabs loop above RunBar.
src/components/Editor/EditorInput/EditorInput.test.js Mock EditorPanel and add test for error placement relative to run bar.
src/components/Editor/ErrorMessage/ErrorMessage.jsx Add cancel icon, restructure markup, gate FriendlyErrorMessage behind fem = false.
src/components/Editor/FriendlyErrorMessage/FriendlyErrorMessage.jsx New component fetching a friendly error message via stubbed API.
src/components/Editor/FriendlyErrorMessage/friendlyErrorMessageApi.stub.js New stub API returning a hardcoded friendly error message.
src/assets/stylesheets/ErrorMessage.scss Switch to design-system tokens/typography mixin; add __python / __fem / __error styles.
src/assets/stylesheets/FriendlyErrorMessage.scss New styles for friendly error message.
src/assets/stylesheets/InternalStyles.scss Register new SCSS file; Prettier reformatting.
src/assets/stylesheets/EditorPanel.scss Prettier reformatting only.
src/assets/icons/cancel_FILL.svg New cancel/error icon asset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/web-component.html
newWebComp.setAttribute("with_projectbar", "true");
newWebComp.setAttribute("with_sidebar", "true");
newWebComp.setAttribute("use_editor_styles", "true");
// newWebComp.setAttribute("use_editor_styles", "true");
<div className={`error-message error-message--${settings.fontSize}`}>
<pre ref={message} className="error-message__content"></pre>
<div className="error-message__python">
<CancelFillIcon />
/>
</TabPanel>
))}
<ErrorMessage />
@maxelkins maxelkins temporarily deployed to previews/1485/merge June 2, 2026 08:42 — with GitHub Actions Inactive
cocomarine added a commit that referenced this pull request Jun 4, 2026
Part of
RaspberryPiFoundation/digital-editor-issues#1448

### Changes
- Added pfem package and required changes for it to run properly
- Added dompurify package for sanitising HTML contents that are returned
from pfem
- Added `friendly_errors_enabled` attribute set to `false` by default
and added to redux
- The new redux state read by PythonRunner and passed as a prop to both
PyodideRunner and SkulptRunner
- Added pfem logic to both runners and stored the friendly error html in
redux
- Updated ErrorMessage component to display the friendly errors
conditionally
- For now, CSS used to restrict to displaying title and summary parts of
friendly error html
- pfem will be updated so that we can choose parts before storing in
redux
- ⚠️ The error messages will be formatted in another PR:
#1485

### Behaviour

- When the editor-wc in the host app has `friendly_errors_enabled`
attribute not set or set to `false`, it shows the original error.
<img width="450" alt="Screenshot 2026-05-28 at 14 59 03"
src="https://github.com/user-attachments/assets/4bff14ca-40cd-4a3e-b76e-98a69a45301e"
/>

- When the editor-wc in the host has `friendly_errors_enabled` attribute
set to `true`, it shows the original error followed by title and summary
of the new friendly error.
<img width="500" alt="Screenshot 2026-06-01 at 15 16 33"
src="https://github.com/user-attachments/assets/68b55121-0051-4169-84db-4abb9df4ca74"
/>

### Notes on using the pfem ESM in Jest
- Tried adding it to `jest.transformIgnorePatterns` in package.json, but
resulted in a cascade of errors from plotly
- Just moved `three` to `jest.transformIgnorePatterns` from
`scripts.test`
- Added global jest mocks for pfem and plotly to `setupTests.js`
  - Also imported plotly to `PyodideRunner/VisualOutputPane.test.js` 
- <- with a CJS build of pfem, these changes may be unnecessary
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.

3 participants