Skip to content

fix(web): prevent Prism worker handler conflict - #3521

Merged
kev1n77 merged 1 commit into
GCWing:mainfrom
kev1n77:fmy/uifix
Oct 22, 2026
Merged

kev1n77 merged 1 commit into
GCWing:mainfrom
kev1n77:fmy/uifix

Conversation

@kev1n77

@kev1n77 kev1n77 commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Disable Prism's default JSON worker message handler before Prism initializes in the custom highlight worker.
  • Keep the application's structured { id, content, language } worker protocol unchanged.
  • Add a real Vite-bundle worker regression test that verifies structured messages return highlighted output without the [object Object] JSON parse failure.

Fixes #

Type and Areas

Type: Regression fix / test

Areas: Web UI

Motivation / Impact

Prism automatically installs a JSON-based worker handler when it detects a worker. The application already sends structured objects to the same worker, so Prism attempted to run JSON.parse(event.data) on an object converted to "[object Object]", producing the frontend crash seen in the recent #185 run. The setup module now sets Prism.disableWorkerMessageHandler before Prism is imported, leaving the application's handler as the only message handler.

No direct user-facing copy change. ResizeObserver and Peer workspace issues were intentionally not modified.

Verification

  • pnpm run test:run src/flow_chat/timeline/highlight.worker.test.ts — passed (1 test).
  • pnpm exec tsc --noEmit --target ES2020 --module ESNext --moduleResolution bundler --lib 'es2020,dom,dom.iterable' --strict --skipLibCheck --esModuleInterop --allowSyntheticDefaultImports src/flow_chat/timeline/prismWorkerSetup.ts src/flow_chat/timeline/highlight.worker.ts src/flow_chat/timeline/highlight.worker.test.ts — passed.
  • pnpm run desktop:dev with the requested profile-dev environment — Rust/Tauri build completed and the dev desktop started successfully.
  • Manual dev-browser Worker check using the Vite-generated highlight.worker.ts?worker_file&type=module bundle — TypeScript, JSON, Rust, and unknown-language fallback messages all returned; monitored structured-object request returned one response with zero Worker errors.
  • Current profile-dev webview log inspection — no highlight.worker, Prism SyntaxError, or "[object Object]" is not valid JSON entry after the fix.

Reviewer Notes

  • The rebase was completed onto upstream/main before pushing.
  • The change is limited to the highlight worker setup and its focused regression test.
  • Remote workspace, Peer Device Mode, and Detached Dispatch scenarios were not exercised; this is a local Web UI Worker fix.
  • Full workspace checks were not run because the focused Worker test and TypeScript verification cover the changed files and the desktop dev build was separately validated.
  • AI-assisted change; focused runtime and regression verification completed.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Generated with OpenBitFun

Co-authored-by: OpenBitFun <318544290+bitfun-ai@users.noreply.github.com>
@kev1n77
kev1n77 marked this pull request as ready for review October 22, 2026 07:05
@kev1n77
kev1n77 merged commit bc016f4 into GCWing:main Oct 22, 2026
9 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.

1 participant