feat: auto enable on apple terminal

Carlos Alexandro Becker created

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Change summary

internal/config/config.go | 2 +-
internal/config/load.go   | 7 +++++++
internal/tui/tui.go       | 7 ++++++-
3 files changed, 14 insertions(+), 2 deletions(-)

Detailed changes

internal/config/config.go 🔗

@@ -130,7 +130,7 @@ type LSPConfig struct {
 type TUIOptions struct {
 	CompactMode bool   `json:"compact_mode,omitempty" jsonschema:"description=Enable compact mode for the TUI interface,default=false"`
 	DiffMode    string `json:"diff_mode,omitempty" jsonschema:"description=Diff mode for the TUI interface,enum=unified,enum=split"`
-	Transparent bool   `json:"transparent,omitempty" jsonschema:"description=Enable transparent background for the TUI interface,default=false"`
+	Transparent *bool  `json:"transparent,omitempty" jsonschema:"description=Enable transparent background for the TUI interface,default=false"`
 	// Here we can add themes later or any TUI related options
 	//
 

internal/config/load.go 🔗

@@ -74,6 +74,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 {
@@ -674,3 +679,5 @@ func isInsideWorktree() bool {
 	).CombinedOutput()
 	return err == nil && strings.TrimSpace(string(bts)) == "true"
 }
+
+func isAppleTerminal() bool { return os.Getenv("TERM_PROGRAM") == "Apple_Terminal" }

internal/tui/tui.go 🔗

@@ -508,11 +508,16 @@ func (a *appModel) moveToPage(pageID page.PageID) tea.Cmd {
 	return tea.Batch(cmds...)
 }
 
+func (a *appModel) isTransparent() bool {
+	cfg := a.app.Config().Options.TUI
+	return cfg.Transparent != nil && *cfg.Transparent
+}
+
 // View renders the complete application interface including pages, dialogs, and overlays.
 func (a *appModel) View() tea.View {
 	var view tea.View
 	t := styles.CurrentTheme()
-	if !a.app.Config().Options.TUI.Transparent {
+	if !a.isTransparent() {
 		view.BackgroundColor = t.BgBase
 	}
 	if a.wWidth < 25 || a.wHeight < 15 {