Skip to content

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

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

Activity

  1. huyz commented on Apr 2, 2026

    @huyz

    Hmm, I think I have the opposite problem. My diffnav seems to think the terminal is in light mode but I'm in dark mode.

  2. BrahmingWu commented on May 23, 2026

    @BrahmingWu

    Thanks for the detailed explanation and the pointer to tea.RequestBackgroundColor() / BackgroundColorMsg.IsDark() — that was really helpful to understand the root cause.

    I’m also hitting this on a light terminal and getting poor contrast with dark‑mode deltas inside diffnav.

    If automatically detecting the terminal background via Bubbletea is not a quick fix, would you be open to adding a smaller, intermediate step to let users control the delta theme explicitly?

    For example:

    • A config option like delta_theme = "dark" | "light" in diffnav’s config, or
    • A CLI flag like --delta-theme=dark / --delta-theme=light, or
    • A way to pass extra args to delta (e.g. delta_args = "--light --paging=never"), so we can force --dark / --light from the outside.

    This wouldn’t fix the auto‑detection issue, but it would unblock users who are okay with manually matching their terminal theme, without having to wrap or modify delta themselves.

    Totally understand if you’d rather hold out for the “proper” Bubbletea‑based solution, but I figured I’d suggest a simpler escape hatch in case it’s easy to add and helps people in the meantime.

    Thanks again for diffnav — aside from this light‑mode issue it’s been really nice to use.

  3. dlvhdr commented on Aug 21, 2026

    @dlvhdr
    Owner

    Can you check with the latest main?
    I added theme support in #152

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions