Skip to content

emit OSC 8 terminal hyperlinks for file paths and error locations #4295

@ryanhanks-bestow

Description

@ryanhanks-bestow

Feature Request: Add OSC 8 Hyperlink Support

build_runner currently prints file paths and error locations (both relative paths and package: URIs) as plain text.

Modern terminal emulators and editors (including JetBrains + VS Code) support OSC 8 hyperlinks. These make file paths and error locations clickable, instantly opening the file (optionally, at an exact line and column.)

Adding this to build_runner would improve developer productivity.

Official Specification & References

  1. Primary specification – Xterm control sequences (updated June 2025)
    https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands

  2. Detailed practical documentation – mintty wiki
    https://github.com/mintty/mintty/wiki/CtrlSeqs#hyperlinks

Implementation Notes

  • The Dart SDK already has reusable ANSI utilities (detect ANSI support via stdout.supportsAnsiEscapes). Optionally add a --no-hyperlinks flag for CI environments if necessary.
  • Resolve the hyperlink target to an absolute file:// URI (required for reliable opening in all terminals/IDEs):
    • Relative paths (e.g. lib/src/utils.dart:45) → resolve against the project root using the path package or Directory.current.
    • package: URIs (e.g. package:my_app/utils.dart:120) → resolve via package_config or Uri.base.resolve() to the real on-disk location (local package or .pub-cache).
  • Keep the display text exactly as currently printed (relative or package: form) — only the invisible hyperlink target changes.

Example:

lib/src/utils.dart:45:8      → clickable → file:///Users/me/project/lib/src/utils.dart:45:8
package:my_app/foo.dart:23   → clickable → file:///Users/me/.pub-cache/hosted/pub.dev/my_app-1.2.3/lib/foo.dart:23

Thank you for considering this enhancement!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions