Skip to content

TUI theme cannot be re-applied at runtime: running sessions stay stale after terminal palette switch (theme_list keybind doesn't work in 2.2.5) #61598

Open

Description

@sporteka2

Environment

  • OS: Gentoo Base System 2.18 (X11, Cinnamon 6.6.7)
  • OpenCode: v2.2.5 (npm package @opencode/cli, TUI opencode.exe)
  • Terminal: Alacritty 0.16.1 (palette switched at runtime via the terminal's own config rewrite)
  • Config: ~/.config/opencode/opencode.json with "theme": "system"

Problem

The TUI theme is only applied when the TUI process starts. When the terminal's palette changes at runtime (system light/dark switch, terminal config reload), an already-running TUI keeps its old colors forever. There is no working runtime way to re-apply the current theme without restarting the TUI.

The system theme is explicitly documented to "adapt to your terminal's color scheme" and to "preserve terminal defaults", but that adaptation happens once at startup — so TUIs end up stale after a terminal palette switch.

Attempts (what was tried to re-apply the theme at runtime)

  1. theme_list keybind — documented as <leader>t (default leader ctrl+x). Pressing ctrl+x then t in a running TUI (2.2.5) does not open any theme list; focus moves somewhere else (embedded shell pane) and no dialog appears.
  2. /theme command palette — typing / opens the command palette, but filtering with the does not surface /theme (unrelated commands are shown and the typed text stays in the prompt). Even when invoked manually, this cannot be automated reliably from outside.
  3. theme_switch_mode / theme_mode_lock — both default to none, so there is no bound runtime action to flip the theme mode at all.

Expected

  • Pressing the documented theme_list keybind opens the theme selection dialog and re-applies the selected theme immediately (re-reading the current terminal background for system theme), or
  • The TUI detects terminal background changes (OSC 11 / palette change) and re-applies the active theme live, or
  • theme_switch_mode has a sensible default binding and cycles light/dark/system with immediate repaint.

Use case

Users who switch their whole system between light and dark (Cinnamon/KDE, or a script that rewrites the terminal palette and pushes it live) expect every open TUI to follow. Today this requires restarting the TUI in every tab — the server keeps sessions, but TUI-local state is lost on every theme toggle, which makes system-wide light/dark switching impractical for opencode.

Contrast for reference: GTK applications, and even WM-drawn titlebars of other terminals in the same session, repaint live on the same switch — only the opencode TUI stays stale.

Activity

  1. opencodejr commented on Nov 4, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up!

    You're asking for a running TUI to pick up terminal palette changes, such as a light/dark switch or an Alacritty config rewrite, without restarting. In v2 the system theme re-reads the terminal's colours only in these cases:

    • once after startup
    • when the terminal sends a colour-scheme report (mode 2031, ESC[?997;…n)
    • when the TUI process receives SIGUSR2

    As far as I know Alacritty doesn't send those reports, so a running TUI stays on the old palette. That's how it's currently built, so I'm treating this as a feature request. Maintainers will consider it.

    On the things you tried: the keybind docs you followed still show v1 names, which is confusing. In 2.2.x:

    • <leader>t is bound to toggle terminal pane (terminal.toggle). That's why ctrl+x t opened the shell pane.
    • The theme picker is the theme.switch action. It has no default key in v2, but you can bind it, e.g. "keybinds": { "theme.switch": "<leader>y" } in your v2 config (~/.config/opencode/cli.json). The same goes for theme.switch_mode and theme.mode.lock.
    • The slash command is /themes (plural), not /theme.

    Workaround for your script: after it pushes the new Alacritty palette, send SIGUSR2 to the running TUI processes, e.g. pkill -USR2 -f opencode. With "theme": "system" they re-read the terminal colours and repaint without restarting.

    Related issues:

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