fix(dashboard): bundle backdrop filler image via Vite import (#24355) - #24713
fix(dashboard): bundle backdrop filler image via Vite import (#24355)#24713Tranquil-Flow wants to merge 1 commit into
Conversation
| // Import directly so Vite bundles the asset; the prior `/ds-assets/...` | ||
| // path 404s whenever the `npm run sync-assets` prebuild hook is bypassed | ||
| // (issue #24355). | ||
| import fillerBg from "@nous-research/ui/assets/filler-bg0.jpg"; |
There was a problem hiding this comment.
fillerBg has moved to filler-bg0.webp
There was a problem hiding this comment.
Fixed — import now references filler-bg0.webp (verified via npm pack: the @nous-research/ui@0.10.0 lockfile-pinned version ships .jpg, but 0.15.0 ships only .webp so any lockfile bump would have broken the old path). New head: 798ec38.
There was a problem hiding this comment.
Pull request overview
This PR fixes a dashboard regression where the default backdrop filler image could 404 when sync-assets didn’t populate web/public/ds-assets/ (e.g., direct vite build, partial prebuild failure, or stale-dist fallback). It switches the filler image to be bundled via a Vite-resolved module import so the asset is emitted into web_dist/assets/ with a content-hashed name.
Changes:
- Update
Backdropto import the filler image via@nous-research/ui/assets/filler-bg0.jpgand use the bundled URL in<img src>. - Add a contract test ensuring
Backdrop.tsxdoesn’t reference the fragile/ds-assets/...path and does import via the design system package export.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| web/src/components/Backdrop.tsx | Replaces a fragile public-path image reference with a Vite-bundled asset import. |
| tests/tools/test_backdrop_filler_bundling.py | Adds a regression/contract test to prevent reintroducing the /ds-assets/ dependency for the default backdrop filler. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| source = BACKDROP.read_text(encoding="utf-8") | ||
| assert '"@nous-research/ui/assets/filler-bg0.jpg"' in source, ( | ||
| "Backdrop.tsx must import the filler image from " | ||
| "`@nous-research/ui/assets/filler-bg0.jpg` so Vite bundles it. " | ||
| "See #24355." | ||
| ) |
There was a problem hiding this comment.
Loosened — the assertion is now a regex tolerating either quote style and either extension:
pattern = re.compile(
r'''from\s+['"]@nous-research/ui/assets/filler-bg0\.(?:webp|jpg)['"]'''
)
assert pattern.search(source), ...Formatting changes (single vs double quotes, whitespace, multi-line import) no longer break the contract. Negative check on /ds-assets/ is unchanged. New head: 798ec38.
|
@austinpickett — fixed the filler-bg rename: import now references Also addressed the Copilot inline note on New head: |
|
It's important to bump the @nous-research/ui package first, 0.15.0. There's some breaking changes that were caused from that. |
Copy that, will integrate this. |
|
@copilot resolve the merge conflicts in this pull request |
798ec38 to
81f7083
Compare
|
@austinpickett — done, and the PR is now narrower than it was. Turns out the Reformulated the PR around the two remaining pieces:
New head: Happy to split the ui bump out as its own PR if you'd prefer the test landing separately. |
austinpickett
left a comment
There was a problem hiding this comment.
Review: fix(dashboard): bundle backdrop filler image via Vite import
Contract test + @nous-research/ui version bump. The actual Vite import fix landed in a prior commit; this PR adds the regression guard.
(item 1) Contract test is well-designed — negative check (no /ds-assets/filler-bg0 literal) + positive check (import from @nous-research/ui/assets/). Regex tolerates quote style and extension changes. Thorough docstring.
(item 2) Version bump 0.14.0 → 0.15.0 is a minor bump that presumably adds the ./assets/* package export map entry Vite needs. Pinned version appropriate for internal design system.
(item 3) 4500+ line package-lock.json diff is mechanical.
Verdict: Approve ✅ — Clean regression guard.
Reviewed by Hermes Agent
81f7083 to
09b386f
Compare
09b386f to
529bf17
Compare
What does this PR do?
When this PR was first opened,
web/src/components/Backdrop.tsxstill imported the filler image via the fragile/ds-assets/filler-bg0.*public path that depended on thesync-assetsprebuild hook firing. Directvite build, partial prebuild failures, or_build_web_ui's stale-dist fallback (#23817) would silently 404 the asset and the default backdrop would disappear. The PR switched the import to@nous-research/ui/assets/filler-bg0.webpso Vite bundles a content-hashed copy intoweb_dist/assets/.That
Backdrop.tsxchange has since landed onmainindependently (along with removal of the redundantsync-assets/predev/prebuildscripts), so the original code change is no longer needed.This PR now carries the two remaining pieces around that landed change:
Regression contract test (
tests/tools/test_backdrop_filler_bundling.py) — assertsBackdrop.tsxdoes NOT reference the fragile public path and DOES import via the design-system package's./assets/*export. The import-pattern assertion uses a regex that tolerates either quote style and either.webp/.jpgextension so future ds-asset bumps or reformats don't false-positive the contract.@nous-research/uibump 0.14.0 → 0.15.0 per @austinpickett's request — the breaking changes that surfaced the original regression originate in the 0.15.0 release. Verified that 0.15.0 still shipsdist/assets/filler-bg0.webp+dist/hooks/use-gpu-tier+ everydist/ui/components/{button,list-item,selection-switcher,spinner,badge,select,tabs,command-block}import used inweb/src/.npm run buildpasses clean.Related Issue
Addresses #24355 (original code change already on main; this PR adds the regression test + the upstream-requested ui bump)
Type of Change
Changes Made
tests/tools/test_backdrop_filler_bundling.py(new, 63 LOC, 2 tests) — contract guard against re-introducing the/ds-assets/public-path dependency inBackdrop.tsx.web/package.json— bump@nous-research/uifrom0.14.0to0.15.0.web/package-lock.json— regenerated against0.15.0.How to Test
pytest tests/tools/test_backdrop_filler_bundling.py -q→ 2 passed.cd web && npm install && npm run build→ vite build passes clean;web_dist/assets/filler-bg0-<hash>.webpemitted.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs