Skip to content

Delta always defaults to dark mode — terminal background detection broken #119

@jdgomeza

Description

@jdgomeza

Describe the bug

Delta always renders with dark mode colors inside diffnav, even on light terminal backgrounds. Standalone delta detects correctly.

Delta's detection sends OSC 11 to the terminal and reads the response. Inside diffnav this fails because:

  • diffFile()/diffDir() pipe delta's stdout to a buffer — is_terminal() returns false, detection skips, defaults to dark
  • bubbletea owns the terminal in raw mode, so even forcing detection via --detect-dark-light always races with bubbletea's input reader

Same root cause as jesseduffield/lazygit#4550.

Related: #5, #86, #89

To Reproduce

  1. Set terminal to a light background
  2. Run echo "" | delta — correct light colors
  3. Run git diff HEAD~1 | diffnav — dark colors, poor contrast

Expected behavior

Diffs should match the terminal's actual background. Bubbletea v2 provides tea.RequestBackgroundColor() which queries OSC 11 during init and delivers BackgroundColorMsg with .IsDark(). diffnav can pass --dark/--light to delta based on this.

I have an implementation with tests ready if you'd like a PR.

Screenshots

N/A

Desktop (please complete the following information):

  • OS: Mac
  • Version: v0.11.0
  • Terminal Emulator: Ghostty
  • Using tmux? Reproducible with and without

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions