Skip to content

DISCO-282: Report why the local preview doesn't load - #462

Open
Philipp Koytek (philippkoytek) wants to merge 3 commits into
mainfrom
DISCO-282-preview-app-reporter
Open

Philipp Koytek (philippkoytek) wants to merge 3 commits into
mainfrom
DISCO-282-preview-app-reporter

Conversation

@philippkoytek

Copy link
Copy Markdown
Contributor

Description

content-cli sdk preview now injects a small reporter script as the first element of every proxied HTML page and adds its SHA-256 hash to script-src. The app's own inline scripts stay blocked unless --allow-inline-scripts is passed.

The reporter posts to the Celonis preview that the page loaded, how many inline scripts the preview blocks, and which uncaught errors, rejections and CSP violations stopped the app. With that, the Codehub Local preview can show the matching hint right away instead of waiting for the SDK: preview not reachable, inline scripts blocked, or the app's error.

  • preview-app-reporter.ts: copy of SANDBOX_APP_REPORTER from ems-frontend and injectAppReporter(). The proxy computes the hash at runtime, so LOCAL_PREVIEW_HEADERS stays equal to ems-frontend's localPreviewHeaders().
  • The report messages are the contract with ems-frontend; the spec runs the copy and checks them.
  • Safe to release before or after the ems-frontend change: without it, nothing listens to the reports.

Relevant links

Checklist

  • I have self-reviewed this PR
  • I have tested the change and proved that it works in different scenarios (Chrome with a Vite + React app: preview not running, untrusted certificate, inline scripts blocked and allowed, localStorage error, blocked external request)
  • I have updated docs if needed

Co-Authored-By: Claude noreply@anthropic.com
Includes-AI-Code: true

sdk preview now adds the Celonis app reporter as the first element of
every proxied HTML page and allows it by its hash in the preview CSP.
The reporter tells the Celonis preview that the page loaded, how many
inline scripts the preview blocks, and which errors stopped the app, so
the Codehub can show the matching hint right away.

Co-Authored-By: Claude <noreply@anthropic.com>
Includes-AI-Code: true
The reporter is copied from ems-frontend's SANDBOX_APP_REPORTER, which
is now built from typed observers. The proxy hashes the copy it injects
and adds that hash to script-src, so LOCAL_PREVIEW_HEADERS stays equal to
ems-frontend's localPreviewHeaders(). The spec checks the report
messages, which are the contract with ems-frontend.

Co-Authored-By: Claude <noreply@anthropic.com>
Includes-AI-Code: true
Co-Authored-By: Claude <noreply@anthropic.com>
Includes-AI-Code: true
@sonarqubecloud

Copy link
Copy Markdown

@philippkoytek
Philipp Koytek (philippkoytek) marked this pull request as ready for review November 11, 2026 17:54
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.

1 participant