Skip to content

Serve htmx and Pico locally instead of from a CDN - #75

Merged
aaronsmulktis merged 3 commits into
facebookresearch:mainfrom
aaronsmulktis:aaronsmulktis/vendor-frontend-assets
Aug 24, 2026
Merged

Serve htmx and Pico locally instead of from a CDN#75
aaronsmulktis merged 3 commits into
facebookresearch:mainfrom
aaronsmulktis:aaronsmulktis/vendor-frontend-assets

Conversation

@aaronsmulktis

Copy link
Copy Markdown
Contributor

Why serve local dependencies?

fast_app()/FastHTML() load htmx, Pico and three helper scripts from cdn.jsdelivr.net by default. Many eval nodes have no outbound network, so in these cases none of those dependencies arrives there, and nothing anywhere reports that:

htmx missing makes every hx- attribute inert. /todo alone carries 15 hx-put attributes. A checkbox still toggles on click -- that is native browser behaviour, not htmx -- so the screenshot shows the interaction landing while no PUT is sent, /todo_all never changes, and the task scores zero. The trajectory reads as a model that clicked the right element.
Pico missing renders every page unstyled, which changes the observation a screenshot-only agent is graded on.

This PR vendors htmx 2.0.4 (0BSD) and Pico 2.1.1 (MIT) under apps/assets/vendor, served by the static route that already serves jquery and fontawesome the same way. Versions are pinned in the filename: the default pulled pico@latest`, so a run's styling depended on the day it ran.

Every FastHTML construction site now passes default_hdrs=False and takes headers from open_apps.frontend.local_hdrs(). That also removes a duplicate htmx 1.9.10 from unpkg in messenger, which was racing the 2.0.4 FastHTML injected, and two picolink references in codeeditor whose hdrs are rebuilt in set_environment.

Tests:

tests/test_no_egress.py ratchets this. The load-bearing case is test_interactive_routes_load_htmx_locally: a page with hx-* attributes must load htmx from local assets. Verified it has teeth by reverting todo_app to fast_app() -- three tests fail with the fix in the message. Full suite: 704 passed.

fast_app()/FastHTML() load htmx, Pico and three helper scripts from
cdn.jsdelivr.net by default. The eval nodes have no outbound network, so none
of it arrives there, and nothing anywhere reports that:

  * htmx missing makes every hx-* attribute inert. /todo alone carries 15
    hx-put attributes. A checkbox still toggles on click -- that is native
    browser behaviour, not htmx -- so the screenshot shows the interaction
    landing while no PUT is sent, /todo_all never changes, and the task scores
    zero. The trajectory reads as a model that clicked the right element.
  * Pico missing renders every page unstyled, which changes the observation a
    screenshot-scored agent is graded on.

Vendors htmx 2.0.4 (0BSD) and Pico 2.1.1 (MIT) under apps/assets/vendor, served
by the static route that already serves jquery and fontawesome the same way.
Versions are pinned in the filename: the default pulled pico@latest, so a run's
styling depended on the day it ran.

Every FastHTML construction site now passes default_hdrs=False and takes
headers from open_apps.frontend.local_hdrs(). That also removes a duplicate
htmx 1.9.10 from unpkg in messenger, which was racing the 2.0.4 FastHTML
injected, and two picolink references in codeeditor whose hdrs are rebuilt in
set_environment.

Out of scope here, and still listed in the test allowlist: Tailwind, daisyUI,
Font Awesome, highlight.js, phosphor-icons and Leaflet. Those change appearance
rather than behaviour; Leaflet needs the map app rethought.

tests/test_no_egress.py ratchets this. The load-bearing case is
test_interactive_routes_load_htmx_locally: a page with hx-* attributes must
load htmx from local assets. Verified it has teeth by reverting todo_app to
fast_app() -- three tests fail with the fix in the message. Full suite: 704
passed.
@aaronsmulktis
aaronsmulktis requested a lite review from Copilot August 24, 2026 19:06
@aaronsmulktis aaronsmulktis self-assigned this Aug 24, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the runtime dependency on external CDNs for core frontend assets by vendoring htmx and Pico under local static assets and standardizing FastHTML header construction to serve those assets offline on eval nodes.

Changes:

  • Add open_apps.frontend.local_hdrs() + pinned local asset URLs for htmx and Pico.
  • Update apps / start-page host app construction to disable FastHTML default CDN headers and use locally served headers instead.
  • Add no-egress regression tests to ensure interactive routes load local htmx and that static serving of vendored assets works.

Reviewed changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_no_egress.py Adds offline/egress regression tests for CDN usage and local asset loading.
src/open_apps/frontend.py Introduces local_hdrs() and pinned vendor URLs/constants for htmx + Pico.
src/open_apps/apps/todo_app/main.py Switches fast_app() construction to use default_hdrs=False and local headers.
src/open_apps/apps/start_page/helper.py Ensures the main mounted app uses local headers and disables default CDN headers.
src/open_apps/apps/messenger_app/main.py Replaces CDN htmx/Pico usage with vendored headers and disables default CDN headers.
src/open_apps/apps/codeeditor_app/main.py Replaces CDN Pico usage with vendored headers and disables default CDN headers.
src/open_apps/apps/calendar_app/main.py Switches calendar app headers to include vendored Pico/htmx and disables default CDN headers.
src/open_apps/apps/assets/vendor/README.md Documents rationale, versions, and update process for vendored assets.
src/open_apps/apps/assets/vendor/pico-2.1.1.min.css Adds vendored Pico CSS asset.
src/open_apps/apps/assets/vendor/htmx-2.0.4.min.js Adds vendored htmx JS asset.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/open_apps/apps/messenger_app/main.py Outdated
Comment thread src/open_apps/apps/todo_app/main.py
Comment thread src/open_apps/apps/codeeditor_app/main.py
Comment thread src/open_apps/apps/calendar_app/main.py
Comment thread src/open_apps/apps/codeeditor_app/main.py
Comment thread tests/test_no_egress.py
aaronsmulktis and others added 2 commits August 24, 2026 15:16
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@marksibrahim marksibrahim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a great life improvement for us, especially when launching in internet restricted clusters. Thanks Aaron!

@aaronsmulktis
aaronsmulktis merged commit 7edfa64 into facebookresearch:main Aug 24, 2026
2 checks passed
@aaronsmulktis
aaronsmulktis deleted the aaronsmulktis/vendor-frontend-assets branch August 24, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants