tui: removing theme from cli.json does not revert to default theme
Summary
In the TUI, changing or adding theme.name in cli.json applies live, but removing the theme entry does not revert the theme to the default (opencode) — the last explicitly applied theme stays, even after /reload.
Environment
- opencode version: 2.3.0
- OS: Windows 11 10.0.26300 (win32 x64)
- Terminal: Windows Terminal
- Shell: cmd.exe
- Install/channel: latest (npm,
@opencode/cli) - Active plugins: none
Reproduction
- Start the TUI with no
themeentry in~/.config/opencode/cli.json(default theme shown). - Add
"theme": { "name": "gruvbox" }→ the theme changes live, no restart needed. - Remove the
themeentry again → the TUI keeps thegruvboxcolors. - Run
/reload→ the theme still staysgruvbox. - Set
"theme": { "name": "opencode" }explicitly → the default look is applied immediately.
Verified repeatedly (gruvbox and nord as test themes), with the TUI window focused during each change.
Expected Behavior
Removing the theme entry (or forcing a reload with /reload) restores the default theme (opencode), since the setting is no longer present.
Actual Behavior
The theme is only re-applied when a value is present in the config; an absent value does not reset the currently displayed theme. Reverting to the default requires explicitly setting "theme": { "name": "opencode" } or restarting the TUI.
Additional Context
- The
cli.jsonfile is read and hot-reloaded correctly (theme changes apply live), so this is not a config-loading issue. - Workaround: set
"theme": { "name": "opencode" }explicitly, or restart the TUI. - Minor/harmless; logged for completeness. Observed on Windows; not tested on Linux.
Thanks for the clear steps. I reproduced this on @opencode/cli 2.3.0, and it still happens on the latest dev (a9a35b4).
What I did, with the TUI running (the recording and screenshots below show each step):
- Started with an empty global
cli.json: defaultopencodetheme. - Added
"theme": { "name": "gruvbox" }: gruvbox applied live. - Removed the
themeentry again: the TUI stayed on gruvbox. - Ran
/reload: the "Configuration reloaded" toast appeared, still gruvbox. - Set
"theme": { "name": "opencode" }explicitly: the default theme came back right away.
The script below reproduces it. Until it is fixed, your workaround works: set "name": "opencode" explicitly, or restart the TUI.
https://github.com/user-attachments/assets/933cfd6d-28c9-4f43-8852-b1aceacefa02
Reproduction script (drive.ts)
// Repro for anomalyco/opencode#64420: removing `theme` from cli.json does not revert to the default theme.
import { Effect } from "effect"
import { OpenCodeDriver } from "opencode-drive"
import { mkdirSync, writeFileSync } from "node:fs"
import { join } from "node:path"
// Drive points OPENCODE_CONFIG_DIR at <artifacts>/files/.opencode, so this is the global cli.json.
const write = (artifacts: string, cfg: object) =>
Effect.sync(() => {
const dir = join(artifacts, "files", ".opencode")
mkdirSync(dir, { recursive: true })
writeFileSync(join(dir, "cli.json"), JSON.stringify(cfg, null, 2) + "\n")
})
export default OpenCodeDriver.use(
{
...(process.env.OC_DEV ? { opencode: { dev: process.env.OC_DEV } } : {}),
tui: { recording: true, keypressOverlay: true },
},
({ ui, artifacts }) =>
Effect.gen(function* () {
yield* write(artifacts, {})
yield* Effect.sleep(3000)
yield* ui.screenshot("1-default-no-theme")
yield* write(artifacts, { theme: { name: "gruvbox" } })
yield* Effect.sleep(4000)
yield* ui.screenshot("2-gruvbox-added")
yield* write(artifacts, {})
yield* Effect.sleep(4000)
yield* ui.screenshot("3-theme-removed")
yield* ui.submit("/reload")
yield* Effect.sleep(4000)
yield* ui.screenshot("4-after-reload")
yield* write(artifacts, { theme: { name: "opencode" } })
yield* Effect.sleep(4000)
yield* ui.screenshot("5-opencode-explicit")
}),
)
Run it with opencode-drive: opencode-drive run ./drive.ts. It drives opencode from your PATH; set OC_DEV to the path of an OpenCode checkout to run that from source instead.
The reactive theme effect returns early when theme.name disappears, while provider initialization already defaults to opencode. This focused patch applies that same fallback on updates (commit 0488d1cb157b5aae85047390d9b7b6d349a1d293, based on a9a35b4).
Automated macOS validation exercises the real ConfigProvider → ThemeProvider → rendered text/color path. Both removal cases fail on the base and pass with the patch; explicit theme changes and the pinned light-mode preference are covered. All 7 tests pass across 10 runs, 122 adjacent theme/config tests pass, and root bun run check passes all 35 tasks.
The full TUI suite hits an OpenTUI runtime-plugin import stack overflow, also reproduced with both changed files restored to the base; its candidate run ended in SIGKILL. Windows-native testing and hosted CI remain unverified. PR creation is still blocked by the account's existing CreatePullRequest permission error; the branch and patch are available for review.