Skip to content

bug(ui): code in a language outside the 39 preloaded grammars is never highlighted in the browser #5384

Closed

Description

@yannickmonney

Summary

The shared Shiki highlighter in packages/ui loads 39 grammars, plus Tale's template grammars, and loads any other language on demand. That on-demand load is a runtime import() of a bare module name, `shiki/langs/${lang}.mjs`, which a browser cannot resolve. So every other language falls back to plain text, with a console warning. The chat agents epic's browser pass (#5371) saw this on 2026-11-05: previewing planets.csv logged [shiki] language "csv" not loadable, falling back to plaintext.

What the repository says today (main 9be27c4e2)

  • The strategy comment says: "Anything else is lazy-loaded on demand via a runtime dynamic import." (packages/ui/src/markdown/shiki.ts:1-14)
  • The eager grammars are at :69-111.
  • The on-demand load is at :338-365: import(/* @vite-ignore */ `shiki/langs/${resolvedLang}.mjs`). @vite-ignore tells Vite to leave the import as written.
  • The production build keeps it that way. The platform's built app-*.js (a build from 2026-11-05) contains import(`shiki/langs/${n}.mjs`). The eager grammars are chunks of their own (for example lua-*.js and sql-*.js), and nothing is built for csv. The app has no import map.
  • Callers:
    • The file preview highlights by the file's extension (services/platform/app/features/documents/components/document-preview-text.tsx:45-75); a CSV file is in the data category.
    • A Markdown code block highlights by its fence's language (packages/ui/src/markdown/code-block.tsx:54 → highlighted-code.tsx:104), which includes chat replies.

Not examined: the docs sites; which other languages people use; a test of the on-demand path (git grep finds none).

Options (no preference)

  1. Let the bundler see every possible import: a glob or a fixed map of the extra grammars, each as its own lazy chunk.
  2. Add the common extras (CSV, for example) to the eager list.
  3. Drop the on-demand path and its promise: other languages are plain text, without the warning.

Related

Activity

  1. added
    priority: low
    bug
    service: platform
    on Nov 5, 2026
  2. added
    agent-ready
    on Nov 5, 2026
  3. added a commit that references this issue on Nov 5, 2026
    f1dbd1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybugpriority: lowservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions