Skip to content

fix(explore): mount Ask pill via importmap for dompurify and marked#305

Merged
SimplicityGuy merged 1 commit intomainfrom
fix/ask-pill-importmap
Apr 15, 2026
Merged

fix(explore): mount Ask pill via importmap for dompurify and marked#305
SimplicityGuy merged 1 commit intomainfrom
fix/ask-pill-importmap

Conversation

@SimplicityGuy
Copy link
Copy Markdown
Owner

Summary

  • The global Ask pill introduced in feat: redesign Ask as global pill with agent-driven UI actions #304 never mounted in production — nlq-markdown.js uses bare module specifiers (dompurify, marked) but explore serves static files with no bundler, so the browser throws Failed to resolve module specifier "dompurify". The error cascades through the module chain (nlq.jsnlq-summary-strip.jsnlq-markdown.js), window.NlqInit is never set, and app.js's DOMContentLoaded handler finds nothing to call. Vitest tests passed throughout because jsdom resolves from node_modules.
  • Fix: add an <script type="importmap"> in explore/static/index.html mapping both specifiers to pinned cdn.jsdelivr.net/.../+esm URLs (matching the existing pinned-CDN pattern used for d3, plotly, and alpine).
  • Regression test: explore/__tests__/importmap-coverage.test.js scans every static/js/**/*.js for bare import specifiers and asserts each one is declared in the importmap, and that the importmap appears before the first module script.
  • Drive-by: normalize nlq-pill.css href from /css/nlq-pill.css to css/nlq-pill.css to match the file's existing relative-path convention for own static assets.

Test plan

  • just test-js — 987 tests passing (up from 985; includes the 2 new regression tests)
  • Reload explore in the browser and confirm:
    • Ask pill appears on page load
    • Browser console shows no module-resolution errors
    • Submitting a query streams a summary strip with applied actions
    • nlq-pill.css still loads correctly after the href change

🤖 Generated with Claude Code

The Ask pill never mounted in production because nlq-markdown.js uses
bare module specifiers (dompurify, marked) but explore serves static
files with no bundler. The browser rejected the imports with
"Failed to resolve module specifier", which cascaded through the
module chain (nlq.js → nlq-summary-strip.js → nlq-markdown.js) so
window.NlqInit was never set and app.js's DOMContentLoaded handler
found nothing to call. Vitest tests still passed because jsdom
resolves from node_modules.

Add an import map in index.html pointing both specifiers to pinned
jsdelivr /+esm URLs (matching the existing CDN-with-version pattern),
add a regression test that scans all static JS for bare specifiers
and asserts each is declared in the importmap, and normalize
nlq-pill.css to a relative href to match the rest of the file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (firefox)

Totals Coverage
Statements: 46.5% ( 1241 / 2669 )
Lines: 46.5% ( 1241 / 2669 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit)

Totals Coverage
Statements: 46.5% ( 1241 / 2669 )
Lines: 46.5% ( 1241 / 2669 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (chromium)

Totals Coverage
Statements: 46.5% ( 1241 / 2669 )
Lines: 46.5% ( 1241 / 2669 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPhone 15)

Totals Coverage
Statements: 46.5% ( 1241 / 2669 )
Lines: 46.5% ( 1241 / 2669 )

StandWithUkraine

@github-actions
Copy link
Copy Markdown
Contributor

E2E Coverage (webkit - iPad Pro 11)

Totals Coverage
Statements: 46.5% ( 1241 / 2669 )
Lines: 46.5% ( 1241 / 2669 )

StandWithUkraine

@SimplicityGuy SimplicityGuy merged commit 9563739 into main Apr 15, 2026
46 checks passed
@SimplicityGuy SimplicityGuy deleted the fix/ask-pill-importmap branch April 15, 2026 20:46
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