From f33e6c3458ce8b7ba8b3035282e38f87cecd2c6a Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 12 Mar 2026 20:40:38 -0400 Subject: [PATCH] chore(ui): add toggle for transparent bg to command palette --- internal/config/store.go | 9 +++++++++ internal/ui/dialog/actions.go | 25 +++++++++++++------------ internal/ui/dialog/commands.go | 16 +++++++++++++--- internal/ui/model/ui.go | 21 +++++++++++++++++++++ 4 files changed, 56 insertions(+), 15 deletions(-) diff --git a/internal/config/store.go b/internal/config/store.go index 4dfe6130bc23007ec3df12e5a88cb53bc3ad5a2d..f95a6fc7f124c71492969b212b2e806071020e10 100644 --- a/internal/config/store.go +++ b/internal/config/store.go @@ -151,6 +151,15 @@ func (s *ConfigStore) SetCompactMode(scope Scope, enabled bool) error { return s.SetConfigField(scope, "options.tui.compact_mode", enabled) } +// SetTransparentBackground sets the transparent background setting and persists it. +func (s *ConfigStore) SetTransparentBackground(scope Scope, enabled bool) error { + if s.config.Options == nil { + s.config.Options = &Options{} + } + s.config.Options.TUI.Transparent = &enabled + return s.SetConfigField(scope, "options.tui.transparent", enabled) +} + // SetProviderAPIKey sets the API key for a provider and persists it. func (s *ConfigStore) SetProviderAPIKey(scope Scope, providerID string, apiKey any) error { var providerConfig ProviderConfig diff --git a/internal/ui/dialog/actions.go b/internal/ui/dialog/actions.go index 8fea38fb75d8e2eca73e4b6693f6469fc1e743d6..09755417a5a12e4bdb7df1e5f932ade18016fb8f 100644 --- a/internal/ui/dialog/actions.go +++ b/internal/ui/dialog/actions.go @@ -44,20 +44,21 @@ type ActionSelectModel struct { // Messages for commands type ( - ActionNewSession struct{} - ActionToggleHelp struct{} - ActionToggleCompactMode struct{} - ActionToggleThinking struct{} - ActionTogglePills struct{} - ActionExternalEditor struct{} - ActionToggleYoloMode struct{} - ActionToggleNotifications struct{} - // ActionInitializeProject is a message to initialize a project. - ActionInitializeProject struct{} - ActionSummarize struct { + ActionNewSession struct{} + ActionToggleHelp struct{} + ActionToggleCompactMode struct{} + ActionToggleThinking struct{} + ActionTogglePills struct{} + ActionExternalEditor struct{} + ActionToggleYoloMode struct{} + ActionToggleNotifications struct{} + ActionToggleTransparentBackground struct{} + ActionInitializeProject struct{} + ActionSummarize struct { SessionID string } - // ActionSelectReasoningEffort is a message indicating a reasoning effort has been selected. + // ActionSelectReasoningEffort is a message indicating a reasoning effort + // has been selected. ActionSelectReasoningEffort struct { Effort string } diff --git a/internal/ui/dialog/commands.go b/internal/ui/dialog/commands.go index 14ffaf3aedc11d9fefb1b4932664c5d95d34e413..a5b555f2b345f51d9624ce87a2dcc6aaa3c1f70e 100644 --- a/internal/ui/dialog/commands.go +++ b/internal/ui/dialog/commands.go @@ -427,9 +427,9 @@ func (c *Commands) defaultCommands() []*CommandItem { commands = append(commands, NewCommandItem(c.com.Styles, "toggle_sidebar", "Toggle Sidebar", "", ActionToggleCompactMode{})) } if c.hasSession { - cfg := c.com.Config() - agentCfg := cfg.Agents[config.AgentCoder] - model := cfg.GetModelByType(agentCfg.Model) + cfgPrime := c.com.Config() + agentCfg := cfgPrime.Agents[config.AgentCoder] + model := cfgPrime.GetModelByType(agentCfg.Model) if model != nil && model.SupportsImages { commands = append(commands, NewCommandItem(c.com.Styles, "file_picker", "Open File Picker", "ctrl+f", ActionOpenDialog{ // TODO: Pass in the file picker dialog id @@ -472,6 +472,16 @@ func (c *Commands) defaultCommands() []*CommandItem { NewCommandItem(c.com.Styles, "toggle_yolo", "Toggle Yolo Mode", "", ActionToggleYoloMode{}), NewCommandItem(c.com.Styles, "toggle_help", "Toggle Help", "ctrl+g", ActionToggleHelp{}), NewCommandItem(c.com.Styles, "init", "Initialize Project", "", ActionInitializeProject{}), + ) + + // Add transparent background toggle. + transparentLabel := "Disable Background Color" + if cfg != nil && cfg.Options != nil && cfg.Options.TUI.Transparent != nil && *cfg.Options.TUI.Transparent { + transparentLabel = "Enable Background Color" + } + commands = append(commands, NewCommandItem(c.com.Styles, "toggle_transparent", transparentLabel, "", ActionToggleTransparentBackground{})) + + commands = append(commands, NewCommandItem(c.com.Styles, "quit", "Quit", "ctrl+c", tea.QuitMsg{}), ) diff --git a/internal/ui/model/ui.go b/internal/ui/model/ui.go index 8bb398f387929dd30b1df1e6e27d2c72097797b8..ed0a7dd6851fbbe0b16540a4b72dc2486e96f438 100644 --- a/internal/ui/model/ui.go +++ b/internal/ui/model/ui.go @@ -1328,6 +1328,27 @@ func (m *UI) handleDialogMsg(msg tea.Msg) tea.Cmd { return util.NewInfoMsg("Thinking mode " + status) }) m.dialog.CloseDialog(dialog.CommandsID) + case dialog.ActionToggleTransparentBackground: + cmds = append(cmds, func() tea.Msg { + cfg := m.com.Config() + if cfg == nil { + return util.ReportError(errors.New("configuration not found"))() + } + + isTransparent := cfg.Options != nil && cfg.Options.TUI.Transparent != nil && *cfg.Options.TUI.Transparent + newValue := !isTransparent + if err := m.com.Store().SetTransparentBackground(config.ScopeGlobal, newValue); err != nil { + return util.ReportError(err)() + } + m.isTransparent = newValue + + status := "disabled" + if newValue { + status = "enabled" + } + return util.NewInfoMsg("Transparent background " + status) + }) + m.dialog.CloseDialog(dialog.CommandsID) case dialog.ActionQuit: cmds = append(cmds, tea.Quit) case dialog.ActionInitializeProject: