fix(opencode): allow Ghostty WASM data URLs in web CSP#26004
Closed
mxl wants to merge 1 commit into
Closed
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Author
|
Duplicates #25937 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #26001
Closes #21088
Related to #9185, #9420, and #5237.
Type of change
What does this PR do?
Fixes web UI CSP handling for the embedded app and Ghostty web terminal.
Ghostty loads its WASM runtime from a
data:application/wasm;base64,...URL. The current CSP blocks that throughconnect-src, so this PR allowsdata:there.The embedded UI path also used a static CSP that did not include the hash for the inline
oc-theme-preload-script. This PR generates embedded HTML CSP from the actual inline script body, matching the proxied HTML behavior.It also avoids falling back to
index.htmlfor missing asset-like embedded paths, so missing.wasm,.js,.css, and/assets/...requests return404instead of HTML.How did you verify your code works?
Ran:
cd packages/app && bun typecheckcd packages/opencode && bun typecheckcd packages/opencode && bun test test/server/httpapi-ui.test.tsThe pre-push hook also ran
bun turbo typechecksuccessfully.The fix was also verified in browser against the reported failure: the terminal opens after allowing
data:inconnect-src.Screenshots / recordings
No screenshot. This is a CSP/server response fix.
Checklist