diff --git a/internal/config/config.go b/internal/config/config.go index 0e475ee89654914722b829aaea4d1b7830618914..d5f3b8fb65b0d8d7f694fa3368d0263f4c3336a9 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -204,6 +204,7 @@ type TUIOptions struct { // Completions Completions `json:"completions,omitzero" jsonschema:"description=Completions UI options"` + Transparent *bool `json:"transparent,omitempty" jsonschema:"description=Enable transparent background for the TUI interface,default=false"` } // Completions defines options for the completions UI. diff --git a/internal/config/load.go b/internal/config/load.go index 3ad4b909cb16cf5672dcadc9322a476854350632..a651f4846307ed9729ba8a10835e98aece486dbd 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -62,6 +62,11 @@ func Load(workingDir, dataDir string, debug bool) (*Config, error) { assignIfNil(&cfg.Options.TUI.Completions.MaxItems, items) } + if isAppleTerminal() { + slog.Warn("Detected Apple Terminal, enabling transparent mode") + assignIfNil(&cfg.Options.TUI.Transparent, true) + } + // Load known providers, this loads the config from catwalk providers, err := Providers(cfg) if err != nil { @@ -792,3 +797,5 @@ func GlobalSkillsDirs() []string { filepath.Join(configBase, "agents", "skills"), } } + +func isAppleTerminal() bool { return os.Getenv("TERM_PROGRAM") == "Apple_Terminal" } diff --git a/internal/ui/model/ui.go b/internal/ui/model/ui.go index 1e81a5625b909598668487b137fb80afce5754da..6231c82c514ee021e7e8f47272c8f606ec54ff09 100644 --- a/internal/ui/model/ui.go +++ b/internal/ui/model/ui.go @@ -127,6 +127,8 @@ type UI struct { height int layout layout + isTransparent bool + focus uiFocusState state uiState @@ -296,8 +298,12 @@ func New(com *common.Common) *UI { // set initial state ui.setState(desiredState, desiredFocus) + opts := com.Config().Options + // disable indeterminate progress bar - ui.progressBarEnabled = com.Config().Options.Progress == nil || *com.Config().Options.Progress + ui.progressBarEnabled = opts.Progress == nil || *opts.Progress + // enable transparent mode + ui.isTransparent = opts.TUI.Transparent != nil && *opts.TUI.Transparent return ui } @@ -1884,7 +1890,9 @@ func (m *UI) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor { func (m *UI) View() tea.View { var v tea.View v.AltScreen = true - v.BackgroundColor = m.com.Styles.Background + if !m.isTransparent { + v.BackgroundColor = m.com.Styles.Background + } v.MouseMode = tea.MouseModeCellMotion v.WindowTitle = "crush " + home.Short(m.com.Config().WorkingDir())