Commit Graph

8 Commits

  • fix(tui): default hyperlinks off for unknown terminals and tmux/screen
    OSC 8 hyperlinks landed in #3248, but detectCapabilities() returned
    hyperlinks: true in the unknown-terminal fallback. Terminals that
    silently swallow OSC 8 (most xterm-compatible hosts, tmux/screen
    without passthrough) end up dropping the URL from rendered markdown
    links entirely, since the fallback 'text (url)' rendering is skipped
    whenever hyperlinks is true.
    
    - Unknown terminals now default to hyperlinks: false.
    - tmux and screen (TMUX env, TERM starting with tmux/screen) force
      hyperlinks: false even when the outer terminal would otherwise
      advertise OSC 8 support. Image protocols also left disabled.
    - Added detectCapabilities tests covering the known-capable set and
      the tmux/screen/unknown cases.
  • feat(tui): use OSC 8 hyperlinks in Markdown when terminal supports them (#3248)
    TerminalCapabilities already tracks hyperlinks: boolean and returns true
    for Ghostty, Kitty, WezTerm, and iTerm2, but nothing generated OSC 8
    sequences. This completes that stub.
    
    Changes to packages/tui:
    - terminal-image.ts: add hyperlink(text, url) and setCapabilities()
    - index.ts: export hyperlink and setCapabilities
    - utils.ts: extend AnsiCodeTracker to track active OSC 8 URLs
      - process() now handles OSC 8 open/close sequences
      - getActiveCodes() re-emits the OSC 8 open at each line start
      - getLineEndReset() closes the OSC 8 hyperlink before each line break
      This ensures hyperlinks wrap correctly across multiple lines.
    - components/markdown.ts: link renderer uses hyperlink() when
      getCapabilities().hyperlinks is true; falls back to (url) text
    - Tests: new wrap-ansi tests for OSC 8 line-wrapping; terminal-image
      tests for hyperlink(); markdown tests covering both code paths;
      table-cell width test pinned to hyperlinks:false (checks raw columns)
    
    closes #3239
    
    Co-authored-by: AI (Pi/Claude Sonnet 4.6) <noreply@pi.dev>
    Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
  • fix(tui): isImageLine should detect image escape sequences anywhere in line
    Changed isImageLine() from using startsWith() to includes() to detect
    Kitty and iTerm2 image escape sequences anywhere in a line, not just
    at the start. This prevents TUI width checks from failing on lines
    containing image data, which could cause crashes when rendering tool
    results with images (e.g., when reading image files).
    
    Also added comprehensive test coverage for isImageLine() including:
    - Both iTerm2 and Kitty protocols
    - Regression tests for long lines and terminals without image support
    - Negative cases to ensure no false positives
    
    Fixes crash: 'Rendered line exceeds terminal width' when image
    escape sequences appear in output.