feat: auto-enable if $SSH_TTY

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/components/chat/messages/messages.go | 3 ++-
3 files changed, 10 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"`
-	ReduceAnimations bool   `json:"reduce_animations,omitempty" jsonschema:"description=Reduce animations in the TUI,default=false"`
+	ReduceAnimations *bool  `json:"reduce_animations,omitempty" jsonschema:"description=Reduce animations in the TUI,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 isSSH() {
+		slog.Warn("Running over SSH, will enable reduce animations")
+		assignIfNil(&cfg.Options.TUI.ReduceAnimations, 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 isSSH() bool { return os.Getenv("SSH_TTY") != "" }

internal/tui/components/chat/messages/messages.go 🔗

@@ -431,5 +431,6 @@ func isReduceAnimations() bool {
 	cfg := config.Get()
 	return cfg.Options != nil &&
 		cfg.Options.TUI != nil &&
-		cfg.Options.TUI.ReduceAnimations
+		cfg.Options.TUI.ReduceAnimations != nil &&
+		*cfg.Options.TUI.ReduceAnimations
 }