Repository navigation
fix: keep host page styles off code, lists and text in widget replies - #601
Merged
neuromechanist merged 5 commits intoOct 8, 2026
Merged
neuromechanist merged 5 commits into
neuromechanist merged 5 commits into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Review of the host-style protection: inline code and pre take line-height and font-size from the reply instead of a fixed 1.5 and 14px, and list markers revert to the browser default so nested lists keep their circles. Tested in headless Chrome: zero computed-style differences from develop on a bare page, light and dark.
The Run this Python and run-code cards render code outside the reply, so they took a host theme's code rules (border, padding, font, nowrap). The card's pre gets an explicit border and line height, its code reverts to browser defaults. Tested in headless Chrome: zero differences on a bare page, none from the code rules under the Read the Docs and PyData themes.
…t host styles Same approach for the other reply properties a docs theme sets: li/th/td font size and line height, list marker position and image, table vertical alignment and border style, hr height, opacity and color, strong and em color, link hover color and underline offset, citation superscript position, copy and run button fonts. Tested in headless Chrome: zero differences from develop on a bare page, light and dark; the only differences left under the two themes are text color inherited by the cards from the page body.
Runs the widget in happy-dom under a page that carries Read the Docs and PyData style rules on code, pre, p, li and h2: computed styles for what happy-dom resolves, a plain code element outside the widget as the control, and stylesheet pins for inherit and revert. 39 checks pass; against develop's stylesheet 31 fail. Registered in test.yml and tests.yml.
neuromechanist
merged commit Oct 8, 2026
7f08ee5
into
OpenScience-Collective:develop
7 of 8 checks passed
11 tasks
neuromechanist
pushed a commit
that referenced
this pull request
Oct 10, 2026
Retitles [Unreleased] to [0.8.18], as for earlier releases. Adds the entries that were missing for #599 (hed-suggest in the image), #600 (HED prompt), #601 (widget host styles) and #605 (live tests by hand), and one for the DEFAULT_MODEL check at startup. Names the three classes that are accepted (the other five are refused), and fixes a reference that pointed the wrong way. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_019MtQNfPzMpGxEJFUciXbTN
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.
Part of #597 (the reply content; what is left of the widget is under Not covered).
Summary
On a Sphinx docs site the host theme's rules on bare elements reach the widget's replies wherever the widget's stylesheet leaves a property unset. With
sphinx_rtd_themea code block collapses onto one line (white-space: nowraponcode), inline code turns red with a border, list markers disappear and paragraph text grows to 16px. With the PyData theme inline code turns purple.This sets those properties explicitly in the
.osa-message-contentrules:color,border,white-space,max-width,overflowandline-heightoncode;white-space: preonpre code;font-family,font-size,line-height,borderandclearonpre;font-sizeandline-heightonp;font-familyandcoloron headings;list-style-typeon lists. Stylesheet only.On a page with no host styles nothing changes: each value is what the element already computed to there.
Tests
sphinx_rtd_themesites and 4 on the PyData one. After: none on any of the six.bun frontend/test-markdown.js(31 passed),test-widget-color-scheme.js(128),test-widget-first-paint.js(91),test-widget-capsule.js(133),test-citation-markers.js(10),test-streaming.js(all passed), with bun 1.4.2.node --check frontend/osa-chat-widget.js.frontend/test-widget-host-styles.js, below. The comparison against the real theme stylesheets needs a real browser and is not part of the suite.Not covered
The rest of the widget is still reachable by host rules (
box-sizing: border-boxon every element, fonts on the header buttons and the input); see #597.Review follow-up
Commits added to this branch after review (
a99a279to58d1d82):pretakeline-heightandfont-sizefrom the reply (inherit) instead of a fixed 1.5 and 14px, so a heading containing code keeps the heading's line height and a different bubble font size carries through. List markers userevert, notdiscanddecimal, so nested lists keep their circles and squares.codeandprerules too. The card'spregets an explicit border and line height; itscodeisall: revert, which is exactly what a page with no host styles gives it.li,thandtdfont size and line height, list marker position and image, table cell vertical alignment, caption side and row border style,hrheight, opacity and color,strongandemcolor, link hover color and underline offset, the citation superscript's position, and the fonts of the copy and run buttons.frontend/test-widget-host-styles.js(39 checks, registered intest.ymlandtests.yml): the widget in happy-dom under a page with Read the Docs and PyData rules oncode,pre,p,liandh2, computed styles for what happy-dom resolves (a plain<code>outside the widget is the control that the host rule is live), and stylesheet pins forinherit,revertandall. Against develop's stylesheet 32 of its 39 checks fail.Additional tests:
hr, citations, sources, usage line, both code cards) on a bare page and under the realsphinx_rtd_theme(PyNWB) and PyData (NeuroConv) stylesheets, every computed property of every element compared. Bare page, light and dark: zero differences from develop. Under both themes, none fromcode,pre, lists, headings, tables,hr, links, the citation or the buttons; what is left is the text color the code cards inherit from the page body.node --checkon the widget.Not covered:
body. Fixing it would change the card on a bare page (black to the widget's text color), so I left it.box-sizing: border-boxon every element,-webkit-tap-highlight-colorandtext-size-adjustfrom a host's*rules, and the header buttons and input, as in the first version.#content code) still wins; no stylesheet rule can stop that short of!important.