on main help sign in
chore(ui): add toggle for transparent bg to command palette (#2405)
81f2d38Christian Rocha
internal/config/store.go+9
@@ -151,6 +151,15 @@ func (s *ConfigStore) SetCompactMode(scope Scope, enabled bool) error {
151 return s.SetConfigField(scope, "options.tui.compact_mode", enabled)
151 return s.SetConfigField(scope, "options.tui.compact_mode", enabled)
152}
152}
153
153
154+// SetTransparentBackground sets the transparent background setting and persists it.
155+func (s *ConfigStore) SetTransparentBackground(scope Scope, enabled bool) error {
156+ if s.config.Options == nil {
157+ s.config.Options = &Options{}
158+ }
159+ s.config.Options.TUI.Transparent = &enabled
160+ return s.SetConfigField(scope, "options.tui.transparent", enabled)
161+}
162+
154// SetProviderAPIKey sets the API key for a provider and persists it.
163// SetProviderAPIKey sets the API key for a provider and persists it.
155func (s *ConfigStore) SetProviderAPIKey(scope Scope, providerID string, apiKey any) error {
164func (s *ConfigStore) SetProviderAPIKey(scope Scope, providerID string, apiKey any) error {
156 var providerConfig ProviderConfig
165 var providerConfig ProviderConfig
internal/ui/dialog/actions.go+13−12
@@ -44,20 +44,21 @@ type ActionSelectModel struct {
44
44
45// Messages for commands
45// Messages for commands
46type (
46type (
47− ActionNewSession struct{}
47+ ActionNewSession struct{}
48− ActionToggleHelp struct{}
48+ ActionToggleHelp struct{}
49− ActionToggleCompactMode struct{}
49+ ActionToggleCompactMode struct{}
50− ActionToggleThinking struct{}
50+ ActionToggleThinking struct{}
51− ActionTogglePills struct{}
51+ ActionTogglePills struct{}
52− ActionExternalEditor struct{}
52+ ActionExternalEditor struct{}
53− ActionToggleYoloMode struct{}
53+ ActionToggleYoloMode struct{}
54− ActionToggleNotifications struct{}
54+ ActionToggleNotifications struct{}
55− // ActionInitializeProject is a message to initialize a project.
55+ ActionToggleTransparentBackground struct{}
56− ActionInitializeProject struct{}
56+ ActionInitializeProject struct{}
57− ActionSummarize struct {
57+ ActionSummarize struct {
58 SessionID string
58 SessionID string
59 }
59 }
60− // ActionSelectReasoningEffort is a message indicating a reasoning effort has been selected.
60+ // ActionSelectReasoningEffort is a message indicating a reasoning effort
61+ // has been selected.
61 ActionSelectReasoningEffort struct {
62 ActionSelectReasoningEffort struct {
62 Effort string
63 Effort string
63 }
64 }
internal/ui/dialog/commands.go+13−3
@@ -427,9 +427,9 @@ func (c *Commands) defaultCommands() []*CommandItem {
427 commands = append(commands, NewCommandItem(c.com.Styles, "toggle_sidebar", "Toggle Sidebar", "", ActionToggleCompactMode{}))
427 commands = append(commands, NewCommandItem(c.com.Styles, "toggle_sidebar", "Toggle Sidebar", "", ActionToggleCompactMode{}))
428 }
428 }
429 if c.hasSession {
429 if c.hasSession {
430− cfg := c.com.Config()
430+ cfgPrime := c.com.Config()
431− agentCfg := cfg.Agents[config.AgentCoder]
431+ agentCfg := cfgPrime.Agents[config.AgentCoder]
432− model := cfg.GetModelByType(agentCfg.Model)
432+ model := cfgPrime.GetModelByType(agentCfg.Model)
433 if model != nil && model.SupportsImages {
433 if model != nil && model.SupportsImages {
434 commands = append(commands, NewCommandItem(c.com.Styles, "file_picker", "Open File Picker", "ctrl+f", ActionOpenDialog{
434 commands = append(commands, NewCommandItem(c.com.Styles, "file_picker", "Open File Picker", "ctrl+f", ActionOpenDialog{
435 // TODO: Pass in the file picker dialog id
435 // TODO: Pass in the file picker dialog id
@@ -472,6 +472,16 @@ func (c *Commands) defaultCommands() []*CommandItem {
472 NewCommandItem(c.com.Styles, "toggle_yolo", "Toggle Yolo Mode", "", ActionToggleYoloMode{}),
472 NewCommandItem(c.com.Styles, "toggle_yolo", "Toggle Yolo Mode", "", ActionToggleYoloMode{}),
473 NewCommandItem(c.com.Styles, "toggle_help", "Toggle Help", "ctrl+g", ActionToggleHelp{}),
473 NewCommandItem(c.com.Styles, "toggle_help", "Toggle Help", "ctrl+g", ActionToggleHelp{}),
474 NewCommandItem(c.com.Styles, "init", "Initialize Project", "", ActionInitializeProject{}),
474 NewCommandItem(c.com.Styles, "init", "Initialize Project", "", ActionInitializeProject{}),
475+ )
476+
477+ // Add transparent background toggle.
478+ transparentLabel := "Disable Background Color"
479+ if cfg != nil && cfg.Options != nil && cfg.Options.TUI.Transparent != nil && *cfg.Options.TUI.Transparent {
480+ transparentLabel = "Enable Background Color"
481+ }
482+ commands = append(commands, NewCommandItem(c.com.Styles, "toggle_transparent", transparentLabel, "", ActionToggleTransparentBackground{}))
483+
484+ commands = append(commands,
475 NewCommandItem(c.com.Styles, "quit", "Quit", "ctrl+c", tea.QuitMsg{}),
485 NewCommandItem(c.com.Styles, "quit", "Quit", "ctrl+c", tea.QuitMsg{}),
476 )
486 )
477
487
internal/ui/model/ui.go+21
@@ -1328,6 +1328,27 @@ func (m *UI) handleDialogMsg(msg tea.Msg) tea.Cmd {
1328 return util.NewInfoMsg("Thinking mode " + status)
1328 return util.NewInfoMsg("Thinking mode " + status)
1329 })
1329 })
1330 m.dialog.CloseDialog(dialog.CommandsID)
1330 m.dialog.CloseDialog(dialog.CommandsID)
1331+ case dialog.ActionToggleTransparentBackground:
1332+ cmds = append(cmds, func() tea.Msg {
1333+ cfg := m.com.Config()
1334+ if cfg == nil {
1335+ return util.ReportError(errors.New("configuration not found"))()
1336+ }
1337+
1338+ isTransparent := cfg.Options != nil && cfg.Options.TUI.Transparent != nil && *cfg.Options.TUI.Transparent
1339+ newValue := !isTransparent
1340+ if err := m.com.Store().SetTransparentBackground(config.ScopeGlobal, newValue); err != nil {
1341+ return util.ReportError(err)()
1342+ }
1343+ m.isTransparent = newValue
1344+
1345+ status := "disabled"
1346+ if newValue {
1347+ status = "enabled"
1348+ }
1349+ return util.NewInfoMsg("Transparent background " + status)
1350+ })
1351+ m.dialog.CloseDialog(dialog.CommandsID)
1331 case dialog.ActionQuit:
1352 case dialog.ActionQuit:
1332 cmds = append(cmds, tea.Quit)
1353 cmds = append(cmds, tea.Quit)
1333 case dialog.ActionInitializeProject:
1354 case dialog.ActionInitializeProject: