Skip to content

Agent V2 file preview renders code and config files without syntax highlighting #45031

Closed

Description

@lyzno1

The Agent V2 file preview dialog shows every text file as plain monospace lines. It is the shared preview for configured files, the build note, skill packages, and the preview working directory. Scripts, config, and SKILL.md all render without syntax colors. The web app already ships @pierre/highlights, but only Markdown code blocks use it.

Direction

Highlight the dialog's text branch with Highlights. Keep the existing order of loading, error, image, binary, and empty states.

  • Infer the language from the file name. Use the extension, or the bare name for files such as Dockerfile. Highlights accepts extensions as language aliases but does not detect languages itself. Unknown names and .txt stay plain text.
  • Load the highlighter and both themes on demand. Show plain text until it is ready, and keep plain text if loading or tokenizing fails.
  • Tokenize once for both color schemes using CSS custom properties, and let the app's data-theme choose. Switching themes then needs no JS theme subscription and no new lexer pass.
  • Cap token output for very long lines so minified files do not create thousands of spans.

Follow-ups worth considering

  • Markdown code blocks pass a JS theme into Highlights and re-tokenize when the theme changes. They could use the same dual-theme tokens.
  • Agent roster tool calls render request and response payloads as plain text.
  • Extension-based detection misses Dockerfile.* and CMakeLists.txt, and some extensions are ambiguous, such as .m.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions