Skip to content

Fix the published widget embed snippets - #467

Merged
neuromechanist merged 7 commits into
developfrom
fix/embed-snippets
Sep 24, 2026
Merged

neuromechanist merged 7 commits into
developfrom
fix/embed-snippets

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

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 defer on the script tag. An embed follows it with an inline OSAChatWidget.setConfig({...}), and an inline script runs before a deferred one, so the page throws ReferenceError: OSAChatWidget is not defined and the widget starts with its default community. Measured in Chrome: a page asking for FieldTrip got the HED assistant; without defer it gets FieldTrip. The snippet was generated by release.yml into every release's notes, printed by scripts/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: no defer; the release notes and widget-sri.py now also print the setConfig line 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 at https://osa.osc.earth/frontend/osa-chat-widget.js. osa.osc.earth was never created (OSC's hostnames put the project in the path: Record the hostname rule: plane subdomain, project path osc#2); it now shows https://demo.osc.earth/osa-chat-widget.js, then setConfig.
  • README.md: the BIDS assistant is available, not planned; the key link is platform.claude.com/settings/keys.
  • Nothing touches osa-demo.pages.dev: outside sites embed from it today, and it keeps serving.

Tests

tests/test_frontend/test_embed_snippet_hygiene.py parses every published snippet (the test page through a real TestClient request, both demo-page snippets from the file, the release-notes heredoc executed as the workflow runs it, and widget-sri.py's real output for v0.8.13, network-marked) and fails on defer or async before an inline setConfig, or on a host other than demo.osc.earth, a jsDelivr pin of this repository, or a relative path. Putting defer back in the demo page fails it. In Chrome, the corrected structure loads FieldTrip, and adding defer back reproduces the ReferenceError.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://fix-embed-snippets-demo.osc.earth
Branch fix/embed-snippets
Commit 16aa3f9

This preview will be updated automatically when you push new commits.

@neuromechanist

Copy link
Copy Markdown
Member Author

Review response

A Sonnet reviewer ran real checks on every source (the release-notes heredoc executed as the workflow runs it, widget-sri.py v0.8.13 fetched live, the test page through TestClient) and found four things. All are fixed:

  • A broken snippet already on develop. docs/community-widget.md, added by NEMAR's widget in the search-button blue; boot Python on the first message #463, loaded https://widget.osc.earth/osa/osa-chat-widget.js, which is the API edge and answers HTTP 400; serving the script there is Serve the widget script from widget.osc.earth/osa #464. It now loads demo.osc.earth (0c04770).
  • The checker could not see order. A setConfig script placed before the widget's tag, with no defer, throws the same ReferenceError, and swapping them passed every test. The checker now tracks document order and requires a non-deferred widget script before any inline setConfig; a test reorders the real demo-page snippet (bfa73ea).
  • A snippet in a new file was invisible, which is how the first item slipped through. A tripwire scans every tracked text file for a widget <script> tag and requires each to be a parsed source, a docs/**/*.md page (whose fenced html blocks are now parsed), or one of two commented relative-path harness pages. A throwaway broken page under docs/ fails it (bfa73ea).
  • Three more console.anthropic.com links (the osa init docstring and welcome text, and the 403 body) now point at platform.claude.com; no occurrence remains (4b8d5ed).

Confirmed fine: every snippet's order and host, and osa-demo.pages.dev untouched in every allowlist. Full suite: 2,761 passed; the one failure is #434.

@neuromechanist
neuromechanist merged commit e3ae469 into develop Sep 24, 2026
21 of 22 checks passed
@neuromechanist
neuromechanist deleted the fix/embed-snippets branch September 24, 2026 05:31
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