Skip to content

fix(webview): allow service worker via CSP worker-src#1016

Merged
enyst merged 1 commit into
developfrom
fix/webview-worker-src-csp
Apr 5, 2026
Merged

fix(webview): allow service worker via CSP worker-src#1016
enyst merged 1 commit into
developfrom
fix/webview-worker-src-csp

Conversation

@enyst
Copy link
Copy Markdown
Owner

@enyst enyst commented Apr 5, 2026

What

Add worker-src to the webview Content-Security-Policy so VS Code can register the webview service worker.

Why

Without worker-src, the webview can fail to load with:

Could not register service worker: InvalidStateError: The document is in an invalid state


Open with Devin

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enabled web worker execution in webviews to support service worker functionality.

This unblocks webview loading when VS Code fails service worker registration with InvalidStateError.

Co-authored-by: smolpaws <engel@enyst.org>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 396e5d88-b379-4a8a-9940-0395ffe905da

📥 Commits

Reviewing files that changed from the base of the PR and between 43c56dc and 93d2be4.

📒 Files selected for processing (1)
  • src/webview/getWebviewHtml.ts

📝 Walkthrough

Walkthrough

The CSP configuration in getWebviewHtml has been updated to include a worker-src directive that permits web worker execution from the webview's CSP source, enabling VS Code webview service worker functionality.

Changes

Cohort / File(s) Summary
CSP Worker Configuration
src/webview/getWebviewHtml.ts
Added worker-src ${webview.cspSource} directive to Content Security Policy, explicitly allowing web workers to execute from the webview's CSP source.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A tiny thread now hops and plays,
Worker threads bloom in CSP's maze,
Service friends dance in webview's light,
One small directive sets things right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding worker-src CSP directive to enable service worker functionality in the webview.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/webview-worker-src-csp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Content Security Policy (CSP) in src/webview/getWebviewHtml.ts to explicitly allow service workers by adding the worker-src directive. Feedback indicates that the CSP is currently missing a connect-src directive; since default-src is set to 'none', network operations such as fetch and WebSocket will be blocked unless connect-src is explicitly defined.

Comment thread src/webview/getWebviewHtml.ts
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 5, 2026

🔧 VSCode Extension Built Successfully

• File: openhands-tab-0.9.3.vsix (548 KB)
• Download: https://github.com/enyst/OpenHands-Tab/actions/runs/24010755386

To install:

  1. Download the artifact from the run page above
  2. VS Code → Command Palette → "Extensions: Install from VSIX..."
  3. Select the downloaded .vsix

Built with Node 22. Commit a28f1c9.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@enyst enyst merged commit d266a36 into develop Apr 5, 2026
11 of 21 checks passed
@enyst enyst deleted the fix/webview-worker-src-csp branch April 5, 2026 21:50
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