Skip to content

[Website] Render Playground logs as escaped text - #4031

Merged
adamziel merged 2 commits into
trunkfrom
website-escape-playground-logs
Jul 13, 2026
Merged

[Website] Render Playground logs as escaped text#4031
adamziel merged 2 commits into
trunkfrom
website-escape-playground-logs

Conversation

@adamziel

Copy link
Copy Markdown
Collaborator

Playground logs are currently passed through dangerouslySetInnerHTML() so Error: and Fatal: can be marked. A log entry containing HTML is therefore interpreted as page markup instead of displayed as log text.

This splits severity markers into plain data and lets React render every segment. Log text is escaped, the markers remain highlighted, and entries keep their original append-only index when filtering or reversing the list.

Tested with:

  • npm exec nx -- test playground-website --testFile=log-highlights.spec.ts
  • npm exec nx -- run playground-website:lint
  • npm exec nx -- run playground-website:typecheck

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR removes dangerouslySetInnerHTML() from Playground log rendering to ensure log entries containing HTML are displayed as escaped text while still highlighting severity markers.

Changes:

  • Added a splitLogHighlights() helper to split log lines into highlighted/non-highlighted segments.
  • Updated the log modal to render segments via React elements instead of injecting HTML.
  • Added Vitest coverage to verify highlighting behavior and HTML-escaping.

Reviewed changes

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

File Description
packages/playground/website/src/components/log-modal/log-highlights.ts Introduces a line-splitting helper that returns structured segments instead of HTML.
packages/playground/website/src/components/log-modal/log-highlights.spec.ts Adds tests validating highlighting rules and that markup is treated as plain text.
packages/playground/website/src/components/log-modal/index.tsx Switches rendering from dangerouslySetInnerHTML to React-rendered segments with stable keys.

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

Comment thread packages/playground/website/src/components/log-modal/log-highlights.ts Outdated
Comment thread packages/playground/website/src/components/log-modal/log-highlights.ts Outdated
@adamziel
adamziel merged commit aeed868 into trunk Jul 13, 2026
53 checks passed
@adamziel
adamziel deleted the website-escape-playground-logs branch July 13, 2026 19:40
adamziel added a commit that referenced this pull request Jul 13, 2026
## What this does

Shows the SQLite database size without copying the database file into
the browser's JavaScript heap.

The database panel now resolves the SQLite path from the runtime
document root and asks PHP to `stat()` it. The download action reuses
that resolved path instead of assuming `/wordpress`.

Stacked on #4031.

## Testing

- `npm exec nx -- run-many -t lint typecheck -p playground-website
--parallel=2`
- `npm exec nx -- run playground-website:e2e:playwright --
--grep="should stat the database size without reading the database into
JavaScript" --project=chromium`
- assertion passed; local Vite startup needed Playwright's first retry
because its shared dependency cache omitted a generated chunk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment