on main help sign in
feat(ui): transparent mode (#2087)
d0ed2c5Carlos Alexandro Becker
internal/config/config.go+1
@@ -204,6 +204,7 @@ type TUIOptions struct {
204 //
204 //
205
205
206 Completions Completions `json:"completions,omitzero" jsonschema:"description=Completions UI options"`
206 Completions Completions `json:"completions,omitzero" jsonschema:"description=Completions UI options"`
207+ Transparent *bool `json:"transparent,omitempty" jsonschema:"description=Enable transparent background for the TUI interface,default=false"`
207}
208}
208
209
209// Completions defines options for the completions UI.
210// Completions defines options for the completions UI.
internal/config/load.go+7
@@ -62,6 +62,11 @@ func Load(workingDir, dataDir string, debug bool) (*Config, error) {
62 assignIfNil(&cfg.Options.TUI.Completions.MaxItems, items)
62 assignIfNil(&cfg.Options.TUI.Completions.MaxItems, items)
63 }
63 }
64
64
65+ if isAppleTerminal() {
66+ slog.Warn("Detected Apple Terminal, enabling transparent mode")
67+ assignIfNil(&cfg.Options.TUI.Transparent, true)
68+ }
69+
65 // Load known providers, this loads the config from catwalk
70 // Load known providers, this loads the config from catwalk
66 providers, err := Providers(cfg)
71 providers, err := Providers(cfg)
67 if err != nil {
72 if err != nil {
@@ -792,3 +797,5 @@ func GlobalSkillsDirs() []string {
792 filepath.Join(configBase, "agents", "skills"),
797 filepath.Join(configBase, "agents", "skills"),
793 }
798 }
794}
799}
800+
801+func isAppleTerminal() bool { return os.Getenv("TERM_PROGRAM") == "Apple_Terminal" }
internal/ui/model/ui.go+10−2
@@ -127,6 +127,8 @@ type UI struct {
127 height int
127 height int
128 layout layout
128 layout layout
129
129
130+ isTransparent bool
131+
130 focus uiFocusState
132 focus uiFocusState
131 state uiState
133 state uiState
132
134
@@ -296,8 +298,12 @@ func New(com *common.Common) *UI {
296 // set initial state
298 // set initial state
297 ui.setState(desiredState, desiredFocus)
299 ui.setState(desiredState, desiredFocus)
298
300
301+ opts := com.Config().Options
302+
299 // disable indeterminate progress bar
303 // disable indeterminate progress bar
300− ui.progressBarEnabled = com.Config().Options.Progress == nil || *com.Config().Options.Progress
304+ ui.progressBarEnabled = opts.Progress == nil || *opts.Progress
305+ // enable transparent mode
306+ ui.isTransparent = opts.TUI.Transparent != nil && *opts.TUI.Transparent
301
307
302 return ui
308 return ui
303}
309}
@@ -1884,7 +1890,9 @@ func (m *UI) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
1884func (m *UI) View() tea.View {
1890func (m *UI) View() tea.View {
1885 var v tea.View
1891 var v tea.View
1886 v.AltScreen = true
1892 v.AltScreen = true
1893+ if !m.isTransparent {
1887− v.BackgroundColor = m.com.Styles.Background
1894+ v.BackgroundColor = m.com.Styles.Background
1895+ }
1888 v.MouseMode = tea.MouseModeCellMotion
1896 v.MouseMode = tea.MouseModeCellMotion
1889 v.WindowTitle = "crush " + home.Short(m.com.Config().WorkingDir())
1897 v.WindowTitle = "crush " + home.Short(m.com.Config().WorkingDir())
1890
1898