Skip to content

OSC 10 / OSC 11 queries report incorrect colors #3590

Closed

Description

@tautropfli

Issue description

When querying for the foreground or background color using the corresponding OSC sequences, zellij always answers with black.

For instance, when I send OSC 11 ; ? ST (query background) I receive back OSC 11 ; rgb:0000/0000/0000 ST even though I'm in a light terminal. Similarly in a dark terminal OSC 10 ; ? ST (query foreground) is responded to with OSC 10 ; rgb:0000/0000/0000 ST.

Example:

$ printf '\e]11;?\e\\' && cat -v
^[]11;rgb:0000/0000/0000^[\

Collected information

Basic information

zellij --version: zellij 0.40.1

stty size: 26 102

uname -av or ver(Windows): Linux taus-fedora 6.8.1-300.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Mar 20 04:39:30 UTC 2024 x86_64 GNU/Linux

Terminal: Alacritty and vte (Ptyxis)

Logs
zellij-12.log
zellij.log

Further information

I noticed that when I clean the cache directory (~/.cache/zellij) I get correct results for the first run of zellij.

Originally this issue was reported in delta (dandavison/delta#1663). Reporting this here totally fell off my radar (sorry).

Activity

  1. jmodrako commented on Nov 8, 2024

    @jmodrako

    Similar behaviour here. I'm using Omakub and when I've been switching themes, the NeoVim has had background=light set for some dark themes. I've checked the OSC11 response and it seems that it was wrong. After clearing the cache, all started working properly :)

  2. linuxmobile commented on Jan 4, 2026

    @linuxmobile

    I did some digging on this and found the root cause.

    TL;DR: Zellij caches the OSC 10/11 response and never invalidates it.

    When Zellij starts, it queries the terminal for fg/bg colors and saves the response to ~/.cache/zellij/. On subsequent sessions, it returns the cached values instead of asking the terminal again.

    The problem is this cache persists even when:

    • You switch between dark/light themes
    • You open Zellij in a different terminal
    • The terminal's color scheme changes

    So if Zellij cached colors from a dark theme session, then you switch to light mode, apps still get the old dark theme colors. Worse: if the initial query fails or times out, Zellij caches rgb:0000/0000/0000 (black) for both fg AND bg.

    This breaks any app that uses termenv/lipgloss to detect background color — which includes glow, mods, gh, delta, neovim, and pretty much all charmbracelet TUIs. They query OSC 11, get stale/wrong colors from Zellij's cache,
    and render text with wrong contrast.

    Workaround: rm -rf ~/.cache/zellij/* and restart Zellij. Works until the cache goes stale again.
    This is especially painful if you switch between dark/light modes regularly.

  3. hicder commented on Feb 26, 2026

    @hicder

    for Mac, you'll need to remove this directory

    rm -rf ~/Library/Caches/org.Zellij-Contributors.Zellij/*
    
  4. yepengfan commented on Mar 15, 2026

    @yepengfan

    hi there, any update on this fix?

  5. karlbunch commented on Mar 15, 2026

    @karlbunch
    Contributor

    Have you tried pulling head and testing? I pushed a PR that adds full background color support, it should report the right values now.

  6. tummetott commented on Mar 19, 2026

    @tummetott

    Have you tried pulling head and testing? I pushed a PR that adds full background color support, it should report the right values now.

    i did pull the latest main (fc0599a) and build from source:

    cargo xtask run

    version is:

    ❯ ./target/dev-opt/zellij --version
    zellij 0.44.0
    

    I did delete the old cache (just in case):

     rm -rf $HOME/Library/Caches/org.Zellij-Contributors.Zellij/
    

    Now i query OSC11

    ❯ printf '\e]11;?\e\\' && cat -v
    ^[]11;rgb:2d2d/2d2d/2d2d^[\
    

    This matches my wezterm bg color:

    [colors]
    background = "#2d2d2d"
    # ... truncated

    next, i change my color scheme in wezterm

    [colors]
    background = "#eaeef2"
    # ... truncated

    Visually, the terminal is now light instead of dark, however OSC11 still shows:

    ❯ printf '\e]11;?\e\\' && cat -v
    ^[]11;rgb:2d2d/2d2d/2d2d^[\
    

    When i now delete the cache again, then it shows the correct value:

    ❯ printf '\e]11;?\e\\' && cat -v
    ^[]11;rgb:eaea/eeee/f2f2^[\
    

    So it seems like that your PR @karlbunch does not fix this issue. Or am i doing something wrong?

  7. calebreed601-dot commented on Mar 19, 2026

    @calebreed601-dot
  8. tummetott commented on Mar 24, 2026

    @tummetott

    @karlbunch i downloaded the latest release 0.44 and i still have the same behavior: OSC11 queries are still reporting incorrect colors. Are you sure this exact scenario was fixed with your PR?

  9. SametAylak commented on Apr 4, 2026

    @SametAylak

    I am using broot, and it doesn’t report the correct colors. However, if I exit the zellij session, broot starts using the correct values.

    ❯ zellij --version
    zellij 0.44.0
    
  10. VasilisManol commented on Apr 21, 2026

    @VasilisManol
    Contributor

    I am having a similar, annoying issue when using helix together with zellij. I think it is the same underlying logic. It came after helix-editor/helix#15527 got merged in helix.
    If I change the background of the terminal (alacritty in my case) while a zellij session is on, all the colors change as expected. However, if I start a helix instance and then exit it helix sets the background color to the old one. Even if I exit zellij, kill or delete all sessions the problem persists. The only workaround is to delete the ~/.cache/zellij/0.44.1/stdin_cache.
    I don't know what would be the correct logic in this case. I guess zellij keeps reporting the cached background color to helix for some reason, which is strange to me since existing and new sessions have the correct new background color.
    Is there a workaround to trigger re-caching of stdin_cache for a running zellij instance?

  11. tummetott commented on Apr 21, 2026

    @tummetott

    I must delete the cash every time I switch from a dark to a light theme. Very annoying. Would love to see a fix of this issue soon too

  12. oguzhanoya commented on Apr 29, 2026

    @oguzhanoya

    for Mac, you'll need to remove this directory

    rm -rf ~/Library/Caches/org.Zellij-Contributors.Zellij/*
    

    That worked for me, thank you @hicder

  13. Ehab-Ibrahim commented on Apr 30, 2026

    @Ehab-Ibrahim

    I think this should be fixed with #5105. I haven't tried it out myself though.

  14. jonas-srlabs commented on May 5, 2026

    @jonas-srlabs

    Yes i can confirm this is fixed in the new release. thanks!

  15. imsnif commented on May 5, 2026

    @imsnif
    Member

    Fixed in 0.44.2

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