Skip to content

fix(web-integration): handle serialized static screenshots#2684

Merged
quanru merged 3 commits into
mainfrom
fix/static-page-serialized-screenshot
Jun 23, 2026
Merged

fix(web-integration): handle serialized static screenshots#2684
quanru merged 3 commits into
mainfrom
fix/static-page-serialized-screenshot

Conversation

@quanru

@quanru quanru commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Handle StaticPage screenshots that arrive as JSON-serialized ScreenshotItem objects from Playground Server mode.
  • Preserve support for normal ScreenshotItem instances and string/base64 screenshots, while throwing a clearer error for screenshot refs without inline base64 data.
  • Add focused StaticPage coverage and a Playground Server regression test for JSON-serialized screenshots.

Root Cause

The first introducing change was 8e02e9a292db73c2b9c29f24ffff9b1580433f11 (refactor(core): replace StorageProvider with ReportGenerator protocol, #1823) on 2026-02-03. That refactor removed the ScreenshotItem.toJSON() path that serialized screenshots as { base64 }. In report Playground Server mode, UIContext is sent through JSON to /execute; the server middleware then updates the static page context with a plain object containing internal screenshot fields such as _base64. StaticPage.screenshotBase64() only recognized a public base64 property and otherwise returned the whole object, which later reached imageInfoOfBase64() and produced imageBase64.replace is not a function.

9a84b5bfd6e8b8dee8c5f5f965453bf6c166fdfe (#1994) later kept the same fallback while removing legacy context compatibility, but it was not the first introducing commit for this error shape.

Validation

  • pnpm --dir packages/web-integration exec vitest --run tests/unit-test/static-page.test.ts tests/unit-test/playground-server.test.ts
  • npx nx test @midscene/web -- tests/unit-test/static-page.test.ts tests/unit-test/playground-server.test.ts
  • npx nx build @midscene/web
  • pnpm run lint
  • git diff --check

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 16, 2026

Copy link
Copy Markdown

Deploying midscene with  Cloudflare Pages  Cloudflare Pages

Latest commit: cd7de56
Status: ✅  Deploy successful!
Preview URL: https://bc223085.midscene.pages.dev
Branch Preview URL: https://fix-static-page-serialized-s.midscene.pages.dev

View logs

@quanru quanru merged commit 64e5cd6 into main Jun 23, 2026
4 of 5 checks passed
@quanru quanru deleted the fix/static-page-serialized-screenshot branch June 23, 2026 06:41
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