Grey background issue with Helix inside Byobu

I often work on a remote Linux box and like to have Byobu running so that I have tab view and status bar. But somedays in mid 2024, somethings start to break when I open Helix inside Byobu and get this annoying gray background every where:

Grey background

The root issue is that, Byobu runs Tmux with a configuration, and that configuration makes tmux disable some features which is needed to render Helix theme correctly. The key is the TERM environment variable. No matter which terminal emulator we use, after running Byobu, the TERM is set to screen-256color.

❯ echo $TERM
screen-256color

The good TERM value to prevent that background issue is xterm-256color or any xterm-xxx. Byobu comes with a bunch of Tmux configuration files that are foreign to me.

I found the line which indirectly modifies the TERM variable. It is in /usr/share/byobu/profiles/tmux file:

set -g default-terminal "$BYOBU_TERM"

but I don't want to modify this file, because it will be overwritten if we update Byobu.

After some times doing trial and errors, I came up with a simple solution, that is to add this line to ~/.config/byobu/backend (or ~/.byobu/backend, if your server was installed from very old Ubuntu and upgraded version by version):

BYOBU_TERM=xterm-256color

After exitting Byobu and run again, Helix render correctly:

Normal background

Note, you can also use this:

BYOBU_TERM=$TERM

to let Byobu retains the same value of TERM as before it was running.