Repository navigation
Fix the published widget embed snippets - #467
Merged
Merged
Conversation
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
Member
Author
Review responseA Sonnet reviewer ran real checks on every source (the release-notes heredoc executed as the workflow runs it,
Confirmed fine: every snippet's order and host, and |
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.
Fixes the widget embed snippets OSA publishes, found while auditing the docs on 2026-09-23.
The bug
The pinned, integrity-checked snippet for security-sensitive embeds carried
deferon the script tag. An embed follows it with an inlineOSAChatWidget.setConfig({...}), and an inline script runs before a deferred one, so the page throwsReferenceError: OSAChatWidget is not definedand the widget starts with its default community. Measured in Chrome: a page asking for FieldTrip got the HED assistant; withoutdeferit gets FieldTrip. The snippet was generated byrelease.ymlinto every release's notes, printed byscripts/widget-sri.py, and shown twice on the demo page. (The published v0.8.13 release notes were corrected by hand the same day, with a dated note.)Changes
release.yml,scripts/widget-sri.py,frontend/index.html: nodefer; the release notes andwidget-sri.pynow also print thesetConfigline after the tag, so the snippet is complete and in order.src/api/routers/widget_test.py: the test page's copy-paste card pointed adopters athttps://osa.osc.earth/frontend/osa-chat-widget.js.osa.osc.earthwas never created (OSC's hostnames put the project in the path: Record the hostname rule: plane subdomain, project path osc#2); it now showshttps://demo.osc.earth/osa-chat-widget.js, thensetConfig.README.md: the BIDS assistant is available, not planned; the key link isplatform.claude.com/settings/keys.osa-demo.pages.dev: outside sites embed from it today, and it keeps serving.Tests
tests/test_frontend/test_embed_snippet_hygiene.pyparses every published snippet (the test page through a realTestClientrequest, both demo-page snippets from the file, the release-notes heredoc executed as the workflow runs it, andwidget-sri.py's real output forv0.8.13, network-marked) and fails ondeferorasyncbefore an inlinesetConfig, or on a host other thandemo.osc.earth, a jsDelivr pin of this repository, or a relative path. Puttingdeferback in the demo page fails it. In Chrome, the corrected structure loads FieldTrip, and addingdeferback reproduces theReferenceError.